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): a signed-out browser paired before says why [N26,H5]
Corey Olson801b0dfefb9a
diff --git a/src/view/hosted.js b/src/view/hosted.jsindex ddc48d6a..e7c36e0a 100644--- a/src/view/hosted.js+++ b/src/view/hosted.js@@ -95,7 +95,7 @@ export function hostedBrowser(agent) {* 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 - looking, asking, blocked, not-running, mismatch, problem, signed-out, no-linked, unpaired, linked-failed or local-failed.+ * @param {string|null} state - looking, asking, blocked, not-running, mismatch, problem, signed-out, no-linked, unpaired, signed-out-paired, linked-failed or local-failed.* @param {{phone?: boolean, detail?: string, linked?: string[]}} [facts] - Whether the page runs on a phone, a refusal's own words, and the boards the account shares that this browser cannot open yet.* @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}}*/@@ -127,6 +127,8 @@ export function hostedState(state, facts = {}) {// screen says to open that link or scan its QR, as the screen before it did.'unpaired': { ...share, text: 'On the computer with your projects, open a terminal and run this, then open the link it prints here or scan its QR:', ask: opening,small: 'Your account shares ' + (shared.join(', ') || 'your boards') + '. This browser opens ' + (shared.length === 1 ? 'it' : 'them') + ' from that link.' },+ // A browser paired here before whose relay session ended: its shared boards cannot load, so it says why (#902).+ 'signed-out-paired': { kind: 'note', heading: 'Signed out of pullboard.dev', text: 'Your session here ended, so your shared boards cannot open. Sign in again to see them; the boards on this computer stay open.', parts: ['github'] },'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 },};diff --git a/src/view/page-script-2.js b/src/view/page-script-2.jsindex 9ad6565d..eb051263 100644--- a/src/view/page-script-2.js+++ b/src/view/page-script-2.js@@ -979,6 +979,7 @@ async function hostedListed(boards) {// A list that arrives after a failed read, once this computer's view answered, means the page recovered: the problem// it showed is over, and this list decides what shows now.if (shown === 'problem' && localReached) { localNote(null); shown = ''; }+ if (boards.length && !hosted.relaySession && pageStartup(document.documentElement).pairedBefore()) { localNote('signed-out-paired'); 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; }diff --git a/src/view/page-startup.js b/src/view/page-startup.jsindex 6b13e0a6..e83c3033 100644--- a/src/view/page-startup.js+++ b/src/view/page-startup.js@@ -32,6 +32,10 @@ export function pageStartup(root) {status.textContent = text;return true;},+ /** Whether this browser keeps relay board keys, so it was paired and signed in here before (#902). */+ pairedBefore() {+ try { return Object.keys(JSON.parse(localStorage.getItem('pullboard.relay.keys.v1') || '{}')).length > 0; } catch { return false; }+ },/** Await load(), failing with message after ms; the timer is cleared either way, so it never outlives the load. */within(load, ms, message) {let timer;diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.jsindex f60787ac..9ef8524d 100644--- a/test/cockpit/local-origin.test.js+++ b/test/cockpit/local-origin.test.js@@ -1254,3 +1254,67 @@ test('the hosted page paints no other screen before the one it settles on [N26,H}}});++test('a browser paired here before says it was signed out above this computer\'s boards [N26,H5]', { timeout: 120_000 }, async () => { // budget: hang ceiling for two hosted loads with real round trips in Chrome.+ const executable = chromeExecutable();+ assert.ok(executable, 'the signed-out note needs real Chrome');+ const box = machine();+ const board = project(box, 'signed-out-paired');+ box.run(board.repo, 'add', 'web', 'A board on this computer', '--specs', 'G1');+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-signed-out-paired-'));+ // Signed out on the relay: its session ended, as when Chrome's cookie jar lost it (#902).+ const relay = createRelayBrowserHandler({ authenticate: async () => { throw new Refused('AUTH_REQUIRED', 'Sign in.'); } });+ let view, chrome, listener;+ const failures = [];+ try {+ view = await startView(box);+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);+ 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) {+ const reply = await call({ base: view.base }, address.pathname + address.search, { method: asked.method, headers: Object.fromEntries(Object.entries(asked.headers).filter(([name]) => name.toLowerCase() !== 'host')) });+ return chrome.send('Fetch.fulfillRequest', { requestId, responseCode: reply.status, responseHeaders: Object.entries(reply.headers).filter(([name]) => !['content-length', 'transfer-encoding', 'connection', 'keep-alive', 'date'].includes(name)).map(([name, value]) => ({ name, value: String(value) })), body: Buffer.from(reply.body).toString('base64') });+ }+ 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' });+ const policy = head['content-security-policy'].replace("connect-src 'self'", "connect-src 'self' " + view.base);+ return chrome.send('Fetch.fulfillRequest', { requestId, responseCode: 200, responseHeaders: [{ name: 'Content-Type', value: head['content-type'] }, { name: 'Cache-Control', value: 'no-store' }, { name: 'Content-Security-Policy', value: policy }], body: Buffer.from(body).toString('base64') });+ })().catch((error) => failures.push(error.message));+ };+ chrome.socket.addEventListener('message', listener);+ await chrome.send('Fetch.enable', { patterns: [{ urlPattern: HOSTED + '/*', requestStage: 'Request' }, { urlPattern: LOCAL + '/*', requestStage: 'Request' }] });+ 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 */ }+ }+ // ?paired: this browser keeps a relay board key from an earlier pairing; ?fresh: it never paired.+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `(() => {+ if (location.origin !== ${JSON.stringify(HOSTED)}) return;+ if (location.search === '?paired') localStorage.setItem('pullboard.relay.keys.v1', JSON.stringify({ 'b_paired': 'key' }));+ if (location.search === '?fresh') localStorage.removeItem('pullboard.relay.keys.v1');+ })()` });+ const note = "JSON.stringify({ state: document.querySelector('#local-note').hidden ? null : document.querySelector('#local-note').dataset.state, heading: document.getElementById('local-note-title').textContent, text: document.getElementById('local-note-text').textContent, signIn: !document.querySelector('#local-note [data-part=\"github\"]').hidden, board: document.querySelector('#chain')?.textContent.includes('A board on this computer') })";++ await chrome.send('Page.navigate', { url: HOSTED + '/?paired' });+ await chrome.waitFor("document.querySelector('#chain')?.textContent.includes('A board on this computer') && document.querySelector('#local-note').dataset.state === 'signed-out-paired'", 45_000); // budget: hang ceiling for a hosted load with its local round trip.+ const paired = JSON.parse(await chrome.stable(note));+ assert.deepEqual(paired, { state: 'signed-out-paired', heading: 'Signed out of pullboard.dev',+ text: 'Your session here ended, so your shared boards cannot open. Sign in again to see them; the boards on this computer stay open.', signIn: true, board: true });++ await chrome.send('Page.navigate', { url: HOSTED + '/?fresh' });+ await chrome.waitFor("location.search === '?fresh' && document.querySelector('#chain')?.textContent.includes('A board on this computer')", 45_000); // budget: hang ceiling for a hosted load with its local round trip.+ const fresh = JSON.parse(await chrome.stable(note));+ assert.notEqual(fresh.state, 'signed-out-paired', 'a browser that never paired here sees only this computer\'s boards');+ assert.deepEqual(failures, []);+ } finally {+ try { if (chrome) { if (listener) chrome.socket.removeEventListener('message', listener); await closeSnapshotChrome(chrome); } }+ finally {+ try { if (view) await view.stop(); }+ finally { rmSync(profile, { recursive: true, force: true }); }+ }+ }+});