Simplify background shell reconciliation - #339345
Anthony Kim (anthonykim1) wants to merge 3 commits into
Conversation
Replace task-read counters with captured shell execution identities, clarify reconciliation ordering, and cover pending-read races. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation correctly handles the identified races and includes targeted regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Simplifies background shell reconciliation while preserving execution identity across asynchronous task reads.
Changes:
- Replaces read counters with shell/tool-call snapshots.
- Prevents stale reads from settling reused shell IDs.
- Adds regression coverage for shell replacement and concurrent completion.
| File | Description |
|---|---|
copilotAgentSession.ts |
Captures and reconciles shell snapshots before stale-publication checks. |
copilotNonPtyShellTerminals.ts |
Implements execution-aware snapshot reconciliation. |
copilotNonPtyShellTerminals.test.ts |
Tests ID reuse and completion during pending reads. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Screenshot ChangesBase: Changed (2)3 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. |
Replace the public snapshot handshake with one operation that owns task-list reads, execution identity checks, and disposal. Exercise the async boundary with pending-read regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Anthony Kim (anthonykim1)
left a comment
There was a problem hiding this comment.
Self-review at 73882d1. No regression found; the open question is the shape of the second commit.
- The settle rule is unchanged: being in the map captured before the read is the same condition as the old "read started after the shell went to the background", and the
toolCallIdcheck covers shell-ID reuse. - Superseded reads still settle shells before the revision check.
- Moving
completeBackgroundShellFromHelperResultup is a no-op; only the construction ofcontentsits between the old and new positions. copilotNonPtyShellTerminals.test.tsandcopilotAgentSession.test.tsat this commit: 836 passing.
Replacing the read counters with an identity snapshot (c1fd94f) is a real cleanup. Passing the task read through the shell class as a callback (73882d1) is the part to undo; details inline.
The description still describes the first commit's shape ("Name the running-shell set…") and says 832 passing.
Restore synchronous shell reconciliation while preserving execution snapshots. Remove callback-only SDK coupling and tests, and cover read ordering and running/idle shells at the session boundary. Addresses dependent review threads: #339345 (comment) #339345 (comment) #339345 (comment) #339345 (comment) #339345 (comment) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Follow-up to #339220.
Validation
npm run transpile-client: passed.npm run typecheck-client: passed../scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotNonPtyShellTerminals.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --reporter dot: 834 passing.npx --no-install eslint src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts src/vs/platform/agentHost/node/copilot/copilotNonPtyShellTerminals.ts src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts src/vs/platform/agentHost/test/node/copilotNonPtyShellTerminals.test.ts: passed.Manual smoke test (not run):
read_bashwaiting for completion. Verify the terminal exits with the reported exit code and the shell leaves the background list.Inspirations from: