feat(browser): add Copy to context menu when text is selected#7159
Conversation
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThis change adds clipboard "Copy" support for text selections in the browser context menu. The shared event type, main process context-menu handler, preload IPC bridge, and renderer context-menu components are all extended with Changes
Sequence Diagram(s)sequenceDiagram
participant WebContents
participant browserGuestUi as browser-guest-ui.ts
participant Preload as preload/index.ts
participant BrowserPane as BrowserPane.tsx
WebContents->>browserGuestUi: context-menu event (selectionText, editFlags)
browserGuestUi->>Preload: browser:context-menu-requested (selectionText, canCopy)
Preload->>BrowserPane: onContextMenuRequested callback (selectionText, canCopy)
BrowserPane->>BrowserPane: render Copy menu item if selectionText present
BrowserPane->>BrowserPane: write selectionText to clipboard on click
Estimated code review effort: 2/5 (~15 minutes) Related PRs: None identified. Related issues: None identified. Suggested labels: browser, renderer, enhancement Suggested reviewers: None identified. 🌸 A right-click, a highlighted word, 🚥 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/browser-pane/BrowserPane.tsx (1)
281-288: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPopulate the remote context-menu fields
The remote path only sets
linkUrlandpageUrl;selectionTextandcanCopyare never populated, so the state shape is incomplete and the Copy item can’t appear for remote panes. Wire those fields through the remote result or make them optional.
🧹 Nitpick comments (1)
src/renderer/src/components/browser-pane/BrowserPane.tsx (1)
2447-2461: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
canCopyis threaded through the whole stack but never used.Both Copy menu items gate purely on
contextMenu.selectionTexttruthiness;canCopy(sourced from Electron'seditFlags.canCopy) is stored in state but never read. Consider using it (e.g.contextMenu.canCopy && contextMenu.selectionText) to match Electron's own signal for whether copy is actually permitted, or drop the field if it's not needed.Also applies to: 4840-4854
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d770af7a-4a4e-4e92-8198-804adde5a29f
📒 Files selected for processing (5)
src/main/browser/browser-guest-ui.test.tssrc/main/browser/browser-guest-ui.tssrc/preload/index.tssrc/renderer/src/components/browser-pane/BrowserPane.tsxsrc/shared/browser-guest-events.ts
…lyai#7036) The built-in browser's custom context menu replaced the native Chromium menu but lacked a Copy action for selected text. Users could not right-click to copy text from web pages. - Forward selectionText and canCopy from Electron's ContextMenuParams through the IPC bridge to the renderer - Add a Copy button to both remote and local webview context menus when text is selected - Update shared types and preload API types for the new fields
The context-menu Copy from stablyai#7159 did not compile and did not work on the remote/paired-web browser: - RemoteBrowserContextMenu required a selectionText that the remote setter never provided (type error). The remote eval now reads window.getSelection() so the SSH/paired-web browser gets the same Copy affordance as the local webview. - Drop the unused canCopy field from the IPC event, preload, and renderer; the menu gates purely on a non-empty (trimmed) selection. - Gate the item on selectionText.trim() and add a trailing separator so Copy groups like the existing link section. - Register the new 'Copy' translate() key in all five locale catalogs (es/ja/ko/zh mirror the existing Copy translation); PR left it unsynced. - Add a unit test asserting the native selection is forwarded to the renderer. Co-authored-by: Orca <help@stably.ai>
e2cf68c to
040396d
Compare
|
Took ownership of this PR (rebased onto latest DescriptionIssue #7036 is "I can't copy to clipboard in the built-in browser; prevention should at least be opt-in." The real failure mode is page-level copy suppression: sites that call The original patch was on the right track but did not compile and did not work on the remote/SSH browser. My commit fixes that:
EvidenceReproduced and verified in a real Electron dev build (
Checks:
ELI5Some websites turn off "copy" so you can't grab their text. Before, Orca's mini-browser had no Copy button in the right-click menu, so those sites left you stuck. Now, when you've highlighted text, right-click shows a Copy button that puts the highlighted text on your clipboard directly — it doesn't ask the webpage's permission, so it works even on pages that try to block copying. It also works over SSH/remote browsers now, and only shows up when you've actually selected something. Trade-offs / regressions
|
Fixes #7036
Summary
Adds a Copy button to the built-in browser's context menu when text is selected. Previously the context menu only showed Back/Forward/Reload and DevTools — users had to open DevTools or use keyboard shortcuts to copy text from a page.
Changes
selectionTextandcanCopyfrom Electron's ContextMenuParams to the renderercanCopytoBrowserGuestContextMenuEventwindow.api.ui.writeClipboardText()canCopyis true (both local and remote webviews)Testing
Screenshots
No visual change — standard context menu item.