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.

fix(init): name app.pullboard.dev, never the bare view address [I1,N26]

Corey Olsonbd4d21cfe0f4
diff --git a/src/background-view.js b/src/background-view.js
index c4860714..5923b33d 100644
--- a/src/background-view.js
+++ b/src/background-view.js
@@ -21,7 +21,10 @@ import { fileURLToPath } from 'node:url';
import { fetchLocal } from './local-fetch.js';
import { Refused } from './refused.js';
import { registryFile } from './projects.js';
-import { LOOPBACK } from './serve.js';
+import {
+ HOSTED_ORIGIN,
+ LOOPBACK,
+} from './serve.js';
import { defaultViewPort } from './view-port.js';
import {
portHolder,
@@ -189,18 +192,18 @@ export async function keepViewRunning(env = process.env) {
/**
* The one line init and resume print about the background view, or null when there is nothing
- * to say. Every line that names a running view says how to stop it.
+ * to say. Every line that names a running view says how to stop it, and names app.pullboard.dev
+ * rather than the bare view address, which opens only to a refusal without the key.
*
* @param {Awaited<ReturnType<typeof keepViewRunning>>} outcome
* @returns {string | null}
*/
export function backgroundViewLine(outcome) {
- const where = `http://${LOOPBACK}:${outcome.port}`;
const off = `turn this off with "view": { "background": false } in ${machineSettingsFile()}`;
if (outcome.state === 'started') {
- return `Pullboard view is running in the background at ${where}, so pullboard.dev finds this computer's boards (log: ${outcome.log}). To stop it: ${stopCommand(outcome.pid)}; ${off}`;
+ return `Pullboard view is running in the background, so ${HOSTED_ORIGIN} finds this computer's boards (log: ${outcome.log}). To stop it: ${stopCommand(outcome.pid)}; ${off}`;
}
- if (outcome.state === 'running') return `Pullboard view is running at ${where}, so pullboard.dev finds this computer's boards. To stop it: ${stopCommand(outcome.pid)}`;
+ if (outcome.state === 'running') return `Pullboard view is running, so ${HOSTED_ORIGIN} finds this computer's boards. To stop it: ${stopCommand(outcome.pid)}`;
if (outcome.state === 'busy') {
const { holder } = outcome;
return `Port ${outcome.port} is in use${holder ? ` by ${holder.name} (pid ${holder.pid})` : ''}, so the background view did not start, and pullboard.dev looks for your view on that port: stop ${holder ? `it with ${stopCommand(holder.pid)}` : 'the program there'}, then run pullboard resume`;
diff --git a/src/init-finish.js b/src/init-finish.js
index 0cb66ba6..5b7e3ab7 100644
--- a/src/init-finish.js
+++ b/src/init-finish.js
@@ -42,6 +42,7 @@ import {
relayOfferAtInit,
} from './init.js';
import { Refused } from './refused.js';
+import { HOSTED_ORIGIN } from './serve.js';
export const SETUP_COMMIT_QUESTION = 'Commit Pullboard setup now? [Y/n] ';
export const SETUP_COMMIT_LATER = "To commit Pullboard's files: pullboard init --yes";
@@ -55,9 +56,12 @@ export function initNextLine(agentSession, { verbose = false } = {}) {
: 'Next: ask your agent to run pullboard resume to finish setup.';
}
-/** Describe the view without suggesting process termination, including when its port belongs to another program. */
+/**
+ * Describe the view without suggesting process termination, including when its port belongs to another program.
+ * A running view is named by app.pullboard.dev, never its bare address, which opens only to a refusal without the key.
+ */
export function initViewLine(view, { verbose = false } = {}) {
- if (['started', 'running'].includes(view.state)) return `Pullboard view is running at http://127.0.0.1:${view.port}.${verbose && view.log ? ` Log: ${view.log}` : ''}`;
+ if (['started', 'running'].includes(view.state)) return `Pullboard view is running; open ${HOSTED_ORIGIN} to see your board.${verbose && view.log ? ` Log: ${view.log}` : ''}`;
if (view.state === 'busy') return `Port ${view.port} is in use; the background view did not start.`;
if (view.state === 'failed') return verbose
? `The background view did not start: ${view.message}${view.log ? ` (log: ${view.log})` : ''}`
diff --git a/test/background-view.test.js b/test/background-view.test.js
index 755b50af..66ae3eaa 100644
--- a/test/background-view.test.js
+++ b/test/background-view.test.js
@@ -101,7 +101,7 @@ test('init leaves a view running for pullboard.dev [H5,N26]', async (t) => {
const lines = viewLines(init.out);
assert.equal(lines.length, 1, `init prints one line about the view:\n${init.out}`);
const log = join(box.env.PULLBOARD_HOME, `view-${port}.log`);
- assert.equal(lines[0], `Pullboard view is running at http://127.0.0.1:${port}.`);
+ assert.equal(lines[0], 'Pullboard view is running; open https://app.pullboard.dev to see your board.');
assert.doesNotMatch(init.out, /\b(?:kill\s+\d+|taskkill\s+\/PID\s+\d+)/iu, 'init does not advise killing the live view');
assert.ok(!init.out.includes(record.secret), 'the line names where the view is, never its secret');
@@ -146,7 +146,7 @@ test('resume starts the view once and the setting turns it off [H5,N26]', async
const record = sessionRecord(box, port);
started.push(record.pid);
assert.equal(viewLines(first.out).length, 1, `resume says it started the view:\n${first.out}`);
- assert.match(viewLines(first.out)[0], new RegExp(`^Pullboard view is running in the background at http://127\\.0\\.0\\.1:${port},.* To stop it: kill ${record.pid};`, 'u'));
+ assert.match(viewLines(first.out)[0], new RegExp(`^Pullboard view is running in the background, so https://app\\.pullboard\\.dev finds .* To stop it: kill ${record.pid};`, 'u'));
assert.equal((await answers(port, record.secret))?.status, 200);
const second = box.run(repo, 'resume', '--json');
diff --git a/test/init.test.js b/test/init.test.js
new file mode 100644
index 00000000..f7a45fa4
--- /dev/null
+++ b/test/init.test.js
@@ -0,0 +1,45 @@
+/** What pullboard init tells a person to open once setup is done [I1,N26]. */
+import assert from 'node:assert/strict';
+import { mkdirSync, readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { after, test } from 'node:test';
+import { HOSTED_ORIGIN } from '../src/serve.js';
+import { createE2eHelpers } from './e2e-helpers.js';
+import { takeDefaultViewPort } from './view-port-fixture.js';
+
+const e2e = createE2eHelpers();
+after(e2e.cleanup);
+
+/** Stop the background view this private home's session record names, if init started one. */
+async function stopRecordedView(box, port) {
+ let record;
+ try { record = JSON.parse(readFileSync(join(box.env.PULLBOARD_HOME, `view-${port}.json`), 'utf8')); }
+ catch (error) { if (error.code === 'ENOENT') return; throw error; }
+ if (!Number.isInteger(record.pid) || record.pid <= 1 || record.pid === process.pid) return;
+ try { process.kill(record.pid, 'SIGTERM'); }
+ catch (error) { if (error.code !== 'ESRCH') throw error; }
+}
+
+test('init names app.pullboard.dev and never the bare view address [I1,N26]', async (t) => {
+ const box = e2e.sandbox();
+ const lease = await takeDefaultViewPort(box.dir, { agent: `init-hosted-${process.pid}` });
+ t.after(() => stopRecordedView(box, lease.port));
+ t.after(() => lease.release());
+ box.env.PULLBOARD_VIEW_PORT = String(lease.port);
+ delete box.env.PULLBOARD_VIEW_BACKGROUND;
+ delete box.env.PULLBOARD_VIEW_FOREGROUND;
+ delete box.env.PULLBOARD_VIEW_BACKGROUND_CHILD;
+ const repo = join(box.dir, 'fresh');
+ mkdirSync(repo);
+ box.git(repo, 'init', '-q', '-b', 'main');
+ box.git(repo, 'config', 'user.name', 'Init Fixture');
+ box.git(repo, 'config', 'user.email', '[email protected]');
+ box.git(repo, 'commit', '-q', '--allow-empty', '-m', 'start');
+
+ const init = box.run(repo, 'init', '--yes', '--model', 'x');
+ assert.equal(init.code, 0, init.err || init.out);
+ const said = init.out + init.err;
+ assert.ok(said.includes(HOSTED_ORIGIN), `init tells the person to open ${HOSTED_ORIGIN}:\n${said}`);
+ const bare = said.split('\n').filter((line) => /http:\/\/(?:127\.0\.0\.1|localhost):\d+(?![\w/#?])/u.test(line));
+ assert.deepEqual(bare, [], 'no line names the view address without its key, which opens only to a refusal');
+});