Skip to content

fix(native-chat): show right-click Copy and Paste only where they apply - #26207

Merged
brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:native-chat-copy-only-for-selection
Oct 7, 2026
Merged

brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:native-chat-copy-only-for-selection

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​179 $\color{#cf222e}{\Huge{\mathbf{−}}}$​24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​155
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

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.

  • With nothing highlighted, Copy was greyed out and clicking it did nothing.
  • If you had highlighted something earlier and then clicked away, Copy looked active and silently copied that old text.
  • Paste was offered on messages and empty space, and put the clipboard into the message box at the bottom, away from where you clicked.

After:

  • Copy appears only when chat text is highlighted, and it copies exactly that text.
  • Paste appears only when you right-click a text box, such as the message box.
  • Right-clicking a message with nothing highlighted goes straight to the pane actions. Copy image and the copy button on each message are unchanged.

How:

  • The menu used to keep a memory of the last text you ever highlighted in that chat and fall back to it, because the click that opens the menu can clear the highlight before the menu appears. That memory was never cleared, which is where the stale copy came from. The menu now stops the opening click (right-click, or ctrl-click on Mac) from clearing the highlight, and reads what is highlighted at that moment. The memory is gone.
  • When the menu opens it now checks whether the click landed in a text box, and only then lists Paste.
  • With Copy and Paste no longer always present, the dividers between menu groups are only drawn when there is something above them, and the menu does not open at all if it would be empty.

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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Tested on macOS, in both the chat view of a terminal pane and the structured chat tab:

  1. Right-click a word with nothing highlighted: no Copy and no Paste.
  2. Highlight a sentence, right-click inside it or on another paragraph: Copy is first and copies that sentence.
  3. Highlight a sentence, click away, right-click: no Copy.
  4. Highlight a sentence, ctrl-click: Copy is first.
  5. Right-click the message box: Paste is first and pastes into it.
  6. Right-click an image: Copy image still works.
  7. In a split, right-click the unfocused chat pane: the menu acts on the pane you clicked.

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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The 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 16cfd

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: showing Copy and Paste only when they apply in the native chat context menu.
Description check ✅ Passed The description explains the user-facing change, why it is needed, implementation, visual proof, and testing. It leaves the linked issue field without a link and the lint, typecheck, test, and build c…
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: baba801a-b430-4281-bbcb-04e19122df43
📥 Commits

Reviewing files that changed from the base of the PR and between 2dc98c9 and 16cfd58.

📒 Files selected for processing (7)
  • src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/use-native-chat-context-menu.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-context-menu.tsx
  • src/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.test.tsx
  • src/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.ts
  • tests/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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@brennanb2025

brennanb2025 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

@AmoabaKelvin shouldn't it still show the 'Move tab to split' button in the right click menu everywhere?

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator Author

@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

@brennanb2025
brennanb2025 merged commit 49e6cc1 into stablyai:main Oct 7, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants