feat(vscode): add native context menu copy actions for webview chat#3477
Conversation
yiliang114
left a comment
There was a problem hiding this comment.
The overall direction looks good and seems to address the main UX gap behind #3052. I left two inline notes: one correctness issue around routing the command back to the webview that actually triggered the context menu when multiple chat surfaces are open, and one markdown-fence edge case in Copy All Messages when tool output already contains triple backticks. I also ran the targeted provider tests locally after building @qwen-code/qwen-code-core and @qwen-code/webui.
ee0d038 to
d846b0f
Compare
yiliang114
left a comment
There was a problem hiding this comment.
The feature direction looks good and the UX addition makes sense, but there is still one correctness issue that can make Copy Message resolve the wrong item when non-rendered messages are present in allMessages. I left the blocker inline, plus one non-blocking maintainability note.
fd6722b to
0b5da78
Compare
Add three right-click context menu items to the chat message area using VSCode's native webview/context API: - Copy Message: copies the right-clicked message's raw markdown content - Copy All Messages: copies the full conversation in markdown format - Copy Last Reply: copies the last assistant response Implementation details: - Commands registered in package.json with webview/context menu entries - Clipboard writes go through extension host (vscode.env.clipboard) for reliability in webview sandbox - Message identification via data-msg-idx stamped after render - Tool-call outputs supported including diff format (git diff style) - i18n support via package.nls.json (English) and package.nls.zh-cn.json - Menu only shown in message area (not input box or empty state) Closes QwenLM#3052
… not single Copy Message
… dynamic code fences
…hared message handling Replace the wrapper-div approach (which broke CSS layout) with a render-time childIndexMap that maps DOM child positions to allMessages indices. This avoids both the useLayoutEffect index-drift bug and the wrapper-div CSS side effects. - Remove data-msg-idx wrapper divs; messages render directly as container children, preserving original [&>*] CSS layout - Build childIndexMap during MessageList render, skipping null items (empty AssistantMessage, hidden tool calls via shouldShowToolCall) - findMessageIndex walks up from click target to container's direct child, then maps through childIndexMap - Filter hidden tool calls and empty content in copyAllMessages - Extract handleCommonWebviewMessage to deduplicate routing logic across sidebar, editor panel, and restored panel handlers - Clear lastContextMenuProvider on dispose to prevent memory leaks
…opy failure - Copy Message on image messages now outputs markdown format  instead of empty string - Copy All Messages includes image messages as  instead of skipping them - Copy Last Reply skips empty assistant placeholders during streaming - Resolve intermittent copy failure by pre-resolving message index on right-click instead of storing a DOM element reference that can become stale after React re-renders
0b5da78 to
e7bd6fd
Compare
…wenLM#3477) * feat(vscode): add native context menu copy actions for webview chat Add three right-click context menu items to the chat message area using VSCode's native webview/context API: - Copy Message: copies the right-clicked message's raw markdown content - Copy All Messages: copies the full conversation in markdown format - Copy Last Reply: copies the last assistant response Implementation details: - Commands registered in package.json with webview/context menu entries - Clipboard writes go through extension host (vscode.env.clipboard) for reliability in webview sandbox - Message identification via data-msg-idx stamped after render - Tool-call outputs supported including diff format (git diff style) - i18n support via package.nls.json (English) and package.nls.zh-cn.json - Menu only shown in message area (not input box or empty state) Closes QwenLM#3052 * fix(vscode): wrap tool-call content text in code blocks for copy * fix(vscode): only wrap tool-call content in code blocks for Copy All, not single Copy Message * fix(vscode): route copy commands to the right-clicked webview and use dynamic code fences * fix(vscode): use childIndexMap for copy-message routing and extract shared message handling Replace the wrapper-div approach (which broke CSS layout) with a render-time childIndexMap that maps DOM child positions to allMessages indices. This avoids both the useLayoutEffect index-drift bug and the wrapper-div CSS side effects. - Remove data-msg-idx wrapper divs; messages render directly as container children, preserving original [&>*] CSS layout - Build childIndexMap during MessageList render, skipping null items (empty AssistantMessage, hidden tool calls via shouldShowToolCall) - findMessageIndex walks up from click target to container's direct child, then maps through childIndexMap - Filter hidden tool calls and empty content in copyAllMessages - Extract handleCommonWebviewMessage to deduplicate routing logic across sidebar, editor panel, and restored panel handlers - Clear lastContextMenuProvider on dispose to prevent memory leaks * fix(vscode): handle image messages in copy and resolve intermittent copy failure - Copy Message on image messages now outputs markdown format  instead of empty string - Copy All Messages includes image messages as  instead of skipping them - Copy Last Reply skips empty assistant placeholders during streaming - Resolve intermittent copy failure by pre-resolving message index on right-click instead of storing a DOM element reference that can become stale after React re-renders

TLDR
Add three right-click context menu items to the chat message area using VSCode's native webview/context API:
This improves usability by allowing users to quickly copy specific messages without manual text selection.
Screenshots / Video Demo
CopyMessage.mp4
Dive Deeper
Implementation details:
package.jsonwithwebview/contextmenu entriesvscode.env.clipboard) for reliability in webview sandboxdata-msg-idxstamped after renderpackage.nls.json(English) andpackage.nls.zh-cn.jsonReviewer Test Plan
Testing Matrix
Linked issues / bugs
Resolves #3052
🤖 Generated with Qwen Code