Reconnect to in-progress remote agent host chat sessions#304589
Merged
Reconnect to in-progress remote agent host chat sessions#304589
Conversation
When opening a remote agent host session that has an active (in-progress) turn, the chat UI now reconnects to it and streams ongoing progress instead of only showing completed turns as history. Key changes: - activeTurnToProgress() converts accumulated active turn state into IChatProgress[] for initial replay - provideChatSessionContent detects activeTurn on session state, includes it in history, and wires up live streaming via progressObs - _reconnectToActiveTurn(): streams incremental text/reasoning/tool call/permission updates, handles turn completion, dispatches turnCancelled on interrupt, resolves pending permissions interactively - Fixes live object identity (reuses ChatToolInvocation instances from initial progress), snapshot-to-listener race (immediate reconciliation), and proper cancellation dispatch (Written by Copilot)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables the chat UI to reconnect to an in-progress remote agent host session turn, replaying accumulated partial output and then continuing to stream live progress (text/reasoning/tool activity/permissions) instead of showing only completed turns.
Changes:
- Added
activeTurnToProgress()to convert anIActiveTurnsnapshot into replayableIChatProgress[](including liveChatToolInvocations where applicable). - Updated
AgentHostSessionHandler.provideChatSessionContentand session plumbing to seedprogressObs/isCompleteObswhen an active turn exists and to attach a reconnection listener that streams incremental state changes. - Added unit tests for
activeTurnToProgressand integration tests for reconnection behavior (history seeding, streaming deltas, cancellation dispatch, tool calls, permissions, reasoning).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts | Adds unit tests covering activeTurnToProgress behavior and ordering. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Adds integration tests validating reconnection to an active turn and live streaming behavior. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Introduces activeTurnToProgress() to replay active turn state into chat progress items. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Implements reconnection flow: seeds session observables, streams live state updates, and wires permission confirmation + cancellation for active turns. |
…mpleted tool calls between snapshots (Written by Copilot)
joshspicer
previously approved these changes
Mar 25, 2026
…ve-ah-session Co-authored-by: Copilot <copilot@github.com>
cb56b55 to
6c2aa29
Compare
rzhao271
previously approved these changes
Mar 26, 2026
Collaborator
|
Looks like an actual build error. |
Member
Author
|
lmao thanks |
…ve-ah-session # Conflicts: # src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts # src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts
Yoyokrazy
approved these changes
Mar 26, 2026
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.
When opening a remote agent host session that has an active (in-progress) turn, the chat UI now reconnects to it and streams ongoing progress instead of only showing completed turns as history.
Changes
agentHostSessionHandler.tsAgentHostChatSession: AcceptsinitialProgressfor reconnection. SetsisCompleteObs=falseand seedsprogressObswhen reconnecting. ExposesappendProgress()andcomplete()for the reconnect flow.interruptActiveResponseCallbackis mutable so reconnection can replace it with a real cancel callback.provideChatSessionContent: DetectssessionState.activeTurn, includes the active turn's request in history with an empty response placeholder, generates initial progress viaactiveTurnToProgress(), and calls_reconnectToActiveTurn()._reconnectToActiveTurn()(new): Streams incremental state changes intoprogressObs. Extracts liveChatToolInvocationobjects frominitialProgress(same instances the chat UI holds). Handles text/reasoning deltas, tool call lifecycle, permission resolution, turn completion/error. Dispatchessession/turnCancelledon interrupt. Immediately reconciles after listener registration to close the snapshot-to-listener race._wireUpPermissionConfirmation()(new): Shared helper for interactive permission confirmation withCancellationTokenSourcecleanup.stateToProgressAdapter.tsactiveTurnToProgress(): Converts anIActiveTurn's accumulated state (reasoning, streaming text, tool calls, permissions) intoIChatProgress[]items suitable for initial replay.Tests
activeTurnToProgressinstateToProgressAdapter.test.tsagentHostChatContribution.test.tscovering: history loading, progressObs/isCompleteObs state, interrupt callback dispatch, live streaming, turn completion, tool calls, permissions, reasoning, and no-active-turn baseline(Written by Copilot)