revert(renderer): restore the module-local agent-status memo; a graphState field needs a banned cast

This commit is contained in:
Jinwoo-H
2026-09-17 17:24:56 -04:00
parent 14a03a29ad
commit edebbdd56f
2 changed files with 18 additions and 6 deletions
@@ -67,7 +67,6 @@ export const graphState = {
cachedOpenFilesProjection: null as OpenFilesProjectionCache | null,
cachedBrowserWorkspacesProjection: null as BrowserWorkspacesProjectionCache | null,
cachedBrowserPagesProjection: null as BrowserPagesProjectionCache | null,
cachedMobileSessionAgentStatus: null as MobileSessionAgentStatusCache | null,
cachedOpenFileIndexesSource: null as AppState['openFiles'] | null,
cachedOpenFileIndexes: null as OpenFileIndexes | null,
cachedEditorDraftHashes: null as EditorDraftHashCache | null,
@@ -77,11 +76,22 @@ export const graphState = {
hasCachedMobileTerminalTheme: false
}
// Module-local rather than `graphState` fields: a nullable field on that object literal needs an
// `as` cast, which the changed-code casting gate rejects.
let terminalTabOwnershipIndexCache: TerminalTabOwnershipIndex | null = null
let mobileSessionAgentStatusCache: MobileSessionAgentStatusCache | null = null
export function getMobileSessionAgentStatusCache(): MobileSessionAgentStatusCache | null {
return mobileSessionAgentStatusCache
}
export function setMobileSessionAgentStatusCache(cache: MobileSessionAgentStatusCache): void {
mobileSessionAgentStatusCache = cache
}
export function resetRuntimeGraphSliceScanCaches(): void {
terminalTabOwnershipIndexCache = null
graphState.cachedMobileSessionAgentStatus = null
mobileSessionAgentStatusCache = null
}
export function registeredTerminalTabKey(
@@ -10,8 +10,10 @@ import {
EMPTY_WORKTREE_TERMINAL_TABS,
EMPTY_WORKTREE_UNIFIED_TABS,
EMPTY_LAYOUT_BY_WORKTREE,
getMobileSessionAgentStatusCache,
getTerminalTabOwnershipIndex,
graphState
graphState,
setMobileSessionAgentStatusCache
} from './graph-state'
import type {
MobileSessionAgentStatusByWorktree,
@@ -70,7 +72,7 @@ export function buildMobileSessionAgentStatusByWorktree(
agentStatusByPaneKey: AppState['agentStatusByPaneKey'],
tabsByWorktree: AppState['tabsByWorktree']
): MobileSessionAgentStatusByWorktree {
const cached = graphState.cachedMobileSessionAgentStatus
const cached = getMobileSessionAgentStatusCache()
if (cached?.agentStatusSource === agentStatusByPaneKey && cached.tabsSource === tabsByWorktree) {
return cached.byWorktreeId
}
@@ -101,11 +103,11 @@ export function buildMobileSessionAgentStatusByWorktree(
byWorktreeId.set(worktreeId, previousBucket)
}
}
graphState.cachedMobileSessionAgentStatus = {
setMobileSessionAgentStatusCache({
agentStatusSource: agentStatusByPaneKey,
tabsSource: tabsByWorktree,
byWorktreeId
}
})
return byWorktreeId
}