Repository navigation
feat(native-chat): offer actions for what you right-click in chat - #28729
AmoabaKelvin merged 3 commits into
Conversation
3ce6ed0 to
5a7f589
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
📥 Commits
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
5a7f589 to
d96ec1f
Compare
…component Moves the split, expand, title, ID and close rows unchanged out of use-native-chat-context-menu.tsx so the hook stays under the file size limit.
The chat's right-click menu only knew about selections and images, so links, code blocks and messages offered nothing, and the terminal menu's Copy Context and Clear Pane Title were missing over a terminal-backed chat. The menu now reads what was right-clicked and offers the action that target's own surface already runs: the link popover's rows plus Copy link or Copy Path, the code block's and message's hover copy text, the selection quote's Add to chat, the hover rewind button, and Find in chat. Rows carry only ids in the DOM; message text comes from the transcript through the message list handle. Click and right-click now share one link-action builder, and the terminal and chat menus share the Hand Off, Copy Context and Clear Pane Title rows.
c372368 to
abe8d26
Compare
ELI5
Right-clicking in a chat used to offer almost nothing about the thing you clicked. Now the menu offers what makes sense for it: open or copy a link, copy a code block or a whole message, quote a selection back into the chat, rewind to a prompt, or open Find. A chat running over a terminal also gets the terminal menu's Copy Context and Clear Pane Title.
What Changed
Before: the chat right-click menu offered Copy image, Copy (only with a selection), Paste (only in a text field), plus the session and pane items. Right-clicking a link, a code block or a message gave no actions for it. The "Add to chat" quote button hid itself while the menu was open, and Copy Context and Clear Pane Title from the terminal menu were missing in a terminal-backed chat.
After: the menu offers rows for whatever was right-clicked, each running the action that target's own button or click already runs:
Copy, Paste and the other rows still show only where they apply (#26207). Select All, Quick Commands, Clear Screen and Reset Terminal stay terminal-only. The transcript is windowed, so a select-all would copy only part of it. Quick Commands would type into the agent's terminal behind the composer. Clear Screen and Reset Terminal change nothing you can see in chat.
Mechanism: when the menu opens, it reads what was right-clicked (
native-chat-context-menu-target.ts). Rows carry only ids in the DOM, never copy text. Message text comes from the transcript's own rows through the message list's handle (messageCopyText), using the same text derivation as the hover copy buttons. Link rows come from one builder,native-chat-link-target-actions.ts, that the click popover now uses as well, so click and right-click can't drift apart. Hand Off, Copy Context and Clear Pane Title render through components shared with the terminal menu. The find hook exposes the open step its shortcut already ran.Reviewing: the first commit is a pure move. The existing split/expand/title/ID/close rows go unchanged into
NativeChatPaneMenuItems.tsx, because the menu hook hit the 400-line limit. Check it withgit diff --color-moved; the second commit is the new behavior.Why
Every new row reuses an existing handler (hover copy, quote popover, link popover, rewind button, find shortcut, terminal pane menu), so the menu adds no new behavior that could disagree with the button next to it. The alternatives were storing copy text in DOM attributes or recomputing message text from the host's raw message list. The first duplicates large text in every row. The second misses rows the list builds itself: pending sends, the launch prompt, merged tool runs.
Linked Issue
No issue; internal request to make the chat right-click menu richer and bring over the terminal items that apply.
Visual Proof
Hidden dev build over CDP (macOS, a Claude chat tab and a Claude chat over a terminal pane):
Before: the same right-clicks showed only Copy/Paste where they applied plus the pane items (no link, code, message, quote, Find, Copy Context or Clear Pane Title rows).
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Live (macOS, hidden dev build): Copy code and Copy message put exactly the hover buttons' text on the clipboard. Add to chat quoted the selection into the composer. Find opened and focused the find bar. Copy Context copied the agent transcript and showed "Context copied". Clear Pane Title appeared only after Set Title and removed the title. The terminal pane's own menu still shows Copy Context.
New tests:
use-native-chat-context-menu.targets.test.tsx(links, file links, Add to chat, rewind enabled and disabled, empty area, Find, Copy Context, Clear Pane Title),NativeChatResolvedView.context-menu.test.tsx(copy a real rendered reply, its code block and a prompt, matched against the hover copy button; no Copy message on a reply still being written), andTerminalPaneNativeChatPortal.test.tsx(the new actions target the chat's pane). All 9 new behavior tests fail with the production files reverted to main.Ran:
pnpm tc, oxlint and oxfmt on changed files, and the focused test files for the changed modules.Not verified:
pnpm tc,check:code-quality:changed,check:react-doctor:changedand the focus-read ratchet pass, and repo-wide oxlint is clean exceptmax-lineson two test files this PR does not touch (src/shared/git-binary-compatibility.test.ts820/800,mobile/src/session/MobileNativeChatView.test.ts806/800), which both fail on a cleanorigin/maintoo.pnpm lintstops at that oxlint step, so its later audit steps last passed one rebase earlier.Notes
use-native-chat-link-actions.tstonative-chat-link-target-actions.ts, because the same read moved with the builder.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)