perf(ui): trim hidden session and bootstrap work

This commit is contained in:
Pascal André
2026-03-14 11:50:56 +01:00
parent 695c3fa954
commit 6f15ba2051
6 changed files with 151 additions and 64 deletions

View File

@@ -2,10 +2,30 @@ import { createEffect, createSignal, type Accessor } from "solid-js"
import { messageStoreBus } from "../../../stores/message-v2/bus"
import { clearSessionRenderCache } from "../../message-block"
import { getLogger } from "../../../lib/logger"
import { runtimeEnv } from "../../../lib/runtime-env"
const log = getLogger("session")
const SESSION_CACHE_LIMIT = 5
function getSessionCacheLimit() {
if (runtimeEnv.platform === "mobile") {
return 2
}
if (runtimeEnv.host === "tauri") {
return 3
}
if (typeof navigator !== "undefined") {
const deviceMemory = (navigator as Navigator & { deviceMemory?: number }).deviceMemory
if (typeof deviceMemory === "number" && deviceMemory <= 4) {
return 3
}
}
return 5
}
const SESSION_CACHE_LIMIT = getSessionCacheLimit()
type SessionCacheOptions = {
instanceId: Accessor<string>