GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(browser): open a middle-clicked link in a new tab by Hona · Pull Request #65091 · anomalyco/opencode

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

A middle-click on a link in the browser pane showed "Pop-up blocked" and opened nothing. It now opens a new tab behind the current one, as Chrome does. The same goes for the other ways a person opens a link elsewhere: Ctrl+click (Cmd on macOS), with Shift as well, Shift+click, and Enter on the focused link with those modifiers.

Before After
Pop-up blocked notice after a middle-click New tab behind the selected tab after a middle-click
Ctrl+Shift+click opens it in front: New tab in front after Ctrl+Shift+click

Pictures were taken from the pane's component fixture (real side region, pane and model) with a throwaway fake main on a made-up page; that fake main is not part of this PR. "Before" is the same setup with dev's rule.

Cause

  • A regression of feat(desktop): signed-in browser pane with extensions, previews, prompts and agent safeguards #63002. Before it, setWindowOpenHandler allowed every web destination. Since it, a request opens only when CDP's Page.windowOpen reported it with userGesture: popupActivated(popupReport, url) at packages/gui-plugins/src/browser/chromium.ts:891 on dev, refused at :906.
  • Chromium sends that report only for window.open and target="_blank". A link it routes to a new tab by the click's button and modifiers goes through OpenURL and has no report (measured in Electron 44.9.1: disposition: "background-tab", no Page.windowOpen). So every such click was a pop-up without a gesture.

Rule

windowOpening in the new window-open.ts owns the decision.

  • A request Chromium reports as window.open or target="_blank" (Page.windowOpen) is decided by that report's userGesture alone, as on dev.
  • A request with no such report opens only as the link the person pressed. Every part is Chromium's own word:
    • It is a clicked link. Chromium reported a link navigation to a new tab for this address (Page.frameRequestedNavigation, reason anchorClick). window.open never has one.
    • The press is the person's and unused. The tab is theirs (activityOwner), and their latest input is a press of the left or middle button, or Enter, within Chromium's activation lifetime. Any request uses the press up.
    • The disposition is the press's. For Enter it follows from the key's modifiers. For a mouse press, Electron reports no modifiers, so: background-tab opens, because Chromium gives it only while it handles a real press with the middle button or Ctrl/Cmd; foreground-tab and new-window, which a made-up click can ask for, open only the link under the pointer (update-target-url).

Why this does not rest on timing:

  • A missing or late part only blocks. A window.open whose own report were lost has no anchorClick report, so a press gives it nothing.
  • The reports do come first. Blink flushes Page.windowOpen and Page.frameRequestedNavigation before it sends CreateNewWindow or OpenURL, all on the frame's channel-associated pipe, and Electron emits the event synchronously. Measured in Electron 44.9.1 with the CPU throttled 6x, busy loops and a spinning worker: 2,200 of 2,200 window.open requests had their report when the handler ran.
  • A timer is not "no gesture" to Chromium. window.open in a timer 50 ms after a click in the same frame is reported with userGesture: true and opens, as on dev and in Chrome. What stays blocked is what Chromium reports without a gesture, and a link click the page makes up.
flowchart TD
  R[page asks for a tab] --> A{artifact?}
  A -- yes --> ASK[offer the link in a notice]
  A -- no --> O{a tab can show it?}
  O -- no --> REF[answer as a click on that link]
  O -- yes --> P{Page.windowOpen report?}
  P -- yes --> G{userGesture, same address}
  P -- no --> L{anchorClick report for this address?}
  L -- no --> B[Pop-up blocked]
  L -- yes --> U{person's unused press, and its disposition?}
  G -- no --> B
  U -- no --> B
  G -- yes --> T[new tab: behind for background-tab, else in front]
  U -- yes --> T
Loading
The person does Chrome This pane
Middle-click, Ctrl/Cmd+click, Ctrl/Cmd+Enter on a link New tab behind, next to the opener, no window.opener even with rel="opener" Same, but at the end of the strip
Ctrl/Cmd+Shift+click, Shift+middle-click New tab in front Same
Shift+click New window New tab in front (the pane has no windows)
Click a target="_blank" link, or window.open from a click New tab in front Unchanged: same
window.open with no gesture Blocked Unchanged: blocked, same notice
A modified link click the page makes up within 5 s of a real press Opens (user activation) Blocked, same notice, as on dev
Middle-click on no link, or on a javascript: link No request Nothing, no notice
Middle-click a mail or app link No tab The offer a click on it gets
A new tab whose first navigation becomes a download The tab closes once the download has its place; in front, the opener is selected again Same
A new tab whose first navigation redirects to a mail or app link The tab closes after the app is launched The tab closes, and the tab it was opened from gets the offer a click gets
A new tab whose first navigation redirects to a refused address Error page in the tab The tab stays on the new-tab view with the pane's refusal notice

Sources: DispositionFromClick, NavigationPolicyFromEvent (a background tab needs a real input event), ShouldBlockPopup called from Browser::OpenURLFromTab, kActivationLifespan, DetermineInsertionIndex, InspectorPageAgent::WindowOpen and FrameRequestedNavigation (flushed before CreateNewWindow and BeginNavigation, on the pipe of FrameHost), NavigationPolicyForCreateWindow, Electron's OpenURLFromTab, DownloadUIController::OnDownloadUpdated and LaunchUrlWithoutSecurityCheckWithDelegate (a new tab left with nothing to show closes), and Chrome's mouse shortcuts, which list the modified clicks but not the middle button.

A tab closes this way only when a page opened it, it has shown no document, and it is the person's (closesUnshown). A tab that had committed a page stays.

Unchanged

  • The agent. Its middle-click and modified clicks stay blocked pop-ups, as do clicks while its command runs. The Linux middle-click refusal, the activity mark and every refusal in policy.ts are untouched. Its click on a target="_blank" link still opens its tab, and its new tab keeps its download and stays.
  • No gesture. window.open on load or a timer, and a modified click the page makes up, stay blocked with the same notice.
  • Artifacts. A middle-click asks before it opens, as a click does.
  • Extension pages and previews. Same rule as a web page. A preview's link to another workspace file now opens behind on a middle-click. An extension popup still opens links as a tab in front.
  • The new tab. Same path as a target="_blank" tab: partition, session guard, URL policy, blocker wait, saved tabs and history.

Tests

  • window-open.test.ts: both rules as tables, person and agent, web page, preview, extension page and artifact.
  • electron-links.test.ts: real Electron through electron-run.ts, hidden window, Chromium input events. Fails on dev with the pop-up notice. Downloads get their save path in the fixture's own will-download listener before the page's handler runs, so no save dialog can open; the download ends after its tab has closed.
  • The same test presses first and lets the page act 50 ms, 500 ms and 2 s later, with the renderer throttled 4x: a window.open from a frame the press gave no activation, and a Shift+click the page makes up, after a press elsewhere and after a press on a link whose navigation the page prevents. 12 cases, all blocked with the notice.
  • pane-machine.test.ts: a tab closed in front selects its opener; behind, the selection stays.

Limits

  • Rewritten links. Shift+click and Ctrl+Shift+click on a link whose address the page changes as it is pressed get the notice with Open, because the address no longer matches the link under the pointer. Middle-click and Ctrl+click are not affected.
  • Position. The host strip only appends (Layout.open), so the tab lands at the end, not next to its opener.
  • Save dialog. The wait while the person is still choosing where to save is covered by the rule's table only: no test opens the dialog.
  • Pane wiring. No test attaches a pane to a server, so the callbacks in pane.ts that close the tab and pass the opener's notice are covered by the page-level test and the machine test, not end to end.
  • Not run: the installed app, macOS, Linux.

No feature flag: this is a fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Hona added 3 commits November 20, 2026 17:28
@Hona
fix(browser): open a middle-clicked link in a new tab
7feb2a0
@Hona
Merge remote-tracking branch 'origin/dev' into browser-middle-click
01764dd
@Hona
test(browser): cover a link that asks for an opener
fc3a480
opencodejr[bot]
opencodejr Bot reviewed Nov 20, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The decision logic matches the description, and it follows Chromium's rule for whether a link opens or counts as a blocked pop-up. I checked the rule table in window-open.test.ts (passes) and tsc -b (clean). I couldn't run the real-Electron test: Electron won't start in this container because a system library is missing. So the fix itself is not verified here. The before/after images in the description show the desktop change.

Public API: unchanged. PageMenuHost.open gains an optional background argument, but that type is internal to the plugin.

Two things worth a look (inline):

  • When there's no Page.windowOpen report, the rule now allows the request after a recent press, where before it blocked it. If that report can ever arrive after the window-open handler runs, a window.open without a gesture made soon after a click or key press would now open.
  • The new component-test story checks a fake main that calls windowOpening itself, so it adds little beyond the Electron test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/gui-plugins/src/browser/window-open.ts Outdated

if (!request.openable) return { type: "refuse" }

const activated = request.report

@opencodejr opencodejr Bot Nov 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

When there's no report, a press in the last 5 s is now enough to open. Before, this path blocked. That's correct for a link Chromium routes by its click. But if Page.windowOpen (a CDP event from the renderer) can ever arrive after setWindowOpenHandler runs, a window.open without a gesture made shortly after any click or key press would now open: the base blocked it, and this opens it. Is that ordering guaranteed? If not, could the press path be limited to requests that can't come from window.open, or could the handler wait briefly for the report? The timer/synthetic cases in electron-links.test.ts run with no press before them, so they don't cover this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Hona Hona Nov 20, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The order holds for window.open (Blink flushes Page.windowOpen before the sync CreateNewWindow on the same channel pipe; 2,200 of 2,200 reports came first with the CPU throttled 6x), but the press path no longer rests on it: it now also needs Chromium's anchorClick navigation report for the same address, which window.open never has, and the press's own disposition, so a missing or late report only blocks. electron-links.test.ts now presses first and lets the page ask 50 ms, 500 ms and 2 s later (12 cases, renderer throttled 4x, 30 runs), and the Shift+click it makes up, which the old rule opened, is blocked.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencodejr[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

@opencodejr opencodejr Bot Nov 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm satisfied this resolves the concern. In pr/head (2450d30), a late or missing Page.windowOpen report can no longer make a no-gesture window.open open.

  • Clicked link required: linkPressed (window-open.ts) returns false unless request.link?.url === request.url. link is only ever set from Page.frameRequestedNavigation with reason === "anchorClick" and a newTab/newWindow disposition (chromium.ts:601-602), and window.open never produces that report. A window.open whose own report was lost is therefore blocked, even right after a press.
  • Disposition must match the press: for Enter, the disposition has to equal the one worked out from the key's modifiers. For a mouse press, background-tab opens. foreground-tab and new-window open only for the link under the pointer (hovered, from update-target-url). This is what closes the case of a Shift+click the page makes up on another link.
  • One request per press: after every request the handler clears popupReport, linkReport and press, whether it opened or not (chromium.ts:1001-1004). A new mouse-down also clears press, as does any key other than Enter. An agent press never sets press.
  • Tests: electron-links.test.ts:104-112 now presses first, either elsewhere on the page or on a link whose navigation the page prevents. 50 ms, 500 ms and 2 s later, a frame window.open and a made-up Shift+click are both expected to be blocked: 2 × 2 × 3 = 12 cases.

What I checked: I read window-open.ts, the handler and event wiring in chromium.ts, and the test at pr/head. bun test src/browser/window-open passes (50/50). I couldn't run electron-links.test.ts here because Electron fails to start (libnspr4.so is missing in this container). So I haven't confirmed the 12 cases, the 30-run result, or the 2,200/2,200 ordering measurement.

I didn't change anything. I used a temporary worktree in /tmp/opencode and removed it. repo/ is still on its older HEAD, with the existing bun.lock change left in place.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/gui-plugins/src/browser/panel.fixture.tsx Outdated
// new tab in its inventory, selected only when it opens in front, or the pop-up notice.
const linked: Browser.Tab[] = []

const openLink = (event: MouseEvent) => {

@opencodejr opencodejr Bot Nov 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This fake main runs windowOpening itself with report: undefined and pressedAt === at, so it can only answer "open". What the story really tests is the pane getting a state event that doesn't change the selection, which the target="_blank" path already covers. electron-links.test.ts is the test of the fix. I'd drop this handler and the new story in browser-pane-restore.spec.ts to keep the change smaller.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Hona Hona Nov 20, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Dropped: the fake-main handler and both new stories are gone, so panel.fixture.tsx and browser-pane-restore.spec.ts are the same as on dev. electron-links.test.ts is the test of the fix, and pane-machine.test.ts holds the selection after a tab closes itself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencodejr[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

@opencodejr opencodejr Bot Nov 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Confirmed. On pr/head, git diff pr/base pr/head shows no changes to panel.fixture.tsx or browser-pane-restore.spec.ts, so both match dev again. The fixture no longer has the fake-main handler, which could only ever answer "open".

  • The behaviour change is now covered by electron-links.test.ts and window-open.test.ts.
  • The new pane-machine.test.ts case (lines 430–447) covers what the dropped story only touched. It checks that a tab closing itself returns focus to its opener only when it was in front. When it was behind, the selection stays put and no focus is emitted. When the opener is gone, focus goes to the first tab.
  • bun test src/browser/pane-machine.test.ts src/browser/window-open.test.ts passes: 60 tests, 0 failures.
  • I didn't run electron-links.test.ts (it needs Electron) or the component specs.

I made no changes. bun.lock shows as modified in the shared checkout; that isn't from me, and I left it alone.

Nothing more to do in this thread.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Hona added 4 commits November 20, 2026 17:47
@Hona
fix(browser): close a new tab whose first navigation left it nothing …
4cdec64
…to show
@Hona
Merge remote-tracking branch 'origin/dev' into browser-middle-click
7d9cf22
@Hona
test(browser): keep the links fixture's state in its run
4b5ca3c
@Hona
Merge remote-tracking branch 'origin/dev' into browser-middle-click
6b328c3
opencodejr[bot]
opencodejr Bot reviewed Nov 20, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new commits look sound. The tab-closing logic only closes a tab a page opened, that has shown no document and is the person's. For a download it waits until the download has its save path or has ended. The opener gets the offer for a mail or app link, and the opener is selected again only when the closed tab was in front. I ran window-open.test.ts and pane-machine.test.ts (60 pass) and tsc -b (clean). I still couldn't run the real-Electron test here (libnspr4.so is missing), so the fix itself isn't verified.

Public API: unchanged. tab.closed gains an optional opener and the popup callback gains a refused argument, but both are internal to the plugin.

Neither earlier point is addressed yet: the press-only fallback when there's no Page.windowOpen report, and the fake-main handler in panel.fixture.tsx. Both threads stay open.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Hona added 3 commits November 20, 2026 18:32
@Hona
fix(browser): open a link in a new tab only for the link the person p…
59827c3
…ressed
@Hona
Merge remote-tracking branch 'origin/dev' into browser-middle-click
bb59cce
# Conflicts:
#	packages/gui-plugins/src/browser/chromium.ts
@Hona
test(browser): space the links fixture's server
2450d30
opencodejr[bot]
opencodejr Bot reviewed Nov 20, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Both earlier points are addressed.

  • Late gesture report: a request with no Page.windowOpen report now needs Chromium's anchorClick navigation report for the same address, as well as the person's unused press. A late or missing report now blocks instead of opening.
  • Fake main in the fixture: that handler and its component story are gone.

The new rule looks sound. I ran window-open.test.ts and pane-machine.test.ts (76 pass) and tsc -b (clean). I still couldn't run the real-Electron test here (Electron won't start in this container), so the fix itself isn't verified by me.

Public API: unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona merged commit 5fe4c38 into dev Nov 20, 2026
39 of 42 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the browser-middle-click branch November 20, 2026 09:04
@Hona Hona mentioned this pull request Nov 20, 2026
feat(browser): open a link's new tab beside the tab it came from #65126
Merged
huuhabn pushed a commit to huuhabn/opencode that referenced this pull request Nov 20, 2026
@Hona Huu Ha
fix(browser): open a middle-clicked link in a new tab (anomalyco#65091)
7cd87ed
@Edo771977 Edo771977 mentioned this pull request Nov 21, 2026
chore: merge upstream/dev into the fork Edo771977/opencode#97
Merged
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Hona
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.