Skip to content

sessions: fix archive and retention of stopped temp sessions#308629

Merged
osortega merged 2 commits intomainfrom
copilot/terrible-mouse
Apr 8, 2026
Merged

sessions: fix archive and retention of stopped temp sessions#308629
osortega merged 2 commits intomainfrom
copilot/terrible-mouse

Conversation

@osortega
Copy link
Copy Markdown
Contributor

@osortega osortega commented Apr 8, 2026

Problem

Fixes: #306956
Ref: #307664

When a copilot-cli session is stopped before the first turn commits (i.e. the session resource is still copilotcli:/untitled-…), two bugs occur:

  1. Archive fails and deletes contentarchiveSession() couldn't find the temp session in the agent model, so it fell through to _cleanupTempSession() which deleted and disposed the session instead of archiving it.
  2. Stopped session disappears — The CancellationError handler in _sendFirstChat() didn't mark the session as completed, so it could vanish from the session list.

Fix

  • setArchived() on temp sessions — Added setArchived() to both CopilotCLISession and RemoteNewSession with a private _isArchived observable, so archiveSession() / unarchiveSession() can toggle archive state in-place without deleting.
  • Stopped session retention — The CancellationError path in _sendFirstChat() now sets SessionStatus.Completed and fires a changed event so the session stays visible.

Testing

  • Updated existing archive test to verify session stays in list with isArchived === true
  • Added new tests for deleting and archiving uncommitted temp sessions
  • All tests pass with no disposable leaks

When a copilot-cli session is stopped before the first turn commits, the
session remained in a temp/untitled state. Archiving such a session
previously fell through to cleanup logic that deleted and disposed it
instead of archiving in-place.

- Add setArchived() to CopilotCLISession and RemoteNewSession so temp
  sessions can be archived/unarchived without deletion
- Handle CancellationError in _sendFirstChat by marking the session as
  Completed so it stays visible in the session list
- Add tests for deleting and archiving uncommitted temp sessions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 22:40
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

Fixes Copilot Chat Sessions (Agents window) behavior for uncommitted temp sessions (copilotcli:/untitled-…) so that archiving no longer deletes session content and stopped-before-commit sessions remain visible.

Changes:

  • Add in-place archive state tracking to temp session implementations (CopilotCLISession, RemoteNewSession) via a private _isArchived observable and setArchived().
  • Update archiveSession() / unarchiveSession() to toggle archive state for uncommitted temp sessions instead of cleaning them up.
  • Update/extend tests to validate archiving behavior for in-flight and stopped-before-commit temp sessions.
Show a summary per file
File Description
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts Adds temp-session archive toggling support and uses it from archive/unarchive flows.
src/vs/sessions/contrib/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts Updates archive test expectations and adds coverage for archiving a stopped-before-commit temp session.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@osortega osortega merged commit 2d443f3 into main Apr 8, 2026
23 checks passed
@osortega osortega deleted the copilot/terrible-mouse branch April 8, 2026 23:53
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 8, 2026
joshspicer pushed a commit that referenced this pull request Apr 9, 2026
* sessions: fix archive and retention of stopped temp sessions

When a copilot-cli session is stopped before the first turn commits, the
session remained in a temp/untitled state. Archiving such a session
previously fell through to cleanup logic that deleted and disposed it
instead of archiving in-place.

- Add setArchived() to CopilotCLISession and RemoteNewSession so temp
  sessions can be archived/unarchived without deletion
- Handle CancellationError in _sendFirstChat by marking the session as
  Completed so it stays visible in the session list
- Add tests for deleting and archiving uncommitted temp sessions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: assert doesNotReject instead of swallowing sendPromise errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Sessions App: Cannot archive session

3 participants