agents: group worktree sessions by repository root#312770
agents: group worktree sessions by repository root#312770cavokz wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Sessions from user-created git worktrees (at arbitrary paths) were grouped separately in the Agents Sessions list because session metadata only contained `workingDirectoryPath` (the worktree-specific path), not the common repository root. `_buildMetadata()` in `AgentHostSessionListController` now also emits `repositoryPath` from `project.uri` (the git repository root resolved by the Copilot agent at session-creation time). Both local (`file://`) and remote (`vscode-agent-host://`) project URIs are handled — the latter is unwrapped via `fromAgentHostUri()` so that worktree sessions on remote hosts also collapse into a single group. The viewer's `getRepositoryName()` already checks `repositoryPath` before `workingDirectoryPath`, so sessions sharing the same repo root now collapse into a single group regardless of which worktree they ran in. Fixes microsoft#312729 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect grouping of Agent sessions created from user-managed Git worktrees by ensuring session metadata includes a stable repository-root path (repositoryPath) derived from the Copilot agent’s resolved project URI.
Changes:
- Emit
repositoryPathinAgentHostSessionListControllermetadata based onproject.uri, handling both localfile://and remotevscode-agent-host://URIs. - Add unit tests verifying
repositoryPathis populated correctly for local and remote sessions. - Add a grouping test ensuring sessions with the same
repositoryPath(but different worktreeworkingDirectoryPaths) collapse into a single repository group.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts | Adds repositoryPath to emitted session metadata by resolving/unwrapping project URIs. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Tests metadata generation for repositoryPath in both local and remote URI cases. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentSessionsDataSource.test.ts | Tests repository grouping behavior when multiple worktrees share the same repositoryPath. |
I asked support to my company legal department, I'll come back as soon as I get an answer. |
|
@cavokz please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Fixes #312729
Problem
Sessions from user-created git worktrees (at arbitrary paths) appeared as separate groups in the Agents Sessions list. Each worktree had a different
workingDirectoryPathin session metadata, which the viewer used for grouping — so each worktree produced its own group even though they belong to the same repository.Fix
_buildMetadata()inAgentHostSessionListControllernow also emitsrepositoryPathfromproject.uri(the git repository root, resolved by the Copilot agent at session-creation time viaresolveGitProject()).The viewer's
getRepositoryName()already checksrepositoryPathbeforeworkingDirectoryPath, so sessions sharing the same repo root now collapse into a single group regardless of which worktree they ran in. No changes to the viewer were needed.Both URI schemes are handled:
file://project URI →fsPathused directly asrepositoryPathvscode-agent-host://server/file/-/pathURI (as wrapped byremoteAgentHostProtocolClient) → unwrapped viafromAgentHostUri()to extract the remote pathTests
agentHostChatContribution.test.ts: verifiesrepositoryPathis set fromproject.urifor local sessions, and that remote (vscode-agent-host://) project URIs are unwrapped correctlyagentSessionsDataSource.test.ts: verifies that 3 sessions with the samerepositoryPathbut differentworkingDirectoryPathvalues are grouped into a single repository group