fix(app): Cmd+C/Ctrl+C copies highlighted text in non-editable chat content (#136) - #152
Merged
jeonghun-jj-lee merged 2 commits intoAug 9, 2026
Merged
Conversation
…ontent (#136) Inside the VS Code webview iframe, Electron intercepts Cmd+C at the host level before a `copy` event fires in the iframe DOM. The existing capture-phase keydown handler bailed on non-editable targets — the assumption that 'native behavior works' is false in this context. Fix: extend the onKeyDown handler to bridge Cmd+C/X/A for non-editable targets through `writeClipboardViaBridge`, the same path the context menu's Copy already uses successfully. - Cmd+C: reads window.getSelection(), writes via bridge - Cmd+X on non-editable: copy-only (cannot delete from rendered DOM) - Cmd+A on non-editable: selectAllChildren(document.body) - No selection → no-op (clipboard unchanged) - Existing editable-target behavior unchanged - CLIPBOARD_SELF_SELECTOR opt-out unaffected (paste-only) Fixes #136
The original fix bridged Cmd+C for highlighted text in non-editable chat content, but the Cmd+A → Cmd+C sequence to copy the full session failed: the prompt input held focus, so the non-editable path never fired, and the virtualised timeline meant DOM selection was incomplete anyway. Fix: serialize the full session from the message store (data model) rather than relying on DOM selection. - Add sessionCopyProvider slot (registered by the session page; returns the full session as markdown with role labels) - Cmd+A on an empty prompt arms a fullSessionCopyPending flag and visually highlights the timeline (best-effort); Cmd+A on a non-empty prompt preserves standard select-all-in-editor behavior - Cmd+C when the flag is armed calls the provider → writeClipboardViaBridge - Non-editable Cmd+A → Cmd+C path also uses the provider when available - Cmd+A inside #review-panel scopes to that panel's content - Add serialize-session.ts (messages + parts → markdown text) - Fix stale test from the prior commit (non-editable interception) - 49 tests pass (41 clipboard + 8 serializer) Known limitation: Cmd+A inside a rendered code block selects the full chat rather than scoping to the block (keydown target is the focused viewport, not the clicked element). Code blocks already have a copy button for this.
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
Cmd+C on selected text in the chat panel (rendered messages, code blocks) silently failed — the clipboard retained its previous content. Right-click → Copy worked because it explicitly calls
writeClipboardViaBridge.Root cause
global-clipboard.ts:186bailed on non-editable targets:The assumption ("native behavior works") is false inside a VS Code webview iframe. Electron intercepts Cmd+C at the host level before a
copyevent fires in the iframe DOM.Fix
Extend the existing capture-phase
keydownhandler to bridge Cmd+C/X/A for non-editable targets throughwriteClipboardViaBridge— the same path the context menu already uses.Behavior
selectAllChildren(document.body)Structure
Constraints preserved
CLIPBOARD_SELF_SELECTORopt-out unaffected (it is paste-only)writeClipboardViaBridgeremains the sole outbound clipboard pathchat_bridge.tsclipboard-write handler) needs no changesFixes #136