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): pullboard.dev opens your board one step at a time [N26,H5]
Corey Olson45741d71022e
diff --git a/src/cockpit.js b/src/cockpit.jsindex 71730c33..fc81d672 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -78,7 +78,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ<link rel="stylesheet" href="${cssAttribute}"><link rel="icon" href="data:,"></head>-<body class="loading${snapshot ? ' snapshot' : ''}${readOnly ? ' read-only' : ''}${requestMode ? ' requests' : ''}">+<body class="loading${hostedLocal && !snapshot ? ' hosted-page open-board' : ''}${snapshot ? ' snapshot' : ''}${readOnly ? ' read-only' : ''}${requestMode ? ' requests' : ''}"><div class="shell"><aside class="side" id="side" aria-label="Projects"><div class="side-top">@@ -88,7 +88,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ</div><div class="side-body" id="side-body"><div class="label">Projects</div>- <nav id="proj-list" aria-label="Projects on this machine"></nav><p class="side-hint" id="side-hint" hidden></p>+ <nav id="proj-list" aria-label="Projects on this machine"></nav><section class="products" id="products" aria-label="Products" hidden><div class="label">Products</div><div id="prod-list"></div></section></div></aside>@@ -110,7 +110,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ<p>Run <code>pullboard init</code> in a git repo, or ask an agent to. Its board shows up here by itself.</p></section><p class="empty" id="project-loading" role="status" hidden>Loading project…</p>- ${hostedMarkup('http://127.0.0.1:4890')}+ ${hostedMarkup('http://127.0.0.1:4890', { looking: Boolean(hostedLocal) && !snapshot, signIn })}<section class="card-panel snapshot-controls" id="snapshot-controls" ${snapshot ? '' : 'hidden'} aria-label="Snapshot replay"><span>Read-only snapshot</span><button class="ghost" id="replay-play" type="button">Play from first event</button>@@ -251,9 +251,9 @@ if (hosted.local && !relayPairing) {catch { removed = false; }let returnedSession = null;try { returnedSession = JSON.parse(returned); } catch { /* refused below */ }- if (!removed) localProblem = 'This browser kept the connection secret in the address, so this page will not use it. Close this tab, then open the local view.';+ if (!removed) localProblem = 'This browser kept the connection secret in the address, so this page will not use it. Close this tab, then open your board below.';else if (validLocalSession(returnedSession)) localSession = { version: 1, origin: returnedSession.origin, key: returnedSession.key };- else localProblem = 'The local view sent back a connection this page cannot read. Try again, or open the local view.';+ else localProblem = 'Pullboard on this computer sent back a connection this page cannot read.';} else {try { const kept = JSON.parse(tabValue(LOCAL_TAB) ?? 'null'); if (validLocalSession(kept)) localSession = kept; } catch { /* nothing kept for this tab */ }}@@ -311,9 +311,12 @@ const $ = (id) => document.getElementById(id);const hostedState = (${hostedState.toString()});const hostedBrowser = (${hostedBrowser.toString()});const drawHosted = (${drawHosted.toString()});-/** Show the hosted state the page is in (src/view/hosted.js), with its next step, or none with null. */+/**+ * Show the open-board screen the page is in (src/view/hosted.js), or none with null. A phone is the one the relay's+ * page names before first paint (#757), and it hears nothing about this computer.+ */function localNote(state, facts = {}) {- drawHosted(document, hostedState(state, { browser: hostedBrowser(navigator), ...facts }), { view: localSession?.origin || LOCAL_VIEW, signIn: hosted.signIn, session: hosted.relaySession });+ drawHosted(document, hostedState(state, { browser: hostedBrowser(navigator), phone: document.documentElement.dataset.relayDevice === 'phone', ...facts }), { view: localSession?.origin || LOCAL_VIEW, signIn: hosted.signIn, session: hosted.relaySession });}/** Hide the relay's own banner, which speaks for the relay, on a page the relay does not serve this time. */@@ -327,7 +330,7 @@ function localTrip(base) {const trips = Number(tabValue(LOCAL_TRIPS) || 0);if (trips >= 2) {tabValue(LOCAL_TRIPS, null);- localNote('problem', { detail: 'The local view did not give this page a session it accepts. Open the local view to see its boards.' });+ localNote('problem', { detail: 'Pullboard on this computer did not give this page a session it accepts.' });return false;}tabValue(LOCAL_TRIPS, String(trips + 1));@@ -344,39 +347,62 @@ function localExpired() {localTrip(base);}+// The screens that wait on this computer: the page looks again by itself while one shows, with no Try again (#764).+const LOCAL_STATES = ['looking', 'asking', 'blocked', 'not-running', 'mismatch'];+let localChecking = false;+let localReached = false;+/**- * Reach this machine's view: say first why the browser may ask about local network access, then read the view's- * public protocol, which holds no secret and no board, and take the session the round trip brought back. It is- * 'local' when the page now reads the local view, 'away' when the browser is on the round trip, and 'unreachable'- * when the page cannot read it, with what it knows of why on the page.+ * Reach this machine's view: read the view's public protocol, which holds no secret and no board, and take the session+ * the round trip brought back. While the browser asks the person, which it does before the request goes anywhere, the+ * page draws the prompt and says it waits. It is 'local' when the page now reads the local view, 'away' when the+ * browser is on the round trip, 'unreachable' when the page cannot read it, with the screen that says why, and 'busy'+ * while another look is still on its way. A look again by itself (again) redraws only a screen that waits on this+ * computer, so a later screen, such as signing in, stays.*/-async function connectLocal() {+async function connectLocal(again = false) {+ if (localChecking) return 'busy';+ localChecking = true;+ try { return await lookLocal(again); }+ finally { localChecking = false; }+}++/** One look for this machine's view, for connectLocal, which keeps two from running at once. */+async function lookLocal(again) {const base = localSession?.origin || LOCAL_VIEW;+ /** Draw this screen, unless the page has moved past the ones that wait on this computer. */+ const show = (state) => {+ const shown = $('local-note').dataset.state || '';+ if (shown !== state && (!again || LOCAL_STATES.includes(shown))) localNote(state);+ };let permission = null;for (const name of ['loopback-network', 'local-network-access']) {try { permission = (await navigator.permissions.query({ name })).state; break; } catch { /* this browser has no such permission */ }}if (permission === 'denied') {- localNote('blocked');+ show('blocked');return 'unreachable';}- if (permission !== 'granted') {- localNote('asking');- // The line is on screen before the request that can raise the browser's prompt.+ // A browser that says it will ask gets Click Allow on screen before the request that raises its prompt; one that+ // says nothing gets it only once the request is slow to come back, as it is while a prompt waits.+ let slow = null;+ if (permission === 'prompt' && !again) {+ show('asking');await new Promise((painted) => requestAnimationFrame(() => requestAnimationFrame(painted)));- }+ } else if (permission !== 'granted' && !again) slow = setTimeout(() => show('asking'), 800);let reply;try { reply = await fetch(base + '/local/protocol', { signal: AbortSignal.timeout(3000), credentials: 'omit', redirect: 'error' }); }- catch {- // One discovery request is all this page makes of this device (P5), so a view too old to answer it reads as none,- // and the state names that case in its hint.- localNote('not-running');+ catch (error) {+ // A request that ran out of time while the browser may still be asking is the prompt waiting for the person;+ // one refused at once means nothing runs here. One discovery request at a time is all this page makes of this+ // device, so a view too old to answer it reads as none.+ show(error?.name === 'TimeoutError' && permission !== 'granted' ? 'asking' : 'not-running');return 'unreachable';- }+ } finally { clearTimeout(slow); }let protocol = null;try { protocol = await reply.json(); } catch { /* not this protocol */ }if (!reply.ok || protocol?.version !== 1 || protocol?.apiVersion !== 1 || protocol?.hostedOrigin !== location.origin) {- localNote('mismatch');+ show('mismatch');return 'unreachable';}if (!localSession) return localTrip(base) ? 'away' : 'unreachable';@@ -386,9 +412,11 @@ async function connectLocal() {localReadHeaders = { ...connection.headers };readOnly = false;requests = false;+ localReached = true;document.body.classList.remove('read-only', 'requests');hideRelayNotice();- localNote(null);+ // Finding your boards stays until the list arrives, so the page never shows an empty board on its way to one.+ if (LOCAL_STATES.includes($('local-note').dataset.state || '')) localNote('looking');return 'local';}@@ -423,8 +451,11 @@ function theme(pick) {else delete document.documentElement.dataset.theme;const now = document.documentElement.dataset.theme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');document.documentElement.dataset.scheme = now;- $('theme').title = now === 'dark' ? 'Dark theme: switch to light' : 'Light theme: switch to dark';- $('theme').setAttribute('aria-label', $('theme').title);+ // The open-board screens carry the same toggle in their own header (#764), as the sidebar is hidden there.+ for (const button of [$('theme'), $('ob-theme')]) {+ button.title = now === 'dark' ? 'Dark theme: switch to light' : 'Light theme: switch to dark';+ button.setAttribute('aria-label', button.title);+ }}theme(keep('pb.theme'));matchMedia('(prefers-color-scheme: dark)').addEventListener?.('change', () => theme(keep('pb.theme')));@@ -1061,9 +1092,11 @@ async function listedBoards() {/** After a hosted board list: a list clears a state it stood in for, and a signed-in empty one says why it is empty. */async function hostedListed(boards) {const shown = $('local-note').dataset.state || '';- if (boards.length) { if (['not-running', 'no-linked', 'unpaired', 'signed-out'].includes(shown)) localNote(null); return; }+ if (boards.length) { if (['looking', 'not-running', 'no-linked', 'unpaired', 'signed-out'].includes(shown)) localNote(null); return; }+ // Nobody signed in and no board on this computer yet: the page says how to make one, as the local view does.+ if (!hosted.relaySession) { if (shown === 'looking') localNote(null); return; }// An empty local view can still leave linked boards on another computer waiting for this browser to pair.- if (!hosted.relaySession || !['', 'not-running', 'no-linked', 'unpaired'].includes(shown)) return;+ if (!['', 'looking', 'not-running', 'no-linked', 'unpaired'].includes(shown)) return;let linked;try { linked = await linkedList(); } catch { return; /* the relay's banner says why */ }const names = (linked.boards || []).filter((board) => typeof board.repository === 'string').map((board) => board.repository);@@ -1788,7 +1821,7 @@ function renderSide() {const on = x.root === view.root;const parts = doing(x).split(' · '), asks = [x.decisions, x.pending, x.drafts, x.holds].filter(Boolean).length;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' ? 'linked' : 'this computer') + '</span> · ' : '') + line + '</small></button>';+ 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) => {@@ -3283,6 +3316,8 @@ $('shouts-pane').addEventListener('click', (event) => {// Enter shouts; Shift+Enter starts a new line.$('shout-text').addEventListener('keydown', (event) => { if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { event.preventDefault(); $('shout-form').requestSubmit(); } });document.addEventListener('click', (event) => {+ // The open-board screens name their state in data-state and handle their own presses (#764).+ if (event.target.closest('#local-note')) return;if (view.filterOpen && !event.target.closest('.filter-control')) { view.filterOpen = false; render(); }const t = event.target.closest('[data-filter-toggle],[data-filter-choice],[data-status],[data-roadmap-jump],[data-shout-id],[data-roadmap-key],[data-roadmap-all],[data-root],[data-tab],[data-go],[data-item],[data-items-view],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],[data-code-all],[data-code-less],[data-stats-toggle],#proj-switch,#console');if (!event.target.closest('.side')) fold(false);@@ -3440,11 +3475,14 @@ $('side-toggle').addEventListener('click', () => {fold(false);keep('pb.side', collapsed ? 'collapsed' : 'open');});-$('theme').addEventListener('click', () => {+/** Pick the scheme the page does not show now, and keep it. */+function flipTheme() {const next = document.documentElement.dataset.scheme === 'dark' ? 'light' : 'dark';keep('pb.theme', next);theme(next);-});+}+$('theme').addEventListener('click', flipTheme);+$('ob-theme').addEventListener('click', flipTheme);$('q').addEventListener('input', () => { search(); view.foundAt = 0; showFound(); });// Leaving the field closes the results a moment later, so a press on a result lands first; coming back to the field// before then keeps them, or a search begun straight after Esc would lose its new results to the old close.@@ -3538,13 +3576,42 @@ if (snapshot) {if (snapshotReplay.playing) { clearTimeout(snapshotReplay.timer); snapshotReplay.timer = setTimeout(advanceReplay, 1000 / Number($('replay-speed').value)); }});}-if (hosted.local) $('local-note-retry').addEventListener('click', () => {- localProblem = null;- tabValue(LOCAL_TRIPS, null);- // Reload both source-scoped connections together when relay streams are already active.- if (transport) { location.reload(); return; }- connectLocal().then((local) => local === 'local' ? refresh() : null).catch((error) => localNote('problem', { detail: error.message }));+/** Copy a screen's command or sentence; a browser without the clipboard API copies from a selected field. */+async function copyWords(text) {+ try { await navigator.clipboard.writeText(text); return true; }+ catch { /* Older and embedded browsers refuse the clipboard API: copy from a selected field below. */ }+ const field = document.createElement('textarea');+ field.value = text;+ field.setAttribute('readonly', '');+ field.style.position = 'fixed';+ field.style.opacity = '0';+ document.body.append(field);+ field.select();+ const copied = document.execCommand('copy');+ field.remove();+ return copied;+}+$('local-note').addEventListener('click', async (event) => {+ const button = event.target instanceof Element ? event.target.closest('button[data-copy]') : null;+ if (!button || !button.dataset.copy) return;+ button.textContent = await copyWords(button.dataset.copy) ? 'Copied' : 'Select and copy';});+/**+ * Look for this machine's view again, by itself, while a screen waits on it or a signed-in person waits for a board:+ * the moment the view answers, the page opens the board, with no Try again (#764). Over a relay stream, a reload+ * starts both sources together.+ */+function lookAgain() {+ if (!hosted.local || relayPairing || localReached || localProblem || document.hidden) return;+ if (![...LOCAL_STATES, 'no-linked', 'unpaired'].includes($('local-note').dataset.state || '') || $('local-note').dataset.state === 'looking') return;+ connectLocal(true).then((local) => {+ if (local !== 'local') return;+ if (transport) { location.reload(); return; }+ transportModule = null;+ return refresh();+ }).catch((error) => localNote('problem', { detail: error.message }));+}+if (hosted.local && !snapshot) setInterval(lookAgain, 2000);/** Load the configured decrypting transport once, only when relay reads or pairing need it. */let transportLoading = null;async function loadTransport() {@@ -3579,7 +3646,12 @@ async function startPage() {}await refresh();}-startPage().catch((error) => { document.body.classList.remove('loading'); $('live').textContent = 'cannot reach the view: ' + error.message; });+startPage().catch((error) => {+ document.body.classList.remove('loading');+ $('live').textContent = 'cannot reach the view: ' + error.message;+ // Finding your boards never stays on a page that has stopped looking.+ if (hosted.local && $('local-note').dataset.state === 'looking') localNote('problem', { detail: 'Pullboard on this computer did not answer: ' + error.message });+});// The relay transport keeps its own stream and timer. The local view reads on a timer only while it has no live// stream, and its live line says so (#545). Each timer asks which the page uses as it fires: the hosted page starts// out on the relay and turns to this machine's view once it reaches it (#513).diff --git a/src/view.css b/src/view.cssindex ce8b298e..cb50bd57 100644--- a/src/view.css+++ b/src/view.css@@ -135,42 +135,89 @@ main { padding: 16px 18px 56px; }.first code { font: 600 13px var(--mono); color: var(--ink); }.boardless .first { display: block; }.loading .top, .loading [data-pane], .boardless .top, .boardless [data-pane] { display: none; }-/* The hosted page's states (#749): a card with a heading, one line and the next step, then the Ways in panel. In- * place of a board they stand alone in the middle of the page; over a list a note is one quiet card. */a { color: var(--accent-strong); text-underline-offset: 2px; }a.go, a.ghost { display: inline-flex; align-items: center; text-decoration: none; }a.ghost { color: var(--ink); }-.hosted { display: grid; gap: 14px; margin: 0 0 14px; }-.loading .hosted, .boardless .hosted, .hosted-state .hosted { max-width: 560px; margin: 10vh auto 56px; }-.hosted-card { display: grid; gap: 8px; padding: 22px 24px; }-.hosted h2 { margin: 0; font-size: 18px; }-.hosted-card p { margin: 0; color: var(--ink-muted); }-.hosted-card .hosted-hint { color: var(--ink); }-.hosted-card .hosted-cmd:not([hidden]) + .hosted-hint { color: var(--ink-muted); font-size: 13px; }-.hosted-hint code { font: 12.5px var(--mono); color: var(--ink); white-space: nowrap; }-.hosted-cmd { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 5px 5px 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }-.hosted-cmd code { flex: 1; min-width: 0; overflow-x: auto; font: 600 13px var(--mono); color: var(--ink); white-space: nowrap; }-.hosted-cmd .ghost { flex: none; padding: 3px 10px; font-size: 12px; }-.hosted-card .hosted-step { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }-.hosted-ways { padding: 16px 24px 6px; }-.hosted-ways h2 { margin-bottom: 2px; font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }-.hosted-ways dl { margin: 0; }-.way { padding: 10px 0; border-top: 1px solid var(--line); }-.way:first-child { border-top: 0; }-.way dt { font-weight: 600; }-.way dd { margin: 2px 0 0; color: var(--ink-muted); font-size: 13px; }-.way code { font: 12px var(--mono); color: var(--ink); white-space: nowrap; }-.way .ghost { display: flex; width: fit-content; margin-top: 8px; }-.hosted-state .first, .hosted-state #proj-list .empty { display: none; }.proj small .src { color: var(--ink-muted); }.proj .pname .owner { color: var(--ink-faint); font-weight: 400; }-.side-hint { margin: 0; padding: 4px 8px; color: var(--ink-faint); font-size: 12.5px; line-height: 1.45; }+/* Opening your board at app.pullboard.dev (#764): one screen at a time stands alone on the page, centred, with the+ * theme toggle in its own header; the sidebar, tabs and status line wait until there is a board to list. A note over+ * a list is one quiet card. Every big button, command box and "or" box is 60 px tall; the GitHub button is dark. */+.open-board .shell, .hosted-page.boardless .shell { display: block; }+.open-board .side, .open-board .top, .open-board .status, .open-board main > :not(#local-note), .hosted-page.boardless .side { display: none !important; }+.open-board main { padding: 0; }+.open-board #local-note { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; min-height: 100dvh; }+.ob-top { display: flex; justify-content: flex-end; padding: 12px 16px 0; }+.ob-panel { align-self: center; justify-self: center; box-sizing: border-box; width: 100%; max-width: 520px; padding: 24px 20px 64px; text-align: center; font-size: 16px; }+#local-note.wide .ob-panel { max-width: 900px; }+.ob-mark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }+.ob-mark svg { width: 28px; height: 28px; }+.ob-panel h1 { margin: 22px 0 0; font-size: 30px; line-height: 1.15; letter-spacing: -.025em; text-wrap: balance; }+.ob-say { margin: 12px auto 0; max-width: 440px; color: var(--ink-muted); font-size: 17px; text-wrap: balance; }+.ob-act { margin: 28px auto 0; max-width: 400px; text-align: left; }+.ob-big { display: flex; align-items: center; justify-content: center; gap: 12px; box-sizing: border-box; width: 100%; height: 60px; border-radius: 14px; font-weight: 600; font-size: 18px; text-decoration: none; cursor: pointer; }+.ob-big svg { width: 22px; height: 22px; }+.ob-gh, .ob-gh:hover { background: #1f2328; color: #fff; }+:root[data-scheme="dark"] .ob-gh { border: 1px solid var(--line-strong); }+.ob-go, .ob-go:hover { background: var(--accent); color: var(--on-accent); }+.ob-cmd, .ob-agent { display: flex; align-items: center; justify-content: space-between; gap: 10px; box-sizing: border-box; height: 60px; padding: 0 0 0 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }+.ob-cmd code { overflow: hidden; color: var(--ink); font: 600 17px var(--mono); white-space: nowrap; text-overflow: ellipsis; }+.ob-p { margin-right: 8px; color: var(--ink-faint); }+.ob-agent > span { flex: 1; min-width: 0; font-weight: 600; line-height: 1.3; }+.ob-agent small { display: block; color: var(--ink-muted); font-weight: 400; font-size: 13px; }+.ob-agent svg, .ob-help svg { flex: none; width: 22px; height: 22px; color: var(--accent); }+/* Inside a 60 px box the Copy button takes the box's own right edge, so box and button are both 60 px. */+.ob-cmd button, .ob-agent button, .ob-help button { flex: none; box-sizing: border-box; height: 60px; padding: 0 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer; }+.ob-cmd button, .ob-agent button { margin: -1px -1px -1px 0; border-radius: 0 14px 14px 0; }+.ob-cmd button:hover, .ob-agent button:hover, .ob-help button:hover { background: var(--accent-soft); }+.ob-or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--ink-faint); font-size: 13.5px; }+.ob-or::before, .ob-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }+.ob-small { margin: 12px auto 0; max-width: 400px; color: var(--ink-muted); font-size: 14.5px; text-wrap: balance; }+.ob-live { display: inline-flex; align-items: center; gap: 10px; margin: 22px 0 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-muted); font-size: 14.5px; }+.ob-live i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: ob-pulse 1.4s ease-in-out infinite; }+@keyframes ob-pulse { 50% { opacity: .25; transform: scale(.8); } }+/* The spinner is a ring with one dot going round it, so no edge of any box takes the accent colour. */+.ob-spin { position: relative; width: 36px; height: 36px; margin: 28px auto 0; box-sizing: border-box; border-radius: 50%; border: 3px solid var(--line); animation: ob-turn .9s linear infinite; }+.ob-spin::after { content: ""; position: absolute; top: -5.5px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--accent); }+@keyframes ob-turn { to { transform: rotate(1turn); } }+@media (prefers-reduced-motion: reduce) { .ob-live i, .ob-spin { animation: none; } }+.ob-help { display: flex; align-items: center; gap: 12px; max-width: 420px; margin: 26px auto 0; padding: 10px 10px 10px 14px; border: 1px dashed var(--line-strong); border-radius: 14px; text-align: left; color: var(--ink-muted); font-size: 14.5px; }+.ob-help > span { flex: 1; min-width: 0; }+.ob-help small { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }+/* The browser's own permission prompt, drawn so people know what to click. */+.ob-ask { position: relative; margin: 28px auto 0; max-width: 380px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); text-align: left; }+.ob-ask .t { font-weight: 600; }+.ob-ask .d { margin-top: 4px; color: var(--ink-muted); font-size: 14.5px; }+.ob-ask .b { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }+.ob-ask .b span { padding: 7px 16px; border: 1px solid var(--line); border-radius: 999px; font-size: 14.5px; }+.ob-ask .b .yes { border-color: #1a73e8; background: #1a73e8; color: #fff; outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 3px; }+.ob-ask .arrow { position: absolute; right: 4px; bottom: -30px; color: var(--accent-strong); font-weight: 700; font-size: 14px; }+.ob-steps { margin: 24px auto 0; max-width: 420px; padding: 0; list-style: none; text-align: left; counter-reset: ob-step; }+.ob-steps li { counter-increment: ob-step; display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink-muted); }+.ob-steps li:first-child { border-top: 0; }+.ob-steps li::before { content: counter(ob-step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font: 600 13px var(--mono); }+.ob-steps b { color: var(--ink); font-weight: 600; }+/* The one place two paths exist: two equal cards that say plainly how they differ. */+.ob-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 30px; text-align: left; }+.ob-card { display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 8px; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }+.ob-k { color: var(--accent-strong); font: 700 12.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; }+.ob-card h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }+.ob-card p { margin: 0; color: var(--ink-muted); }+.ob-card .ob-act { margin: 10px 0 0; max-width: none; }+.ob-card .ob-small { margin: 10px 0 0; max-width: none; text-align: left; }+.ob-two.signed-in { grid-template-columns: minmax(0, 440px); justify-content: center; }+.ob-two.signed-in .ob-card + .ob-card { display: none; }+@media (width < 760px) { .ob-two { grid-template-columns: 1fr; } .ob-cmd code { font-size: 15px; } }+#local-note[data-kind="note"] { display: grid; gap: 4px; margin: 0 0 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }+#local-note[data-kind="note"] .ob-top, #local-note[data-kind="note"] .ob-mark { display: none; }+#local-note[data-kind="note"] .ob-panel { max-width: none; padding: 0; text-align: left; font-size: 14px; }+#local-note[data-kind="note"] h1 { margin: 0; font-size: 15px; }+#local-note[data-kind="note"] .ob-say { margin: 2px 0 0; max-width: none; font-size: 14px; }/* The relay's banner, filled by its client: the same quiet card. */#relay-notice { display: grid; gap: 6px; margin: 0 0 14px; padding: 14px 16px; }#relay-notice p { margin: 0; color: var(--ink-muted); }#relay-notice a { justify-self: start; font-weight: 600; }.loading #relay-notice, .boardless #relay-notice { max-width: 560px; margin: 10vh auto 14px; }-.loading #relay-notice:not([hidden]) ~ .hosted, .boardless #relay-notice:not([hidden]) ~ .hosted { margin-top: 0; }#pairing-storage-notice { margin: 0 0 14px; padding: 12px 16px; color: var(--ink-muted); }.two { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 42%, 600px); gap: 16px; align-items: start; }.two.narrow { grid-template-columns: minmax(0, 1fr) var(--agents-w); }diff --git a/src/view/hosted.js b/src/view/hosted.jsindex fa085fa8..2a52db8f 100644--- a/src/view/hosted.js+++ b/src/view/hosted.js@@ -1,39 +1,79 @@/**- * The hosted page's states at https://app.pullboard.dev [N26,H5]. Each state is a heading, one line on what it- * means and the one next step, and a short "Ways in" panel lists every route to a board in plain words.- * hostedMarkup builds the panel on the server; hostedState, hostedBrowser and drawHosted run in the page, which- * inlines them by their source, so each reads nothing beyond its own arguments.+ * Opening your board at https://app.pullboard.dev [N26,H5]: the page shows one screen at a time, in the words the+ * person approved on 17 Oct, until there is a board to show. Each screen is a heading, at most one line, one thing to+ * do, and, where something can go wrong, a sentence to copy for your agent. There is no Try again: the page looks+ * again by itself and says that it is waiting. hostedMarkup builds every part on the server; hostedState,+ * hostedBrowser and drawHosted run in the page, which inlines them by their source, so each reads nothing beyond its+ * own arguments.*/-/** The routes to a board, as the Ways in panel lists them: a title, then one line with its commands. */-const WAYS_IN = [- ['The local view', 'Run <code>pullboard view</code> on the computer that holds your boards. It opens them in a browser tab.'],- ['This computer through pullboard.dev', 'While <code>pullboard view</code> runs, this page opens the same boards, and their data stays on this computer.'],- ['Your phone and other devices', 'Run <code>pullboard relay on --all</code> to link your boards, then scan the QR it prints and sign in.'],- ['A second computer', 'Run <code>pullboard relay pair</code> on this one, then <code>pullboard relay join <code></code> on the other.'],-];+const MARK = '<svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect fill="var(--accent)" width="56" height="14" x="3" y="25" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg>';+const GITHUB = '<svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>';+const SPEECH = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12Z"/></svg>';+const THEME = '<svg class="sys" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="currentColor" d="M8 2a6 6 0 0 1 0 12Z"/></svg><svg class="sun" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" d="M8 1.5v1.2M8 13.3v1.2M1.5 8h1.2M13.3 8h1.2M3.4 3.4l.85.85M11.75 11.75l.85.85M3.4 12.6l.85-.85M11.75 4.25l.85-.85"/></svg><svg class="moon" viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" d="M13.6 9.6A6 6 0 1 1 6.4 2.4a5.2 5.2 0 0 0 7.2 7.2Z"/></svg>';++/** The sentence each computer command box offers to say to your agent instead. */+const OPEN_ASK = 'Help me open my Pullboard board.';++/**+ * A command in a mono box with its Copy button, then the "or" box of the same height that asks your agent instead.+ *+ * @param {string} command - The command, or '' for one the page fills in.+ * @param {string} ask - The sentence for the agent.+ * @param {string} [id] - The id prefix of a box whose command and sentence the page fills in.+ * @returns {string}+ */+function commandBoxes(command, ask, id = '') {+ const code = id ? ` id="${id}-code"` : '';+ const copy = id ? ` id="${id}-copy"` : '';+ const said = id ? ` id="${id}-ask"` : '';+ const agentCopy = id ? ` id="${id}-agent"` : '';+ return `<div class="ob-cmd"><code><span class="ob-p" aria-hidden="true">$</span><span${code}>${command}</span></code><button type="button" data-copy="${command}"${copy}>Copy</button></div>`+ + '<div class="ob-or">or</div>'+ + `<div class="ob-agent">${SPEECH}<span>Ask your agent<small${said}>“${ask}”</small></span><button type="button" data-copy="${ask}"${agentCopy}>Copy</button></div>`;+}/**- * The hosted panel's markup: the state card, with its heading, line, command and buttons, and the Ways in panel.- * The ids are the ones the page always had (local-note, local-note-text, local-note-links, local-note-view,- * local-note-sign-in, local-note-retry), so what reads them keeps working.+ * Every part of every open-board screen, shown one screen at a time. The section keeps the ids the page always read+ * (local-note, local-note-title, local-note-text, local-note-code, local-note-view), so what reads them keeps working.+ * On the hosted page the first screen, Finding your boards, is there at first paint, before any script runs.** @param {string} localView - The local view's address, the default the page links before it knows another.+ * @param {{looking?: boolean, signIn?: string|null}} [options] - Whether the page opens on Finding your boards, and the sign-in path.* @returns {string}*/-export function hostedMarkup(localView) {- const ways = WAYS_IN.map(([title, line], n) => `<div class="way"><dt>${title}</dt><dd>${line}${n === 2 ? ' <a class="ghost" id="local-note-sign-in" hidden>Sign in with GitHub</a>' : ''}</dd></div>`).join('');- return `<section class="hosted" id="local-note" role="status" hidden>- <div class="card-panel hosted-card"><h2 id="local-note-title"></h2><p id="local-note-text"></p>- <div class="hosted-cmd" id="local-note-cmd" hidden><code id="local-note-code"></code><button class="ghost" id="local-note-copy" type="button">Copy</button></div><p class="hosted-hint" id="local-note-hint" hidden></p>- <p class="hosted-step" id="local-note-links" hidden><a class="go" id="local-note-view" href="${localView}/local/view" hidden>Open the local view</a><a class="go" id="local-note-go" hidden>Sign in with GitHub</a><button class="go" id="local-note-retry" type="button" hidden>Try again</button></p></div>- <section class="card-panel hosted-ways" id="ways-in" aria-labelledby="ways-in-title" hidden><h2 id="ways-in-title">Ways in</h2><dl>${ways}</dl></section>+export function hostedMarkup(localView, { looking = false, signIn = null } = {}) {+ const github = `<a class="ob-big ob-gh"${signIn ? ` href="${signIn}"` : ''}>${GITHUB}Sign in with GitHub</a>`;+ return `<section class="open-board" id="local-note" role="status" data-state="${looking ? 'looking' : ''}" data-kind="${looking ? 'state' : ''}"${looking ? '' : ' hidden'}>+ <header class="ob-top"><button class="theme-btn" id="ob-theme" type="button" title="Theme">${THEME}</button></header>+ <div class="ob-panel">+ <div class="ob-mark">${MARK}<span>Pullboard</span></div>+ <h1 id="local-note-title">${looking ? 'Finding your boards…' : ''}</h1>+ <p class="ob-say" id="local-note-text" hidden></p>+ <div class="ob-spin" data-part="spin" aria-hidden="true"${looking ? '' : ' hidden'}></div>+ <div class="ob-ask" data-part="ask" hidden><div class="t">app.pullboard.dev wants to</div> <div class="d">Access other apps and services on this device</div> <div class="b"><span>Block</span> <span class="yes">Allow</span></div> <div class="arrow">↑ click this</div></div>+ <ol class="ob-steps" data-part="steps" hidden><li><span>Click the <b>icon left of the address</b>, at the top of this window.</span></li><li><span>Find <b>Local network access</b>, or <b>Apps on this device</b>.</span></li><li><span>Set it to <b>Allow</b>.</span></li></ol>+ <div class="ob-two" data-part="two" hidden>+ <section class="ob-card"><span class="ob-k">Local only</span><h2>Open them on this computer</h2><p>Your boards stay on this computer, and only this computer sees them. Open a terminal and run:</p>+ <div class="ob-act">${commandBoxes('pullboard view', OPEN_ASK)}</div>+ <p class="ob-small">Either way, this page opens your boards by itself.</p></section>+ <section class="ob-card"><span class="ob-k">Everywhere</span><h2>Open them from any device</h2><p>Your boards on your phone and every computer, from the GitHub account you shared them with.</p>+ <div class="ob-act">${github}</div>+ <p class="ob-small">Not shared yet? After you sign in, it shows the one step.</p></section>+ </div>+ <div class="ob-act" data-part="github" hidden>${github.replace('<a ', '<a id="local-note-go" ')}</div>+ <div class="ob-act" data-part="command" hidden>${commandBoxes('', OPEN_ASK, 'local-note')}</div>+ <div class="ob-act" data-part="open" hidden><a class="ob-big ob-go" id="local-note-view" href="${localView}/local/view">Open your board</a></div>+ <p class="ob-small" id="local-note-small" hidden></p>+ <p class="ob-live" id="local-note-live" hidden><i aria-hidden="true"></i><span></span></p>+ <div class="ob-help" id="local-note-help" hidden>${SPEECH}<span><span id="local-note-lead"></span><small id="local-note-said"></small></span><button type="button" id="local-note-help-copy" data-copy="">Copy</button></div>+ </div></section>`;}/**- * Name the browser the page runs in, for the step that lifts its block. Only Chromium browsers answer the- * local network permission the page asks about, so they are the ones a block is ever reported from.+ * Name the browser the page runs in. Only Chromium browsers answer the local network permission the page asks about,+ * so they are the ones a block is ever reported from.** @param {{userAgent?: string, userAgentData?: {brands?: {brand: string}[]}}} agent - The page's navigator.* @returns {string}@@ -50,39 +90,47 @@ export function hostedBrowser(agent) {}/**- * What the hosted page says in one state, or null for none. A "state" stands in for the board; a "note" sits- * over a list that shows; "wait" is the line on screen while the browser may ask its question.+ * What the page shows in one state, or null for none. A "state" stands in for the board, alone on the page; a "note"+ * is one quiet line over a list that shows. The words are the approved screens' own: Finding your boards, Click Allow,+ * Your browser said no and Where are your projects? on a computer, and #757's two screens, Your boards, on your phone+ * and One step on your computer, for a phone and for a person signed in with nothing shared.*- * @param {string|null} state - asking, not-running, blocked, mismatch, problem, signed-out, no-linked, unpaired, linked-failed or local-failed.- * @param {{browser?: string, linked?: string[], detail?: string}} [facts] - The browser's name, the linked boards this browser cannot open, and a refusal's own words.- * @returns {null|{state: string, kind: string, heading: string, text: string, hint?: string, command?: string, button?: string, side?: string}}+ * @param {string|null} state - looking, asking, blocked, not-running, mismatch, problem, signed-out, no-linked, unpaired, linked-failed or local-failed.+ * @param {{phone?: boolean, detail?: string}} [facts] - Whether the page runs on a phone, and a refusal's own words.+ * @returns {null|{state: string, kind: string, heading: string, text?: string, parts: string[], command?: string, ask?: string, small?: string, live?: string, lead?: string, help?: string, detail?: string}}*/export function hostedState(state, facts = {}) {- const browser = facts.browser || 'This browser';- const linked = facts.linked || [];- const chromium = ['Chrome', 'Edge', 'Opera'].includes(browser);+ const agent = 'Something not working? Ask your agent';+ const opening = 'Help me open my Pullboard board.';+ const share = { kind: 'state', heading: 'One step on your computer', text: 'On the computer with your projects, open a terminal and run this once:', parts: ['command'], command: 'pullboard relay on --all', ask: 'Help me share my boards with my phone.',+ small: 'It shares every project with your account. Your boards show up here by themselves.', live: 'Waiting for your boards' };const models = {- 'asking': { kind: 'wait', heading: 'Looking for Pullboard on this computer', text: 'Your browser may ask to let this page reach apps on this device. Allow it to open the boards running here.' },- 'not-running': { kind: 'state', heading: 'Start Pullboard on this computer', text: 'This page cannot reach a local view on this computer. Run this in a terminal, then try again.', command: 'pullboard view', hint: 'A Pullboard older than 0.8.29 cannot answer this page, so update it first with `npm i -g pullboard`.', button: 'retry', side: 'Boards on this computer show here once pullboard view runs.', offline: 'not connected' },- 'blocked': { kind: 'state', heading: 'Let this page reach Pullboard', text: browser + ' has refused this page access to apps on this device, so it cannot open the board running here.',- hint: chromium ? 'In ' + browser + ', click the icon at the left of the address bar, turn on Local network access, then try again.' : 'Allow this site to reach apps on this device in the browser\'s site settings, then try again.',- button: 'retry', side: 'Boards on this computer show here once ' + (browser === 'This browser' ? 'the browser' : browser) + ' allows it.', offline: 'not connected' },- 'mismatch': { kind: 'state', heading: 'Update Pullboard on this computer', text: 'The Pullboard view running here does not match this page. Update Pullboard, restart pullboard view, then try again.', command: 'npm i -g pullboard', button: 'retry', side: 'Boards on this computer show here once the versions match.', offline: 'not connected' },- 'problem': { kind: 'state', heading: 'Open the local view', text: facts.detail || 'This page could not take the connection the local view sent back.', button: 'view', side: 'Boards on this computer show in the local view.', offline: 'not connected' },- 'signed-out': { kind: 'state', heading: 'Sign in to pair this browser', text: 'This link pairs this browser with your boards. Sign in with GitHub to finish, and they open here.', button: 'sign-in', side: 'Your linked boards show here after you sign in.', offline: 'not signed in' },- 'no-linked': { kind: 'state', heading: 'No linked boards yet', text: 'Your account has no linked boards. Link them from the computer that runs them:', command: 'pullboard relay on --all', side: 'Linked boards show here.' },- 'unpaired': { kind: 'state', heading: 'Pair this browser', text: 'You are signed in, and your account has ' + (linked.length === 1 ? 'a linked board: ' : 'linked boards: ') + linked.join(', ') + '. Each browser pairs once before it can read ' + (linked.length === 1 ? 'it' : 'them') + '. On the computer that linked ' + (linked.length === 1 ? 'it' : 'them') + ', run this, then open the link it prints here or scan its QR:', command: 'pullboard relay on --all',- side: linked.length + (linked.length === 1 ? ' linked board waits' : ' linked boards wait') + ' for this browser to pair.' },- 'linked-failed': { kind: 'note', heading: 'Linked boards did not load', text: facts.detail || 'The relay did not answer.', button: 'retry' },- 'local-failed': { kind: 'note', heading: 'This computer\'s boards did not load', text: facts.detail || 'The local view did not answer.', button: 'retry' },+ 'looking': { kind: 'state', heading: 'Finding your boards…', parts: ['spin'] },+ 'asking': { kind: 'state', heading: 'Click Allow', text: 'Your browser is asking if this page may open the boards on this computer. Your boards stay on this computer.', parts: ['ask'],+ live: 'Waiting for you to click Allow', lead: agent, help: 'Help me allow Pullboard in my browser.' },+ 'blocked': { kind: 'state', heading: 'Your browser said no', text: 'That\'s fine. Turn it back on in three clicks:', parts: ['steps'],+ live: 'Your boards open as soon as it\'s on', lead: agent, help: 'My browser blocked Pullboard. Help me fix it.' },+ 'not-running': { kind: 'state', heading: 'Where are your projects?', parts: ['two'], live: 'Still looking on this computer', wide: true },+ 'mismatch': { kind: 'state', heading: 'Update Pullboard on this computer', text: 'The Pullboard on this computer does not match this page. Update it, and this page opens your boards by itself.', parts: ['command'],+ command: 'npm i -g pullboard', ask: opening, live: 'Still looking on this computer' },+ 'problem': { kind: 'state', heading: 'Open your board', text: facts.detail || 'This page could not take the connection Pullboard on this computer sent back.', parts: ['open'], lead: agent, help: opening },+ 'signed-out': facts.phone+ ? { kind: 'state', heading: 'Your boards, on your phone', text: 'Sign in with the GitHub account you use on your computer.', parts: ['github'], small: 'Nothing to install on your phone.',+ lead: 'Stuck? On your computer, ask your agent', help: 'Help me see my boards on my phone.' }+ : { kind: 'state', heading: 'Open them from any device', text: 'Your boards on your phone and every computer, from the GitHub account you shared them with.', parts: ['github'], small: 'Not shared yet? After you sign in, it shows the one step.' },+ 'no-linked': share,+ 'unpaired': share,+ 'linked-failed': { kind: 'note', heading: 'Shared boards did not load', text: 'They show here by themselves once they answer.', parts: [], detail: facts.detail },+ 'local-failed': { kind: 'note', heading: 'This computer\'s boards did not load', text: 'They show here by themselves once Pullboard answers.', parts: [], detail: facts.detail },};const model = state ? models[state] : null;return model ? { state, ...model } : null;}/**- * Draw one hosted state into the page, or clear it with null. A state stands in for the board, so it brings the- * Ways in panel and a line in the empty sidebar, and the relay's own banner steps aside while it speaks for it.+ * Draw one state into the page, or clear it with null. A state stands alone: the page's body takes the open-board+ * class, which hides the sidebar, the tabs and the status line until there is a board to list. The relay's own banner+ * steps aside while a state speaks for it, and comes back when the state goes.** @param {Document} doc - The page.* @param {ReturnType<typeof hostedState>} model - What to show.@@ -92,36 +140,33 @@ export function drawHosted(doc, model, place) {const $ = (id) => doc.getElementById(id);const full = Boolean(model && model.kind === 'state');const note = $('local-note');+ /** Show an element with these words, or hide it with none. */+ const say = (id, text) => { $(id).hidden = !text; $(id).textContent = text || ''; };note.hidden = !model;note.dataset.state = model ? model.state : '';- doc.body.classList.toggle('hosted-state', full);+ note.dataset.kind = model ? model.kind : '';+ note.classList.toggle('wide', Boolean(model?.wide));+ note.title = model?.detail || '';+ doc.body.classList.toggle('open-board', full);$('local-note-title').textContent = model ? model.heading : '';- $('local-note-text').textContent = model ? model.text : '';- $('local-note-hint').hidden = !model?.hint;- // A command in a hint, between backticks, is code that never breaks across lines.- $('local-note-hint').replaceChildren(...String(model?.hint || '').split('`').map((part, n) => {- if (n % 2 === 0) return doc.createTextNode(part);- const code = doc.createElement('code');- code.textContent = part;- return code;- }));- if (full && model.offline) $('live').textContent = model.offline;- $('local-note-cmd').hidden = !model?.command;+ say('local-note-text', model?.text);+ for (const part of note.querySelectorAll('[data-part]')) part.hidden = !(model?.parts || []).includes(part.dataset.part);$('local-note-code').textContent = model?.command || '';- const copy = $('local-note-copy');- copy.textContent = 'Copy';- copy.onclick = () => navigator.clipboard?.writeText(model.command).then(() => { copy.textContent = 'Copied'; }, () => { copy.textContent = 'Select and copy'; });- const button = model?.button;- $('local-note-links').hidden = !button;- $('local-note-view').hidden = button !== 'view';+ $('local-note-copy').dataset.copy = model?.command || '';+ $('local-note-ask').textContent = model?.ask ? '“' + model.ask + '”' : '';+ $('local-note-agent').dataset.copy = model?.ask || '';+ say('local-note-small', model?.small);+ $('local-note-live').hidden = !model?.live;+ $('local-note-live').lastElementChild.textContent = model?.live || '';+ $('local-note-help').hidden = !model?.help;+ $('local-note-lead').textContent = model?.lead || '';+ $('local-note-said').textContent = model?.help ? '“' + model.help + '”' : '';+ $('local-note-help-copy').dataset.copy = model?.help || '';+ for (const button of note.querySelectorAll('button[data-copy]')) button.textContent = 'Copy';$('local-note-view').href = place.view + '/local/view';- $('local-note-go').hidden = button !== 'sign-in' || !place.signIn;- $('local-note-retry').hidden = button !== 'retry';- $('local-note-sign-in').hidden = !place.signIn || place.session;- for (const link of [$('local-note-go'), $('local-note-sign-in')]) if (place.signIn) link.href = place.signIn;- $('ways-in').hidden = !full;- $('side-hint').hidden = !full || !model.side;- $('side-hint').textContent = full ? model.side || '' : '';+ for (const link of note.querySelectorAll('.ob-gh')) if (place.signIn) link.href = place.signIn;+ // A person already signed in is never asked to sign in: Where are your projects? keeps only this computer's card.+ note.querySelector('.ob-two').classList.toggle('signed-in', Boolean(place.session));// The relay's banner says what the state now says; it comes back when the state goes.const banner = $('relay-notice');if (banner && full && ['signed-out', 'no-linked', 'unpaired'].includes(model.state)) { banner.hidden = true; banner.dataset.hostedHid = '1'; }diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.jsindex 1fbda21b..1e961a41 100644--- a/test/cockpit/local-origin.test.js+++ b/test/cockpit/local-origin.test.js@@ -143,7 +143,7 @@ test('a pullboard.dev page reads the local board [N26,A2]', { timeout: 120_000 }const log = window.__localFetches = [];window.fetch = (input, init) => {const note = document.getElementById('local-note');- log.push({ url: String(typeof input === 'string' ? input : input.url), address: location.href, note: note ? !note.hidden : false, text: document.getElementById('local-note-text')?.textContent ?? '' });+ log.push({ url: String(typeof input === 'string' ? input : input.url), address: location.href, note: note ? !note.hidden : false, state: note?.dataset.state ?? '' });return nativeFetch(input, init);};})()` });@@ -161,27 +161,28 @@ test('a pullboard.dev page reads the local board [N26,A2]', { timeout: 120_000 }};const localFetches = "JSON.stringify((window.__localFetches || []).filter((entry) => entry.url.startsWith('http://127.0.0.1:')))";- // With no view on this machine, the page says why and links the local view; a person with no relay session gets- // the sign-in link and the relay module is never loaded, while one with a session gets the relay page. The browser- // has not been allowed to reach this device yet, so the page says why it may ask before it first asks.+ // With no view on this machine, the page asks where the projects are: pullboard view here, or sign in for every+ // device (#764). A person with no relay session never loads the relay module, while one with a session gets the+ // relay page. The browser has not been allowed to reach this device yet, so a screen is up before it first asks.await view.stop();await chrome.send('Page.navigate', { url: HOSTED + '/' });- await chrome.waitFor("location.search === '' && /cannot reach a local view/.test(document.querySelector('#local-note-text')?.textContent)", 20_000); // budget: hang ceiling for one refused loopback request.+ await chrome.waitFor("location.search === '' && document.querySelector('#local-note')?.dataset.state === 'not-running'", 20_000); // budget: hang ceiling for one refused loopback request.const asked = JSON.parse(await chrome.stable(localFetches));assert.equal(asked[0]?.url, LOCAL + '/local/protocol', 'the page first reads the public protocol at the default address');- assert.ok(asked[0].note && /may ask to let this page reach apps on this device/.test(asked[0].text), `the line saying why the browser may ask is on screen before that request: ${JSON.stringify(asked[0])}`);- const away = JSON.parse(await chrome.stable("JSON.stringify({ links: !document.querySelector('#local-note-links').hidden, view: document.querySelector('#local-note-view').href, signIn: document.querySelector('#local-note-sign-in').hidden ? null : document.querySelector('#local-note-sign-in').getAttribute('href') })"));- assert.deepEqual(away, { links: true, view: LOCAL + '/local/view', signIn: '/auth/github/start' }, 'an unreachable view is named, with the local view and sign-in linked');+ assert.ok(asked[0].note && ['looking', 'asking'].includes(asked[0].state), `Finding your boards, or Click Allow, is on screen before that request: ${JSON.stringify(asked[0])}`);+ const away = JSON.parse(await chrome.stable("JSON.stringify({ command: document.querySelector('#local-note .ob-two .ob-cmd button').dataset.copy, signIn: document.querySelector('#local-note .ob-two .ob-gh').getAttribute('href') })"));+ assert.deepEqual(away, { command: 'pullboard view', signIn: '/auth/github/start' }, 'nothing running here: the page offers pullboard view and sign-in');assert.equal(relayModule(), 0, 'without a relay session the relay module is never loaded');assert.equal(await chrome.stable(banner), true, 'and the relay\'s banner does not speak for it');await chrome.send('Page.navigate', { url: HOSTED + '/?relay' });- await chrome.waitFor("location.search === '?relay' && !document.querySelector('#local-note-links').hidden", 20_000); // budget: hang ceiling for one refused loopback request.+ await chrome.waitFor("location.search === '?relay' && ['blocked', 'not-running', 'no-linked'].includes(document.querySelector('#local-note')?.dataset.state)", 20_000); // budget: hang ceiling for one refused loopback request.// A browser that has since refused this page the access is named as the reason, as it is the one the page knows.- const second = JSON.parse(await chrome.stable(`(async () => JSON.stringify({ text: document.querySelector('#local-note-text').textContent, permission: await navigator.permissions.query({ name: 'loopback-network' }).then((p) => p.state, () => null) }))()`));- assert.match(second.text, second.permission === 'denied' ? /has refused this page access to apps on this device/ : /cannot reach a local view/, `the page names what it knows: ${JSON.stringify(second)}`);+ const second = JSON.parse(await chrome.stable(`(async () => JSON.stringify({ state: document.querySelector('#local-note').dataset.state, permission: await navigator.permissions.query({ name: 'loopback-network' }).then((p) => p.state, () => null) }))()`));await relayAsked(1);- assert.equal(await chrome.stable("document.querySelector('#local-note-sign-in').hidden"), true, 'a person with a relay session is not asked to sign in');- assert.equal(await chrome.stable(banner), false, 'and the relay page keeps its banner');+ // This stand-in serves no relay client, so a signed-in page stays on the screen that waits for this computer.+ assert.ok(second.permission === 'denied' ? second.state === 'blocked' : ['not-running', 'no-linked'].includes(second.state), `the page shows what it knows: ${JSON.stringify(second)}`);+ assert.equal(await chrome.stable("[...document.querySelectorAll('#local-note .ob-gh')].every((link) => link.getClientRects().length === 0)"), true, 'a person with a relay session is not asked to sign in');+ assert.equal(await chrome.stable("document.querySelector('#relay-notice').getClientRects().length"), 0, 'and the screen stands alone, without the relay page\'s banner');// A relay pairing link stays the relay's: the page does not look for this machine on that load.await chrome.send('Page.navigate', { url: HOSTED + '/#board=b1&key=k1' });await relayAsked(2);@@ -199,7 +200,7 @@ test('a pullboard.dev page reads the local board [N26,A2]', { timeout: 120_000 }await new Promise((ready) => other.listen(0, '127.0.0.1', ready));local.target = 'http://127.0.0.1:' + other.address().port;await chrome.send('Page.navigate', { url: HOSTED + '/?other' });- await chrome.waitFor("location.search === '?other' && /does not match this page/.test(document.querySelector('#local-note-text')?.textContent)", 20_000); // budget: hang ceiling for one loopback request.+ await chrome.waitFor("location.search === '?other' && document.querySelector('#local-note')?.dataset.state === 'mismatch'", 20_000); // budget: hang ceiling for one loopback request.assert.equal(trips(), 0, 'no round trip starts toward a view the page cannot use');// This machine's view: the page finds it at the default address, goes round for its secret, and reads the board.@@ -345,10 +346,8 @@ test('a signed-in local view with linked metadata and no paired transport says hassert.ok(seen.fetches.some((x) => x.origin === 'https://app.pullboard.dev' && x.path === '/api/v1/boards' && x.status === 200), 'the hosted page read the signed-in account metadata');assert.equal(seen.state, 'unpaired', `linked account metadata with no paired transport must show pairing guidance, not the generic local empty state: ${JSON.stringify(seen)}`);assert.equal(seen.hidden, false);- assert.equal(seen.heading, 'Pair this browser');- assert.match(seen.text, /acme\/web/);+ assert.equal(seen.heading, 'One step on your computer', 'the one step #757 names for a person with nothing open here');assert.equal(seen.command, 'pullboard relay on --all');- assert.match(seen.text, /scan its QR/, 'the pairing guidance tells the person to use the QR printed by relay on --all');assert.equal(seen.cards, 0, 'no local or paired board is falsely shown');assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught exceptions');} finally {@@ -484,10 +483,10 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tconst tokens = ['--accent-strong', '--ink', '--ink-muted', '--surface'].map((token) => { probe.style.color = 'var(' + token + ')'; return getComputedStyle(probe).color; });probe.remove();return {- state: document.getElementById('local-note').dataset.state, heading: text('local-note-title'), text: text('local-note-text'), hint: text('local-note-hint'), command: text('local-note-code'),- steps: [...document.querySelectorAll('#local-note-links a, #local-note-links button')].filter(on).map((step) => [step.textContent.trim(), step.getAttribute('href')]),- ways: on(document.getElementById('ways-in')) ? [...document.querySelectorAll('#ways-in dt')].map((title) => title.textContent) : null,- waysText: text('ways-in'), side: document.getElementById('side-hint').hidden ? null : document.getElementById('side-hint').textContent, banner: on(document.getElementById('relay-notice')), browser: hostedBrowser(navigator),+ state: document.getElementById('local-note').dataset.state, heading: text('local-note-title'), text: text('local-note-text'), command: text('local-note-code'),+ steps: [...document.querySelectorAll('#local-note a, #local-note button')].filter(on).map((step) => [step.textContent.trim(), step.getAttribute('href')]),+ cards: [...document.querySelectorAll('#local-note .ob-card h2')].filter(on).map((title) => title.textContent),+ side: on(document.querySelector('.side')), banner: on(document.getElementById('relay-notice')), browser: hostedBrowser(navigator),defaults: [...document.querySelectorAll('*')].filter((element) => ['rgb(0, 0, 238)', 'rgb(85, 26, 139)'].includes(getComputedStyle(element).color)).map((element) => element.outerHTML.slice(0, 80)),bare: [...document.querySelectorAll('a')].filter((link) => on(link) && !link.className && !tokens.includes(getComputedStyle(link).color)).map((link) => link.outerHTML.slice(0, 80)),};@@ -527,45 +526,39 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tawait proofShot(chrome, 'hosted-' + state, 1280);assert.deepEqual(seen.defaults, [], `${state}: no element keeps the browser's default link colours`);assert.deepEqual(seen.bare, [], `${state}: every link has a class or the view's colours`);- assert.deepEqual(seen.ways, ['The local view', 'This computer through pullboard.dev', 'Your phone and other devices', 'A second computer'], `${state}: the Ways in panel lists every route`);- for (const command of ['pullboard view', 'pullboard relay on --all', 'pullboard relay pair', 'pullboard relay join <code>']) assert.ok(seen.waysText.includes(command), `${state}: Ways in names ${command}`);- assert.ok(seen.side, `${state}: the empty sidebar says what fills it`);+ // Each state is one open-board screen (#764): alone, with no sidebar and no Try again; the page looks again by itself.+ assert.equal(seen.side, false, `${state}: the sidebar waits until there is a board to list`);+ assert.ok(!seen.steps.some(([label]) => label === 'Try again'), `${state}: no Try again`);await styledControls(state);return seen;};- const retry = [['Try again', null]];-const blocked = await open('?blocked', 'blocked');- assert.equal(blocked.heading, 'Let this page reach Pullboard');- assert.match(blocked.text, new RegExp('^' + blocked.browser + ' has refused this page access to apps on this device'), 'the line names the browser and what it refused');+ assert.equal(blocked.heading, 'Your browser said no');+ assert.equal(blocked.text, 'That\'s fine. Turn it back on in three clicks:', 'the line leads to the steps that lift the block');assert.equal(blocked.browser, 'Chrome', 'the fixture Chrome is named as Chrome');- assert.match(blocked.hint ?? '', /^In Chrome, click the icon at the left of the address bar, turn on Local network access, then try again\.$/, 'the step is the one for this browser');- assert.deepEqual(blocked.steps, retry, 'and its button tries again');+ assert.deepEqual(blocked.steps.map(([label]) => label), ['', 'Copy'], 'its one control copies the sentence for the agent, beside the theme toggle');const absent = await open('?absent', 'not-running');- assert.equal(absent.heading, 'Start Pullboard on this computer');- assert.match(absent.text, /cannot reach a local view on this computer/);- assert.equal(absent.command, 'pullboard view', 'the next step is the command that starts the local view');- assert.deepEqual(absent.steps, retry);- assert.equal(await chrome.stable("document.querySelector('#local-note-copy').textContent"), 'Copy', 'the command has a copy button');+ assert.equal(absent.heading, 'Where are your projects?');+ assert.deepEqual(absent.cards, ['Open them on this computer', 'Open them from any device'], 'the two ways in, as two cards');+ assert.equal(await chrome.stable("document.querySelector('#local-note .ob-two .ob-cmd button').dataset.copy"), 'pullboard view', 'the command that starts Pullboard here has a copy button');assert.equal(absent.banner, false, 'the relay\'s banner stays out of it');const out = await open('?out#board=' + 'b'.repeat(32) + '&key=k1', 'signed-out');- assert.equal(out.heading, 'Sign in to pair this browser');- assert.deepEqual(out.steps, [['Sign in with GitHub', '/auth/github/start']], 'the next step is signing in');+ assert.equal(out.heading, 'Open them from any device');+ assert.deepEqual(out.steps.filter(([, href]) => href), [['Sign in with GitHub', '/auth/github/start']], 'the next step is signing in');assert.equal(out.banner, false, 'the state speaks for the relay\'s banner');stand.signedIn = true;const none = await open('?in', 'no-linked');- assert.equal(none.heading, 'No linked boards yet');+ assert.equal(none.heading, 'One step on your computer');assert.equal(none.command, 'pullboard relay on --all', 'the next step links the boards');assert.equal(none.banner, false);- assert.equal(await chrome.stable("document.querySelector('#local-note-sign-in').hidden"), true, 'a signed-in person is not asked to sign in');+ assert.equal(await chrome.stable("[...document.querySelectorAll('#local-note .ob-gh')].every((link) => link.getClientRects().length === 0)"), true, 'a signed-in person is not asked to sign in');stand.linked = [{ id: 'a'.repeat(32), repository: 'acme/web', linkedAt: 0 }];const unpaired = await open('?linked', 'unpaired');- assert.equal(unpaired.heading, 'Pair this browser');- assert.match(unpaired.text, /^You are signed in, .*acme\/web\. Each browser pairs once before it can read it\..*scan its QR:$/, 'the line says the person is signed in, names the board, that each browser pairs once, and the QR');+ assert.equal(unpaired.heading, 'One step on your computer');assert.equal(unpaired.command, 'pullboard relay on --all', 'the next step prints the QR');// This machine's view: the normal list, with no state over it.@@ -582,13 +575,11 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tawait new Promise((ready) => old.listen(0, '127.0.0.1', ready));stand.local = 'http://127.0.0.1:' + old.address().port;const outdated = await open('?old', 'not-running');- assert.equal(outdated.heading, 'Start Pullboard on this computer');- assert.equal(outdated.hint, 'A Pullboard older than 0.8.29 cannot answer this page, so update it first with npm i -g pullboard.', 'the state names the update an old view needs');- assert.deepEqual(outdated.steps, retry);+ assert.equal(outdated.heading, 'Where are your projects?', 'a view too old to answer reads as none');stand.local = view.base;await chrome.send('Page.navigate', { url: HOSTED + '/?list' });await chrome.waitFor("location.origin === 'https://app.pullboard.dev' && document.querySelector('#chain')?.textContent.includes('A board the hosted page lists')", 30_000); // budget: hang ceiling for the discovery, one round trip and the first board read.- const list = JSON.parse(await chrome.stable(`JSON.stringify({ note: document.querySelector('#local-note').hidden, ways: document.querySelector('#ways-in').hidden, heading: document.querySelector('#proj-list .proj.on .pname')?.textContent, source: document.querySelector('#proj-list .proj.on .src')?.textContent, tab: document.querySelector('.tab.on')?.textContent, step: document.querySelector('#new-item').getClientRects().length > 0, side: document.querySelector('#side-hint').hidden, state: JSON.parse(${shown}) })`));+ const list = JSON.parse(await chrome.stable(`JSON.stringify({ note: document.querySelector('#local-note').hidden, side: document.querySelector('.side').getClientRects().length > 0, heading: document.querySelector('#proj-list .proj.on .pname')?.textContent, source: document.querySelector('#proj-list .proj.on .src')?.textContent, tab: document.querySelector('.tab.on')?.textContent, step: document.querySelector('#new-item').getClientRects().length > 0, state: JSON.parse(${shown}) })`));// Normal-list next actions use the view styles at both sizes and in both themes (outside review 950).for (const width of [390, 1280]) {await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });@@ -616,7 +607,7 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { t}await chrome.stable('delete document.documentElement.dataset.theme');await styledControls('list');- assert.deepEqual({ note: list.note, ways: list.ways, side: list.side }, { note: true, ways: true, side: true }, 'the list shows with no state, panel or hint over it');+ assert.deepEqual({ note: list.note, side: list.side }, { note: true, side: true }, 'the list shows with its sidebar and no state over it');assert.equal(list.heading, 'hosted-states', 'the sidebar names the board shown');assert.equal(list.source, 'this computer', 'with a quiet label for where it comes from');assert.equal(list.tab, 'Items', 'its items are open');diff --git a/test/cockpit/open-board.test.js b/test/cockpit/open-board.test.jsnew file mode 100644index 00000000..fe885fe1--- /dev/null+++ b/test/cockpit/open-board.test.js@@ -0,0 +1,315 @@+/** Opening your board from pullboard.dev: one clear screen at a time, in the approved words, moving on by itself [N26,H5]. */+import assert from 'node:assert/strict';+import { request } from 'node:http';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { test } from 'node:test';+import { cockpitPage } from '../../src/cockpit.js';+import { Refused } from '../../src/refused.js';+import { createRelayBrowserHandler } from '../../relay/browser-page.js';+import { RELAY_SCREEN_WORDS } from '../../relay/browser-notice.js';+import { machine, project, startView, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, proofShot, press } from './fixture.js';++const HOSTED = 'https://app.pullboard.dev';+const LOCAL = 'http://127.0.0.1:4890';+const NO_JARGON = /local view|relay|linked|try again/i;++/** One plain HTTP request to a view, with exactly these headers, following nothing. */+function call(base, path, { method = 'GET', headers = {} } = {}) {+ return new Promise((done, fail) => {+ const outgoing = request(new URL(path, base), { method, headers, agent: false }, (res) => {+ const chunks = [];+ res.on('data', (chunk) => chunks.push(chunk));+ res.on('end', () => done({ status: res.statusCode, headers: res.headers, body: Buffer.concat(chunks) }));+ });+ outgoing.on('error', fail);+ outgoing.end();+ });+}++/**+ * Stand in for app.pullboard.dev and this computer's default view address inside one Chrome. Documents come from the+ * relay's real page handler, or, for an address with ?plain, the view's own page without the relay's screens. A+ * request to 127.0.0.1:4890 is refused while no view runs, held while the browser is asking (as Chrome holds it until+ * the person answers), and otherwise passed to the view the test started on its own port.+ */+async function openBoardStand(chrome, view) {+ const stand = { signedIn: false, linked: [], local: null, hold: false, held: [], failures: [] };+ const client = 'export function rememberPairing() { return null; }\nexport async function createTransport() { return { async request(path) { if (path === "/api/v1/boards") return { version: 1, boards: [], warnings: [] }; throw new Error("no paired board"); } }; }\n';+ const relay = createRelayBrowserHandler({ authenticate: async () => { if (stand.signedIn) return { kind: 'session' }; throw new Refused('AUTH_REQUIRED', 'Sign in.'); } });+ const send = (requestId, status, headers, body) => chrome.send('Fetch.fulfillRequest', { requestId, responseCode: status, responseHeaders: headers, body: Buffer.from(body).toString('base64') });+ const fulfil = (requestId, type, body, extra = []) => send(requestId, 200, [{ name: 'Content-Type', value: type }, { name: 'Cache-Control', value: 'no-store' }, ...extra], body);+ /** Answer one request to this computer's default view address from the view the test runs. */+ const toView = async ({ requestId, asked, address }) => {+ if (!stand.local) return chrome.send('Fetch.failRequest', { requestId, errorReason: 'ConnectionRefused' });+ const reply = await call(stand.local, address.pathname + address.search, { method: asked.method, headers: Object.fromEntries(Object.entries(asked.headers).filter(([name]) => name.toLowerCase() !== 'host')) });+ return send(requestId, reply.status, Object.entries(reply.headers).filter(([name]) => !['content-length', 'transfer-encoding', 'connection', 'keep-alive', 'date'].includes(name)).map(([name, value]) => ({ name, value: String(value) })), reply.body);+ };+ const listener = ({ data }) => {+ const message = JSON.parse(String(data));+ if (message.method !== 'Fetch.requestPaused') return;+ const { requestId, request: asked } = message.params;+ const address = new URL(asked.url);+ (async () => {+ if (address.origin === LOCAL) {+ if (stand.hold) { stand.held.push({ requestId, asked, address }); return; }+ return toView({ requestId, asked, address });+ }+ if (address.pathname === '/relay/client.js') return fulfil(requestId, 'text/javascript', client);+ if (address.pathname === '/api/v1/boards') return fulfil(requestId, 'application/json', JSON.stringify({ version: 1, boards: stand.linked, warnings: [] }));+ const connect = "connect-src 'self' " + LOCAL + ' http://localhost:4890 ' + view.base;+ if (address.pathname === '/' && address.search.startsWith('?plain')) {+ // A phone, as the relay's page names it before first paint (#757), for the view's own drawing of its screens.+ const page = cockpitPage('', { readOnly: true, requests: stand.signedIn, transportModule: stand.signedIn ? '/relay/client.js' : '/relay/sign-in.js', apiHeaders: {}, stylesheet: '/view.css', hostedLocal: true, relaySession: stand.signedIn, signIn: '/auth/github/start' })+ .replace('</head>', address.search.includes('phone') ? "<script>document.documentElement.dataset.relayDevice = 'phone';</script>\n</head>" : '</head>');+ return fulfil(requestId, 'text/html; charset=utf-8', page, [{ name: 'Content-Security-Policy', value: connect + "; frame-ancestors 'none'" }]);+ }+ let head = {}, body = '';+ const handled = await relay({ method: 'GET', url: address.pathname, headers: {} }, { writeHead: (status, headers) => { head = headers; }, end: (content) => { body = content ?? ''; } });+ if (!handled) return chrome.send('Fetch.failRequest', { requestId, errorReason: 'Failed' });+ return fulfil(requestId, head['content-type'], body, [{ name: 'Content-Security-Policy', value: head['content-security-policy'].replace("connect-src 'self'", "connect-src 'self' " + view.base) }]);+ })().catch((error) => stand.failures.push(error.message));+ };+ chrome.socket.addEventListener('message', listener);+ await chrome.send('Fetch.enable', { patterns: [{ urlPattern: HOSTED + '/*', requestStage: 'Request' }, { urlPattern: LOCAL + '/*', requestStage: 'Request' }] });+ // The browser's answer about local network access, per load: ?asking asks, ?blocked has said no, anything else allows.+ // window.__access changes the answer on an open page, as the person does in the browser's settings. While the browser+ // asks, the discovery request waits as long as the person does, so its timeout never fires on those loads.+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `(() => {+ if (location.origin !== ${JSON.stringify(HOSTED)}) return;+ const search = location.search;+ window.__access = search.startsWith('?asking') ? 'prompt' : search.startsWith('?blocked') ? 'denied' : 'granted';+ const query = navigator.permissions.query.bind(navigator.permissions);+ navigator.permissions.query = (asked) => ['loopback-network', 'local-network-access'].includes(asked?.name) ? Promise.resolve({ state: window.__access }) : query(asked);+ if (search.startsWith('?asking') || search.startsWith('?looking')) AbortSignal.timeout = () => new AbortController().signal;+ })()` });+ // Chrome itself lets the page reach the view's own port, where the round trip sends it; what the page hears of the+ // permission is the override above. Its names differ between Chrome versions, so the widest set this one knows is used.+ for (const permissions of [['loopbackNetwork', 'localNetwork', 'localNetworkAccess'], ['localNetworkAccess']]) {+ try { await chrome.send('Browser.grantPermissions', { origin: HOSTED, permissions }); break; } catch { /* a name this Chrome does not have */ }+ }+ /** Let every held request through, as the person clicking Allow does. */+ stand.release = async () => {+ stand.hold = false;+ const held = stand.held.splice(0);+ for (const entry of held) await toView(entry);+ };+ /** Stop serving the stand-in. */+ stand.stop = async () => {+ chrome.socket.removeEventListener('message', listener);+ await chrome.send('Fetch.disable');+ };+ return stand;+}++// What one open-board screen shows: its state, every visible heading, the words a person reads, what stands around it,+// and the parts the approved screens are made of, with their sizes and colours.+const SHOWN = `JSON.stringify((() => {+ const on = (element) => Boolean(element) && element.getClientRects().length > 0 && getComputedStyle(element).visibility !== 'hidden';+ const all = (selector) => [...document.querySelectorAll(selector)].filter(on);+ const height = (element) => Math.round(element.getBoundingClientRect().height);+ const note = document.getElementById('local-note');+ const copy = (element) => element.querySelector('button')?.dataset.copy ?? null;+ return {+ state: note.dataset.state, shown: on(note),+ headings: all('h1, h2, h3').map((heading) => heading.textContent.trim()),+ say: on(document.getElementById('local-note-text')) ? document.getElementById('local-note-text').textContent.trim() : null,+ text: document.body.innerText,+ around: ['.side', '.top', '.status', '#relay-notice', '.first', '#relay-screen', '#proj-switch', '[data-pane]'].filter((selector) => all(selector).length),+ cards: all('#local-note .ob-card').map((card) => ({ kind: card.querySelector('.ob-k').textContent, title: card.querySelector('h2').textContent, text: card.textContent, width: Math.round(card.getBoundingClientRect().width), height: height(card) })),+ commands: all('#local-note .ob-cmd').map((box) => ({ code: box.querySelector('code').textContent.trim(), copy: copy(box), mono: /mono|Menlo|Consolas/i.test(getComputedStyle(box.querySelector('code')).fontFamily), height: height(box) })),+ agents: all('#local-note .ob-agent').map((box) => ({ text: box.textContent.replace(/Copy$/, '').trim(), copy: copy(box), height: height(box) })),+ help: all('#local-note .ob-help').map((strip) => ({ text: strip.textContent.replace(/Copy$/, '').trim(), copy: copy(strip), border: getComputedStyle(strip).borderTopStyle })),+ github: all('#local-note .ob-gh').map((button) => ({ text: button.textContent.trim(), href: button.getAttribute('href'), height: height(button), background: getComputedStyle(button).backgroundColor })),+ live: all('#local-note .ob-live').map((line) => line.textContent.trim()),+ ask: all('#local-note .ob-ask').map((bubble) => bubble.textContent.replace(/\\s+/g, ' ').trim()),+ steps: all('#local-note .ob-steps li').map((step) => step.textContent.trim()),+ small: all('#local-note .ob-small').map((line) => line.textContent.trim()),+ spin: all('#local-note .ob-spin').length,+ theme: on(document.getElementById('ob-theme')) && Boolean(document.getElementById('ob-theme').closest('header')),+ controls: all('button, a').map((control) => control.textContent.trim()),+ };+})())`;++/** Open the stand-in page at this address, wait for the open-board state it should settle in, and read it. */+async function openState(chrome, address, state, shot) {+ await chrome.send('Page.navigate', { url: HOSTED + '/' + address });+ await chrome.waitFor(`location.search === ${JSON.stringify(address.split('#')[0])} && document.querySelector('#local-note')?.dataset.state === ${JSON.stringify(state)} && !document.querySelector('#local-note').hidden`, 20_000); // budget: hang ceiling for one page load and one refused or held loopback request.+ const seen = JSON.parse(await chrome.stable(SHOWN));+ if (shot) {+ await proofShot(chrome, shot + '-phone', 390);+ await proofShot(chrome, shot, 1280);+ }+ return seen;+}++/** The checks every open-board screen passes: shown alone, one heading, no Try again and none of the old jargon. */+function alone(seen, heading, { allow = '' } = {}) {+ assert.equal(seen.shown, true, `${seen.state}: the screen shows`);+ assert.deepEqual(seen.headings.filter((text) => !seen.cards.some((card) => card.title === text)), [heading], `${seen.state}: one heading, never stacked with another`);+ assert.deepEqual(seen.around, [], `${seen.state}: no sidebar, Projects header, tabs, status line, banner or board stands beside it`);+ assert.doesNotMatch(allow ? seen.text.split(allow).join('') : seen.text, NO_JARGON, `${seen.state}: no Try again, local view, relay or linked in the words a person reads`);+ assert.ok(!seen.controls.includes('Try again'), `${seen.state}: no Try again button`);+ assert.equal(seen.theme, true, `${seen.state}: the theme toggle sits in the header`);+}++test('each open-board state shows alone with its words [N26,H5]', { timeout: 120_000 }, async () => { // budget: hang ceiling for seven hosted page loads in Chrome with screenshots at two widths.+ const executable = chromeExecutable();+ assert.ok(executable, 'the open-board check needs real Chrome');+ const box = machine();+ project(box, 'open-board-states');+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-open-board-'));+ let view, chrome, stand;+ try {+ view = await startView(box);+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);+ stand = await openBoardStand(chrome, view);+ // A computer's window, wide enough for the two cards to stand side by side.+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });++ // Finding your boards: the page looks on this computer, and the answer has not come yet.+ stand.hold = true;+ const looking = await openState(chrome, '?looking', 'looking', 'open-board-looking');+ alone(looking, 'Finding your boards…');+ assert.equal(looking.spin, 1, 'a spinner turns while it looks');+ assert.deepEqual([looking.say, looking.commands, looking.github, looking.help], [null, [], [], []], 'and there is nothing to do yet');+ await stand.release();++ // Click Allow: the browser asks, the page draws its prompt and waits for the person.+ stand.hold = true;+ const asking = await openState(chrome, '?asking', 'asking', 'open-board-asking');+ alone(asking, 'Click Allow');+ assert.equal(asking.say, 'Your browser is asking if this page may open the boards on this computer. Your boards stay on this computer.');+ assert.equal(asking.ask.length, 1, 'the browser\'s prompt is drawn');+ assert.match(asking.ask[0], /^app\.pullboard\.dev wants to Access other apps and services on this device Block Allow ↑ click this$/, 'with its words and the button to click');+ assert.deepEqual(asking.live, ['Waiting for you to click Allow'], 'a live line says the page waits');+ assert.deepEqual(asking.help, [{ text: 'Something not working? Ask your agent“Help me allow Pullboard in my browser.”', copy: 'Help me allow Pullboard in my browser.', border: 'dashed' }], 'a dashed help strip ends the screen with a sentence to copy');+ await press(chrome, "document.querySelector('#local-note .ob-help button')");+ await chrome.waitFor("document.querySelector('#local-note .ob-help button').textContent === 'Copied'", 5_000); // budget: hang ceiling for one clipboard write.+ // The theme toggle in the header turns the page to the other scheme.+ const before = await chrome.stable('document.documentElement.dataset.scheme');+ await press(chrome, "document.getElementById('ob-theme')");+ assert.equal(await chrome.stable('document.documentElement.dataset.scheme'), before === 'dark' ? 'light' : 'dark', 'the header\'s toggle changes the theme');+ await chrome.stable("(() => { localStorage.removeItem('pb.theme'); return true; })()");+ stand.held.splice(0);+ stand.hold = false;++ // Your browser said no: three steps, then the page carries on by itself.+ const blocked = await openState(chrome, '?blocked', 'blocked', 'open-board-blocked');+ alone(blocked, 'Your browser said no');+ assert.equal(blocked.say, 'That\'s fine. Turn it back on in three clicks:');+ assert.deepEqual(blocked.steps, ['Click the icon left of the address, at the top of this window.', 'Find Local network access, or Apps on this device.', 'Set it to Allow.'], 'three steps');+ assert.deepEqual(blocked.live, ['Your boards open as soon as it\'s on']);+ assert.deepEqual(blocked.help, [{ text: 'Something not working? Ask your agent“My browser blocked Pullboard. Help me fix it.”', copy: 'My browser blocked Pullboard. Help me fix it.', border: 'dashed' }]);++ // Where are your projects: nothing runs here and nobody is signed in, so two equal cards say how the paths differ.+ const absent = await openState(chrome, '?absent', 'not-running', 'open-board-where');+ alone(absent, 'Where are your projects?');+ assert.deepEqual(absent.cards.map((card) => [card.kind, card.title]), [['Local only', 'Open them on this computer'], ['Everywhere', 'Open them from any device']], 'the two cards, local only first');+ assert.match(absent.cards[0].text, /Your boards stay on this computer, and only this computer sees them\. Open a terminal and run:/);+ assert.match(absent.cards[0].text, /Either way, this page opens your boards by itself\./);+ assert.match(absent.cards[1].text, /Your boards on your phone and every computer, from the GitHub account you shared them with\./);+ assert.match(absent.cards[1].text, /Not shared yet\? After you sign in, it shows the one step\./);+ assert.ok(Math.abs(absent.cards[0].width - absent.cards[1].width) <= 1 && Math.abs(absent.cards[0].height - absent.cards[1].height) <= 1, `the cards are equal: ${JSON.stringify(absent.cards.map((card) => [card.width, card.height]))}`);+ assert.deepEqual(absent.commands, [{ code: '$pullboard view', copy: 'pullboard view', mono: true, height: 60 }], 'pullboard view in a mono box with a Copy button');+ assert.deepEqual(absent.agents, [{ text: 'Ask your agent“Help me open my Pullboard board.”', copy: 'Help me open my Pullboard board.', height: 60 }], 'its "or" box asks the agent, at the same height');+ assert.deepEqual(absent.github, [{ text: 'Sign in with GitHub', href: '/auth/github/start', height: 60, background: 'rgb(31, 35, 40)' }], 'one dark 60 px GitHub button');+ assert.deepEqual(absent.live, ['Still looking on this computer'], 'a live line says the page keeps looking');+ await press(chrome, "document.querySelector('#local-note .ob-cmd button')");+ await chrome.waitFor("document.querySelector('#local-note .ob-cmd button').textContent === 'Copied'", 5_000); // budget: hang ceiling for one clipboard write.++ // A pairing link on a computer, not signed in: the one way that opens boards from any device.+ const out = await openState(chrome, '?out#board=' + 'b'.repeat(32) + '&key=k1', 'signed-out', 'open-board-sign-in');+ alone(out, 'Open them from any device');+ assert.deepEqual(out.github.map((button) => [button.text, button.href, button.height]), [['Sign in with GitHub', '/auth/github/start', 60]]);++ // The phone's first screen, drawn by the view from the state #757 provides: one GitHub button, nothing about this computer.+ const phone = await openState(chrome, '?plain-phone#board=' + 'b'.repeat(32) + '&key=k1', 'signed-out', 'open-board-phone');+ const words = RELAY_SCREEN_WORDS;+ alone(phone, words.signIn.title);+ assert.equal(phone.say, words.signIn.say);+ assert.deepEqual(phone.github.map((button) => [button.text, button.height, button.background]), [[words.signIn.action, 60, 'rgb(31, 35, 40)']], 'one dark GitHub button');+ assert.deepEqual(phone.small, [words.signIn.small]);+ assert.deepEqual(phone.help.map((strip) => [strip.text, strip.copy, strip.border]), [[words.signIn.help + '“' + words.signIn.ask + '”', words.signIn.ask, 'dashed']]);+ assert.doesNotMatch(phone.text, /this computer|pullboard view/i, 'a phone hears nothing about this computer or pullboard view');++ // Signed in with nothing shared: the one step on the computer with the projects, and a live waiting line.+ stand.signedIn = true;+ const share = await openState(chrome, '?in', 'no-linked', 'open-board-share');+ alone(share, words.share.title, { allow: words.share.command });+ assert.equal(share.say, words.share.say);+ assert.deepEqual(share.commands.map((command) => [command.code, command.copy, command.height]), [['$' + words.share.command, words.share.command, 60]]);+ assert.deepEqual(share.agents.map((agent) => [agent.text, agent.copy, agent.height]), [[words.share.agent + '“' + words.share.ask + '”', words.share.ask, 60]]);+ assert.deepEqual(share.small, [words.share.small]);+ assert.deepEqual(share.live, [words.share.waiting]);+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught exceptions');+ assert.deepEqual(stand.failures, [], 'the stand-in hosted page was served');+ } finally {+ try { if (stand) await stand.stop(); }+ finally {+ try { if (chrome) await closeSnapshotChrome(chrome); }+ finally {+ try { if (view) await view.stop(); }+ finally { rmSync(profile, { recursive: true, force: true }); }+ }+ }+ }+});++test('the page moves on by itself when the view starts [N26,H5]', { timeout: 120_000 }, async () => { // budget: hang ceiling for two hosted loads, a view start, a round trip and the first board reads.+ const executable = chromeExecutable();+ assert.ok(executable, 'the open-board check needs real Chrome');+ const box = machine();+ const board = project(box, 'open-board-moves');+ box.run(board.repo, 'add', 'web', 'A board that opens by itself', '--specs', 'G1');+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-open-board-moves-'));+ let view, chrome, stand;+ try {+ // A view runs only to give the stand-in its address; the page cannot reach it until the test says so.+ view = await startView(box);+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);+ stand = await openBoardStand(chrome, view);+ // Count every press and click, so the move is shown to need none.+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: "(() => { window.__clicks = 0; addEventListener('pointerdown', () => { window.__clicks += 1; }, true); addEventListener('click', () => { window.__clicks += 1; }, true); })()" });+ const opened = "location.origin === 'https://app.pullboard.dev' && document.querySelector('#chain')?.textContent.includes('A board that opens by itself')";++ // Nothing runs here: Where are your projects?, with its live line. Then the view starts, and the board opens.+ const absent = await openState(chrome, '?absent', 'not-running');+ assert.deepEqual(absent.live, ['Still looking on this computer']);+ assert.ok(!absent.controls.includes('Try again'), 'there is no Try again to press');+ stand.local = view.base;+ await chrome.waitFor(opened, 30_000); // budget: hang ceiling for the next re-check, one round trip and the first board read.+ const shown = JSON.parse(await chrome.stable("JSON.stringify({ note: document.getElementById('local-note').hidden, side: document.querySelector('.side').getClientRects().length > 0, clicks: window.__clicks })"));+ assert.deepEqual(shown, { note: true, side: true, clicks: 0 }, 'the board shows with its sidebar, the open-board screen gone, and nobody clicked');++ // The browser asks: the discovery waits, as Chrome holds it, and the page says so. The person allows it, and the+ // board opens with no click on the page.+ stand.hold = true;+ await chrome.stable("(() => { sessionStorage.clear(); return true; })()");+ const asking = await openState(chrome, '?asking', 'asking');+ assert.deepEqual(asking.live, ['Waiting for you to click Allow']);+ await chrome.stable("(() => { window.__access = 'granted'; return true; })()");+ await stand.release();+ await chrome.waitFor(opened, 30_000); // budget: hang ceiling for the released discovery and the first board read.+ assert.equal(await chrome.stable('window.__clicks'), 0, 'nobody clicked on the page');++ // The browser said no: once the person turns access back on, the page carries on by itself.+ await chrome.stable("(() => { sessionStorage.clear(); return true; })()");+ await openState(chrome, '?blocked', 'blocked');+ await chrome.stable("(() => { window.__access = 'granted'; return true; })()");+ await chrome.waitFor(opened, 30_000); // budget: hang ceiling for the next re-check and the first board read.+ assert.equal(await chrome.stable('window.__clicks'), 0, 'nobody clicked on the page');+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught exceptions');+ assert.deepEqual(stand.failures, [], 'the stand-in hosted page was served');+ } finally {+ try { if (stand) await stand.stop(); }+ finally {+ try { if (chrome) await closeSnapshotChrome(chrome); }+ finally {+ try { if (view) await view.stop(); }+ finally { rmSync(profile, { recursive: true, force: true }); }+ }+ }+ }+});