feat(desktop): add hot view retain/release lifecycle and process metrics

Replace single-shot acquireHotView with retainHotView/releaseHotView
plus a minute-level reaper that closes views idle beyond 5 minutes and
never evicts a view while it still has live retainers. Wrap adapter
calls in try/finally so a failing publish/query still releases the
view. Sample process metrics every minute and expose hot-view policy
and process snapshot via the runtime snapshot for diagnostics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-20 11:07:58 +08:00
parent a46ed4b9f6
commit ef868f81a1
5 changed files with 261 additions and 43 deletions
@@ -1,5 +1,6 @@
import { app } from "electron/main";
import { getProcessMetricsSnapshot } from "./process-metrics";
import { getCircuitBreakerState } from "./circuit-breaker";
import { collectRecoverySnapshot } from "./crash-recovery";
import { getKeepAlivePlan } from "./keep-alive";
@@ -10,7 +11,7 @@ import { getSchedulerState } from "./scheduler";
import { getSessionHandle, listSessionHandleSnapshots } from "./session-registry";
import { getTransportSnapshot } from "./transport/api-client";
import { describeVaultBackend } from "./vault";
import { listHotViews } from "./view-pool";
import { getHotViewPoolPolicy, listHotViews } from "./view-pool";
import { normalizeAccountPlatformUid } from "../shared/account-identity";
function minutesAhead(now: number, minutes: number): number {
@@ -151,6 +152,8 @@ function createLiveRuntimeSnapshot(controller: ReturnType<typeof getRuntimeContr
scheduler,
sessions,
hotViews,
hotViewPool: getHotViewPoolPolicy(),
processMetrics: getProcessMetricsSnapshot(),
vault: describeVaultBackend(),
},
};