Repository navigation
feat(browser): open a link's new tab beside the tab it came from - #65126
Conversation
There was a problem hiding this comment.
I found no problems that should block this. I read the opener logic against the Chrome cases in the description, and the closest tests pass: 130 in pane-machine.test.ts and machine.test.ts, 25 in session-tabs.test.ts. tsc -b is clean in gui-plugins and app. I could not run the new component spec because Playwright's Chromium isn't installed here, and I couldn't drive the desktop pane, so I haven't seen it work end to end. The before/after pictures in the description stand.
Public API: unchanged. BuiltinOpenOptions.after and the BuiltinLayout.open overload are in the workspace-only @opencode/plugin/gui/builtin, and the placed field on the pane's state event is internal Ipc. The public Layout and OpenOptions are untouched.
One minor gap that doesn't block: when a page opens a tab before the session's location is known (the strip is not located yet), the placed hint is dropped. That tab then falls back to the end of the strip once the location arrives.
There was a problem hiding this comment.
I found no bugs in the new commits. I read the new holding step (held, tab.due, list, and the window machine's withheld) and ran the closest tests: pane-machine.test.ts and machine.test.ts give 148 pass. session-tabs.test.ts gives 25 pass, and tsc -b is clean in gui-plugins and app. electron-links.test.ts could not run because Electron can't start in this sandbox. I couldn't drive the desktop pane, so I haven't seen it work end to end. The public API is still unchanged: after and held/placed are in the workspace-only gui/builtin and the internal pane Ipc.
One new concern: a tab a click opens in front can now show nothing for up to 3 s (see the inline comment).
| if (!background) dispatchBinding(binding, { type: "tab.focused", tabID: popup.state().id }) | ||
|
|
||
| return popup.contents | ||
| // The person's stands beside this tab, and takes the pane once the strip shows it (`tab.opened`). |
There was a problem hiding this comment.
When a slow page's link opens a tab in front (target="_blank", Shift+click), the person now sees nothing at all for up to LISTING_DEADLINE_MS (3 s): no tab, no spinner, and the pane stays on the old page. To them the click looks like it did nothing, and they may click again. Chrome shows the new tab straight away and lets it relabel. Holding a background tab back to avoid the width change seems fine, but could a front tab be shown at once, or with a much shorter deadline?
There was a problem hiding this comment.
My earlier point is fixed: a tab a link opens is now listed and, when it opens in front, selected straight away. It shows as "New tab" until its page names itself, so the old 3 s period with nothing visible is gone. I found nothing new to raise in this commit.
I checked it by reading the diff and running the closest tests. pane-machine.test.ts and machine.test.ts give 142 pass, and tsc -b is clean in gui-plugins and app. I couldn't run the Electron or Playwright tests or the desktop pane here, so I haven't seen it work end to end.
The public API is unchanged: unnamed and placed are internal pane Ipc fields, and after is in the workspace-only gui/builtin.
A tab a page or link opens in the browser pane now appears beside the tab it came from, as in Chrome. Before, it was added at the end of the side strip, after every file, review and browser tab. It appears at the click and changes its label once, from "New tab" to the page's title. Follow-up to #65091.
Pictures were taken from the pane's component fixture (real side region, pane and model, main's events sent through the Ipc schema, the fixture's plain strip given borders) on a made-up page, after the real sequence below.
Chrome's rule
All in
tab_strip_model.ccat Chromium 152 (tab_strip_model_order_controllerno longer exists; its logic lives there).DetermineInsertionIndex,GetIndexOfLastWebContentsOpenedBytarget="_blank",window.openfrom a click, Ctrl/Cmd+Shift+click, Shift+click)DetermineInsertionIndex,InsertTabAtImplDetermineInsertionIndexOnActiveTabChangedTabNavigatingFixOpenersFrom click to loaded
TabUIHelper::GetTitle,ShouldRenderLoadingTitle). Chrome's tabs share the strip's width equally, so a new label moves no tab (known behaviour, not read from source).tab.new) until the page has the name it keeps. That is the rule fix(browser): show saved tabs at once when the app reopens, and hold them while they load #65067 uses for restored tabs.Measured in Electron 44.9.1 on a page with 800 ms to first byte and its
<title>400 ms later:dev<title>What the strip does at each step (
getBoundingClientRect()of every tab in the component stories, on the fixture's strip with an 8 px gap; the same in front and behind):Two tabs opened behind and named in reverse order: each appears at its click in the order opened, and each naming moves only the tabs to its right.
How it is built
flowchart LR P[page or link opens a tab] --> M["pane-machine.ts: tab.opened with beside"] M -->|"tab-openers.ts: placedAfter"| I[inventory lists it after that tab, at once] I -->|"state event: placed { tabID, after }, unnamed [...]"| W["window machine: sync-strip"] W -->|"layout.open(key, session, { tab: 'append', after })"| H[host strip: appendSessionTab]tab-openers.ts) and inserts the tab into its inventory, so the saved order and the agent'stabs.listagree with the strip.unnamed), and the strip draws those as "New tab". A tab leaves the list when its document names itself or its load ends (namedinpane-machine.ts):BuiltinLayout.opentakesafter(BuiltinOpenOptionsin@opencode/plugin/gui/builtin), and the host'sappendSessionTabplaces the key after it. No public plugin API changed:LayoutandOpenOptionsare untouched. The host names no plugin.Which tabs
render_view_context_menu.cc).dev. Itstabs.openand the pop-ups of a page it drives are listed at once, at the end, with their activity mark.chrome.tabs.create.Tests
pane-machine.test.ts: two tables of event sequences that replay what a page reports. When a tab is listed and how long it keeps its new-tab label (13 rows: behind and in front; untitled, failed and refused loads; two named in reverse order) and where it stands (10 rows: each row of the Chrome table).electron-links.test.ts: a middle-click on a link to a slow page in real Electron, with the page's reports fed to the pane machine. The window is told of the tab at the click, after the pressed tab, and its label changes once.session-tabs.test.ts: the host's placement.machine.test.ts: the window places a new tab and keeps its new-tab label until main names it.browser-pane-restore.spec.ts: two stories on the strip with three browser tabs, measuring every tab's box at every step of the table above: one tab behind, then two behind named in reverse order, then quit and reopen; and one tab in front. Drawing the address label at the commit fails both.Limits
dev.document.title, or a navigation) changes the tab's width, as for every tab.pane.tsthat passbesideare covered by the machine and component tests only. The installed app, macOS and Linux were not run.shell/titlebar), not this strip; nothing here depends on either.No feature flag: this finishes the Chrome behaviour of #65091 and changes only where a new tab lands and which interim label it skips.