Skip to content

v1.91.193.0 fix(browse): spawn the real bun.exe for the terminal agent on Windows (#2295, port of #3357) - #3388

Merged
capy-ai[bot] merged 5 commits into
mainfrom
capy/gsta-75-terminal-agent-bun-exe
Oct 25, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
capy/gsta-75-terminal-agent-bun-exe

Conversation

@garrytan

@garrytan garrytan commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Port of #3357 by @adammartin0087 (Adam Martin), with authorship kept. Addresses #2295; we'll ask the reporter to confirm before closing it.

Why

The sidebar terminal agent was spawned as a bare bun. With Bun from npm install -g bun, that resolves to npm's bun.cmd shim and runs as cmd.exe /c bun …: windowsHide hides only cmd.exe while bun.exe opens a visible console, and the recorded pid is cmd.exe's. The agent's startup check never matches, it exits after 2 s, and the watchdog respawns it every 60 s.

What changed

Before: spawnTerminalAgent passes a bare 'bun' (main source), and the new test can't import the shared lookup.
Before: spawnTerminalAgent passes a bare 'bun' (main source), and the new test can't import the shared lookup.

After: the spawn goes through resolveBunExecutable(), backed by the one shared findWindowsBunExe() lookup; 10 tests pass.
After: the spawn goes through resolveBunExecutable(), backed by the one shared findWindowsBunExe() lookup; 10 tests pass.

  • browse/src/terminal-agent-control.ts (799113c, contributor): spawnTerminalAgent spawns resolveBunExecutable(): on Windows the running bun.exe, then BUN_INSTALL\bin, each absolute PATH entry (and the node_modules\bun\bin\bun.exe next to an npm bun.cmd), then USERPROFILE\.bun\bin, else bun. macOS and Linux unchanged.
  • browse/src/bun-child-config.ts, browse/src/cookie-import-native.ts (791e173, ours, approved by GStack Minder): the lookup moves to findWindowsBunExe() in bun-child-config.ts, and the Windows native cookie-import worker uses it instead of its own copy, so it also finds an npm-global Bun. This changes the source hash of the native cookie-import inputs (NATIVE_CODE_INPUTS includes both files); the qualification list is empty today, so no receipt is invalidated.
  • browse/test/terminal-agent-bun-exe.test.ts: the contributor's cases plus three for the shared lookup.
  • 1430da3: CHANGELOG entry.
  • e6e3a43 (ours, approved by GStack Minder): browse/test/sidebar-tabs.test.ts pinned the old bare 'bun' spawn literal; the pin now expects resolveBunExecutable() in that slot, so it still fails if a bare bun returns.

Known red, same as main: browse/test/cookie-import-native.test.ts > "production Node Playwright worker > real synthetic Playwright pipe smoke uses no TCP and leaves no browser" fails on this machine with a missing cookie_read stage. Its normalized output is byte-identical on origin/main and this branch, so it is environmental, not caused by this PR.

Not verified here: real Windows behaviour. The contributor tested on Windows 11, and windows-free-tests runs the new unit tests.

Review (CREW rules 3 and 18): file-system probing only (existsSync on candidate paths); no egress, credential, dependency or CI-permission change, and no test weakened.

Approvals

Date Ask Words Covers Pending
2026-10-24 Fix this item in its named files, own PR, unstamped READY GStack Minder crew assignment (GSTA-75) this PR none
2026-10-24 Move the bun.exe lookup into browse/src/bun-child-config.ts GStack Minder: "Do it: option (a). Add the resolver to browse/src/bun-child-config.ts." 791e173 none
2026-10-24 Update the spawn pin in browse/test/sidebar-tabs.test.ts GStack Minder: "Do it: option (a). No other thread owns browse/test/sidebar-tabs.test.ts." e6e3a43 none
standing Merge through a train CREW rule 6 GStack Minder merges train slot

Evidence

  • Focused: focused browse tests 118 pass, 1 fail (the smoke above, identical on main); browse/test/terminal-agent-bun-exe.test.ts 10 pass (on main a module-load failure).
  • Cheap checks at this head: bun run typecheck 0 errors, typecheck:test no new diagnostics, spawnSync-timeout tripwire, module-size ratchet and bun-entry isolation 17 pass, gstack-pregate sealed clean, preflight pass.
  • Remote free-tier pregate (Ubicloud) at this head: 12061 tests, 0 failed; macOS and Windows obligations cleared by this head's CI runs. CI green at e6e3a43dd164 (46 passed, 0 failed). READY sent unstamped; screen --screen (narrow, 3 cases + 1 judge), run 40140044423.

Paid selection: browse-basic, browse-snapshot, diagram-triplet and the browse/SKILL.md judge; 14 browse and QA cases deferred to broad.

Co-authored-by: Adam Martin [email protected]

Open in Capy

adammartin0087 and others added 3 commits October 24, 2026 20:26
Under the Node polyfill a bare 'bun' resolved (via cross-spawn) to npm's
bun.cmd shim and ran as `cmd.exe /c bun run terminal-agent.ts`. windowsHide
only hid cmd.exe, and the detached cmd.exe had no console, so bun.exe
allocated a visible one that stole focus on every spawn. proc.pid was
cmd.exe's, so the agent's startup check (record.pid === process.pid) never
matched; it exited after 2s and the 60s watchdog respawned it (#2295).

resolveBunExecutable() finds the real bun.exe (own execPath under bun,
BUN_INSTALL, PATH, the npm-global node_modules layout, ~/.bun) and falls
back to 'bun'. POSIX is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the native cookie-import worker (#2295)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… port of #3357)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…le() (#3357)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

E2E Evals: ✅ PASS

[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 3/3 · behavior 0/0 · judge 1/1 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m34s · cost $0.17 known + 3 of 4 trial(s) cost unknown

3 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $.17 rule/judge cost | reconcile exit: 0

Profile: pr / mode pr; selected behaviors: 3, judges: 1. Deferred to scheduled/release coverage: 14 behaviors and 0 changed prompt files. Deferred checks did not run and receive no PR-pass credit.

Rule and judge shards
Shard Automated result Manual/unscored Executed Reused Status Cost
e2e-browse/skill-e2e-bws 2/2 0 2 0 ✅ $0.11
llm-judge/skill-llm-eval 1/1 0 1 0 ✅ $0.06
Fail-closed reconciliation
[test:paid] report: 1/1 slices, 3 planned shards, tier=gate, attempt 1
[test:paid] coverage: profile=pr mode=pr; selected E2E=3, judges=1
[test:paid] deferred: 14 broad behaviors, 0 changed prompts without quick live coverage; these are not PR passes
  slice 1  passed             17s  test/skill-llm-eval.test.ts
  slice 1  passed             29s  test/skill-e2e-bws.test.ts
  slice 1  passed             14s  test/skill-e2e-diagram.test.ts
[test:paid] collector final outcomes: 3 executed, 0 reused; 3 passed, 0 failed, 0 manual accepted (unscored; no score-cache credit) (3 attempt records from 2 collectors; every record counts)
[test:paid] deselected testcases, zero credit (28):
[test:paid]     27  outside the run's case selection
[test:paid]      1  periodic-tier case (this lane runs gate)
[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 3/3 · behavior 0/0 · judge 1/1 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m34s · cost $0.17 known + 3 of 4 trial(s) cost unknown
[test:paid] exercised-path map (shadow, non-blocking): 0 MAP_GAP line(s) over 2 executed case(s) with recorded commands
[test:paid] report: every planned shard accounted and passed

Sliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry.

Dispatched narrow screen (gstack-ship-queue ready --screen) of merge commit b76f0188c5e8d4c914d0bfe515a78dd7c62ea836.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title fix(browse): spawn the real bun.exe for the terminal agent on Windows (#2295, port of #3357) v1.91.193.0 fix(browse): spawn the real bun.exe for the terminal agent on Windows (#2295, port of #3357) Oct 25, 2026
@capy-ai
capy-ai Bot merged commit 1b29e5d into main Oct 25, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants