Skip to content

feat(browser): make the browser reachable from everywhere, and let both composers hand it a page - #1429

Closed
gitsatra wants to merge 7 commits into
spacering-net:mainfrom
gitsatra:feat/browser-everywhere
Closed

gitsatra wants to merge 7 commits into
spacering-net:mainfrom
gitsatra:feat/browser-everywhere

Conversation

@gitsatra

@gitsatra gitsatra commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

What this is

The built-in browser worked, but there was almost no way to get to it. Opening a page required either an agent to write a link and clicking it, or finding the + at the end of the file tab strip — which the strip did not render at all while it had no tabs, so a person with an empty column had no route to a page whatsoever. And send to chat, pick an element, screenshot, console errors lived only in the browser tab's own toolbar, so they could only be reached from a page that some other path had already opened. From the assistant page they were unreachable entirely.

This adds the entrances that were missing, and one policy hook they all share.

Where a page can be put — the part that is actually subtle

The answer differs by route, and getting it wrong opens a page where nobody can see it:

route what is on screen where a page goes
conversations the file column a tab of the file column
the assistant page, other full-page routes that page paints over the file column (app/workspace/layout.tsx:594) that page's transcript drawer (SessionViewerHost)

useBrowserSurface() answers this once, as a pure function (decideBrowserSurface), and reports null rather than guessing when a surface has nowhere to put a page. Every new entrance asks it, so the strip, the empty column, the palette, the shortcuts and the composers cannot drift into three different behaviours.

Entrances added

  • The + stays when the strip is empty. A blank strip rendered null, taking its own + with it. It now renders the trailing row with no tabs in it, so "open a file" and "open a browser tab" are reachable from the emptiest possible workspace.
  • The empty file column offers Browser tab instead of only telling you to open a file from the right panel.
  • mod+shift+b opens a page where it can be seen (returning to the conversations route first if another route is covering it).
  • mod+L puts the caret in the address bar of the page already on screen — bringing that page forward by its own URL first (the one-tab-per-URL rule activates it in place) — and opens a blank one when there is no page to focus. Both are new shortcut ids, so they appear in Settings → Shortcuts and are rebindable, like every other shortcut.
  • The ⌘K dialog offers a browser tab while the list is empty, and turns what you typed into a page when it reads as an address (normalizeTypedAddress, the address bar's own parser, so localhost:3000 and example.com work and auth keeps searching conversations). It is listed last, so Enter still prefers a real conversation.

Handing a page to the box you are typing in

Both composers — the chat one and the assistant's — gain a Browser section in the existing + menu: open a page, pick an element, screenshot, console errors.

  • One delivery path. deliverPageHandoff is exported from browser-page-handoff.tsx and used by both the tab toolbar and the composers, so a picked element reads the same wherever it was picked: same badge name, same redacted URL, same picture name, same sent / gone / failed.
  • A hand-off names its target. targetTabId addresses one composer; the assistant's box is addressed by its assistant (personalAgent:<uid>) because it is not a conversation tab. Two boxes mounted at once no longer race for one page, and an untargeted hand-off behaves exactly as it did before.
  • The assistant composer registers the listener at all — it previously had none, so a page sent from the assistant page went nowhere.
  • An armed pick cannot outlive its box. It ends on Escape, on unmount, and when the composer goes away, and the + says picking while a pick is armed (a page covered in a highlight with no way out is the failure mode this avoids).

Not changed

  • Nothing about how the browser itself runs: no new backend command, no change to browser.rs, the picker, or the native surface. pick_element's 180s timeout and the isolated-world overlay are untouched.
  • No new i18n keys. Everything reuses Browser.handoff.* and Folder.*; src/i18n/messages.test.ts stays at 22/22 with all ten locales in parity. Two new entries appear in the shortcut settings because the shortcut ids are new (ShortcutSettings.actions.open_browser_tab, .focus_address_bar).

Verification

  • ./node_modules/.bin/tsc --noEmit — clean.
  • New tests: use-browser-surface.test.ts (6), browser-address-focus.test.ts (4), composer-browser-menu.test.tsx, plus additions to file-workspace-tab-bar.test.tsx (a strip with no tabs keeps its + and opens a browser tab from it), search-command-dialog.test.tsx (an address becomes a page, a word does not, and the group hides when the browser cannot run), message-input.test.tsx and personal-agent/composer.test.tsx (a hand-off lands in the box it names and not in the other).
  • Touched suites: src/components/browser, src/components/chat/composer, src/components/personal-agent, src/components/layout, src/components/files, src/hooks — 2,538 passing, 265 failing.
  • No test that passes on upstream/main fails on this branch. Measured by running that exact set twice — once on this branch, once in a clean upstream/main worktree sharing the same node_modules — and diffing the failing test names: 250 failures on main, 250 on this branch, the same 250 (the extra 53 passes are the new tests below). The failures are this machine's environment: window.localStorage is undefined under vitest's jsdom on Node 26, which breaks any suite that touches storage, and it is not behaviour this PR changes.
  • One failure the comparison did surface was ours and is fixed in bc6142453: workspace-chrome-controller.test.tsx mocks the workspace contexts wholesale, so the three optional reads the browser surface makes threw "No export is defined on the mock" and took all sixteen ⌘W tests with it. The suite now mocks them as absent (a page has nowhere to go in those tests) and is 16/16.
  • Also found by that pass and fixed here: 372669a48 — a typed address that does resolve was listed next to "No results found." The ⌘K dialog now hides the empty state while the address row is showing, and the test asserts its absence.

Checked on a running binary, in the page

A locally built --no-bundle binary (frontend embedded, grep -c -a '/_next/static' codeg.exe → 672), driven over CDP:

do this what happened
open an empty workspace the tab strip renders its +, both "New tab" routes reachable
mod+shift+b a browser tab opens in the file column, address bar focused with Enter an address
mod+L the address bar takes focus (activeElement.placeholder === "Enter an address", text selected)
type example.com, Enter the tab title becomes Example Domain, the URL is https://example.com/
⌘K, empty list offers Open browser tab
⌘K, localhost:3000 / example.com one Browser tab row for http://localhost:3000/ / https://example.com/, no "No results found."
+ in the chat composer Attach files, Browser tab, Quick messages, Live feedback, Slash commands, Experts, Office Work, Scientific Research
+ in the assistant composer Attach files, Browser tab
assistant's Browser tab submenu Open browser tab · Pick an element… · Send a screenshot · Send the console errors
assistant's "Open browser tab" a browser panel opens in that page's drawer; typing example.com there loads Example Domain in it; its toolbar has Back/Forward/Reload, the agent-access badge, Send to chat (the hand-off), device and overflow menus
mod+shift+b on the assistant page opens on the assistant page, not silently behind the workspace
mod+L there focuses that drawer's address bar and selects its text

Element picking itself is armed from that submenu and needs a click inside the live page; the delivery path is covered by composer-browser-menu.test.tsx and the assistant composer's hand-off test rather than asserted through CDP.

CI

Final state on a88dcf886: Frontend (lint + vitest + build) pass (16m23s — eslint, the whole vitest suite and next build), and every Rust job on ubuntu-22.04 and windows-latest pass (cli, server, desktop).

Two red marks on the way there were mine and are fixed: prettier/prettier errors in the new files (commit b7892d535) and runs that were cancelled mid-job. The only remaining non-green check is Rust desktop on macos-latest, whose job conclusion is cancelled after 54m51s with no uploaded log (BlobNotFound) — the identical job fails the same way on #1430, and no Rust file is touched by this branch.

The browser was reachable from exactly one place nobody could find: the "+"
at the end of the file tab strip — which the strip did not even render while
it had no tabs, so a person with an empty column had no way to open a page at
all. This adds the four entrances that were missing, and one policy hook they
all share.

- The strip keeps its "+" with zero tabs instead of rendering nothing.
- The empty file column offers "Browser tab" rather than only telling you to
  open a file from the right panel.
- mod+shift+b opens a page where it can be seen; mod+L puts the caret in the
  address bar of the page already on screen (or opens one).
- The ⌘K dialog offers a browser tab while empty, and — once what you typed
  reads as an address and not a search — opens it in the browser instead.

`useBrowserSurface` answers "where does a page go from here" once, because
the answer differs by route: on the conversations route a page is a tab of
the file column, while a full-page route (the assistant) paints over that
column and must use its transcript drawer. Every new entrance asks it.
"Send to chat" lived in the browser tab's own toolbar, which means it was
reachable only from a tab that some other path had to open first — and it
always went to the conversation in the top bar, so from the assistant page it
went to the wrong place. Both boxes now offer the same hand-offs where the
person already is: open a page, pick an element, take a screenshot, send what
the page printed to the console.

- One delivery path (`deliverPageHandoff`), shared with the tab toolbar, so a
  picked element reads the same wherever it was picked: same badge name, same
  redacted URL, same picture name, same "sent"/"gone"/"failed".
- A hand-off now names its target composer (`targetTabId`). The assistant's
  box is named by its assistant rather than a conversation tab, so two boxes
  mounted at once no longer race for one page; an untargeted hand-off behaves
  exactly as before.
- The assistant composer registers the listener at all, which it did not.
- `useComposerBrowserHandoff` arms a pick through `useBrowserSurface`, so a
  pick from the assistant page runs against that page's drawer and ends on
  Escape, on unmount, and when the box goes away.
…er asks for

`useBrowserSurface` reads the optional forms of the workspace route and the
workspace actions so it can answer outside a workspace, and asks the backend
what the browser can do. The chrome-controller suite mocks those modules
wholesale, so the three new reads threw "No export is defined on the mock" and
took all sixteen ⌘W tests down with them.

Mocking the optional hooks as absent and the capabilities as unknown is the
honest shape here: these tests are about ⌘W, and a page has nowhere to go in
them.
@gitsatra
gitsatra force-pushed the feat/browser-everywhere branch from 5415e8c to bc61424 Compare December 6, 2026 03:50
The conversations list is empty while what was typed is an address, so the
palette announced "No results found." directly above the row offering to open
that very page. The empty state now steps aside when the browser row is going
to appear.

Next: prove it in the live app, and in a test that asserts absence.
@gitsatra

gitsatra commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/main (0.52.0, 08ad3e96f) in #1434 — the merge was conflict-free — with one change from a day of real use added: "Open browser tab" is now a top-level row in the composer's + menu instead of a step inside the submenu, and it is only drawn where a page can actually be shown.

GitHub will not retarget an open PR's head branch, so please treat #1434 as this PR. If #1434 lands, I'll rebase anything else onto it.

@gitsatra gitsatra closed this Dec 6, 2026
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