Repository navigation
feat(browser): add React Grab element picker and composer context chips - #890
sambitcreate wants to merge 14 commits into
Conversation
…ter, and delivery registry
…ter, and delivery registry
…/transcript integration, onboarding art, and docs
…e/thumbnail pipeline, BrowserService and BrowserPanel integration
… label inspection popover
…end, guard key repeat, and plumb grab source
# Conflicts: # renderer/shared/browser.ts
…ration, and E2E fixes
… of docked browser view
# Conflicts: # README.md # docs/analytics.md # docs/plans/README.md # main/services/analytics/analytics-core.test.ts # main/services/analytics/analytics-events.ts # main/services/chat-store-core.test.ts # renderer/components/composer.tsx # renderer/components/onboarding-feature-gallery.test.tsx # renderer/main/chat-pane.tsx
There was a problem hiding this comment.
Caution
This PR can disclose credential values and lets untrusted local pages drive privileged cross-origin or filesystem source-map reads; iframe capture also fails as implemented.
Reviewed changes Reviewed the complete React Grab implementation and its browser runtime, main-process sanitization and capture pipeline, chat/CLI persistence, composer and transcript UI, Remote/mobile compatibility, analytics, documentation, and tests.
- Browser picker runtime Adds framework-aware element inspection, stepping, multi-grab, click suppression, thumbnail masking, and local source-map symbolication.
- Chat delivery and persistence Carries structured element context and linked thumbnails through drafts, queues, forks, stored chats, generation messages, and the serve-only CLI.
- Composer and transcript UI Adds context chips, inspection popovers, Browser controls and shortcuts, onboarding art, analytics, and focused unit/E2E coverage.
- Attachment startup Registers the stored-image protocol before the first window is created.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…e isolated crop viewport read Region screenshots read the viewport in the page's main world, so hostile innerWidth/innerHeight globals could skew crops; go back to the isolated-world CDP read. The grab picker waits on animation frames that stop when the window is covered (detached DevTools on macOS), so hold a background-throttling lease for the session and bound each frame wait with a timer.
…tial field props, and shield frames while grabbing Source-map reads now require the authoritative page's exact loopback origin, or a file:// page with a workspace root and realpath containment. Props never carry value/defaultValue, and credential fields keep only descriptive props. Frames get pointer-events: none during a grab so their input reaches the top document and is suppressed; hit tests lift the shield to grab same-origin frame elements.
There was a problem hiding this comment.
Important
The iframe fix still lets dynamically rendered shadow-DOM frames receive live input during Grab, so this interaction-safety regression should be closed before merge.
Reviewed changes Reviewed the two hardening commits since the prior Pullfrog review and rechecked their browser-runtime, main-process security, capture, documentation, and E2E implications.
- Source authority hardening Bound symbolication to the authoritative page's exact loopback origin or canonical workspace-contained files.
- Credential redaction Redacted live value props and credential-field primitive props in the runtime and main sanitizer.
- Frame and capture reliability Added frame shielding, static iframe coverage, a background-throttling lease, a bounded animation-frame wait, and isolated viewport measurement.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
| } | ||
| } | ||
| }); | ||
| this.observer.observe(document.documentElement, { childList: true, subtree: true }); |
There was a problem hiding this comment.
This observer covers only light-DOM additions. If a web component inserts an iframe into an open shadow root after Grab starts, or attaches that root after activation, the frame is never shielded; its handlers receive the click and Grab receives no top-document event.
Technical details
# Dynamic shadow-root frames bypass Grab
## Affected sites
- `main/services/browser/grab-runtime/index.ts:93-101` — the sole observer is attached to `document.documentElement`; mutation observation does not cross shadow boundaries, and `attachShadow()` does not create a light-DOM child mutation.
- `tests/e2e/browser-grab.spec.ts:515-591` — verifies only frames already present in the light DOM before Grab starts.
## Required outcome
- Keep every discoverable frame shielded for the full Grab session, including frames added to open shadow roots after activation.
- Add a behavioral case that inserts the shadow-root frame after Grab starts and proves its pointer/click handlers remain untouched while the element is captured.
Summary
Adds React Grab to Aiden's embedded Workspace Browser so you can click any live UI element (
⇧⌘Gon macOS,Ctrl+Shift+Gon Linux, or the toolbar cursor toggle beside Annotate) and attach structured component/DOM context plus a clean cropped thumbnail directly to your chat composer.Feature overview
MousePointer2Grab element toggle (aria-pressed) right of the URL bar alongside Annotate, plus a non-intrusive status strip (Click an element to grab for chat · ↑↓ parent/child · ⇧Click to add multiple · Esc to cancel) and⇧⌘G/Ctrl+Shift+Gshortcut intercepted inside both the host renderer and guestWebContentsView.main/services/browser/grab-runtime/, built viascripts/build-browser-grab.mjs) injects a zero-interference closed Shadow DOM highlight box & pill tag over the hovered element, supports↑/↓component-tree stepping,Shift+Clickmulti-grab,Fanimation freeze, and stops page click side effects during capture._debugStack/_debugOwner/ Server Component frames), Vue, Svelte, Astro, Preact, Solid, Angular, and plain DOM fallback. Symbolicates local bundles in the main process (main/services/browser/grab-source-map.ts) strictly for loopback URLs and workspace-containedfile://.js/.mjs/.cjs/.mapfiles.capturePageagainst page bounds rather than full-window rect), hides the highlight before capture, pixel-masks sensitive/password fields viacredential-mask.ts, and bounds output to ≤640 px / ≤512 KiB PNG/JPEG.ChatMessage.grabbedElements?: GrabbedElementContextV1[]sidecar validated strictly on append and stored reads, linking cropped thumbnails as standardgrab-thumb_<id>image attachments stored viachat-image-store(aiden-attachment://). Requires zero Remote protocol revision — paired iOS/Android clients andaiden servepreserve and display the linked image cleanly without breaking existing wire contracts.renderer/components/grabbed-element-chip.tsx) with hover preview (250 ms open / 140 ms close), click-to-pin"Included with your message"popover (cropped thumbnail, Element/Component rows, collapsible details with source path, framework badge, selector, size, page, redacted props, styles, HTML, copy button, Escape focus return), read-only transcript chips (align="end"so popovers stay clear of docked side-by-side Browser views), Edit-in-Fork & queue/draft persistence, and refreshed onboarding art/docs (PRODUCT.md,README.md,docs/environment-browser.md,docs/analytics.md,docs/plans/README.md,.memory/browser-react-grab.md).main/index.ts): MovesregisterChatAttachmentProtocol()beforecreateMainWindow({ startupAdmissionHeld: true })(matchinginstallStudioAssetProtocolandstartDesignProtocol) soaiden-attachment://stored chat images load cleanly in the initial main window withoutnet::ERR_UNKNOWN_URL_SCHEME.Security & architecture invariants
browser:command(grab/stopGrab),browser:event(grabbed), and chat append/create channels.file://reads to.js/.mjs/.cjs/.mapwithin the workspace root.Object.getOwnPropertyDescriptorwithout invoking page getters; redacts password/token/secret/auth/cookie/key props and attributes before returning from main, and pixel-masks sensitive inputs in thumbnails.<attached-browser-elements>context with a quiet non-blocking note; prompt formatting sorts keys deterministically and omits volatile timestamps so prompt caches stay byte-stable.browser_element_grabbed(kind,source) andbrowser_grab_sent(count_bucket,with_screenshot) to the closed registry with zero URLs, selectors, paths, or HTML.Verification
All checks passed on merged head
dec388365(withorigin/mainmerged cleanly):npm run check:aiden-rules: PASS (0 violations)npm run type-check && npm run type-check:e2e && npm run lint: PASS (0 errors, 0 warnings)npm run test:ci:registry: 15/15 PASSnpm run test:ci-policy: 123/123 PASSnpm run test:browser: 299/299 PASSnpm run test:slash-commands: 819/819 PASSnpm run test:onboarding: 81/81 PASSnpm run test:analytics: 174/174 PASSnpm run test:bot-browser: 37/37 PASSnpm run test:e2e:space -- tests/e2e/browser-grab.spec.ts tests/e2e/accessibility.spec.ts tests/e2e/browser.spec.ts): 16/16 PASS (0 failures, 0 retries) — covers live React grab,↑/↓stepping, 0 click side effects, secret redaction, LM Studio prompt +image_url, transcript chip &aiden-attachment://thumbnail (naturalWidth > 0),⇧⌘G/Ctrl+Shift+Gshortcut, unstoppable Escape, host Escape,Shift+Clickmulti-grab, DevTools-open capture, navigation/tab cleanup, 0 axe WCAG A/AA violations with 0 new exclusions on"browser grab chip & inspection popover", and 13/13 existing Browser/Annotate regression tests.