Skip to content

feat(browser): WebKit browser in Rex panes, with point-and-ask for agents - #58

Merged
DeepanshuMishraa merged 6 commits into
mainfrom
feat/webkit-browser
Nov 21, 2026
Merged

DeepanshuMishraa merged 6 commits into
mainfrom
feat/webkit-browser

Conversation

@DeepanshuMishraa

@DeepanshuMishraa DeepanshuMishraa commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What

A WebKit browser that lives in a Rex pane, built into leaf. Nothing is installed in Applications. Point at anything on a page and ask your coding agent about it.

  • Leaf: Open Browser (or leaf browser [url]) splits a pane and keeps a native WebKit window exactly over it. It follows the pane through splits, resizes, zoom and tab switches. It hides during Mission Control and while Rex animates panes, and gives way to Rex's palette.
  • Point and ask: use the pointer button or shift+cmd+c, then pick elements with React Grab. Type a question and press enter. It goes to the agent picked with Leaf: Choose Agent…, either in that agent's pane or in a new pane beside the browser. The composer names the agent live.
  • Browser basics: Safari user agent, find, zoom, downloads, uploads, JS dialogs, an error page, and the pane label follows the page title. Rex's shortcuts keep working while the page has focus, and there's a close button in the toolbar.

How

  • build.rs compiles src/browser.swift for the target arch (macOS 13+), and leaf embeds it. On first use, leaf unpacks it to ~/Library/Caches/leaf/webkit-<hash>, replacing older copies. Without swiftc, leaf builds without the browser; in CI that's a build failure.
  • Placement comes from the session.view fractions, Rex's chrome settings from its preferences, and the window-server frame of the Rex window. Refreshes are driven by session events, ignoring client connect events, which used to cause a feedback loop.
  • The helper and leaf browser exchange JSON lines over stdin and stdout. Rust builds the prompt (unit tested) and sends it with agent::deliver.
  • React Grab 0.2.0 is vendored unmodified under vendor/react-grab (MIT). It's loaded only when pointing starts, with telemetry off.

Safety

Any page can call into injected JS. So a pick only adds context to a native composer, and only enter in that composer sends anything to the agent. Picks are accepted only right after a real click or key in the browser window.

Testing

  • cargo test: 679 pass. Clippy shows no new warnings.
  • Tested live in Rex: placement (side by side, stacked, zoomed); close; navigation, search and errors; find; Cloudflare-protected pages; React Grab picks sent to a stand-in agent pane; the composer naming the agent (picked or open); and the palette over a browser pane.
  • Not tested: an Intel build, dark mode, or Rex layouts other than vertical tabs with no headers.

🤖 Generated with Claude Code


Summary by cubic

Adds a WebKit browser that opens in a Rex pane, embedded in leaf. Point at page elements and ask your agent about them; includes leaf storage and saved HTML pages read as markdown. Also tightens up the browser's security and edge cases and bumps the release to 0.18.0.

New Features

  • Leaf: Open Browser splits a pane and keeps a native WebKit window over it; nothing is installed in Applications.
  • The browser and its pages follow Rex's light or dark appearance.
  • Opened without an address, it shows a start page with leaf's mark and the web servers running on this Mac, one click away.
  • Point-and-ask: pick elements with React Grab, type a question, and it goes to the agent picked with Leaf: Choose Agent….
  • leaf storage shows what fills a drive, with junk to clear.
  • Saved HTML pages read as markdown, with inline images and sharp SVGs.

Fixes

  • Picks are only accepted right after a real click or key in the browser, and a page can't forge the markers around the picked elements, page titles, or addresses.
  • Prompts are capped at 24k characters of elements; shift+cmd+c points while cmd+c stays copy.
  • The browser exits cleanly when its pane closes, and reruns the build script if a Swift toolchain appears.
  • leaf browser --check prints the helper's path so the release can verify it's built for the right architecture.

Written for commit f6330a1. Summary will update on new commits.

View guided diff Turn on auto-fix

DeepanshuMishraa and others added 2 commits November 22, 2026 00:57
Leaf: Open Browser (or `leaf browser [url]`) splits a pane and keeps a
native WebKit window exactly over it. Nothing is installed in
Applications: build.rs compiles src/browser.swift on macOS, leaf embeds
it and unpacks it once per version into ~/Library/Caches/leaf.

- Follows the pane through splits, resizes, zoom and tab switches, using
  session.view fractions, Rex's chrome settings and the Rex window frame;
  refreshes on session events, ignoring client connect noise
- Stays just above the Rex window at normal level, not over other apps
- Exits when its pane closes or leaf goes away
- Minimal toolbar, progress bar, error page, find, zoom, downloads,
  uploads, JS dialogs, Safari user agent, page title as pane label
- Edit menu so copy and paste work; Rex key bindings are forwarded
- Builds for the target arch; without swiftc, leaf builds without the
  browser (CI fails instead)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Click the pointer button (or shift+cmd+c), pick elements with React
Grab, type a question and press enter: leaf sends the elements' HTML
and, on React development builds, their components and source files to
the agent picked with Leaf: Choose Agent…, in its pane or a new one.

- React Grab 0.2.0 vendored (MIT) and loaded into a page only when
  pointing starts, telemetry off; reuses a page's own React Grab
- The question is typed in a native composer, so a page can't send
  anything to the agent by itself; picks only count right after a real
  click or key in the browser
- The helper and `leaf browser` talk in JSON lines; leaf builds the
  prompt (tested) and delivers it with agent::deliver
- The composer names the agent a question would go to, asked live:
  the picked one, else the one open in a pane (agent::current)
- Failed sends keep the composer and copy the prompt to the clipboard

Browser fixes:
- Hidden during Mission Control instead of shown as its own window
- Steps aside while Rex animates panes, then fades back in place
- Gives way to Rex's palette and other Rex windows over the pane
- Close button in the toolbar; macOS 13 check before launching

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Version 0.18.0 in Cargo.toml and Cargo.lock
- CHANGELOG: Unreleased becomes 0.18.0, adding the reader's saved HTML
  pages and sharp SVGs, and the GitHub posting dialog fix, which were
  on main without notes
- Site version pill reads v0.18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/browser.swift Resolved
Comment thread README.md Resolved
Comment thread build.rs Resolved
Comment thread README.md Resolved
Comment thread src/browser.rs Resolved
Comment thread CHANGELOG.md Resolved
Comment thread README.md Resolved
Comment thread src/plugin.rs Resolved
Comment thread CHANGELOG.md Resolved
Comment thread src/browser.swift Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 15 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread Cargo.toml Resolved
- Quote the page's title and address with the elements between markers
  page text can't forge, so a hostile title stays page data
- Cap a prompt's elements at 24k characters and say how many were left out
- Turn off React Grab's own key so cmd+c stays copy; shift+cmd+c points
- Stop the rex events watcher on every exit path
- Also look for the pane in the layout tree before treating it as closed
- Without a Swift toolchain, rerun the build script once one appears
- Drop find's unused fromStart parameter
- Docs: leaf browser opens in the current pane, the send button, which
  agents leaf can start with a question, macOS 13 requirement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/browser.rs Resolved
Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
DeepanshuMishraa and others added 2 commits November 22, 2026 01:23
- The browser, and pages' prefers-color-scheme, follow Rex's light or
  dark choice (Workspace.appearance), or macOS when Rex does
- `leaf browser --check` unpacks the helper and prints its path; the
  release smoke test uses it to check the shipped helper's architecture
  and that it starts
- Review: cap a page's title and address before reading them, and the
  changelog says how the CLI opens and which agents leaf can start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opened without an address, the browser shows a quiet start page:
leaf's mark, a hint for the address bar and pointing, and the web
servers running on this Mac (listening ports that answer with a page,
named by their <title>), each one click away. It's light or dark like
Rex, keeps the address bar empty, and reloads with fresh servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DeepanshuMishraa
DeepanshuMishraa merged commit 284a98a into main Nov 21, 2026
9 checks passed
@DeepanshuMishraa
DeepanshuMishraa deleted the feat/webkit-browser branch November 21, 2026 20:01
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