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(relay): open the approved board on the phone [H17,E16]
Corey Olson8e9e5bcf4324
diff --git a/relay/browser-client.js b/relay/browser-client.jsindex 110e35c9..392f2f7c 100644--- a/relay/browser-client.js+++ b/relay/browser-client.js@@ -95,7 +95,7 @@ async function documentAt(path, onDenied, options = {}) {}/** Build the API adapter the existing cockpit consumes; no board key enters an HTTP request. */-export async function createTransport({ onUpdate = () => {} } = {}) {+export async function createTransport({ onUpdate = () => {}, onOpenBoard = () => {} } = {}) {void registerApp();const savedKeys = stored(localStorage, KEYS, {});const keys = savedKeys && typeof savedKeys === 'object' && !Array.isArray(savedKeys) ? savedKeys : {};@@ -555,7 +555,10 @@ export async function createTransport({ onUpdate = () => {} } = {}) {try {while (!accessLost && Date.now() < context.expires) {await listing(); onUpdate();- if (paired.has(context.board)) return;+ if (paired.has(context.board)) {+ await onOpenBoard(context.board);+ return;+ }await new Promise(resolveWait => setTimeout(resolveWait, 500));}} finally { approvedBoards.delete(context.board); notice(); }diff --git a/test/relay-approval-delivery.test.js b/test/relay-approval-delivery.test.jsindex 9873a510..ca1690b6 100644--- a/test/relay-approval-delivery.test.js+++ b/test/relay-approval-delivery.test.js@@ -605,7 +605,7 @@ async function registerProject(box, name) {const root = join(dirname(box.root), name);mkdirSync(root);for (const args of [['init', '-q', '-b', 'main'], ['-c', 'commit.gpgsign=false', 'commit', '--allow-empty', '-q', '-m', 'fixture base'],- ['remote', 'add', 'origin', '[email protected]:fixture/repository.git']]) {+ ['remote', 'add', 'origin', `[email protected]:fixture/${name}.git`]]) {assert.equal(spawnSync('git', args, { cwd: root, env: box.env }).status, 0);}const initialized = await cliCommand(root, box.env, ['init']).done;@@ -624,7 +624,13 @@ function approvedLinkScenario(t) {approvedLinkRun ??= (async () => {const box = await relayClientFixture(t);const { chrome, native, machineFile } = await pairPhone(box, t);+ box.providerState.repositories.push('notes');const notes = await registerProject(box, 'notes');+ const notesTitle = 'an item only on the newly approved notes board';+ const note = cliCommand(notes, box.env, ['add', box.lane, notesTitle]);+ native.push(note);+ const added = await note.done;+ assert.equal(added.code, 0, `the approved board has its own visible item: ${added.stderr}`);const proposal = JSON.parse(readFileSync(machineFile, 'utf8')).approvals.find(entry => entry.root === notes);assert.ok(proposal?.published, 'init publishes one sealed link card for notes');const board = proposal.context.board;@@ -653,6 +659,10 @@ function approvedLinkScenario(t) {let release;const released = new Promise(resolveRelease => { release = resolveRelease; });box.beforeNextSnapshot(async () => { held = true; await released; });+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 1, mobile: true });+ await chrome.evaluate(`document.querySelector('[data-tab="shouts"]').click()`);+ await chrome.waitFor(`view.tab === "shouts" && document.querySelector('[data-pane="items"]').hidden`);+ const documentOrigin = await chrome.evaluate('performance.timeOrigin');const authorizeBefore = box.calls.filter(call => call.path.endsWith('/authorize')).length;await chrome.evaluate(`document.querySelector(${JSON.stringify(button)}).click()`);await waitFor(() => held, 'the computer starts linking notes in the same run once the phone approves');@@ -669,10 +679,26 @@ function approvedLinkScenario(t) {await chrome.waitFor(`document.querySelectorAll('#proj-list .proj.repo').length === 2&& Object.hasOwn(JSON.parse(localStorage.getItem('pullboard.relay.keys.v1') ?? '{}'), ${JSON.stringify(board)})`);} catch { opened = false; }+ // budget: observe the same bounded navigation transition as the independent mobile counter, without retrying approval.+ try { await chrome.waitFor(`data?.root === ${JSON.stringify(board)} && document.querySelector('#proj-name')?.textContent === 'notes'+ && document.body.innerText.includes(${JSON.stringify(notesTitle)})`, 6_000); } catch { /* The assertion below names a missed selection directly. */ }+ const displayed = await chrome.evaluate(`({ root: data?.root, name: document.querySelector('#proj-name')?.textContent,+ text: document.body.innerText })`);+ const visibleItems = [];+ for (const width of [390, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 844, deviceScaleFactor: 1, mobile: width === 390 });+ visibleItems.push(await chrome.evaluate(`(() => {+ const pane = document.querySelector('[data-pane="items"]');+ const row = [...document.querySelectorAll('#chain [data-item]')].find(node => node.textContent.includes(${JSON.stringify(notesTitle)}));+ const rect = row?.getBoundingClientRect();+ return { width: innerWidth, tab: view.tab, visible: !pane.hidden && Boolean(rect && row.getClientRects().length && rect.height > 0 && rect.top < innerHeight && rect.bottom > 0) };+ })()`));+ }+ const sameDocument = await chrome.evaluate('performance.timeOrigin') === documentOrigin;const rawKey = readFileSync(join(box.env.PULLBOARD_HOME, 'relay-keys', board + '.key'), 'utf8').trim();return {waited, code: finished.code, stdout: finished.stdout, stderr: finished.stderr, linkedAtExit, opened, noticeBeforeKey,- noticeLog: await chrome.evaluate('window.__noticeLog'), rawKey,+ noticeLog: await chrome.evaluate('window.__noticeLog'), rawKey, targetBoard: board, notesTitle, displayed, visibleItems, sameDocument,taps: box.calls.filter(call => call.path.endsWith('/authorize')).length - authorizeBefore,};})();@@ -688,6 +714,15 @@ test('an approved link opens on the phone without another command [H17,E16]', {assert.equal(run.code, 0, `the waiting run finishes cleanly: ${run.stderr}`);assert.equal(run.linkedAtExit, true, 'the same run links notes; no later command is needed');assert.equal(run.opened, true, 'the phone unwraps the notes key and lists the board with no other command');+ assert.equal(run.displayed.root, run.targetBoard, 'the phone selects the newly approved board, rather than only listing it');+ assert.equal(run.displayed.name, 'notes', 'the visible project heading names the approved notes board');+ assert.ok(run.displayed.text.includes(run.notesTitle), "the approved board's own item is visible");+ assert.equal(run.sameDocument, true, 'approval keeps the same browser document');+ for (const result of run.visibleItems) {+ assert.equal(result.tab, 'items', `${result.width}px approval opens Items after Shouts`);+ assert.equal(result.visible, true, `${result.width}px approved item is visible on screen`);+ }+ assert.equal(run.displayed.text.includes('private cleanup fixture item'), false, "the previously open board's item is not left on screen");assert.match(run.noticeBeforeKey, /approved; waiting for the computer to send this phone its key\./u,'before the key arrives the phone says it is on the way');assert.equal(run.noticeLog.some(text => text.includes('pair this browser')), false,diff --git a/test/relay-fixture.js b/test/relay-fixture.jsindex 6cb42388..8db22103 100644--- a/test/relay-fixture.js+++ b/test/relay-fixture.js@@ -7,7 +7,7 @@ import { once } from 'node:events';/** Start a provider with real signed JWT verification and one-use browser/device grants. */export async function githubFixture(t) {const { privateKey, publicKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });- const state = { access: true, permission: 'write', public: false, installed: true, repositoryID: 100, accountID: 7, permissionAccountID: 7, deviceAuthorized: false, deviceDeclined: false, deviceExpired: false, slow: false, redirect: null, beforeDevicePoll: null, beforeUser: null };+ const state = { access: true, permission: 'write', public: false, installed: true, repositoryID: 100, repositories: ['repository'], accountID: 7, permissionAccountID: 7, deviceAuthorized: false, deviceDeclined: false, deviceExpired: false, slow: false, redirect: null, beforeDevicePoll: null, beforeUser: null };const calls = [];const codes = new Map();const userTokens = new Set();@@ -94,16 +94,22 @@ export async function githubFixture(t) {if (state.beforeUser) await state.beforeUser();return reply(res, isUser ? 200 : 401, { id: state.accountID, login: 'fixture-user' });}- if (url.pathname === '/repos/fixture/repository/installation') return reply(res, isApp && state.installed ? 200 : 404, { id: 42 });+ const repositoryPath = url.pathname.match(/^\/repos\/fixture\/([^/]+)(?:\/(.*))?$/u);+ const repositoryName = repositoryPath?.[1];+ const allowedRepository = state.repositories.includes(repositoryName);+ if (allowedRepository && repositoryPath[2] === 'installation') return reply(res, isApp && state.installed ? 200 : 404, { id: 42 });if (url.pathname === '/app/installations/42/access_tokens') {assert.ok(isApp, 'installation request has a valid RSA App JWT');- assert.deepEqual(JSON.parse(raw), { repositories: ['repository'], permissions: { metadata: 'read' } });+ const request = JSON.parse(raw);+ assert.equal(request.repositories.length, 1, 'installation token is scoped to one allowed fixture repository');+ assert.ok(state.repositories.includes(request.repositories[0]), 'installation token names an explicitly allowed fixture repository');+ assert.deepEqual(request, { repositories: request.repositories, permissions: { metadata: 'read' } });const token = 'ghs_' + randomBytes(32).toString('base64url');installationTokens.add(token);return reply(res, 201, { token, expires_at: new Date(Date.now() + 3600_000).toISOString() });}- if (url.pathname === '/repos/fixture/repository') return reply(res, isInstallation || state.public ? 200 : 404, { id: state.repositoryID, full_name: 'fixture/repository', private: !state.public });- if (url.pathname === '/repos/fixture/repository/collaborators/fixture-user/permission') {+ if (allowedRepository && !repositoryPath[2]) return reply(res, isInstallation || state.public ? 200 : 404, { id: state.repositoryID + state.repositories.indexOf(repositoryName), full_name: 'fixture/' + repositoryName, private: !state.public });+ if (allowedRepository && repositoryPath[2] === 'collaborators/fixture-user/permission') {if (state.beforePermission) await state.beforePermission();const role = state.access ? state.permission : 'none';const permission = { triage: 'read', maintain: 'write' }[role] || role;