Skip to content

feat(browser): make element grab opt-in behind an Auto Grab setting#8996

Open
sonhyrd wants to merge 3 commits into
stablyai:mainfrom
sonhyrd:feat/browser-auto-grab-toggle
Open

feat(browser): make element grab opt-in behind an Auto Grab setting#8996
sonhyrd wants to merge 3 commits into
stablyai:mainfrom
sonhyrd:feat/browser-auto-grab-toggle

Conversation

@sonhyrd

@sonhyrd sonhyrd commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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):

  • Cmd/Ctrl+C copies normally; click/drag selects normally; no sticky grab.
  • The crosshair "Grab page element" button is hidden.

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

  • Both entry points are gated: the host keydown handler and the chord forwarded from a focused webview guest (onGrabModeToggle). When off, the keydown listener isn't even registered, so there's zero per-keystroke work in the default case.
  • Gating is renderer-only by design. Main still probes on Cmd+C, but it only forwards when the element is non-editable and there's no selection — where native copy is already a no-op — so nothing observable is affected.
  • The browser onboarding tour won't auto-start while Auto Grab is off: its requiredForStart step targets the now-hidden grab button, and getContextualTourStartStepIndex returns null. Graceful (no broken pointer), and consistent with the feature being off. Can be decoupled later if we want that tour independent of grab.
  • The copy-shortcut gate is extracted into a small tested predicate (shouldGrabOnCopyShortcut).
  • Setting is searchable in Settings → Browser, with a platform-aware label (⌘C on Mac, Ctrl+C elsewhere).
  • New i18n keys added to all 5 locales (non-English carry the English string, as sync:localization-catalog produces for new strings).

Testing

  • New 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.
  • Typecheck + oxlint clean.

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
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an opt-in browserAutoGrabEnabled setting, defaulting to disabled, with searchable browser settings UI and localized labels. Browser copy-shortcut interception, guest grab toggles, and the toolbar crosshair now require Auto Grab to be enabled and pass centralized gating conditions. Adds platform-specific shortcut labels and unit tests covering the gating behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is useful, but it misses required template sections like Summary, Screenshots, AI Review Report, and Security Audit. Reformat the PR description to match the template and add the missing Summary, Screenshots, AI Review Report, and Security Audit sections, plus any needed testing details.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the requested option to turn off Auto Grab by default and preserves grab behavior when enabled.
Out of Scope Changes check ✅ Passed The added settings, localization, and tests all support the Auto Grab opt-in feature and do not appear unrelated.
Title check ✅ Passed The title clearly and concisely summarizes the main change: making element grab opt-in behind an Auto Grab setting.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ad06e2d7-ccbe-4f2d-9c97-fe663b01d534

📥 Commits

Reviewing files that changed from the base of the PR and between cf02cc4 and 124d5f8.

📒 Files selected for processing (13)
  • src/renderer/src/components/browser-pane/BrowserPane.tsx
  • src/renderer/src/components/browser-pane/browser-auto-grab-gate.test.ts
  • src/renderer/src/components/browser-pane/browser-auto-grab-gate.ts
  • src/renderer/src/components/settings/BrowserAutoGrabSetting.tsx
  • src/renderer/src/components/settings/BrowserPane.tsx
  • src/renderer/src/components/settings/browser-search.ts
  • 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
  • src/shared/constants.ts
  • src/shared/types.ts

Comment thread src/renderer/src/components/browser-pane/BrowserPane.tsx
Comment thread src/renderer/src/components/settings/BrowserAutoGrabSetting.tsx Outdated
…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
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:37
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.

[Feature] Option to turn of Auto Grab feature in Web Browser.

3 participants