fix(agent-manager): resolve sessionsLoaded race condition with webview mount (#539)

The loading skeleton gates (worktreesLoaded && sessionsLoaded) could
permanently block the Agent Manager UI. initializeState() called
refreshSessions() which sent sessionsLoaded before the webview's
onMount handlers registered, so the signal was lost. Since sessions
were already populated, the MessageList backup effect never triggered
a retry.

Add refreshSessions() to the requestState handler which fires from
the webview's onMount, guaranteeing all message listeners are ready.
This commit is contained in:
Marius
2026-02-20 17:02:29 +01:00
committed by GitHub
parent c520e4523a
commit 485fa9db52
@@ -156,7 +156,17 @@ export class AgentManagerProvider implements vscode.Disposable {
}
if (type === "agentManager.requestState") {
void this.stateReady
?.then(() => this.pushState())
?.then(() => {
this.pushState()
// Refresh sessions after pushState so the webview's sessionsLoaded
// handler is guaranteed to be registered (requestState fires from
// onMount). Without this, the initial refreshSessions() in
// initializeState() can race ahead of webview mount, causing
// sessionsLoaded to never flip to true.
if (this.state && this.state.getSessions().length > 0) {
this.provider?.refreshSessions()
}
})
.catch((err) => {
this.log("initializeState failed, pushing partial state:", err)
this.pushState()