Merge origin/main into garrytan/tilde-fix-design

Resolves overlap between main #1025 (headed browser auto-shutdown fix) and
this wave's #994 (server persists across Bash calls) + our SIGTERM mode-gate
follow-up. Both touch the parent-PID watchdog and SIGTERM handlers.

Mechanical resolution only — test inversion follows in next commit.

CHANGELOG / VERSION:
- main shipped v0.18.1.0 with #1025 while this wave was open. Bumped this
  branch to v0.18.2.0 with its own entry on top, per CLAUDE.md branch-scoped
  CHANGELOG rules. Both entries preserved, contiguous version sequence.
- package.json synced to v0.18.2.0.

browse/src/server.ts (parent-PID watchdog):
- Combined main's outer env-var gate (BROWSE_HEADED=1 skips the watchdog
  entirely) with our inner mode check (when watchdog runs and parent dies,
  decision tree by mode: active picker > headed/tunnel > normal).
- Defense-in-depth: env var skips the setInterval cost, runtime mode check
  catches anything the env var missed.

browse/src/server.ts (SIGTERM/SIGINT handlers):
- Combined main's lambda wrap (avoids signal name being passed as exitCode
  → NaN → exit 1) with our mode-aware SIGTERM handler. Active picker check
  short-circuits regardless of mode.
- Wrapped SIGINT in a lambda too — main's #1025 fix applied to that handler,
  but our wave didn't have it. Now SIGINT exits with code 0 reliably.

Note: browse/test/watchdog.test.ts test 3 (added by main) currently FAILS
because main's "watchdog kills on parent death" expectation contradicts
post-#994 "server stays alive on parent death." Inverted in the next commit.
This commit is contained in:
Garry Tan
2026-04-17 14:20:34 +08:00
9 changed files with 265 additions and 19 deletions
+11 -1
View File
@@ -1,9 +1,19 @@
import { describe, test, expect, beforeEach, afterEach } from 'bun:test';
import { describe, test as _bunTest, expect, beforeEach, afterEach } from 'bun:test';
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
// Every test in this file shells out to gstack-config + gstack-relink (bash scripts
// invoking subprocess work). Under parallel bun test load, subprocess spawn contends
// with other suites and each test can drift ~200ms past the 5s default. Bump to 15s.
// Object.assign preserves test.only / test.skip / test.each / test.todo sub-APIs.
const test = Object.assign(
((name: any, fn: any, timeout?: number) =>
_bunTest(name, fn, timeout ?? 15_000)) as typeof _bunTest,
_bunTest,
);
const ROOT = path.resolve(import.meta.dir, '..');
const BIN = path.join(ROOT, 'bin');