feat(browser): make element grab opt-in behind an Auto Grab setting#8996
Open
sonhyrd wants to merge 3 commits into
Open
feat(browser): make element grab opt-in behind an Auto Grab setting#8996sonhyrd wants to merge 3 commits into
sonhyrd wants to merge 3 commits into
Conversation
Cmd/Ctrl+C in the browser pane was repurposed to enter grab mode, which hijacked the normal copy gesture and stayed sticky, making click/drag/ select on the page hard to use. Gate the behavior behind a new browserAutoGrabEnabled setting (default off) so the browser behaves like a normal web browser: Cmd+C copies, click/drag selects. Both the host keydown path and the chord forwarded from a focused webview guest are gated, and the crosshair grab button is hidden when off. The Annotate button and the browser.grabElement keybinding are untouched. Adds a searchable Settings -> Browser toggle with a platform-aware label. Extracts the copy-shortcut gate into a tested predicate. Closes stablyai#8874
Contributor
📝 WalkthroughWalkthroughAdds an opt-in 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ad06e2d7-ccbe-4f2d-9c97-fe663b01d534
📒 Files selected for processing (13)
src/renderer/src/components/browser-pane/BrowserPane.tsxsrc/renderer/src/components/browser-pane/browser-auto-grab-gate.test.tssrc/renderer/src/components/browser-pane/browser-auto-grab-gate.tssrc/renderer/src/components/settings/BrowserAutoGrabSetting.tsxsrc/renderer/src/components/settings/BrowserPane.tsxsrc/renderer/src/components/settings/browser-search.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/constants.tssrc/shared/types.ts
…ag check The `autoGrabEnabled` param on `shouldGrabOnCopyShortcut` was dead: the keydown effect already early-returns when Auto Grab is off, so the gate never saw it false. Keep one flag check (the early return, which also avoids registering the listener at all) and let the gate decide only whether a given keystroke is a grab or a native copy. Switch the new translation keys from manual `.title` / `.description` to the repo's `auto.<path>.<sha1-10>` convention.
…b-toggle # Conflicts: # src/renderer/src/i18n/locales/en.json # src/renderer/src/i18n/locales/es.json # src/renderer/src/i18n/locales/ja.json # src/renderer/src/i18n/locales/ko.json # src/renderer/src/i18n/locales/zh.json
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.
Closes #8874
Problem
Inside the browser pane, Cmd/Ctrl+C is repurposed to enter "Grab page element" mode (the crosshair picker) instead of copying — whenever focus isn't in a text field and nothing is selected. Once armed, a left-click grabs+copies the element and then auto-re-arms, so the overlay stays active and captures every subsequent click/drag. Retained panes keep the armed state, so it feels "already on when I enter the browser."
The result: you press Cmd+C expecting to copy, land in a sticky grab mode, and can no longer click, drag, or select text normally.
Change
Puts the behavior behind a new Auto Grab setting (
browserAutoGrabEnabled), default off — so the browser behaves like a normal web browser unless you opt in.When off (default):
When on: today's full behavior, unchanged.
Untouched either way: the Annotate page element button — a separate feature, deliberate click only.
Note on
browser.grabElement: the keybinding definition is unchanged, but while Auto Grab is off the shortcut is inert — the same way the crosshair button is hidden. "Off" means the grab feature is off, per #8874 ("Option to turn off Auto Grab"), not just the Cmd+C hijack. A user who rebinds it to a non-copy chord will need Auto Grab on for it to fire.Notes
onGrabModeToggle). When off, the keydown listener isn't even registered, so there's zero per-keystroke work in the default case.requiredForStartstep targets the now-hidden grab button, andgetContextualTourStartStepIndexreturnsnull. Graceful (no broken pointer), and consistent with the feature being off. Can be decoupled later if we want that tour independent of grab.shouldGrabOnCopyShortcut).sync:localization-catalogproduces for new strings).Testing
browser-auto-grab-gate.test.ts(5 cases) covering the gate: on/off, editable target, markup overlay active, non-matching chord.vitest run src/renderer/src/components/browser-pane src/renderer/src/components/settings→ 294 passing.