Stream built-in shell output over AHP terminal channel#327067
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5083fb1f-34d7-44bf-82a1-c4582e57683b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5083fb1f-34d7-44bf-82a1-c4582e57683b
…t over the terminal channel - Re-vendor agent-host-protocol: terminalComplete removed, exitCode/preview/truncated fold into terminal.result (TerminalCommandResult), isPty added to ToolResultTerminalContent and TerminalState - shell_exit now lands on the tool call's terminal block; history replay synthesizes a non-pty block keyed by toolCallId - Stream tool.execution_partial_result into an output-only agenthost-terminal channel (isPty false) instead of replacing Text content - Normalize LF to CRLF in AgentHostPty when the channel is plain text - Re-apply local CompletionItem.label extension clobbered by the protocol sync (still needs upstreaming)
The runtime emits cumulative plain-text snapshots (ANSI-stripped, throttled) that are capped to the leading ~10KB with a growing truncation marker, so a length-based delta goes stale once output exceeds the cap. Track the last emitted snapshot and prefix-check it: extend in place while the snapshot grows, reset the channel and rewrite when it was rewritten.
Pty-backed channels already carry CRLF because the pty converts output line endings; do the same for output-only channels at the point data enters the channel, so terminal frontends render both identically and AgentHostPty needs no isPty-specific handling. Reverts the client-side normalization.
There was a problem hiding this comment.
Pull request overview
Streams Copilot built-in shell output through AHP output-only terminal channels while adopting the updated terminal protocol and SDK.
Changes:
- Adds non-PTY terminal streaming, replay, reset, and completion handling.
- Moves shell results onto terminal content blocks and updates rendering/tests.
- Updates the Copilot SDK and excludes unused Koffi native packages.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.ts |
Configures xterm for plain-text channels. |
src/vs/workbench/contrib/terminal/browser/agentHostPty.ts |
Tracks non-PTY channel state. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts |
Updates terminal-result restoration tests. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts |
Reads completion data from terminal blocks. |
src/vs/platform/agentHost/test/node/testAgentHostTerminalManager.ts |
Extends the terminal manager test double. |
src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts |
Tests shell-result folding and replay. |
src/vs/platform/agentHost/test/node/copilotShellTools.test.ts |
Updates the terminal manager stub. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests runtime output streaming and resets. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Updates the terminal manager stub. |
src/vs/platform/agentHost/test/node/agentHostTerminalManager.test.ts |
Tests output-only terminal channels. |
src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts |
Maps SDK shell exits to terminal results. |
src/vs/platform/agentHost/node/copilot/copilotSystemNotification.ts |
Adapts to updated SDK types. |
src/vs/platform/agentHost/node/copilot/copilotNonPtyShellTerminals.ts |
Implements cumulative output streaming. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Connects partial shell results to channels. |
src/vs/platform/agentHost/node/agentHostTerminalManager.ts |
Manages output-only terminal resources. |
src/vs/platform/agentHost/common/state/sessionState.ts |
Re-exports the new result type. |
src/vs/platform/agentHost/common/state/protocol/channels-terminal/state.ts |
Adds terminal PTY metadata. |
src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts |
Re-vendors session protocol documentation. |
src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts |
Folds completion data into terminal content. |
src/vs/platform/agentHost/common/state/protocol/.ahp-version |
Updates the protocol source pin. |
remote/package.json |
Updates the remote SDK dependency policy. |
remote/package-lock.json |
Locks remote SDK and Koffi dependencies. |
package.json |
Updates the root SDK dependency policy. |
package-lock.json |
Locks root SDK and Koffi dependencies. |
build/.moduleignore |
Excludes unused Koffi native packages. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 3
- Review effort level: Medium
| */ | ||
| insertText: string; | ||
|
|
||
| /** |
There was a problem hiding this comment.
@DonJayamanne Copilot is telling me #326807 hand-wrote this file and its now getting replaced with the new .ahp-version bc they dont seem to be in upstream ahp.
Dont think there would be regression since label was on attachment.label though. Please can you double check?
There was a problem hiding this comment.
Files impacted (generated by copilot)
• The completion cleanup affects four files:
- src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts:284 —
regenerated; removes handwritten CompletionItem.label.
- src/vs/platform/agentHost/node/copilot/copilotSlashCommandCompletionProvider.ts:200 — puts
and sorts the display label using attachment.label.
- src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/
agentHostSessionHandler.ts:888 — maps attachment.label into the workbench completion item.
- src/vs/workbench/contrib/chat/test/browser/agentSessions/
agentHostChatContribution.test.ts:9658 — verifies a visible label is preserved when
insertText is empty
There was a problem hiding this comment.
hmm, thats weird, I see, the model must have made this change :(
I'll take a look
There was a problem hiding this comment.
Feel free to merge your PR, i'll have a look at this once its merged.
There's no point blocking your PR
Related: microsoft/agent-host-protocol#352
Resolves: #324825
Part of: #323399
exitCode/preview/truncatedonto the terminal result and distinguish PTY-backed terminals from plain-text output channels withisPty.tool.execution_partial_resultevents from runtime-executed shell tools into output-only AHP terminal channels, while keeping client-hosted PTY terminals on their existing path.shell_exitmetadata for the command result. When the external SDK bridge removes that block, use the runtime's trailing shell-completion marker as a scoped non-PTY fallback for the exit code and retained preview.ITerminalInstance, adding a root terminal entry, opening a panel terminal, or exposing terminal Focus/Show actions.isPty === false..ahp-version.Inspirations from:
isPtyandresult: TerminalCommandResultshapes come from the protocol change itself:ToolResultTerminalContent/TerminalCommandResultandTerminalState.isPty.copilotAgentSession.AgentHostTerminalManager._handlePtyData.copilotShellTools.ChatTerminalToolProgressPart._attachAhpCommandSource.