Repository navigation
feat(browser): add React Grab element picker and composer context chips - #890
sambitcreate wants to merge 17 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 | 𝕏
On the smaller macOS CI display the DevTools step clicked #secret-form below the fold, so the click hit nothing and the grab stayed active. Reproduced by shrinking the window; scrolling each target into view first fixes it.
Observe every open shadow root the frame shield finds, and adopt shadow roots and frames from pointer events as a backstop for roots attached after the grab starts. The frames E2E now adds frames inside an existing and a late shadow root mid-grab.
The background-throttling lease a grab held came from a disproven hypothesis; capture already takes its own lease. The 100 ms frame-wait cap stays as a bound on a wait that could otherwise never end. A grab now records the page URL when it starts, and a payload taken before the page moved to another origin carries no source hint.
There was a problem hiding this comment.
Important
The late-shadow-root frame fix still permits child-frame input before the shield is active, so interaction suppression is not complete.
Reviewed changes Reviewed the three commits since the prior Pullfrog review, including the frame-shield follow-up, stale source-hint authority fence, grab-session throttling cleanup, and E2E stabilization.
-
Extended frame discovery Observed discovered open shadow roots and added pointer-driven adoption for roots attached after Grab starts, with expanded iframe E2E coverage.
-
Fenced stale source hints Recorded the Grab-start page URL and discarded source hints after a source-authority change while preserving same-origin route changes.
-
Adjusted capture reliability Removed the disproven session-wide throttling lease, retained bounded overlay frame waits, and scrolled E2E targets into view before clicking.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
| // their host, and on entering a frame the frame element, in this document | ||
| // first, so they are shielded before input can reach the frame. | ||
| const onPointerOver = (event: PointerEvent) => { | ||
| frames.adopt(eventTarget(event)); |
There was a problem hiding this comment.
Late-root safety still depends on this handler running before child input. If an iframe is attached under a stationary pointer, the next click stays entirely in the child browsing context; on direct pointer entry, Chromium still delivers that movement's child pointerover/pointermove after this parent handler, while the E2E first crosses host padding and does not count those events.
Technical details
# Late shadow-root frames still receive input
## Affected sites
- `main/services/browser/grab-runtime/index.ts:379-394` — discovers a late-attached shadow root only from top-document pointer events.
- `tests/e2e/browser-grab.spec.ts:580-658` — moves across `late-host` padding before entering the iframe and counts only pointer down/up/click events.
## Required outcome
- Shield a frame in a newly attached open shadow root without requiring an earlier top-document pointer event.
- Cover a frame inserted under the stationary pointer followed by a click, plus direct entry that asserts `pointerover`/`pointermove` do not reach the child.
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.CI fixes (2026-11-24)
browser-trust.spec.ts"fill dimensions and region crops ignore hostile page viewport globals": region screenshots had switched to readinginnerWidth/innerHeightin the page's main world (executeJavaScript), so page-defined globals could affect crop math. The read is back on the isolated CDP world (cf57b0bb4). The unusedviewportparameter oncapture/capturePageis removed.browser-grab.spec.tsDevTools step: on the hosted macOS runner's smaller display, the test clicked#secret-formbelow the fold. That off-viewport click hit nothing, so the grab stayed active and no chip appeared. I reproduced it on a Mac by shrinking the window to about 560 px tall, and the E2E now scrolls each target into view before clicking (f09ca7685). Each overlay frame wait is capped at 100 ms. The cap bounds a wait that could otherwise never end on a page that does not paint; it is not the fix for this failure. The background-throttling lease thatcf57b0bb4added to the grab session came from a disproven hypothesis and is removed in0a4ae90da. Thumbnail capture still takes its own lease.98b99ab70:file://is read only for afile://page with a workspace root and realpath containment.valueordefaultValue, and credential fields keep only descriptive props.npm run test:browser301/301,type-check,lint,test:ci-policy123/123. Cua Space E2E:browser-grab.spec.ts+browser-trust.spec.ts8/8. Host macOS:browser-grab.spec.ts3/3.41d79f16f: the frame shield's observer watched only the light DOM. It now also observes every open shadow root that its scans find. Apointerover/pointermovebackstop adopts shadow roots attached after the grab starts, and any frame inside them, before the pointer reaches the frame. The frames E2E adds one frame inside an existing shadow root and one inside a late-attached root mid-grab. It asserts that the inner buttons are captured and that no frame sees a pointer event.0a4ae90da): a grab records the page URL when it starts. A payload taken before the page moved to another origin carries no source hint and triggers no source-map fetch. A same-origin route change keeps the hints. Covered ingrab-sanitize.test.ts.0a4ae90da:npm run test:browser302/302,type-check,type-check:e2e,lint. Cua Space E2E:browser-grab.spec.ts+browser-trust.spec.ts8/8, no retries.Flake note
iOS build and simulator testsfailed on98b99ab70inAidenNativeIntegrationTests.testReconcileEndsAnActivityFromAnOlderPairing()(ActivityKit Live Activity, run 45334015770). This PR touches noios/code, andmain's own iOS job onb2b5c3517also failed, on a different test. The fresh run onf09ca7685counts as the one allowed rerun. The iOS job will stay red untilmain(with the iOS fix, Stop iOS simulator tests stalling in CI #917) is merged in.tests/e2e/design-mode.spec.ts:752(E2E shard 2/5) failed once withProtocol error (Page.handleJavaScriptDialog): No dialog is showingand passed on retry. Because of--fail-on-flaky-tests, the job still went red (run 45368050792). The spec is unrelated to this PR and is not fixed here.