Skip to content

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.

test(view): keep cockpit servers owned in foreground [C7,N26]

Corey Olson2dd1711c4faa
diff --git a/test/cockpit/fixture.js b/test/cockpit/fixture.js
index 19a7c05e..31c94f58 100644
--- a/test/cockpit/fixture.js
+++ b/test/cockpit/fixture.js
@@ -151,7 +151,7 @@ function fetchLive(url, init = {}) {
/** Start the real view and wait for a complete HTTP answer, rather than just its printed link. */
async function startView(box, { bin = BIN } = {}) {
- const child = spawn(process.execPath, [bin, 'view', '--no-open'], { cwd: box.dir, env: box.env });
+ const child = spawn(process.execPath, [bin, 'view', '--no-open'], { cwd: box.dir, env: { ...box.env, PULLBOARD_VIEW_FOREGROUND: '1' } });
const link = await new Promise((found, fail) => {
let out = '';
child.stdout.on('data', (chunk) => {
diff --git a/test/cockpit/fixture.test.js b/test/cockpit/fixture.test.js
index 7807d324..2d784724 100644
--- a/test/cockpit/fixture.test.js
+++ b/test/cockpit/fixture.test.js
@@ -5,6 +5,7 @@ import { createServer, request } from 'node:http';
import diagnosticsChannel from 'node:diagnostics_channel';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
import { test } from 'node:test';
import { addItem, closeBoard, openBoard } from '../../src/board.js';
import { exportBoard, importBoard } from '../../src/exchange.js';
@@ -24,6 +25,43 @@ test('the cockpit fixture inits its board without a model [N26]', () => {
assert.equal(join.model, 'Test Model');
});
+test('the cockpit helper starts its view in the foreground [C7,N26]', async t => {
+ const box = machine();
+ project(box, 'foreground-view');
+ delete box.env.PULLBOARD_VIEW_FOREGROUND;
+ const receipt = join(box.dir, 'view-processes.jsonl');
+ const observer = join(box.dir, 'observe-view.mjs');
+ // A preload observes the real spawned Node environment without replacing the CLI or server.
+ writeFileSync(observer, `import { appendFileSync } from 'node:fs';\nappendFileSync(${JSON.stringify(receipt)}, JSON.stringify({ pid: process.pid, marker: process.env.PULLBOARD_VIEW_FOREGROUND ?? null }) + '\\n', { mode: 0o600 });\n`);
+ box.env.NODE_OPTIONS = `${box.env.NODE_OPTIONS ?? ''} --import ${pathToFileURL(observer).href}`.trim();
+ /** Read only the PIDs and marker observed by this fixture's actual Node children. */
+ const observed = () => {
+ try { return readFileSync(receipt, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)); }
+ catch (error) { if (error.code === 'ENOENT') return []; throw error; }
+ };
+ /** Stop any owned child if a failed assertion interrupted the helper's normal cleanup. */
+ t.after(() => {
+ for (const { pid } of observed()) {
+ try { process.kill(pid, 'SIGKILL'); }
+ catch (error) { if (error.code !== 'ESRCH') throw error; }
+ }
+ });
+ const view = await startView(box);
+ let children;
+ try {
+ children = observed();
+ assert.equal(children.length, 1, 'the helper owns one foreground view process');
+ assert.equal(children[0].marker, '1', 'the actual spawned child receives the foreground marker');
+ assert.doesNotThrow(() => process.kill(children[0].pid, 0), 'the owned child stays alive while serving');
+ } finally {
+ await view.stop();
+ }
+ assert.throws(() => process.kill(children[0].pid, 0), error => error.code === 'ESRCH',
+ 'stopping the helper removes its actual view process');
+ await assert.rejects(fetchLive(view.link, { signal: AbortSignal.timeout(1_000) }),
+ error => error.cause?.code === 'ECONNREFUSED', 'stopping the helper also closes the owned listener');
+});
+
test('borrowed board presentation keeps parity, shows staged rows, and leaves the caller connection open [N26,H16]', () => {
const box = machine();
const p = project(box, 'projector');