mirror of https://github.com/garrytan/gstack.git
* feat: gate terminal-agent teardown on ServerConfig.ownsTerminalAgent Adds ownsTerminalAgent?: boolean to ServerConfig (default true). Wraps the three shutdown side effects (pkill -f terminal-agent\.ts + 2 safeUnlinkQuiet calls for terminal-port and terminal-internal-token) inside a single if (ownsTerminalAgent) block. Embedders (gbrowser phoenix overlay) pass false to keep their own PTY lifecycle intact across gstack's teardown. CLI start() call site passes ownsTerminalAgent: true explicitly; static-grep test in the new test file catches a refactor that drops it. Strict opt-out: only explicit false flips the gate (cfg.ownsTerminalAgent === false ? false : true). Defends against JS callers passing truthy non-bool values. Adds __resetShuttingDown test-only export mirroring __resetRegistry. The module-scoped isShuttingDown latch otherwise silently no-ops a second shutdown() in the same process. Drops dead try/catch wrappers around safeUnlinkQuiet inside the new gate — safeUnlinkQuiet already swallows all errors internally. New test file (4 cases) stubs both process.exit AND child_process.spawnSync so a real pkill -f terminal-agent\.ts never fires on the developer machine. beforeAll/afterAll save and restore real-daemon file contents in the state dir so the test cannot clobber a running gstack session. * chore: file followup TODOs (identity-based pkill, cfg.config composition gap, ownership-object trigger) Three P3 followups surfaced by /autoplan + /plan-eng-review while reviewing the ownsTerminalAgent gate: - Identity-based terminal-agent kill: pkill -f terminal-agent\.ts is a latent CLI footgun (regex match kills sibling gstack sessions, editor processes, etc.). Replace with PID-tracked process.kill at both cli.ts:1047 and server.ts:1281. - shutdown() reads module-level config, not cfg.config (pre-existing composition gap). Same gap applies to cleanSingletonLocks(resolveChromiumProfile()) at server.ts:1298 (should be cfg.chromiumProfile). Both are followup work for the embedder-composition story. - 4th caller-owned teardown gate trigger: today ServerConfig has 3 (xvfb?, proxyBridge?, ownsTerminalAgent). If a 4th appears, collapse to cfg.callerOwns?: Set<...> ownership object. * chore: bump version and changelog (v1.42.1.0) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: note ServerConfig.ownsTerminalAgent in CLAUDE.md sidebar block Adds a one-paragraph reference for the v1.42.1.0 embedder teardown gate right after the Sidebar architecture block. Covers default semantics, when embedders must pass `false`, polarity inversion vs xvfb?/proxyBridge?, and the static-grep CI test that pins the CLI call site. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| activity.test.ts | ||
| adversarial-security.test.ts | ||
| batch.test.ts | ||
| bridge-chromium-e2e.test.ts | ||
| browse-client.test.ts | ||
| browser-manager-custom-chromium.test.ts | ||
| browser-manager-unit.test.ts | ||
| browser-skill-commands.test.ts | ||
| browser-skill-write.test.ts | ||
| browser-skills-e2e.test.ts | ||
| browser-skills-storage.test.ts | ||
| build-command-response.test.ts | ||
| build.test.ts | ||
| bun-polyfill.test.ts | ||
| cdp-allowlist.test.ts | ||
| cdp-e2e.test.ts | ||
| cdp-mutex.test.ts | ||
| claude-bin.test.ts | ||
| commands.test.ts | ||
| compare-board.test.ts | ||
| config.test.ts | ||
| content-security.test.ts | ||
| cookie-import-browser.test.ts | ||
| cookie-picker-routes.test.ts | ||
| daemon-mismatch-refuse.test.ts | ||
| data-platform.test.ts | ||
| domain-skills-e2e.test.ts | ||
| domain-skills-storage.test.ts | ||
| dual-listener.test.ts | ||
| dx-polish.test.ts | ||
| error-handling.test.ts | ||
| file-drop.test.ts | ||
| file-permissions.test.ts | ||
| find-browse.test.ts | ||
| findport.test.ts | ||
| from-file-path-validation.test.ts | ||
| gstack-config.test.ts | ||
| gstack-update-check.test.ts | ||
| handoff.test.ts | ||
| learnings-injection.test.ts | ||
| pair-agent-e2e.test.ts | ||
| pair-agent-tunnel-eval.test.ts | ||
| path-validation.test.ts | ||
| pdf-flags.test.ts | ||
| platform.test.ts | ||
| proxy-config.test.ts | ||
| proxy-redact.test.ts | ||
| pty-inject-scan.test.ts | ||
| regression-pr1169-pdf-from-file-invalid-json.test.ts | ||
| sanitize.test.ts | ||
| screenshot-size-guard.test.ts | ||
| security-adversarial-fixes.test.ts | ||
| security-adversarial.test.ts | ||
| security-audit-r2.test.ts | ||
| security-bench-ensemble-live.test.ts | ||
| security-bench-ensemble.test.ts | ||
| security-bench.test.ts | ||
| security-bunnative.test.ts | ||
| security-classifier-download-cleanup.test.ts | ||
| security-classifier-tdz.test.ts | ||
| security-classifier.test.ts | ||
| security-integration.test.ts | ||
| security-live-playwright.test.ts | ||
| security-review-flow.test.ts | ||
| security-sidecar-client.test.ts | ||
| security-sidepanel-dom.test.ts | ||
| security-source-contracts.test.ts | ||
| security.test.ts | ||
| server-auth.test.ts | ||
| server-embedder-terminal-port.test.ts | ||
| server-factory.test.ts | ||
| server-flush-trackers.test.ts | ||
| server-no-import-side-effects.test.ts | ||
| server-proxy-fail-fast.test.ts | ||
| server-sanitize-surrogates.test.ts | ||
| server-tmp-state-path.test.ts | ||
| sidebar-integration.test.ts | ||
| sidebar-security.test.ts | ||
| sidebar-tabs.test.ts | ||
| sidebar-unit.test.ts | ||
| sidebar-ux.test.ts | ||
| skill-token.test.ts | ||
| snapshot.test.ts | ||
| socks-bridge.test.ts | ||
| sse-session-cookie.test.ts | ||
| state-ttl.test.ts | ||
| stealth-extended.test.ts | ||
| stealth-webdriver.test.ts | ||
| tab-each.test.ts | ||
| tab-isolation.test.ts | ||
| tab-session-frame-detach.test.ts | ||
| telemetry.test.ts | ||
| terminal-agent-integration.test.ts | ||
| terminal-agent.test.ts | ||
| test-server.ts | ||
| token-registry.test.ts | ||
| tunnel-gate-unit.test.ts | ||
| url-validation.test.ts | ||
| watch.test.ts | ||
| watchdog.test.ts | ||
| welcome-page.test.ts | ||
| xvfb.test.ts | ||