fix(web-ui): prevent ACP session hydrate deadlock on re-switch - #2137
Open
xielixing wants to merge 1 commit into
Open
fix(web-ui): prevent ACP session hydrate deadlock on re-switch#2137xielixing wants to merge 1 commit into
xielixing wants to merge 1 commit into
Conversation
When switching back to a previously-loaded ACP session, the UI showed a permanent 'loading saved session' overlay. The root cause was a deadlock in switchChatSession: ACP sessions never receive a history session open intent (filtered by isRunning), so shouldActivateBeforeHydrate was false. This meant hydration ran before activation, and with the default deferFullHistoryUntilActive=true, the stale-commit guard in FlowChatStore discarded the loaded turns (resetting to metadata-only). Then activation happened on an empty session, leaving the overlay stuck. Fix: pass deferFullHistoryUntilActive=false for ACP sessions so the hydrate commit is preserved even when activation hasn't happened yet. The subsequent switchSession call then activates a session that already has its loaded turns. Fixes GCWing#1038
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When switching back to a previously-loaded ACP session, the UI shows a permanent loading overlay and never displays content. The agent appears stuck.
Issue: #1038
Root Cause
A deadlock in
switchChatSession(SessionModule.ts) for ACP sessions:shouldHydrateHistoricalSessionBeforeSwitchreturnstrueforisHistoricalsessions with no renderable contentshouldActivateBeforeHydraterequiresconsumeRecentHistorySessionOpenIntent(sessionId)— but running ACP sessions never get an intent (they're filtered byisRunninginSessionsSection.tsx)shouldActivateBeforeHydrate=false, the flow is hydrate-first-then-activate (lines 700-728)hydrateHistoricalSessiondefaultsdeferFullHistoryUntilActive=true(line 256)activeSessionId !== sessionIdis still true (activation hasn't happened yet) →skipStaleLocalHydrateCommitinFlowChatStore.ts:7398-7401fires and discards the loaded turns, resetting tometadata-onlyswitchSession(sessionId)activates it (line 728) — but with empty turns andmetadata-onlystate, the overlay is stuck foreverFix
Pass
deferFullHistoryUntilActive: falsefor ACP sessions in thehydrateHistoricalSessioncall withinswitchChatSession. This ensures the hydrate commit is not discarded even when activation happens after hydration. The subsequentswitchSessioncall then activates a session that already has its loaded turns.Changes:
isAcpFlowSessionfrom../../utils/acpSessiondeferFullHistoryUntilActive: !isAcpFlowSession(session)to the hydrate callNon-ACP sessions retain the default
truebehavior (defer until active), so this change has no effect on existing session switching behavior.Testing