Skip to content

Agents: Keep active Copilot CLI session during steering#319202

Open
Chulong-Li wants to merge 2 commits into
microsoft:mainfrom
Chulong-Li:fix/317183-agents-provider-timeout
Open

Agents: Keep active Copilot CLI session during steering#319202
Chulong-Li wants to merge 2 commits into
microsoft:mainfrom
Chulong-Li:fix/317183-agents-provider-timeout

Conversation

@Chulong-Li
Copy link
Copy Markdown
Member

@Chulong-Li Chulong-Li commented May 31, 2026

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, SessionsManagementService observed 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:

  • rejected sends still clean up the temporary session
  • cancellations keep the temporary session, as before
  • commit timeouts after an accepted send now also keep the temporary session
  • the provider reports changed rather than removed, so the active Agents Window session remains stable

This 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
image

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>
Copilot AI review requested due to automatic review settings May 31, 2026 13:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _sendFirstChat and _sendExistingChat paths and keep the temp session/chat as Completed, firing a changed event.
  • Add helper _isCommitTimeoutError to 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.

@Chulong-Li Chulong-Li marked this pull request as draft May 31, 2026 13:24
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>
@Chulong-Li Chulong-Li changed the title sessions: Keep Copilot CLI sessions on commit timeout Agents: Keep active Copilot CLI session during steering May 31, 2026
@Chulong-Li Chulong-Li marked this pull request as ready for review May 31, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents: Steering brings me to the new session screen

3 participants