GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(browser): open a link's new tab beside the tab it came from by Hona · Pull Request #65126 · anomalyco/opencode Conversation
|
| Before | After |
|---|---|
![]() |
![]() |
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.
All in tab_strip_model.cc at Chromium 152 (tab_strip_model_order_controller no longer exists; its logic lives there).
| Case | Chrome | Source |
|---|---|---|
| A link opens a tab behind (middle-click, Ctrl/Cmd+click) | After the last tab the opener already opened, counting tabs those opened, while they stand in a row to its right; else right after the opener | DetermineInsertionIndex, GetIndexOfLastWebContentsOpenedBy |
A link opens a tab in front (target="_blank", window.open from a click, Ctrl/Cmd+Shift+click, Shift+click) |
Right after the opener, before any opened behind; every earlier opener is forgotten | DetermineInsertionIndex, InsertTabAtImpl |
| "+" or the new-tab shortcut | End of the strip | DetermineInsertionIndex |
| The person selects another tab | Openers are forgotten only when they leave a tab that was opened for an unrelated one. Opener to child, child to opener, sibling to sibling, and the opener to an unrelated tab and back all keep the row | OnActiveTabChanged |
| An address is typed into a tab | Openers are forgotten, except for the first address typed into a new tab at the end (a quick look-up) | TabNavigating |
| A tab closes | What it opened counts as opened by its own opener | FixOpeners |
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 |
Now | |
|---|---|---|
| Opened behind | At the end. "New tab" at 5 ms, its address at 810 ms, its title at 1,212 ms | Beside its opener. "New tab" at 5 ms, its title at 1,212 ms |
| Opened in front | At the end, selected at once over the pane's new-tab state, relabelled twice | Beside its opener, selected at once over the same state, relabelled once |
A document with no <title> |
"New tab", then Chromium's name at the commit | "New tab", then Chromium's name when its load ends |
| A load that fails | "New tab", then its address | "New tab", then its address once, with its error page |
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):
| Step | Label | Tabs left of it | Tabs right of it | Its width |
|---|---|---|---|---|
| Click: the tab is listed, and selected when it opens in front | New tab | 0 px | +97.17 px (its width and the gap) | 89.17 px |
| Load starts | New tab | 0 px | 0 px | same |
| Document commits under Chromium's name, its address | New tab | 0 px | 0 px | same |
| Document names itself | One | 0 px | −25.88 px (the labels' difference) | 63.30 px |
| Icon arrives | One | 0 px | 0 px | same |
| Load ends | One | 0 px | 0 px | same |
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.
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's tabs.list agree 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 (named in pane-machine.ts):function named(before: Browser.Tab, tab: Browser.Tab) { const blank = tab.url === "about:blank" if (!tab.loading) return (before.loading || before.loadError !== undefined) && (blank || tab.title !== "") return !blank && tab.generation === before.generation && tab.title !== "" && tab.title !== before.title }
BuiltinLayout.open takes after (BuiltinOpenOptions in @opencode/plugin/gui/builtin), and the host's appendSessionTab places the key after it. No public plugin API changed: Layout and OpenOptions are untouched. The host names no plugin.render_view_context_menu.cc).dev. Its tabs.open and the pop-ups of a page it drives are listed at once, at the end, with their activity mark.chrome.tabs.create.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.dev.document.title, or a navigation) changes the tab's width, as for every tab.pane.ts that pass beside are 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.