mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-31 01:37:28 +08:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user