perf: cut the boot and poll overhead (one settings fetch, one git process per tick, one fold per poll)
Boot: loadPrefs and loadExternalDisable each fetched the settings document, serially, before the first paint — and the second had no timeout, so a stalled wire kept the sidebar unmounted forever. Both decisions now ride ONE fetch (loadBootDecision) under the existing 2s race. GitLens: the 2s silent poll re-listed worktrees on every tick (a second git process per tick for a list that almost never changes, and a fresh worktrees array re-render each time). Silent ticks now fetch only the selected checkout's status; every 15th tick (~30s) re-lists and re-runs auto-selection, so an agent-created linked checkout is still picked up mid-session. ChangesTab: extractFileOps parses every accumulated tool/call (up to 4000 events); the poll ran it once for the badge and the render ran it AGAIN per tick, and the fresh array defeated the downstream memo. The fold now runs once per poll and its result rides a ref shared by badge and render (reset on session switch).
This commit is contained in:
@@ -217,3 +217,22 @@ export async function loadExternalDisable(settings: SidebarSettingsClient): Prom
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** The boot decision both the prefs and the external-disable flag need:
|
||||
* ONE settings fetch answers both (the boot path used to await
|
||||
* {@link loadPrefs} and {@link loadExternalDisable} serially — two round
|
||||
* trips of the same document before the first paint, and the second had no
|
||||
* timeout, so a stalled wire could keep the sidebar unmounted forever). */
|
||||
export interface BootDecision {
|
||||
prefs: SidebarPrefs
|
||||
suspended: boolean
|
||||
}
|
||||
|
||||
export async function loadBootDecision(settings: SidebarSettingsClient): Promise<BootDecision> {
|
||||
try {
|
||||
const view = await settings.settingsGet()
|
||||
return { prefs: parsePrefs(view.value), suspended: view.externalDisable === true }
|
||||
} catch {
|
||||
return { prefs: { ...SIDEBAR_PREFS_DEFAULTS }, suspended: false }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user