Repository navigation
Tests: never set PLANNOTATOR_BROWSER=none (it opens the system browser); use a real no-op program - #1923
Merged
Conversation
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.
This was referenced Oct 14, 2026
Merged
1 task
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.
The bug
PLANNOTATOR_BROWSER=nonedoes not stop a browser from opening.packages/server/browser.ts(and Pi'sapps/pi-extension/server/network.ts) treatsnone,true,false,:,0and1as no-op sentinels (NOOP_BROWSER_VALUES, #756).openBrowserthen drops them as if the variable were unset and falls through to the system default (open <url>on macOS,xdg-openon Linux).About 25 tests and specs set
PLANNOTATOR_BROWSER: 'none'and expected no browser. Any of them that reachesopenBrowseropens real tabs on the developer's screen. Examples: a foregroundplannotator inbox, or a session started without--background. This happened on the owner's Mac today.I confirmed it with the compiled binary.
plannotator inbox(foreground) ran with a PATH that held only trapopen/xdg-openscripts, so the real opener could not be reached:The fix (tests only; no product change)
tests/helpers/no-browser.tsexportsNO_BROWSER, an absolute path to a program that exits at once:/usr/bin/true(present on macOS and on Linux CI images), else/bin/true, else the firsttrueon PATH. On both macOS and Linux,openBrowserruns a value that contains a/directly, never throughopen -a.%SystemRoot%\System32\whoami.exe, the no-optest.ymlalready uses.openBrowserruns it ascmd.exe /c start "" <path> <url>, so no browser opens (a console window may flash).tests/helpers/inbox-world.ts(worldEnv), 23 specs intests/e2e/*.spec.ts,apps/hook/server/annotate-cli.test.tsandapps/hook/server/inbox-connect-cli.test.ts.inbox-search.spec.tshad a literal/usr/bin/true; it now uses the helper too. No playwright config or workflow sets a sentinel onPLANNOTATOR_BROWSER. Two places setBROWSER: true(the$BROWSERsentinel):release.yml's binary smoke tests on CI runners, andscripts/dast/target.ts, which also setsPLANNOTATOR_SKIP_BROWSER_OPEN=1. I left both as they are.tests/setup/feedback-archive-off.ts, the file everybunfig.tomlloads) now setsPLANNOTATOR_BROWSER=NO_BROWSERunconditionally for every bun test. With this, an in-processopenBrowserand every child that inheritsprocess.envopen nothing. It also overrides a contributor's own value: a VS Code terminal injectsopen-in-vscode, which would otherwise send every test session into an editor tab. Tests of the launch itself already set and restore their own value inside their bodies. The Playwright specs run under node with no preload, so they set the value in the env they build.tests/no-browser-sentinel.test.ts(with the scanner intests/helpers/no-browser-scan.ts):.sh/.ps1/.cmdundertests/andscripts/, everypackage.json, and.github/workflows/*.yml. It fails on a sentinel value given toPLANNOTATOR_BROWSERor to the CLI's--browserflag, in any spelling (object key,process.envassignment, shellVAR=, YAML, PowerShell$env:; any case, surrounding spaces).no-browser-guard: sentinel under test. Onlypackages/server/browser.test.tsdoes (it callsshouldTryRemoteBrowserFallbackand launches nothing).NO_BROWSERruns and exits 0, thatbrowser.tsdoes not read it as a sentinel, and that the preload sets it.origin/main, the scan reports every old'none'.AGENTS.md(=CLAUDE.md) Testing Rules gets one bullet about this.Windows
No CI job runs any of the changed files on Windows. The Windows jobs run
uninstall.test.ts,cli.test.ts,auto-update.test.ts, a filteredreview-workspace.test.ts, the Pi runtime smoke and the install scripts. The Inbox helpers and e2e specs already assume POSIX (#!/bin/shfakes,:-joined PATHs). The helper still has a Windows answer:whoami.exe. The preload loads it on Windows too, and it resolves there.Question for the owner: should
PLANNOTATOR_BROWSER=nonemean "never open"?This PR does not change
browser.ts. The trade-off:BROWSER=true(Claude Code's agent view), and if Plannotator shelled out totrue <url>the server would hang inwaitForDecision()with nothing open. Treating the sentinels as "unset" makes Plannotator open its own window there, which is right for$BROWSER.PLANNOTATOR_BROWSER, the same rule is surprising. Nobody sets the Plannotator-specific variable tononeby accident, and a person who writesPLANNOTATOR_BROWSER=nonealmost certainly means "do not open anything". Today they get the system browser.PLANNOTATOR_BROWSER(only) mean "open nothing", and keep fix(browser): treat no-op BROWSER values as unset so headless sessions can fall back #756's fall-through for$BROWSER; (c) (b) plus a stderr line that prints the URL, so a person can still open it by hand. (b) or (c) would makePLANNOTATOR_SKIP_BROWSER_OPENpartly redundant for callers. They would also change remote-mode behaviour, becauseshouldTryRemoteBrowserFallbackalso reads the sentinel as "no handler". Which do you want?Tested
bun test tests/no-browser-sentinel.test.ts: 7 pass.bun test tests/ apps/hook/server/annotate-cli.test.ts apps/hook/server/inbox-connect-cli.test.ts packages/server/browser.test.ts: 129 pass, 0 fail.bun testwith the new preload: 7888 pass, 1 fail. The failure wasauto-update.test.ts"group SIGINT" (a 30 s timeout under a load average of about 17). It passes alone (43/43) and is not browser-related.apps/pi-extension/server/network.test.tsflaked 2 times in 12 runs with the preload and 0 in 4 runs without it. Both flakes were the existing race wherewaitForFilesees the file thatprintf ... > filecreated before the write lands. The env value is not involved.tscforpackages/serverandapps/hook/tsconfig.server.json: clean..local/plannotator,PLANNOTATOR_INBOX_CONNECT=0, temp dirs):inbox-order,inbox-archived,inbox-tailscale(its PATH holds only fakes, so this checks the absolute path),surface: 21 passed.