Skip to content

Agentic UI: add a native text context menu - #4388

Merged
shaunandrews merged 12 commits into
trunkfrom
add-text-context-menu
Aug 6, 2026
Merged

Agentic UI: add a native text context menu#4388
shaunandrews merged 12 commits into
trunkfrom
add-text-context-menu

Conversation

@shaunandrews

@shaunandrews shaunandrews commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

AI wrote the implementation and tests from a scope I set interactively. I reviewed the approach, iterated on the menu behavior from review feedback, and tested it in the app.

Proposed Changes

Native text context menu in Studio

Right-click previously did nothing in Studio’s Agentic UI because Electron does not provide Chromium’s browser context menu automatically. This adds a native operating-system menu while keeping browser builds on their existing browser-provided menu.

Action When it appears
Look Up “…” macOS, when text is selected
Copy When text is selected, including selected composer text
Copy code When right-clicking a rendered code block
Copy All When right-clicking a user or assistant message
Paste In an editable text field when the clipboard contains text
Quote in composer When read-only text is selected

Copy All is message-level: assistant replies split by tool calls still copy all assistant text blocks. Tool details and tool output are not included. Code blocks retain their existing copy button, and the native menu’s Copy code action copies only the code block.

Quote in composer formats each selected line as a Markdown blockquote and leaves a blank line after it, with the composer focused and ready for the user to continue typing.

Every item is conditional on whether it can do something. Non-text inputs, read-only fields without a selection, unrelated controls, and empty canvas do not open an irrelevant menu. Undo, redo, cut, and delete remain deliberately outside this focused first pass.

Testing Instructions

This includes main-process code, so fully restart the app before testing.

  1. Send a message that includes normal text and a fenced code block.
  2. Select text in an assistant reply and right-click.
    • macOS: Look Up, Copy, Copy All, and Quote in composer.
    • Windows/Linux: Copy, Copy All, and Quote in composer.
  3. Choose Quote in composer. Confirm the selected text is inserted as a Markdown quote followed by a blank line, with the caret ready for typing.
  4. Right-click a code block. Confirm Copy code copies only the code while Copy All copies the full assistant message.
  5. Right-click earlier and later paragraphs of a reply split by a tool call. Confirm Copy All produces the same complete assistant message from either paragraph.
  6. Select text in the composer and right-click. Confirm Copy appears; with text on the clipboard, Paste also appears.
  7. Right-click a message with no selection. Confirm only the applicable message/code actions appear.
  8. Right-click unrelated UI, a checkbox, or empty canvas. Confirm no text menu opens.
  9. On macOS, choose Look Up and confirm the system Dictionary panel opens.
  10. Select a long passage and confirm the Look Up label collapses whitespace and truncates with an ellipsis.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Notes for reviewers:

  • ESLint passes for all touched TypeScript files.
  • npm run typecheck passes across all workspaces.
  • npm run cli:build:ui completes successfully.
  • The native-menu test plus the full apps/ui suite pass: 71 files, 508 tests.

…ok up

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This comment was marked as outdated.

@wpmobilebot

wpmobilebot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 6432fd3 vs trunk

app-size

Metric trunk 6432fd3 Diff Change
App Size (Mac) 1402.94 MB 1402.95 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk 6432fd3 Diff Change
load 1072 ms 1052 ms 20 ms ⚪ 0.0%

site-startup

Metric trunk 6432fd3 Diff Change
siteCreation 7548 ms 7539 ms 9 ms ⚪ 0.0%
siteStartup 2878 ms 2865 ms 13 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

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

Looks good!

Some comments:

  1. On the composer only "Paste" is available, should we also offer "Copy"?
Image
  1. "Copy All" is a translated string. Should the other options also be translated?
    menu.ts:364-366 already does { label: __( 'Copy' ), role: 'copy' } — macOS
    localizes roles natively, so this would only show on Windows/Linux.

  2. conversation/index.tsx:473 uses copyText ?? text, but copyText is only set on
    the last text block (line 281). On a reply split by tool calls, right-clicking an
    earlier paragraph makes "Copy All" copy just that fragment — the comment on line 262 says it should yield the whole message.

Suggestion: what do you think about an option to quote the selected text into the
composer? Could be useful for referencing part of the agent's reply. Could be done in a follow-up PR if you think it's a good idea

Comment thread apps/studio/src/text-context-menu.ts
Comment thread apps/studio/src/text-context-menu.ts Outdated
Comment thread apps/studio/src/tests/text-context-menu.test.ts

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

Nice work! I saw that the changes Bernardo mentioned were already implemented ❤️

I left some minor suggestions and a couple of questions but nothing that is blocking

@shaunandrews

Copy link
Copy Markdown
Contributor Author

@bcotrim thanks for the review.

  1. Added! Now you can copy text in the composer.
  2. I added __() calls for all the options, so they should get translated.
  3. Fixed!

I also added your suggestion to let users quote text into their composer.

@katinthehatsite I implemented your suggestions as well!

Let me know whatcha thinK!

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

Thanks for making the changes 🙇
Quote in composer is showing up everywhere now, could we limit it just to the composer?

Image

@katinthehatsite

Copy link
Copy Markdown
Contributor

I am also seeing the same behavior as @bcotrim , I think it would make sense to clean that up as it does not seem to be necessary to have it on the buttons and other controls

@shaunandrews

Copy link
Copy Markdown
Contributor Author

Good catch; should be fixed now.

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

LGTM 👍

@shaunandrews
shaunandrews merged commit 3ce9399 into trunk Aug 6, 2026
7 checks passed
@shaunandrews
shaunandrews deleted the add-text-context-menu branch August 6, 2026 22:12
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.

5 participants