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
fix(view): one local discovery request; every control styled [N26,H5]
Corey Olsonb0ddea4390de
diff --git a/src/cockpit.js b/src/cockpit.jsindex 3861bfe2..7f358aef 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -367,10 +367,9 @@ async function connectLocal() {let reply;try { reply = await fetch(base + '/local/protocol', { signal: AbortSignal.timeout(3000), credentials: 'omit', redirect: 'error' }); }catch {- // A view from before 0.8.29 answers without the header that lets this page read it; an opaque answer still- // says something listens there, where a closed port answers nothing at all.- const listening = await fetch(base + '/local/protocol', { mode: 'no-cors', signal: AbortSignal.timeout(3000), credentials: 'omit' }).then(() => true, () => false);- localNote(listening ? 'too-old' : 'not-running');+ // 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');return 'unreachable';}let protocol = null;diff --git a/src/view.css b/src/view.cssindex 4424d35d..c332ce47 100644--- a/src/view.css+++ b/src/view.css@@ -146,6 +146,7 @@ a.ghost { color: var(--ink); }.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-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; }diff --git a/src/view/hosted.js b/src/view/hosted.jsindex 8c5f04c0..bd65cf09 100644--- a/src/view/hosted.js+++ b/src/view/hosted.js@@ -24,8 +24,8 @@ const WAYS_IN = [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><p class="hosted-hint" id="local-note-hint" hidden></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>+ <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></section>`;@@ -53,7 +53,7 @@ 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.*- * @param {string|null} state - asking, not-running, blocked, mismatch, too-old, problem, signed-out, no-linked, unpaired, linked-failed or local-failed.+ * @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}}*/@@ -63,12 +63,11 @@ export function hostedState(state, facts = {}) {const chromium = ['Chrome', 'Edge', 'Opera'].includes(browser);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', button: 'retry', side: 'Boards on this computer show here once pullboard view runs.', offline: 'not connected' },+ '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' },- 'too-old': { kind: 'state', heading: 'Update Pullboard on this computer', text: 'Something answered at the local view\'s address without the connection this page needs, as a Pullboard older than 0.8.29 does. Update Pullboard, restart pullboard view, then try again.', command: 'npm i -g pullboard', button: 'retry', side: 'Boards on this computer show here once Pullboard is updated.', 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.' },diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.jsindex fa39c853..b731ed9e 100644--- a/test/cockpit/local-origin.test.js+++ b/test/cockpit/local-origin.test.js@@ -493,6 +493,32 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { t};})())`;/** Open the hosted page at this address and read the state it settles in. */+ // Every visible control beside a reference of its own kind that sees only the browser's own styles: a control that+ // matches it on appearance, background, border and radius is a native default the view never styled.+ const native = `JSON.stringify((() => {+ const host = document.body.appendChild(document.createElement('div'));+ const root = host.attachShadow({ mode: 'open' });+ const signature = (element) => { const style = getComputedStyle(element); return [style.appearance, style.backgroundColor, style.borderTopStyle, style.borderTopWidth, style.borderRadius].join(' | '); };+ const found = [...document.querySelectorAll('button, input, select, textarea')].filter((element) => element.type !== 'hidden' && element.getClientRects().length > 0).filter((element) => {+ const probe = root.appendChild(document.createElement(element.tagName));+ if (element.type) probe.type = element.type;+ return signature(element) === signature(probe);+ }).map((element) => element.outerHTML.slice(0, 90));+ host.remove();+ return found;+ })())`;+ /** Check every visible control at phone and desktop width, in light and in dark. */+ const styledControls = async (state) => {+ for (const width of [390, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ for (const theme of ['light', 'dark']) {+ await chrome.stable(`document.documentElement.dataset.theme = '${theme}'`);+ assert.deepEqual(JSON.parse(await chrome.stable(native)), [], `${state}: no visible control keeps the browser's native look at ${width}px in ${theme}`);+ }+ }+ await chrome.stable('delete document.documentElement.dataset.theme');+ await chrome.send('Emulation.clearDeviceMetricsOverride');+ };const open = async (address, state) => {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 refused loopback request and an empty relay list.@@ -504,6 +530,7 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tassert.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`);+ await styledControls(state);return seen;};const retry = [['Try again', null]];@@ -549,13 +576,14 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tfor (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 */ }}- // A view from before 0.8.29 refuses the hosted page without the header that would let it read the refusal.+ // A view from before 0.8.29 refuses the hosted page without the header that would let it read the refusal. The page+ // makes one discovery request of this device (P5), so it reads as no view, and the state's hint names the update.old = createServer((req, res) => { res.writeHead(403, { 'content-type': 'application/json' }); res.end(JSON.stringify({ error: 'this view needs its own address and secret: open the link pullboard view printed' })); });await 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', 'too-old');- assert.equal(outdated.heading, 'Update Pullboard on this computer', 'an old view is told apart from none');- assert.equal(outdated.command, 'npm i -g pullboard', 'the next step updates Pullboard');+ 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);stand.local = view.base;await chrome.send('Page.navigate', { url: HOSTED + '/?list' });@@ -587,6 +615,7 @@ test('every hosted page state says what it is and what to do next [N26,H5]', { tawait proofShot(chrome, width === 390 ? 'hosted-list-phone' : 'hosted-list', width);}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.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');