Skip to content

Add Browser pane element inspector that attaches picked elements as chips - #1644

Merged
currentbits merged 2 commits into
mainfrom
coder/p2-select-a-browser-element-and-attach-p-ef93f1
Oct 15, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/p2-select-a-browser-element-and-attach-p-ef93f1

Conversation

@currentbits

Copy link
Copy Markdown
Owner

What

Adds an Inspect mode to the Browser pane (#1193). You can pick an element on the previewed page and add it to the thread's composer as a context chip, with an optional comment and a cropped screenshot.

Browser pane (BrowserPane.tsx, .module.css)

  • New ⌖ toolbar button toggles inspect mode. While it is on, a hint explains the controls: click an element, or Tab to one and press Enter. ↑ selects the parent element and Esc cancels.
  • Once you pick an element, a "Selected element" card shows its label and URL, the element crop, and a comment field. It has Add to composer and Discard buttons, plus an expandable preview of the exact text that will be added to the message.
  • The existing screenshot thread/mount guard is now a shared liveGuard, so a pick that finishes after a thread switch is dropped. Inspect state resets when the thread changes.

Main process (electron/preview.js, IPC)

  • New preview:inspect / preview:cancelInspect channels, wired through ipc-devserver.js, preload.js, ipcChannels.ts and the web scope allowlist.
  • The picker runs inside the guest in an isolated world. It returns the tag, role and accessible name, a selector hint, capped outerHTML, computed styles, the rect and viewport, and a source hint taken from data-* attributes.
  • Privacy and safety:
    • The picker never reads text field values.
    • Password and hidden values are redacted, along with secret-looking attributes (token/auth/session/cookie names and JWT- or API-key-shaped values).
    • Iframes are reported but their contents are not inspected.
    • When a submit button is picked, the picker swallows the activating click and keypresses so the form isn't submitted.
  • Inspect cancels on Escape, cancelInspect, navigation, or the pane closing.
  • The element crop is cut from capturePage, accounts for the zoom factor, and is capped at 800px per edge.

Context chips (contextChips.ts, ContextChips.tsx, Composer.tsx, ThreadView.tsx)

  • New element chip kind. Its text is frozen when the element is captured, so the chip stays tied to its thread, page and capture time.
  • The chip expands to a <browser-element url=… captured=…> block that labels the page content as untrusted data. A closing tag planted by the page is neutralised so it can't break out of the block.
  • Element chips can be edited, persisted and parsed, the same way quote chips are.
  • ThreadView attaches the crop through the existing screenshot handoff path. attachBrowserScreenshot now resolves to a boolean, so the chip text correctly says whether an image is attached.

Testing

  • electron/test/preview-inspect.test.js: main-process inspect/cancel, sanitising and crop rect.
  • test/browserInspect.test.tsx: pane UI flow.
  • test/contextChips.test.ts: element chip formatting and round-trip.
  • npm run verify:browser-inspect (scripts/verify-browser-inspect.js): runs in real Electron and checks things the unit tests can't. A synthetic click picks a submit button without submitting the form. The reported rect matches the layout, and the crop comes from the right pixels at zoom 1 and 1.5. Escape cancels.

🤖 Generated with Claude Code

Solenta-Message-Id: cc82d9b1-17c9-4cb8-af73-3fcbe039620a
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T15:40:58.538459Z 6662c92 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@currentbits
currentbits merged commit c01b721 into main Oct 15, 2026
6 checks passed
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.

1 participant