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(view): collapse unreadable boards [N33,N34,N36]

Corey Olsona809b79a484b
diff --git a/src/cockpit.js b/src/cockpit.js
index 22ce72e5..c9b4bdc0 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -639,7 +639,7 @@ function playReplay() {
* this until the new board arrives, so the main column never mixes the old board with the new pick.
*/
function renderSide() {
- /** Render a repo button or one muted recovery line when its board cannot be read. */
+ /** Render a repo button or a transient board-read error line. Registered unreadable boards are disclosed below. */
const repoButton = (x) => {
if (!x.ok) return '<p class="repo-error" role="status"><b>' + esc(x.name) + ':</b> ' + esc(x.error) + '</p>';
const on = x.root === view.root;
@@ -647,15 +647,20 @@ function renderSide() {
const line = x.loading ? 'Loading…' : (asks ? '<span class="asks">' + esc(parts.slice(0, asks).join(' · ')) + '</span>' + (parts.length > asks ? ' · ' : '') : '') + esc(parts.slice(asks).join(' · '));
return '<button class="proj repo' + (on ? ' on' : '') + '"' + (on ? ' aria-current="true"' : '') + ' data-root="' + esc(x.root) + '" title="' + esc(x.root) + '" type="button"><span class="pname">' + (x.owner ? '<span class="owner">' + esc(x.owner) + '/</span>' : '') + esc(x.name) + '</span><small>' + (hosted.local && x.source ? '<span class="src">' + (x.source === 'relay' ? 'shared' : 'this computer') + '</span> · ' : '') + line + '</small></button>';
};
- const groupedRoots = new Set(data.groups.flatMap((group) => group.repos.map((repo) => repo.root)));
- const grouped = data.groups.map((group) => {
+ const readableProjects = data.projects.filter((repo) => repo.ok);
+ const unreadableProjects = data.projects.filter((repo) => !repo.ok && !repo.id);
+ const otherErrors = data.projects.filter((repo) => !repo.ok && repo.id).map(repoButton).join('');
+ const groups = projectGroups(readableProjects);
+ const groupedRoots = new Set(groups.flatMap((group) => group.repos.map((repo) => repo.root)));
+ const grouped = groups.map((group) => {
const on = group.key === view.root;
const needs = group.repos.reduce((total, repo) => total + needCount(repo), 0);
const count = group.repos.length;
return '<section class="repo-group"><button class="proj project-pick' + (on ? ' on' : '') + '"' + (on ? ' aria-current="true"' : '') + ' data-root="' + esc(group.key) + '" type="button"><span class="pname">' + esc(group.name) + '</span><small>' + (needs ? '<span class="asks">' + needs + ' need you</span> · ' : '') + count + ' ' + (count === 1 ? 'repo' : 'repos') + '</small></button><div class="repos">' + group.repos.map(repoButton).join('') + '</div></section>';
}).join('');
- const loose = data.projects.filter((repo) => !groupedRoots.has(repo.root)).map(repoButton).join('');
- $('proj-list').innerHTML = grouped || loose ? grouped + loose : '<div class="empty">None yet.</div>';
+ const loose = readableProjects.filter((repo) => !groupedRoots.has(repo.root)).map(repoButton).join('');
+ const unreadable = unreadableProjects.length ? '<details class="unreadable-projects"><summary>' + unreadableProjects.length + ' ' + (unreadableProjects.length === 1 ? 'board can' : 'boards can') + ' no longer be found</summary><ul>' + unreadableProjects.map((repo) => '<li><b>' + esc(repo.name) + '</b> <code>' + esc(repo.root) + '</code></li>').join('') + '</ul>' + (snapshot || readOnly ? '' : '<button type="button" data-forget-unreadable>Forget all</button>') + '</details>' : '';
+ $('proj-list').innerHTML = grouped || loose || otherErrors || unreadable ? grouped + loose + otherErrors + unreadable : '<div class="empty">None yet.</div>';
const p = data.project;
const selectedGroup = data.groups.find((group) => group.key === view.root);
const selectedRepo = data.projects.find((x) => x.root === view.root);
diff --git a/src/serve.js b/src/serve.js
index 93e0ae63..adadb4f1 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -53,6 +53,7 @@ import {
import { committedIds } from './history.js';
import { productSummaries } from './products.js';
import {
+ forgetProject,
listApiProjects,
registryFile,
} from './projects.js';
@@ -449,7 +450,7 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b
let bound = 0;
// The API reads projectState and codeAt from this module. Load its factory after our exports
// initialize, and use the real CLI entry point without adding a second move implementation.
- const { createLocalApiHandler } = await import('./api.js');
+ const { apiBoards, createLocalApiHandler } = await import('./api.js');
const { main } = await import('./cli.js');
const { startViewSignIn, viewSignInStatus, viewSignInPairingNavigation, cancelViewSignIn } = await import('./relay-setup.js');
const signIns = new Set();
@@ -500,6 +501,47 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b
return body;
}
+ /** Read the single explicit confirmation for the machine-local unreadable-project action. */
+ async function forgetUnreadableBody(req) {
+ if (!/^application\/json(?:\s*;\s*charset=utf-8)?$/iu.test(String(req.headers['content-type'] ?? ''))) {
+ throw new Refused('BAD_REQUEST', 'send the confirmation as a JSON object');
+ }
+ let length = 0;
+ const chunks = [];
+ for await (const chunk of req) {
+ length += chunk.length;
+ if (length <= 4096) chunks.push(chunk);
+ }
+ if (length > 4096) throw new Refused('BAD_REQUEST', 'send only the confirmation');
+ let body;
+ try { body = JSON.parse(Buffer.concat(chunks).toString('utf8')); } catch { /* Refuse below. */ }
+ if (!body || typeof body !== 'object' || Array.isArray(body)
+ || body.confirm !== true || Object.keys(body).length !== 1) {
+ throw new Refused('BAD_REQUEST', 'confirm forgetting the boards that are unreadable now');
+ }
+ return body;
+ }
+
+ /** Forget only roots that the same current registry snapshot cannot open as boards. */
+ async function forgetUnreadableRequest(req, res, url) {
+ const given = Buffer.from(String(req.headers['x-pullboard-key'] ?? ''));
+ if (given.length !== key.length || !timingSafeEqual(given, key) || url.search || req.headers.authorization !== undefined) {
+ return json(res, 403, refusalDocument(new Refused('VIEW_SIGN_IN_AUTH', 'open this view and send its session key in the x-pullboard-key header only')));
+ }
+ if (req.method !== 'POST') return json(res, 405, refusalDocument(new Refused('BAD_REQUEST', 'use a confirmed JSON POST to forget unreadable boards')));
+ try {
+ await forgetUnreadableBody(req);
+ const registered = listApiProjects();
+ const readable = new Set(apiBoards(() => registered).map((project) => project.root));
+ const unreadable = registered.filter((project) => !readable.has(project.root));
+ const forgotten = unreadable.filter((project) => forgetProject(project.root)).length;
+ return json(res, 200, { version: 1, forgotten });
+ } catch (error) {
+ const refusal = error instanceof Refused ? error : new Refused('SERVICE_ERROR', 'the unreadable boards could not be forgotten; refresh this view and try again');
+ return json(res, 400, refusalDocument(refusal));
+ }
+ }
+
/** Run only the existing person-channel adapter, with per-view intent ownership and header authentication. */
async function sharingRequest(req, res, url) {
const given = Buffer.from(String(req.headers['x-pullboard-key'] ?? ''));
@@ -585,6 +627,7 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b
return json(res, 403, { error: 'from https://app.pullboard.dev, send the session secret in the x-pullboard-key header only' });
}
if (url.pathname === '/api/v1/view-link') return sharingRequest(req, res, url);
+ if (projectRoot === undefined && url.pathname === '/api/v1/projects/forget-unreadable') return forgetUnreadableRequest(req, res, url);
return apiHandler(req, res);
}
const given = Buffer.from(String(req.headers['x-pullboard-key'] ?? url.searchParams.get('k') ?? ''));
diff --git a/src/view/page-script-2.js b/src/view/page-script-2.js
index 92dda8a0..fcc4f051 100644
--- a/src/view/page-script-2.js
+++ b/src/view/page-script-2.js
@@ -812,6 +812,26 @@ async function jsonRequest(path, body, base, headers, cache, format = 'json') {
return json;
}
+// The list is only a preview: the local view checks the registry again after this one confirmation.
+document.addEventListener('click', async (event) => {
+ const button = event.target.closest('[data-forget-unreadable]');
+ if (!button || snapshot || pageReadOnly) return;
+ if (!confirm('Forget the boards that are unreadable now? Boards recovered since this list was shown will be kept.')) return;
+ button.disabled = true;
+ try {
+ const base = hosted.local ? localReadBase : connection.base;
+ const headers = hosted.local ? localReadHeaders : connection.headers;
+ const result = await jsonRequest('/api/v1/projects/forget-unreadable', { confirm: true }, base, headers);
+ await refresh();
+ $('live').textContent = result.forgotten
+ ? 'Forgot ' + result.forgotten + ' unreadable ' + (result.forgotten === 1 ? 'board.' : 'boards.')
+ : 'No unreadable boards needed forgetting.';
+ } catch (error) {
+ $('live').textContent = String(error.message || error);
+ button.disabled = false;
+ }
+});
+
/** Read only this machine's authenticated view, including when its page is hosted elsewhere. */
function sharingApi(body) {
return jsonRequest('/api/v1/view-link', body, hosted.local ? localReadBase : connection.base,