Agents: Keep active Copilot CLI session during steering#319202
Open
Chulong-Li wants to merge 2 commits into
Open
Agents: Keep active Copilot CLI session during steering#319202Chulong-Li wants to merge 2 commits into
Chulong-Li wants to merge 2 commits into
Conversation
When a first Copilot CLI request is accepted but the untitled-to-committed session handoff is not observed in time, keep the temporary Agents Window session instead of removing it. This prevents active-session removal from redirecting to the new-session page and unpinning the current session.\n\nFixes microsoft#317183\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Handles commit-handoff timeouts during sendRequest so that temporary CLI sessions/chats are preserved (marked Completed) rather than being removed when the request was actually accepted but the commit event timed out.
Changes:
- Catch the "Timed out waiting for session commit" error in both
_sendFirstChatand_sendExistingChatpaths and keep the temp session/chat as Completed, firing achangedevent. - Add helper
_isCommitTimeoutErrorto identify the timeout case. - Update provider documentation and add a test for the first-chat timeout path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts | Preserve temp session/chat on commit-timeout in both send paths; add _isCommitTimeoutError helper. |
| src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts | Add test verifying temp CLI session is retained as Completed when commit times out. |
| src/vs/sessions/contrib/providers/copilotChatSessions/COPILOT_CHAT_SESSIONS_PROVIDER.md | Document the new timeout-preservation behavior. |
Use a dedicated commit timeout error instead of matching the message string, cover the existing-group temporary chat timeout path, and ensure preserved temporary child chats are disposed when the parent session is deleted.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #317183
Summary
Prevents the Agents Window from navigating back to the new-session view when the first Copilot CLI steering request happens before the temporary session has finished committing.
Root Cause
The first Copilot CLI request starts from a temporary
copilotcli:/untitled-*resource. The Copilot sessions provider then waits for the lower-level chat/session stack to report the committed real resource.When that handoff signal is late, missed, or not visible in the provider cache in time, the provider previously treated the timeout as an unexpected failure. It removed and disposed the temporary session it had already exposed to the Agents Window. Since that session could be the active/pinned session,
SessionsManagementServiceobserved the active session disappearing and fell back to the new-session view, which looked like steering redirected away and unpinned the current session.Fix
The fix is deliberately scoped to the Agents Window provider behavior:
changedrather thanremoved, so the active Agents Window session remains stableThis matches the key invariant for #317183: once the request has been accepted, failing to observe the commit handoff in time is not sufficient evidence that the user-visible session should be destroyed.
Why This Approach
This fixes the user-visible failure at the layer that owns Agents Window session lifecycle. If the provider does not observe the commit handoff quickly enough, preserving the temporary session is safer than removing the active session the user is already viewing.
Why Not More Handoff Plumbing
Earlier investigation showed that improving the lower-level handoff path alone does not fully protect the UI. The provider still had a destructive fallback: if the handoff was not observed in time, it removed the active temporary session. Any remaining timing gap could therefore still reproduce the redirect.
This change avoids broad shared chat service or extension-host session plumbing changes and keeps the fix focused on the Agents Window behavior that caused the visible regression.
Validation
Figure: Current Copilot CLI session remains active and pinned after steering instead of switching to a new session
