Agentic UI: Add a right-click context menu to the Studio browser - #4390
Draft
shaunandrews wants to merge 5 commits into
Draft
Agentic UI: Add a right-click context menu to the Studio browser#4390shaunandrews wants to merge 5 commits into
shaunandrews wants to merge 5 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing 8d0e42d vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
shaunandrews
marked this pull request as draft
July 29, 2026 19:14
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Related issues
How AI was used in this PR
AI wrote the implementation and tests from a scope I set. I reviewed the approach and tested it against a running site.
Proposed Changes
Right clicking in Studio's in-app web browser does nothing. This PR introduces an OS-native right-click contextual menu in the Studio browser. This enables users to right click on text, images, and more to copy elements, open the dev tools, and more — including the ability to start annotating for Studio Code.
Look Up "…", which opens the system Dictionary panel.Nothing appears greyed out that could simply be absent. Right-clicking plain text gets you two items, not a wall of them.
Back/Forward/Reload are deliberately absent — the preview's own toolbar already has them, and adding them here made every right-click longer without adding a capability.
Known cosmetic limitation: Look Up placement
On macOS the dictionary panel opens with the right definition but in the wrong
place — it and its floating copy of the word land offset from the actual
selection. macOS anchors the panel to a selection rect the guest page reports in
its own coordinate space, and nothing translates it by the
<webview>'s offsetwithin the window, so the panel and its text shift together.
This isn't fixable from our side:
showDefinitionForSelection()takes noposition argument, and we don't place the panel. It's the same class of problem
Electron now warns about generally — its
<webview>docs say the tag is"undergoing dramatic architectural changes" that affect "the stability of
webviews, including rendering", and recommend
WebContentsViewinstead.Shipping it anyway: the definition is correct, the misplacement is cosmetic, and
having Look Up is more useful than not. The alternative (
dict://, which opensDictionary.app) is accurate but a worse experience than an inline panel. The
call site carries a comment so the next person doesn't re-derive this. Note the
chat panel's Look Up (#4388) is unaffected — it runs on the host renderer, where
there's no guest offset.
Deliberately not included, both worth their own PR:
downloadURL, awill-downloadhandler, a save dialog) with its own error and overwrite handling.params.misspelledWordanddictionarySuggestionsare available, but the spellchecker isn't configured anywhere in the app yet, so this needssetSpellCheckerLanguagesand a decision about which languages to load.This is desktop-only by nature: in the browser builds the preview is a cross-origin
<iframe>and Chrome's own menu already works there.Testing Instructions
Main-process change, so it needs a full app restart —
rs/ hot reload won't pick it up.Look Up "…"on macOS. Look Up should open the system Dictionary panel with the correct definition. Expect it to appear offset from the selection — see the known limitation above; that's not a regression to report.Unit tests:
npm test -- apps/studio/src/tests/preview-context-menu.test.tsPre-merge Checklist
Notes for reviewers:
web-contents-createdblock inindex.ts.contextmenulistener always runs before the menu is even requested), so no coordinates have to survive the trip out to the main process and back. The renderer pushes inspector readiness to main as plain state, which can't race the click that opens the menu.ContextMenuParams, so nothing has to be asked of a renderer.apps/studioandapps/uitypecheck clean, eslint clean, 10 new unit tests, both full suites pass (160 files, 1111 tests).npm run typecheckcurrently fails inapps/clion@earendil-works/pi-ai. That's pre-existing on trunk (stalenode_modulesafter the recentpackages/commonbump), not from this branch.npm installclears it.