Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(view): return unattended view link [N26,N32]
Corey Olson9bc999a508eb
diff --git a/src/cli.js b/src/cli.jsindex 10b0fda2..5c2c8bc2 100644--- a/src/cli.js+++ b/src/cli.js@@ -8,7 +8,7 @@ import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renamimport { loadavg } from 'node:os';import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';import { performance } from 'node:perf_hooks';-import { pathToFileURL } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';import { parseArgs } from 'node:util';import * as store from './board.js';import { CONFIG_FILE, COORDINATOR, DOCTRINE_FILE, LEGACY_DOCTRINE_FILE, loadConfig } from './config.js';@@ -66,6 +66,7 @@ import { milestoneRoadmap } from './roadmap.js';import { listResources } from './resources.js';import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';import { exportView, serveView } from './serve.js';+import { forgetView, rememberView, runningView } from './view-session.js';import { serveApi } from './api.js';import { doctorProblems, doctrineProblems } from './doctor.js';import { staleFrozenItems, staleItemFinding } from './approved-rows.js';@@ -1061,10 +1062,10 @@ function viewSetupComplete(ctx, board) {}/** Atomically record a successful real view bind, scoped to this board's current setup. */-function recordViewBind(ctx, board) {+function recordViewBind(ctx, board, boundAt) {const file = join(ctx.info.commonDir, 'pullboard', 'view-bind.json');const temporary = file + '.' + randomUUID() + '.tmp';- const receipt = { type: 'pullboard.view.bound', version: 1, ...setupIdentity(board), boundAt: new Date().toISOString() };+ const receipt = { type: 'pullboard.view.bound', version: 1, ...setupIdentity(board), boundAt };mkdirSync(dirname(file), { recursive: true });writeFileSync(temporary, JSON.stringify(receipt) + '\n', { mode: 0o600 });renameSync(temporary, file);@@ -1258,33 +1259,61 @@ async function viewHere(io, values) {io.say(`wrote snapshot ${exported.path}`);return 0;}+ const port = values.port === undefined ? 0 : Number(values.port);+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Refused('USAGE', '--port is a number from 0 to 65535; 0 picks a free one');try {const info = repoInfo(io.cwd);if (info.isMain && existsSync(join(info.root, CONFIG_FILE))) await registerProjectAndLink(info.root, new Date(), loadConfig(info.root), io);} catch (error) {if (!(error instanceof Refused)) throw error;}- const port = values.port === undefined ? 0 : Number(values.port);- if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Refused('USAGE', '--port is a number from 0 to 65535; 0 picks a free one');- const view = await serveView({ port, isMain: codeIsFromMain() });- // Only an actual bind writes this typed receipt; ordinary shouts cannot complete setup.+ const internalForeground = process.env.PULLBOARD_VIEW_BACKGROUND_CHILD === '1'+ || process.env.PULLBOARD_VIEW_FOREGROUND === '1';+ if (!internalForeground) {+ const existing = port ? await runningView(port) : null;+ if (existing) {+ reportView(io, { ...existing, reused: true });+ return 0;+ }+ if (process.env.AI_AGENT !== undefined || !io.physicalStdoutIsTTY) return await launchBackgroundView(io, port);+ }+ let view;try {+ view = await serveView({ port, isMain: codeIsFromMain() });+ const boundAt = new Date().toISOString();+ const closeServer = view.close;+ view = {+ ...view,+ pid: process.pid,+ boundAt,+ close: async () => { forgetView(view.port); await closeServer(); },+ };+ try {+ rememberView({ port: view.port, secret: new URL(view.url).searchParams.get('k'), pid: process.pid, boundAt }, { rememberPort: port === 0 });+ } catch (error) {+ throw new Refused('VIEW_STATE', `could not save the private view session: ${error.message}`);+ }+ // Only a successful fresh bind writes this board's typed setup receipt.let info;try { info = repoInfo(io.cwd); }catch (error) { if (!(error instanceof Refused)) throw error; }if (info && existsSync(join(info.root, CONFIG_FILE))) {const ctx = context(io);- withBoard(ctx, board => recordViewBind(ctx, board));+ withBoard(ctx, board => recordViewBind(ctx, board, boundAt));}} catch (error) {- await view.close();+ if (view) await view.close();+ if (process.env.PULLBOARD_VIEW_BACKGROUND_CHILD === '1' && process.send) {+ process.send({ type: 'startup-error', code: error.code ?? 'VIEW_START', message: error.message });+ }throw error;}- io.result?.({ url: view.url, port: view.port });- io.say(`Pullboard view: ${view.url}`);- io.say('Only this machine can reach it, and only with that link. Ctrl-C stops it.');+ reportView(io, { ...view, reused: false });+ if (process.env.PULLBOARD_VIEW_BACKGROUND_CHILD === '1' && process.send) {+ process.send({ type: 'ready', url: view.url, port: view.port, pid: process.pid, boundAt: view.boundAt });+ }io.flush?.(0);- if (!values['no-open']) {+ if (!values['no-open'] && process.env.PULLBOARD_VIEW_BACKGROUND_CHILD !== '1') {const opener = process.platform === 'darwin' ? ['open', [view.url]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', view.url]] : ['xdg-open', [view.url]];spawn(opener[0], opener[1], { detached: true, stdio: 'ignore' }).on('error', () => {}).unref();}@@ -1296,6 +1325,61 @@ async function viewHere(io, values) {return 0;}+/** Print a live or reused view link and the exact stop action for its owning process. */+function reportView(io, view) {+ io.result?.({ url: view.url, port: view.port, pid: view.pid, boundAt: view.boundAt, reused: view.reused });+ io.say(`Pullboard view: ${view.url}`);+ io.say(`Only this machine can reach it, and only with that link. To stop it: ${process.platform === 'win32' ? `taskkill /PID ${view.pid} /T` : `kill ${view.pid}`}`);+}++/** Start the view in a detached CLI child, forwarding only its bound address over IPC. */+async function launchBackgroundView(io, port) {+ const args = [fileURLToPath(new URL('../bin/pullboard.js', import.meta.url)), 'view', '--no-open'];+ if (port) args.push('--port', String(port));+ const child = spawn(process.execPath, args, {+ cwd: io.cwd,+ env: { ...process.env, PULLBOARD_VIEW_BACKGROUND_CHILD: '1' },+ detached: true,+ stdio: ['ignore', 'ignore', 'pipe', 'ipc'],+ });+ let stderr = '';+ child.stderr.setEncoding('utf8').on('data', (part) => { stderr += part; });+ const startup = new Promise((resolveStartup, rejectStartup) => {+ let settled = false;+ const finish = (error, result) => {+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ error ? rejectStartup(error) : resolveStartup(result);+ };+ const timer = setTimeout(() => finish(new Refused('VIEW_START', 'the view did not bind in time; run pullboard view in the foreground for details')),+ 35_000); // budget: the 30s registry lock ceiling plus 5s for local bind and IPC delivery.+ child.on('message', (message) => {+ if (message?.type === 'ready') finish(null, message);+ else if (message?.type === 'startup-error') {+ const prefix = `[${message.code}] `;+ finish(new Refused(message.code, message.message.startsWith(prefix) ? message.message.slice(prefix.length) : message.message));+ }+ });+ child.once('error', (error) => finish(new Refused('VIEW_START', `could not start the view: ${error.message}`)));+ child.once('exit', (code, signal) => {+ finish(new Refused('VIEW_START', `the view stopped before binding (exit ${code ?? signal ?? 'unknown'}): ${stderr.trim() || 'no startup details'}`));+ });+ });+ try {+ const view = await startup;+ child.stderr.destroy();+ child.unref();+ child.disconnect();+ reportView(io, { ...view, reused: false });+ io.flush?.(0);+ return 0;+ } catch (error) {+ child.kill('SIGTERM');+ throw error;+ }+}+/** Serve API v1 until a shutdown signal, printing its address before waiting (A2). */async function serveHere(io, values) {traceServeStartup('serve-context-start');diff --git a/src/json.js b/src/json.jsindex bf96d6b8..8a1754d8 100644--- a/src/json.js+++ b/src/json.js@@ -151,6 +151,7 @@ export function commandOutput(argv, streams) {};return {...streams,+ physicalStdoutIsTTY: Boolean(streams.stdout.isTTY),stdout: { get isTTY() { return enabled ? false : streams.stdout.isTTY; }, write: (text) => streams.stdout.write(text) },say: (line) => emit(streams.stdout, messages, line),err: (line) => emit(streams.stderr, diagnostics, line),diff --git a/src/view-session.js b/src/view-session.jsnew file mode 100644index 00000000..8013562d--- /dev/null+++ b/src/view-session.js@@ -0,0 +1,78 @@+/** Private runtime records that let an unattended CLI hand off its live view link. */+import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';+import { dirname, join } from 'node:path';+import { LOOPBACK, lastPort } from './serve.js';+import { registryFile } from './projects.js';++/** The per-port record keeps the secret out of CLI output and mode 0600 on disk. */+function sessionFile(port) {+ return join(dirname(registryFile()), `view-${port}.json`);+}++/** Read a valid persisted session record, or return null when none is usable. */+function readSession(port) {+ try {+ const record = JSON.parse(readFileSync(sessionFile(port), 'utf8'));+ if (record.port !== port || !Number.isInteger(record.pid) || record.pid < 1+ || typeof record.secret !== 'string' || typeof record.boundAt !== 'string') return null;+ return record;+ } catch {+ return null;+ }+}++/** Atomically store a private session record and update the default port when auto-selected. */+export function rememberView(view, { rememberPort = false } = {}) {+ const file = sessionFile(view.port);+ const temporary = `${file}.${process.pid}.tmp`;+ const pointer = join(dirname(registryFile()), 'view.json');+ const pointerTemporary = `${pointer}.${process.pid}.tmp`;+ try {+ mkdirSync(dirname(file), { recursive: true });+ writeFileSync(temporary, `${JSON.stringify(view)}\n`, { mode: 0o600 });+ chmodSync(temporary, 0o600);+ renameSync(temporary, file);+ if (rememberPort) {+ writeFileSync(pointerTemporary, `${JSON.stringify({ port: view.port })}\n`, { mode: 0o600 });+ chmodSync(pointerTemporary, 0o600);+ renameSync(pointerTemporary, pointer);+ }+ } catch (error) {+ try { rmSync(temporary, { force: true }); } catch { /* Preserve the original failure. */ }+ try { rmSync(pointerTemporary, { force: true }); } catch { /* Preserve the original failure. */ }+ try { rmSync(file, { force: true }); } catch { /* Preserve the original failure. */ }+ throw error;+ }+}++/** Remove the record only when it still belongs to this process and port. */+export function forgetView(port) {+ try {+ if (readSession(port)?.pid === process.pid) rmSync(sessionFile(port), { force: true });+ } catch {+ // A stale record is harmless because reuse also checks the live process and HTTP response.+ }+}++/** Find and authenticate an existing listener for a named port or the remembered default. */+export async function runningView(port = 0) {+ const candidatePort = port || lastPort();+ const view = candidatePort ? readSession(candidatePort) : null;+ if (!view) return null;+ try {+ process.kill(view.pid, 0);+ const response = await fetch(`http://${LOOPBACK}:${view.port}/api/v1/boards?k=${encodeURIComponent(view.secret)}`, {+ signal: AbortSignal.timeout(1_000),+ redirect: 'manual',+ });+ if (!response.ok) {+ await response.body?.cancel();+ return null;+ }+ const listing = await response.json();+ if (!Array.isArray(listing.boards) || !Array.isArray(listing.warnings)) return null;+ return { url: `http://${LOOPBACK}:${view.port}/?k=${view.secret}`, port: view.port, pid: view.pid, boundAt: view.boundAt };+ } catch {+ return null;+ }+}diff --git a/test/api.test.js b/test/api.test.jsindex 265df43f..0c398433 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -833,7 +833,9 @@ test('[A1] long-running servers flush one JSON document before shutdown', asynct.after(() => rmSync(box.dir, { recursive: true, force: true }));const args = [BIN, command, ...(command === 'view' ? ['--no-open'] : []), '--port', '0', '--json'];const startedAt = performance.now();- const child = spawn(process.execPath, args, { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });+ const child = spawn(process.execPath, args, { cwd: box.repo,+ env: command === 'view' ? { ...box.env, PULLBOARD_VIEW_FOREGROUND: '1' } : box.env,+ stdio: ['ignore', 'pipe', 'pipe'] });let stdout = '';let stderr = '';child.stdout.setEncoding('utf8');diff --git a/test/e2e-helpers.js b/test/e2e-helpers.jsindex cf9e5fc0..e4d429b7 100644--- a/test/e2e-helpers.js+++ b/test/e2e-helpers.js@@ -170,7 +170,7 @@ const LIGHT_BRIEF = 'Files:\n- web/page.js\nChange:\n- copy the header from theasync function startView(box, cwd) {const startedAt = performance.now();- const child = spawn(process.execPath, [BIN, 'view', '--no-open'], { cwd, env: box.env });+ const child = spawn(process.execPath, [BIN, 'view', '--no-open'], { cwd, env: { ...box.env, PULLBOARD_VIEW_FOREGROUND: '1' } });const link = await new Promise((found, fail) => {let out = '';let stderr = '';diff --git a/test/e2e-view.test.js b/test/e2e-view.test.jsindex 4f181fc7..6e4413d8 100644--- a/test/e2e-view.test.js+++ b/test/e2e-view.test.js@@ -35,6 +35,115 @@ const {startView, LIGHT_BRIEF,} = e2e;+/** Stop the exact detached view server returned by an isolated fixture invocation. */+function stopOwnedView(pid, signal = 'SIGTERM') {+ try { process.kill(pid, signal); }+ catch (error) { if (error.code !== 'ESRCH') throw error; }+}++/** Wait until the owned listener has closed, treating only a refused socket as completion. */+async function waitForViewStopped(url) {+ const deadline = Date.now() + 5_000; // budget: hang ceiling for observing graceful SIGTERM cleanup.+ while (Date.now() < deadline) {+ try {+ const response = await fetchFresh(url, { signal: AbortSignal.timeout(500) });+ if (!response.ok) throw new Error('the view listener remained open after its owner stopped');+ } catch (error) {+ if (error.cause?.code === 'ECONNREFUSED') return;+ if (error.message.includes('listener remained open')) throw error;+ }+ await new Promise((resolvePromise) => setTimeout(resolvePromise, 25));+ }+ throw new Error('the owned view listener did not close after SIGTERM');+}++test("an agent's pullboard view prints its link and returns [N26,N32]", async () => {+ const box = project();+ const env = { ...box.env };+ delete env.AI_AGENT;+ const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];+ const owned = [];+ try {+ const started = execFileSync(process.execPath, args, { cwd: box.repo, env, encoding: 'utf8', timeout: 40_000 });+ const first = JSON.parse(started);+ owned.push({ pid: first.pid, port: first.port, url: first.url });+ assert.equal(first.reused, false, 'the first unattended start owns the newly bound listener');+ assert.ok(Number.isInteger(first.pid), 'the successful response identifies its owning process');+ assert.ok(Number.isFinite(Date.parse(first.boundAt)), 'the response reports the actual bind time');+ const firstUrl = new URL(first.url);+ assert.equal(firstUrl.pathname, '/');+ const stateFile = join(env.PULLBOARD_HOME, `view-${first.port}.json`);+ const state = JSON.parse(readFileSync(stateFile, 'utf8'));+ assert.equal((statSync(stateFile).mode & 0o077) === 0, true, 'the persisted session secret is private to this user');+ assert.equal(state.pid === first.pid && state.boundAt === first.boundAt, true, 'the runtime record matches the successful bind receipt');+ assert.equal(state.secret === firstUrl.searchParams.get('k'), true, 'the private record authenticates the returned link');+ const page = await fetchFresh(firstUrl);+ assert.equal(page.status, 200, 'the returned link fetches the live view page');++ const secondResult = execFileSync(process.execPath, [BIN, 'view', '--no-open', '--port', String(first.port), '--json'], {+ cwd: box.repo, env, encoding: 'utf8', timeout: 40_000,+ });+ const second = JSON.parse(secondResult);+ assert.equal(second.reused, true, 'a second start reuses the authenticated listener');+ assert.equal(second.url === first.url, true, 'the second start returns the same private link');+ assert.equal(second.pid === first.pid, true, 'the second start identifies the same owner');+ assert.equal(second.boundAt === first.boundAt, true, 'reusing a server preserves its real bind time');++ const agentEnv = { ...env, AI_AGENT: '1' };+ const agentStarted = execFileSync(process.execPath, [BIN, 'view', '--no-open', '--port', '0', '--json'], {+ cwd: box.repo, env: agentEnv, encoding: 'utf8', timeout: 40_000,+ });+ const agent = JSON.parse(agentStarted);+ owned.push({ pid: agent.pid, port: agent.port, url: agent.url });+ assert.equal(agent.reused, false, 'an explicit agent start also creates and returns its owned view');+ assert.equal((await fetchFresh(agent.url)).status, 200, 'the explicit agent link fetches its live page');+ } finally {+ try {+ const port = JSON.parse(readFileSync(join(env.PULLBOARD_HOME, 'view.json'), 'utf8')).port;+ const state = JSON.parse(readFileSync(join(env.PULLBOARD_HOME, `view-${port}.json`), 'utf8'));+ if (!owned.some((view) => view.pid === state.pid)) owned.push({ pid: state.pid, url: `http://127.0.0.1:${state.port}/?k=${encodeURIComponent(state.secret)}` });+ } catch { /* No server record means the fixture never bound. */ }+ let cleanupError;+ for (const view of owned.reverse()) {+ if (!Number.isInteger(view.pid)) continue;+ try {+ stopOwnedView(view.pid);+ await waitForViewStopped(view.url);+ }+ catch (error) {+ cleanupError ??= error;+ try {+ stopOwnedView(view.pid, 'SIGKILL');+ await waitForViewStopped(view.url);+ } catch (forceError) { cleanupError ??= forceError; }+ }+ }+ if (cleanupError) throw cleanupError;+ }+});++test('a person running view with JSON in a terminal keeps the server in that terminal [N26,N32]', () => {+ const box = sandbox();+ box.env.PULLBOARD_MODEL ??= 'Fixture Model';+ project(CONFIG.gate, box);+ const helper = resolve(import.meta.dirname, 'fixtures/view-person-pty.py');+ const result = JSON.parse(execFileSync('python3', [helper], {+ cwd: box.repo,+ env: box.env,+ input: JSON.stringify({ repo: box.repo, node: process.execPath, bin: BIN, env: box.env }),+ encoding: 'utf8',+ timeout: 45_000,+ }));+ assert.equal(result.actualStdoutTTY, true);+ assert.equal(result.aiAgent, false);+ assert.equal(result.jsonMode, true);+ assert.equal(result.pageStatus, 200);+ assert.equal(result.parentRemainedForeground, true);+ assert.equal(result.serverPidMatchesParent, true);+ assert.equal(result.processesGone, true);+ assert.equal(result.listenerClosed, true);+});+test('view serves every project on this machine, on loopback, behind its secret and its own Host [N26, I8]', async () => {const box = project();box.run(box.repo, 'add', 'web', 'Page', '--specs', 'G1', '--criterion', 'renders');diff --git a/test/fixtures/view-person-pty.py b/test/fixtures/view-person-pty.pynew file mode 100644index 00000000..ece5ac65--- /dev/null+++ b/test/fixtures/view-person-pty.py@@ -0,0 +1,140 @@+"""Run one person-mode pullboard view command with real terminal file descriptors."""+import json+import os+import pty+import select+import signal+import socket+import subprocess+import sys+import time+import urllib.request+++def stopped(port):+ deadline = time.monotonic() + 6+ while time.monotonic() < deadline:+ try:+ with socket.create_connection(("127.0.0.1", port), timeout=0.25):+ pass+ except ConnectionRefusedError:+ return True+ except OSError:+ time.sleep(0.025)+ else:+ time.sleep(0.025)+ return False+++def main():+ config = json.load(sys.stdin)+ env = config["env"]+ for key in ("AI_AGENT", "PULLBOARD_VIEW_FOREGROUND", "PULLBOARD_VIEW_BACKGROUND_CHILD"):+ env.pop(key, None)+ master, slave = pty.openpty()+ actual_stdout_tty = os.isatty(slave)+ assert actual_stdout_tty, "fixture did not create a real terminal"+ child = subprocess.Popen(+ [config["node"], config["bin"], "view", "--no-open", "--port", "0", "--json"],+ cwd=config["repo"], env=env, stdin=slave, stdout=slave, stderr=slave, close_fds=True,+ )+ os.close(slave)+ document = None+ buffer = b""+ page_status = None+ cleanup_ok = False+ processes_gone = False+ stayed_foreground = False+ pid_matches = False+ parent_pid = child.pid+ server_pid = None+ try:+ deadline = time.monotonic() + 25+ while time.monotonic() < deadline and document is None:+ if not select.select([master], [], [], 0.2)[0]:+ continue+ try:+ buffer += os.read(master, 65536)+ except OSError:+ break+ text = buffer.decode(errors="replace")+ for start, char in enumerate(text):+ if char != "{":+ continue+ try:+ candidate, _ = json.JSONDecoder().raw_decode(text[start:])+ except ValueError:+ continue+ if isinstance(candidate, dict) and "url" in candidate:+ document = candidate+ break+ assert document is not None, "person PTY command did not print its JSON view link"+ server_pid = document.get("pid")+ with urllib.request.urlopen(document["url"], timeout=5) as response:+ page_status = response.status+ assert page_status == 200, "the PTY view link did not fetch the page"+ stayed_foreground = child.poll() is None+ pid_matches = server_pid == child.pid+ assert stayed_foreground, "person PTY command returned instead of remaining foreground"+ assert pid_matches, "person PTY server did not stay in its foreground process"+ returncode = None+ finally:+ if not document:+ try:+ pointer = os.path.join(env["PULLBOARD_HOME"], "view.json")+ with open(pointer, encoding="utf-8") as stream:+ state_pointer = json.load(stream)+ state_path = os.path.join(env["PULLBOARD_HOME"], f"view-{state_pointer['port']}.json")+ with open(state_path, encoding="utf-8") as stream:+ state = json.load(stream)+ document = {"pid": state["pid"], "port": state["port"]}+ except (FileNotFoundError, KeyError, ValueError, json.JSONDecodeError):+ document = None+ targets = {child.pid}+ if isinstance(document, dict) and isinstance(document.get("pid"), int):+ targets.add(document["pid"])+ for pid in targets:+ try:+ os.kill(pid, signal.SIGTERM)+ except ProcessLookupError:+ pass+ try:+ returncode = child.wait(timeout=8)+ except subprocess.TimeoutExpired:+ child.kill()+ returncode = child.wait(timeout=8)+ if document and isinstance(document.get("port"), int):+ cleanup_ok = stopped(document["port"])+ else:+ cleanup_ok = True+ processes_gone = True+ for pid in targets:+ deadline = time.monotonic() + 5+ while time.monotonic() < deadline:+ try:+ os.kill(pid, 0)+ except ProcessLookupError:+ break+ time.sleep(0.025)+ else:+ processes_gone = False+ os.close(master)+ assert returncode is not None, "person PTY process did not exit during cleanup"+ assert processes_gone, "a PTY view process remained after cleanup"+ assert cleanup_ok, "person PTY listener remained open after cleanup"+ print(json.dumps({+ "actualStdoutTTY": actual_stdout_tty, "aiAgent": False, "jsonMode": True,+ "pageStatus": page_status, "parentRemainedForeground": stayed_foreground,+ "serverPidMatchesParent": pid_matches, "parentPid": parent_pid,+ "serverPid": server_pid, "processesGone": processes_gone, "listenerClosed": cleanup_ok,+ }))+++if __name__ == "__main__":+ try:+ main()+ except Exception as error:+ # Never echo the captured terminal buffer or URL: it contains the session key.+ detail = error.args[0] if isinstance(error, AssertionError) and error.args else "unexpected helper failure"+ print(f"PTY regression failed: {type(error).__name__}: {detail}", file=sys.stderr)+ raise SystemExit(1)diff --git a/test/http-fixture.test.js b/test/http-fixture.test.jsindex a4dfc1da..6d6379ed 100644--- a/test/http-fixture.test.js+++ b/test/http-fixture.test.js@@ -41,7 +41,7 @@ async function startView(t, box) {const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];const startedAt = performance.now();const child = spawn(process.execPath, args, {- cwd: box.root, env: box.env, stdio: ['ignore', 'pipe', 'pipe'],+ cwd: box.root, env: { ...box.env, PULLBOARD_VIEW_FOREGROUND: '1' }, stdio: ['ignore', 'pipe', 'pipe'],});const closed = once(child, 'close');t.after(async () => {diff --git a/test/person.test.js b/test/person.test.jsindex c2be21e6..6b6b16f5 100644--- a/test/person.test.js+++ b/test/person.test.js@@ -167,7 +167,7 @@ async function startView(t, box, extraEnv = {}) {const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];const startedAt = performance.now();const child = spawn(process.execPath, args, {- cwd: box.repo, env: { ...box.env, ...MARKERS, ...extraEnv }, stdio: ['ignore', 'pipe', 'pipe'],+ cwd: box.repo, env: { ...box.env, ...MARKERS, ...extraEnv, PULLBOARD_VIEW_FOREGROUND: '1' }, stdio: ['ignore', 'pipe', 'pipe'],});let output = '';let diagnostics = '';diff --git a/test/row-decisions.test.js b/test/row-decisions.test.jsindex 75be1fab..a916ffb1 100644--- a/test/row-decisions.test.js+++ b/test/row-decisions.test.js@@ -165,7 +165,7 @@ function sourceRow(box, file, id) {/** Start the private real view with clean person credentials and expose authenticated requests. */async function startView(t, box, extraEnv = {}) {const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];- const env = { ...personEnvironment(box.env), ...extraEnv, CODEX_SHELL: 'private-agent-view-host' };+ const env = { ...personEnvironment(box.env), ...extraEnv, CODEX_SHELL: 'private-agent-view-host', PULLBOARD_VIEW_FOREGROUND: '1' };const startedAt = performance.now();const child = spawn(process.execPath, args, {cwd: box.root, env, stdio: ['ignore', 'pipe', 'pipe'],