agentHost: restore missing Copilot worktrees on resume#320326
Draft
roblourens wants to merge 1 commit into
Draft
agentHost: restore missing Copilot worktrees on resume#320326roblourens wants to merge 1 commit into
roblourens wants to merge 1 commit into
Conversation
Recreate persisted worktrees before normal Copilot session resume, but keep archived history lookup lazy by using the persisted repository root with an uncached temporary session. Avoid replacing missing-directory resume failures with empty sessions, and cover archived lookup races/subagent lifetime. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Copilot session resume behavior in the Agent Host by handling cases where a persisted worktree directory has been deleted, and by making archived-history message lookup avoid expensive/eager worktree recreation and caching.
Changes:
- Recreate missing persisted Copilot worktrees on resume (before invoking the SDK) to prevent resume failures when the worktree directory was deleted.
- Treat missing-working-directory resume failures as non-recoverable (don’t replace the session with a fresh empty session).
- Add regression tests covering: missing-directory resume fallback behavior, worktree recreation on resume, archived message lookup behavior (including subagent history lifetime).
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Adds archived-aware message lookup and resume options to support worktree recreation and non-cached archived history reads. |
| src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts | Extends fallback classifier to avoid “empty session” fallback on missing-directory resume errors. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Adds targeted regression coverage for the new resume and archived-history behaviors. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Comment on lines
+1275
to
+1279
| const isArchived = await this._isSessionArchived(session); | ||
| const hadActiveClient = this._activeClients.has(session); | ||
| let entry: CopilotAgentSession; | ||
| try { | ||
| entry = await this._resumeSession(sessionId, { recreateMissingWorktree: !isArchived, cache: !isArchived }); |
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.
Summary
Validation
(Written by Copilot)