chat: add "Copy Final Response" context menu action#306184
Merged
roblourens merged 2 commits intomainfrom Mar 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “Copy Final Response” command to the chat response context menu, backed by a new IResponse.getFinalResponse() API that extracts only the last contiguous block of meaningful markdown/inline-reference text from a response.
Changes:
- Add
IResponse.getFinalResponse()and implement it inAbstractResponse(chatModel.ts). - Register
Copy Final ResponseinMenuId.ChatContextand wire it to the clipboard (chatCopyActions.ts). - Fix context menu scoping by providing
ChatContextKeys.isResponsein the chat list overlay (chatListWidget.ts). - Add unit tests for the new extraction behavior and update mocks for the interface change.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/model/chatModel.ts | Adds getFinalResponse() to IResponse and implements the extraction logic in AbstractResponse. |
| src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts | Introduces the new context menu action that copies response.getFinalResponse() to the clipboard. |
| src/vs/workbench/contrib/chat/browser/widget/chatListWidget.ts | Sets ChatContextKeys.isResponse in the context menu overlay so when clauses work correctly. |
| src/vs/workbench/contrib/chat/test/common/model/chatModel.test.ts | Adds unit tests for getFinalResponse() behavior. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/*.test.ts | Updates test mocks to satisfy the updated IResponse interface. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/common/model/chatModel.ts:521
- In the segment concatenation loop,
getFinalResponseagain checkspart.content.value.length > 0before adding markdown. If you switch the backward scan to a trimmed-blank check, this should be updated too; otherwise whitespace-only markdown can still be included in the copied text.
} else if (part.kind === 'markdownContent' || part.kind === 'markdownVuln') {
if (part.content.value.length > 0) {
segments.push(part.content.value);
}
rebornix
approved these changes
Mar 30, 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.
Summary
Adds a new "Copy Final Response" action to the chat context menu. Unlike "Copy" (which copies the entire response) and "Copy All" (which copies the whole session), this action copies only the last contiguous block of non-empty markdown from a response — the final textual answer the model gave.
This is useful when a response ends with tool calls followed by empty markdown parts, but the user wants to quickly copy just the final prose answer.
Changes
New
getFinalResponse()method onIResponsemarkdownContent,markdownVuln, andinlineReferencepartsAbstractResponseinchatModel.tsNew
CopyFinalResponseActionMenuId.ChatContextunder thecopygroupChatContextKeys.isResponse)response.getFinalResponse()and writes to clipboardContext key fix
ChatContextKeys.isResponseto the context menu overlay inchatListWidget.tsso thatwhenclauses referencing this key work correctly in the context menuTests
Fixes #306185