Skip to content

Fix new cloud session disappearing and misgrouping after commit#326230

Open
osortega wants to merge 3 commits into
mainfrom
osortega/fix-cloud-session-commit-grouping
Open

Fix new cloud session disappearing and misgrouping after commit#326230
osortega wants to merge 3 commits into
mainfrom
osortega/fix-cloud-session-commit-grouping

Conversation

@osortega

Copy link
Copy Markdown
Contributor

Problem

Sending a new cloud agent session from the Agents window (vs/sessions) failed in three ways:

  1. The session disappeared ~5s after clicking Delegate, even though the task was created successfully on the backend.
  2. Once it did appear, it landed in the "Unknown" group.
  3. Its repo label flipped from microsoft/vscode (pre-commit) to vscode (post-commit).

Root causes & fixes

1. Session disappears — wait for the committed resource

A cloud session (RemoteNewSession) commits a new resource mid-request (untitled-…/task/<id>), exactly like Copilot CLI. But _sendFirstChat grouped it with Claude (whose resource is stable), so it waited for the stale untitled resource in the cache, timed out, and removed the session.

  • RemoteNewSession now routes through _waitForCommittedSession to learn the committed /task/<id> resource.
  • That wait is deferred for cloud: it skips the responseCompletePromise race (which resolves early at the confirmation, not when the commit lands) and uses a longer timeout, because the cloud commit is delayed by a confirmation round-trip + network delegation + session load. Diagnosed from trace logs showing the commit event firing at ~T+6.5s while the old 5s safety timeout gave up at ~T+5.6s.

2. "Unknown" group — attach repo metadata to PR-less task cards

Grouping derives the repo from getRepositoryName(session) (metadata.owner/metadata.name). A brand-new PR-less task session item carried no metadata, so it grouped under "Unknown" (Agents window) / "Other" (core).

  • Repo identity is hoisted from PullArtifactRef.repo up to CloudSessionData.repo — a task has a repo regardless of whether it has a pull artifact. resolvePullArtifact now takes repo as an explicit argument (its only consumer).
  • The PR-less task card now attaches metadata: { owner, name } from CloudSessionData.repo.

3. Label flip — consolidate to owner/repo

The two label producers derived the repo label differently: the new-session workspace used owner/repo (stripping /HEAD), while the committed adapter used getRepositoryName (repo name only).

  • Both now route through a single githubRemoteRepoLabel(uri) helper returning owner/repo, so the session stays in the same group across the commit swap.

Tests

  • Adds a regression test for the cloud commit-swap (cloud session that commits a new resource resolves without timing out).
  • Full CopilotChatSessionsProvider suite passes (77); client typecheck and copilot-extension typecheck are clean.

Notes

  • Fixes 2 and 3 also improve grouping in workbench core's session list, which consumes the same provider metadata.
The Agents window (vs/sessions) drove a new cloud (RemoteNewSession) agent
session through the wrong commit path, causing it to disappear ~5s after
delegating, and then group under "Unknown" / flip its repo label once it did
appear. Three related fixes:

1. Wait for the committed resource on cloud sessions. A cloud session commits
   a new resource mid-request (untitled -> /task/<id>), like Copilot CLI, so
   _sendFirstChat now routes RemoteNewSession through _waitForCommittedSession
   instead of waiting on the stale untitled resource (which timed out and
   removed the session). The wait is also deferred (skips the response-complete
   race, longer timeout) because the cloud commit is delayed by a confirmation
   round-trip and network delegation.

2. Attach owner/name metadata to PR-less task cards so a freshly created task
   groups under its repo instead of "Unknown"/"Other" until a PR resolves.
   Repo identity is hoisted from PullArtifactRef.repo to CloudSessionData.repo
   (a task has a repo regardless of a pull artifact); resolvePullArtifact now
   takes repo as an explicit argument.

3. Consolidate the repo label. Both the new-session workspace and the committed
   session adapter now derive an owner/repo label via a shared
   githubRemoteRepoLabel helper, so a cloud session stays in the same group
   before and after commit (no more microsoft/vscode -> vscode flip).

Adds a regression test for the cloud commit-swap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 16, 2026 21:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes cloud-session persistence, repository grouping, and label consistency after commit.

Changes:

  • Waits for cloud sessions to commit to their final resource.
  • Adds repository metadata to PR-less task sessions.
  • Standardizes GitHub repository labels as owner/repo.
Show a summary per file
File Description
copilotChatSessionsProvider.test.ts Adds cloud commit regression coverage.
copilotChatSessionsProvider.ts Handles cloud resource commits and consistent labels.
cloudAgentBackend.ts Hoists repository identity into session data.
taskApiBackend.ts Populates repository data for task listings.
pullArtifactResolver.ts Accepts repository identity explicitly.
copilotCloudSessionsProvider.ts Adds task metadata and forwards repository identity.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Medium
Comment thread extensions/copilot/src/extension/chatSessions/vscode-node/taskApiBackend.ts Outdated
…ssion-commit-grouping

# Conflicts:
#	src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts
@osortega
osortega marked this pull request as ready for review July 16, 2026 22:58
@osortega
osortega enabled auto-merge (squash) July 16, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants