Repository navigation
fix(native-chat): show right-click Copy and Paste only where they apply - #26207
Conversation
Copy was always listed, greyed out or copying text selected earlier. Paste was offered on messages, and did nothing in a structured question's answer field.
📝 WalkthroughWalkthroughThe context-menu hook now handles pointer-down events and captures the current selection when the menu opens. Copy, Paste, and other menu actions appear only when applicable. Native chat views forward pointer-down capture events to the hook. The structured session also passes its question-answer input ref to pane commands and the paste bridge. Unit and end-to-end tests cover menu actions, selection handling, and paste availability. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Paste can put text in the chat draft instead of the model search field. This is a narrow, recoverable issue that should be fixed or accepted before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
baba801a-b430-4281-bbcb-04e19122df43
📒 Files selected for processing (7)
src/renderer/src/components/native-chat/NativeChatResolvedView.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/use-native-chat-context-menu.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-context-menu.tsxsrc/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.test.tsxsrc/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.tstests/e2e/native-chat-context-menu-copy-paste.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| point: { x: event.clientX, y: event.clientY }, | ||
| selectedText, | ||
| selectedText: getNativeChatSelectedText(rootRef.current), | ||
| canPaste: isEditableTarget(event.target), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Restrict Paste to the field that will receive it.
isEditableTarget also accepts controls such as <select> and non-text inputs. It also accepts text fields other than the composer and question-answer input. The menu can therefore offer Paste on an inapplicable control, or paste into the composer instead of the clicked field. Check the actual paste target here, and retain that target if Paste must work in other text fields.
|
@AmoabaKelvin shouldn't it still show the 'Move tab to split' button in the right click menu everywhere? |
|
@brennanb2025 its still the same, those option only come in whenever that tab's group has more than one tab. I only had one tab while recording this |
ELI5
Right-clicking in the chat always showed Copy and Paste, even when there was nothing to copy and nowhere to paste. Now Copy only shows up when you have text highlighted, and Paste only shows up when you right-click a text box.
What Changed
Before: right-clicking anywhere in native chat opened a menu with Copy and Paste at the top, whatever you clicked on.
After:
How:
Why
A menu item that applies to nothing is confusing, and one that copies text you can no longer see highlighted is worse. Paste on a message had the same problem: its effect happened somewhere other than where you clicked.
Visual Proof
Before:
CleanShot.2026-10-07.at.12.30.13.PM.mp4
After:
CleanShot.2026-10-07.at.12.27.35.PM.mp4
Testing
Tested on macOS, in both the chat view of a terminal pane and the structured chat tab:
Unit tests cover Copy appearing only with highlighted text, Paste appearing only in a text box, and which clicks are treated as opening the menu on Mac and elsewhere. Not tested on Windows or Linux.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Renderer-only change to the chat's right-click menu. It behaves the same for local and SSH sessions and for folder workspaces, and nothing sent between client and host changes. The ctrl-click handling applies on Mac only; on Windows and Linux ctrl-click is left alone.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)