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.

feat(relay): clarify device notices [H17,H5]

Corey Olson6ba3456d89b3
diff --git a/relay/auth.js b/relay/auth.js
index a94b6f0a..9f1dc8b1 100644
--- a/relay/auth.js
+++ b/relay/auth.js
@@ -268,7 +268,7 @@ export function createRelayAuth({ database, github, now = Date.now, sessionTTL =
const boards = row.kind === 'board' ? db.prepare('SELECT * FROM relay_boards WHERE id=?').all(row.board) : db.prepare('SELECT * FROM relay_boards ORDER BY id').all();
const visible = [];
for (const board of boards) {
- try { await auth.authenticate(token, { board: board.id }); visible.push({ id: board.id, repository: board.repository }); }
+ try { await auth.authenticate(token, { board: board.id }); visible.push({ id: board.id, repository: board.repository, linkedAt: board.linked_at }); }
catch (error) { if (!['NO_REPO_ACCESS', 'BOARD_NOT_LINKED'].includes(error.code)) throw error; }
}
return visible;
diff --git a/relay/browser-client.js b/relay/browser-client.js
index 867a24e8..4267e7fd 100644
--- a/relay/browser-client.js
+++ b/relay/browser-client.js
@@ -5,6 +5,7 @@ import { snapshotState, presentationState } from './model.js';
import { ENGINE_VERSION } from './engine.js';
import { Refused } from './refused.js';
import { enqueueStream, followStream } from './browser-stream.js';
+import { noticeLines } from './browser-notice.js';
const KEYS = 'pullboard.relay.keys.v1';
const PENDING = 'pullboard.relay.pair.v1';
@@ -81,15 +82,7 @@ export async function createTransport({ onUpdate = () => {} } = {}) {
const element = document.getElementById('relay-notice');
if (!element) return;
element.replaceChildren();
- const lines = ['Requests from this device wait for a linked machine to run Pullboard.'];
- const unpaired = available.filter(board => !paired.has(board.id));
- for (const board of unpaired) lines.push(board.repository + ': pair this browser using a link or QR from a linked machine.');
- for (const warning of warnings) if (warning?.code === 'BOARD_INACTIVE' && Number.isInteger(warning.daysLeft)) {
- lines.push('BOARD_INACTIVE: ' + warning.daysLeft + ' days left before this relay board is deleted. Make a board move from a linked machine to keep it.');
- }
- if (failure) lines.push(failure);
- if (!available.length) lines.push('No linked boards are available for this account.');
- for (const text of lines) {
+ for (const text of noticeLines({ available, paired, warnings, failure })) {
const paragraph = document.createElement('p');
paragraph.textContent = text;
element.append(paragraph);
diff --git a/relay/browser-notice.js b/relay/browser-notice.js
new file mode 100644
index 00000000..9cf00f5e
--- /dev/null
+++ b/relay/browser-notice.js
@@ -0,0 +1,27 @@
+/** Build truthful device notices from authorized boards and their decrypted pending requests. */
+export function noticeLines({ available, paired, warnings = [], failure = '' }) {
+ const lines = [];
+ const waiting = [...paired.values()].flatMap(entry => entry.state?.personRequests ?? [])
+ .filter(request => request.status === 'waiting').length;
+ if (waiting) lines.push(`${waiting} request${waiting === 1 ? '' : 's'} from this device ${waiting === 1 ? 'is' : 'are'} waiting for a linked machine to run Pullboard.`);
+ const pairedRepositories = new Set(available.filter(board => paired.has(board.id)).map(board => board.repository));
+ for (const board of available.filter(value => !paired.has(value.id))) {
+ if (!pairedRepositories.has(board.repository)) {
+ lines.push(board.repository + ': pair this browser using a link or QR from a linked machine.');
+ continue;
+ }
+ const date = Number.isSafeInteger(board.linkedAt) && board.linkedAt >= 0 && board.linkedAt <= 8640000000000000
+ ? new Date(board.linkedAt).toISOString().slice(0, 10) : 'date unavailable';
+ const warning = warnings.find(value => value?.board === board.id && value.code === 'BOARD_INACTIVE' && Number.isInteger(value.daysLeft));
+ const removal = warning
+ ? `To remove it, run pullboard relay off from the machine that linked it, or wait ${warning.daysLeft} days for automatic removal.`
+ : 'To remove it, run pullboard relay off from the machine that linked it, or wait until 90 days without activity for automatic removal.';
+ lines.push(`${board.repository} · linked ${date} · board ${board.id.slice(0, 8)}. ${removal}`);
+ }
+ for (const warning of warnings) if (warning?.code === 'BOARD_INACTIVE' && Number.isInteger(warning.daysLeft)) {
+ lines.push('BOARD_INACTIVE: ' + warning.daysLeft + ' days left before this relay board is deleted. Make a board move from a linked machine to keep it.');
+ }
+ if (failure) lines.push(failure);
+ if (!available.length) lines.push('No linked boards are available for this account.');
+ return lines;
+}
diff --git a/test/relay-browser-stream.test.js b/test/relay-browser-stream.test.js
index 5f159382..6c56f647 100644
--- a/test/relay-browser-stream.test.js
+++ b/test/relay-browser-stream.test.js
@@ -2,6 +2,7 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { enqueueStream, followStream } from '../relay/browser-stream.js';
+import { noticeLines } from '../relay/browser-notice.js';
/** Build a finite standards-shaped stream response for a deterministic transport probe. */
function eventResponse(id) {
@@ -17,6 +18,24 @@ function eventResponse(id) {
/** Resolve one event-loop turn while a test aborts a blocked stream. */
function delay(milliseconds) { return new Promise(resolve => setTimeout(resolve, milliseconds)); }
+test('notice says only what is true now [H17,H5]', () => {
+ const pairedId = '12345678' + 'a'.repeat(24);
+ const orphanId = '87654321' + 'b'.repeat(24);
+ const paired = new Map([[pairedId, { state: { personRequests: [{ status: 'waiting' }, { status: 'refused' }] } }]]);
+ const available = [
+ { id: pairedId, repository: 'pullboard/board', linkedAt: 1767312000000 },
+ { id: orphanId, repository: 'pullboard/board', linkedAt: 1767398400000 },
+ ];
+ const warning = { board: orphanId, code: 'BOARD_INACTIVE', daysLeft: 12 };
+ const lines = noticeLines({ available, paired, warnings: [warning] });
+ assert.match(lines[0], /^1 request from this device is waiting/u, 'only waiting requests appear and the count is visible');
+ assert.match(lines[1], /pullboard\/board · linked 2026-01-03 · board 87654321/u, 'a same-repository orphan is distinguished by link date and short id');
+ assert.match(lines[1], /pullboard relay off.*12 days for automatic removal/u, 'the orphan notice gives both removal paths and its remaining idle time');
+ assert.match(lines[2], /BOARD_INACTIVE: 12 days left/u, 'the existing retention warning remains visible');
+ const noRequests = new Map([[pairedId, { state: { personRequests: [] } }]]);
+ assert.deepEqual(noticeLines({ available: [available[0]], paired: noRequests, warnings: [] }), [], 'all paired boards and no waiting requests produce an empty notice');
+});
+
test('clean SSE EOF reconnects after a bounded delay and resumes from the delivered cursor [H16,H3]', async () => {
const controller = new AbortController();
const requests = [];
diff --git a/test/relay-client.test.js b/test/relay-client.test.js
index e91b3020..f34fe1cd 100644
--- a/test/relay-client.test.js
+++ b/test/relay-client.test.js
@@ -196,7 +196,8 @@ test('[H1,H3,H7,H15,H16] relay on snapshots and orders ciphertext, refuses offli
assert.ok(!relay.calls.some((call) => call.path === '/auth/boards/link'));
chmodSync(keysDirectory, 0o700);
const on = await cli(root, relayEnv, 'relay', 'on', '--url', relay.origin);
- assert.deepEqual(await auth.boardsFor(person.token), [{ id: boardId, repository: 'fixture/repository' }]);
+ const linkedAt = auth.linkedBoards().find(link => link.id === boardId).linkedAt;
+ assert.deepEqual(await auth.boardsFor(person.token), [{ id: boardId, repository: 'fixture/repository', linkedAt }]);
assert.equal(on.version, 1);
assert.equal(on.linked, true);
assert.equal(on.board, boardId);