Repository navigation
fix(browser): treat no-op BROWSER values as unset so headless sessions can fall back - #756
Merged
backnotprop merged 1 commit intoMay 19, 2026
Conversation
…s can fall back Claude Code's agent view (and similar background/headless environments) sets $BROWSER=true to mean "do not launch a browser." The previous logic took that literally and ran `true http://localhost:NNNN` via `Bun.$`, which exits 0 without opening anything. The server then sits forever in waitForDecision() with no visible UI and no way for the user to recover the URL. Detect the documented no-op sentinels (`true`, `false`, `none`, `:`, `0`, `1`) on both PLANNOTATOR_BROWSER and BROWSER and treat them as if the variable were unset. This lets shouldTryRemoteBrowserFallback() reach the VS Code IPC fallback in remote sessions and lets openBrowser() fall through to the platform default when nothing else is configured. Refs backnotprop#154.
Owner
|
Is this the fix for |
Owner
|
great work |
backnotprop
added a commit
that referenced
this pull request
Oct 14, 2026
…1923) browser.ts reads none/true/false/0/1/: as unset (#756) and falls through to the system default, so every test that set PLANNOTATOR_BROWSER=none opened real tabs on the developer's screen whenever it reached openBrowser (a foreground plannotator inbox, a session without --background). - tests/helpers/no-browser.ts: NO_BROWSER, an absolute path to a program that exits at once (/usr/bin/true, /bin/true, true on PATH; whoami.exe on Windows). - Every 'none' in tests/e2e, tests/helpers/inbox-world.ts and the CLI tests now uses it. - The bun test preload sets PLANNOTATOR_BROWSER=NO_BROWSER for every test. - tests/no-browser-sentinel.test.ts scans tests, scripts, package.json files and the workflows for a sentinel value. No product change.
backnotprop
added a commit
that referenced
this pull request
Oct 15, 2026
* Every session prints its URL (re-applies #1184) Every Bun session now writes one stable stderr line on start, before it launches a browser: Plannotator session ready: <url> Remote forwarding advice and a failed browser launch become follow-up lines under it, so the URL appears exactly once. A local session whose browser opened fine used to print nothing (#1134), and a launcher that never exits hid the URL until it did. - shared-handlers: SESSION_READY_LINE_PREFIX, an `announce` option, the line printed before the launch; isCodexDesktopHost removed (its case is covered). - --tailscale: announceTailscaleSession prints the ready line once, then the tailnet line and QR. - OpenCode embedded runtime: announce: false (its toast or transcript notice carries the URL); an OpenCode 2 host without session.synthetic logs the URL instead. The CLI bridge's stderr filter also forwards the remote follow-up and the "Could not open a browser" line. - Pi: the in-turn "opened" message always carries the URL; the after-turn notify runs only for the archive and the event API, or after a failed launch (remote no longer shows the URL twice). Re-applies the design of #1184 by @technicalpickles on current main. Co-authored-by: Josh Nichols <[email protected]> * PLANNOTATOR_BROWSER=none opens nothing A "none" value on PLANNOTATOR_BROWSER (or --browser): none, false, 0, off, no, true, 1 or :, trimmed and any case, now opens nothing at all, local or remote: no VS Code IPC, no Glimpse, no BROWSER, no system opener. Since #756 these values were read as "unset" and opened the system default (or ran BROWSER, or Glimpse), so there was no way to say "never open". The rule lives in one module, packages/shared/browser-intent.ts (resolveBrowserIntent: none | default | explicit), vendored to Pi. Bun's openBrowser and shouldTryRemoteBrowserFallback and Pi's openBrowser use it, so every caller follows it (sessions, the Inbox, sessions --open, t3 login). The Bun CLI prints " Not opening a browser (PLANNOTATOR_BROWSER=none)." under the ready line; Pi says it in its opened message. BROWSER keeps #756: its no-op values are still ignored and the default chain runs, because hosts set it (Claude Code's agent view sets BROWSER=true). Tests: a pure table for the intent; one process test per runtime whose PATH holds only stand-in open, xdg-open and glimpseui scripts (and a recording VS Code IPC server on Bun), proving nothing launches for none (BROWSER set, local and remote) and that BROWSER=true still runs the default opener. * Review fixes: neutral mod starting text, --browser none in help, drop unused quiet option, comment fixes * Fix the merge: drop the blank line main's handleServerReady kept twice --------- Co-authored-by: Josh Nichols <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
$BROWSER(or$PLANNOTATOR_BROWSER) is set to a no-op sentinel liketrue,false,none,:,0, or1— as Claude Code's agent view does (BROWSER=true) —openBrowser()shells out viaBun.$and runs something equivalent totrue http://localhost:NNNN.true(1)exits 0 without doing anything, the function returns success, and the server then sits inwaitForDecision()forever. No browser appears, the URL isn't recoverable, and the session looks hung.This is the BROWSER-sentinel branch of the same family as #163 (which fixed
BROWSER=open/ VS Code devcontainer scripts). The remaining sentinel case still affects every headless / background runner that conventionally setsBROWSER=trueto disable browser launching.Fix
packages/server/browser.ts:isNoOpBrowserSentinel()recognising the documented no-op values (case- and whitespace-insensitive).openBrowser(), treat a sentinel-valuedPLANNOTATOR_BROWSER/BROWSERas if the variable were unset, so we fall through to the platform default (open/xdg-open/cmd.exe /c start) instead of shelling out to the sentinel.shouldTryRemoteBrowserFallback(), treat the same sentinels as "no real handler configured" so the VS Code IPC fallback still fires in remote sessions where it would otherwise be skipped.Net behaviour:
BROWSER=true(agent view)true http://...→ no-opBROWSER=/usr/bin/firefoxPLANNOTATOR_BROWSER='Google Chrome'(macOS)open -achromeopen -achrome (unchanged)No protocol or stdout changes, no new dependencies, no surface-area additions.
Tests
Adds
packages/server/browser.test.tscoverage:shouldTryRemoteBrowserFallbacknow returnstruewhenBROWSER/PLANNOTATOR_BROWSERare sentinels.isNoOpBrowserSentinelrecognises the documented values (incl.TRUE,none) and rejects real handlers (/usr/bin/firefox,Google Chrome,open).bun testis green (1167 pass / 0 fail).bun run typecheckis clean.Refs #154 (BROWSER-sentinel cause; other code paths in that issue may still apply).
Fixes #724