Repository navigation
Offer Stop for copilot detached background shells - #341310
Merged
Merged
Conversation
Detached shells now show the same Stop Shell button as attached ones, but only when the SDK's `tasks.list` reports the shell's process ID. Without one `tasks.cancel` has no process to stop, so the button stays hidden.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is narrowly scoped, consistent with the existing cancellation path, and adequately tested.
0 open findings
What changed in this PR
Extends Agent Host background-shell cancellation to detached shells when the runtime provides a process ID.
Changes:
- Marks eligible detached shells as stoppable.
- Tests detached shells with and without process IDs.
- Updates Agent Host documentation.
| File | Description |
|---|---|
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Enables stopping detached shells with known PIDs. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Covers publication and cancellation behavior. |
src/vs/platform/agentHost/AGENTS.md |
Documents detached-shell stopping semantics. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Background shells without live output, such as detached ones, now show the same card as shells with output: the command, its running status, and Stop in the card's action bar. The terminal appears only when output is available. The details no longer repeat the elapsed time, shell ID, and start time as text; the row's badge and description keep them, as they already did for shells with output.
Contributor
|
Base:
|
Anthony Kim (anthonykim1)
marked this pull request as ready for review
October 13, 2026 16:42
Anthony Kim (anthonykim1)
enabled auto-merge (squash)
October 13, 2026 16:48
Sandeep Somavarapu (sandy081)
approved these changes
Oct 13, 2026
Don Jayamanne (DonJayamanne)
added a commit
that referenced
this pull request
Oct 13, 2026
…xploration-vscode * origin/main: (40 commits) MSRC fixes (#341342) chat: render input attachments for the input model's session (#341350) chat: center subagent tool activity hooks (#341258) Manage Copilot plugin marketplaces through Agent Host (#341301) fix: linux setuid sandbox helper permissions (#341292) agentHost: resolve #chat chips on the host of the chat that shows them (#341332) [Perf] agentHost: limit archived sessions over Mission Control (#341327) Remember expanded state for "Other Models" in model picker (#341335) Offer Stop for copilot detached background shells (#341310) agentHost: allow inherited peer chats to move workspaces (#341317) [Perf] agentHost: reduce Mission Control relay overhead (#341223) Fix Customizations modal spacing (#341144) Fix dependency cycle in QuickInputService and EditorResolverService (#341321) Fix Explorer refresh on restoring deleted workspace root folder (#341323) chat: Share and rate-limit core utility model requests (#340100) agentHost: open #chat chips on the connection that owns the chat (#341313) Fix flaky StorageMainService tests by awaiting storage warm-up (#341305) agentHost: record the default chat role instead of reading the default chat URI shape (#341293) welcome: preserve tab icon color with Modern Icons Fix flaky test in diskFileSystemProvider.test.ts (#341304) ... # Conflicts: # src/vs/platform/agentHost/node/agentService.ts # src/vs/platform/agentHost/node/protocolServerHandler.ts # src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts # src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
This was referenced Oct 16, 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.
Resolves: #341329
Follows #340097. Replaces #340514, which was stacked on #340097 and conflicts now that it has merged.
session.rpc.tasks.listreports its process ID (TaskShellInfo.pid). A detached shell started in the session always has one. Only a detached shell restored without a recorded ID lacks one, andsession.rpc.tasks.cancelcan't stop it, so the button stays hidden there.errorForegroundthere, which sharesdebugIcon.stopForeground's defaults.vscode/stopBackgroundWorkrequest and the SDK'ssession.rpc.tasks.cancel.session.idle, so stopping one doesn't affect the turn.How to test
Use a local Agent Host Copilot session with
chat.agentHost.customTerminalTool.enabledset tofalse.for i in $(seq 1 300); do echo tick $i; sleep 1; donein async mode with detach set to true. Don't read its output."Ran locally:
npm run transpile-client: passed.npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts: 1038 passing. With thecopilotAgentSession.tschange reverted, the two updated tests fail../scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/sessionBackgroundShellsControl.test.ts --run src/vs/workbench/contrib/chat/test/browser/accessibility/chatBackgroundShellOutputAccessibleView.test.ts --run src/vs/workbench/contrib/chat/test/browser/accessibility/chatAccessibilityHelp.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts: 96 passing. Against the previous details code, three of the updated control tests fail.npm run eslinton the changed TypeScript files andnpm run stylelinton the changed CSS: passed.debugIcon.stopForegroundwhen that variable is defined, and toerrorForegroundwhen it isn't, as in the Agents window.npm run typecheck-client: no errors in the changed files. The errors it does report are all in Electron main-process files, from other outdated packages in my local install.sleepshell, using my local@github/copilot-sdk1.0.17-preview.5 install and the binary it bundles:session.rpc.tasks.listreported the shell withattachmentMode: "detached"and apid, andsession.idlearrived before any cancel.session.rpc.tasks.cancelreturned{ cancelled: true }, the task becamecancelled, and the process exited within about 130 ms.@github/copilot-sdk1.0.20-preview.2, the versionmainpins, and no Agent Host errors. I haven't driven the Stop flow end to end myself.Inspirations from:
CopilotAgentSession._toBackgroundWorkfrom Add Stop for attached background shells in Agent Host chats #340097.CopilotAgentSession.stopBackgroundWorkunchanged.toChatBackgroundShells.BackgroundShellCommandViewreuses the title row ofBackgroundShellOutputViewand its status rendering, moved into shared helpers.debug-stoptheme rule, which only the editor window loads.