Fix agent host worktree metadata timing#324280
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a timing problem where Agent Host sessions surfaced stale worktree/branch metadata during session creation and materialization. When a session is created, its provisional working directory is the selected checkout, not the final isolated worktree; the metadata (project, working directory, Git branch) only becomes authoritative once materialization completes. The changes ensure the cached session adapters and the session-list snapshot reflect the final materialized state, and that Git-state refreshes don't run against the transient checkout.
Changes:
- Treat
notify/sessionAddedas an authoritative upsert: update an already-cached adapter in place (via a newupdateAdapterhook) and report it aschanged, instead of ignoring duplicates. - Defer
refreshSessionGitStatewhile a session's lifecycle isCreating, and overlay live workspace metadata (modifiedTime,project,workingDirectory) ontolistSessionssnapshots. - Persist remote adapter updates and fire
onDidChangeSessionswhen session_meta(Git state) changes.
Show a summary per file
| File | Description |
|---|---|
src/vs/platform/agentHost/node/agentHostGitStateService.ts |
Skips Git-state refresh while the session is in the Creating lifecycle. |
src/vs/platform/agentHost/node/agentService.ts |
Overlays live modifiedTime/project/workingDirectory from the state manager summary onto list snapshots. |
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Makes sessionAdded an upsert, adds the updateAdapter hook, and fires change events on meta changes. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts |
Overrides updateAdapter to refresh the persisted metadata cache and mark it dirty. |
src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts |
Adds coverage for deferring Git state while creating. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Adds coverage for overlaying live metadata over a stale snapshot. |
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts |
Adds in-place upsert and Git-meta notification tests; renames the dedup test. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts |
Adds a persistence test for materialized workspace metadata. |
src/vs/sessions/SESSIONS.md / AGENT_HOST_SESSIONS_PROVIDER.md |
Document the authoritative-upsert and deferred Git-state behavior. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 0
- Review effort level: Medium
roblourens
marked this pull request as ready for review
July 4, 2026 03:12
roblourens
enabled auto-merge (squash)
July 4, 2026 03:12
alexdima
approved these changes
Jul 4, 2026
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.
Fix #322529
Summary
Validation
npm run typecheck-clientnpm run valid-layers-checkSessionAdded, corrected branch metadata 185ms later and before turn completion(Written by Copilot)