Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(view): keep late relay calls read-only [N26,H5,H12]

Corey Olson47fea7ea92a6
diff --git a/src/cockpit.js b/src/cockpit.js
index 6179f820..e6ffd772 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -927,7 +927,7 @@ async function api(path, body) {
const source = boardId ? boardSources.get(boardId) : null;
if (boardId && !source) throw new Error('This board is not available in the current view. Refresh the board list and retry.');
if (boardId && source?.kind === 'relay') {
- if (body !== undefined && body !== null) throw new Error('Relay boards are read-only in this view.');
+ if (body !== undefined && body !== null) throw new Error('This is a read-only view of relay boards.');
if (!transport) throw transportLoadError || new Error('The relay transport is still loading.');
const reply = await transport.request(path, body);
if (path.includes('/state') && reply.state) return { ...reply, state: { ...reply.state, root: source.board.root } };
diff --git a/test/cockpit/relay.test.js b/test/cockpit/relay.test.js
index 582b1472..73e8a75e 100644
--- a/test/cockpit/relay.test.js
+++ b/test/cockpit/relay.test.js
@@ -1439,8 +1439,21 @@ test('the hosted page lists linked and local boards together [N26,H5]', {
await pickProject(chrome, duplicateRow);
await chrome.waitFor("view.root === data.projects.find(row => row.id === " + JSON.stringify(duplicateId) + ").root && document.querySelector('#chain')?.textContent.includes(" + JSON.stringify(duplicateTitle) + ") && !readOnly && !requests");
const remoteRow = "Array.from(document.querySelectorAll('#proj-list .proj.repo')).find(row => row.textContent.includes('fixture/repository'))";
+ // Queue the call while a writable local board is selected, then release it only after the real
+ // relay mapping and selected board settle. The late call must take the relay-board refusal.
+ const lateMovePath = '/api/v1/boards/' + linkedId + '/moves';
+ const lateMoveBody = { verb: 'shout', args: { to: 'coordinator', text: 'late relay writes stay refused' } };
+ assert.equal(await chrome.stable(`(() => { window.__lateRelayMove = () => api(${JSON.stringify(lateMovePath)}, ${JSON.stringify(lateMoveBody)}); return !readOnly && !requests; })()`), true,
+ 'the late relay call is queued while the local board is writable');
await pickProject(chrome, remoteRow);
await chrome.waitFor("view.root === data.projects.find(row => row.id === " + JSON.stringify(linkedId) + ").root && readOnly && requests");
+ assert.equal(await chrome.stable(`boardSources.get(${JSON.stringify(linkedId)})?.kind`), 'relay',
+ 'the delayed call resolves to the actual linked relay board, without replacing its source');
+ const relayWritesBefore = linked.calls.filter(call => call.method === 'POST' && call.path === lateMovePath).length;
+ const lateRefusal = await chrome.stable(`(async () => { const release = window.__lateRelayMove; delete window.__lateRelayMove; try { await release(); return 'unexpected success'; } catch (error) { return error.message; } })()`);
+ assert.match(lateRefusal, /read-only view/i, 'the late relay-board branch keeps the established read-only refusal');
+ assert.equal(linked.calls.filter(call => call.method === 'POST' && call.path === lateMovePath).length, relayWritesBefore,
+ 'the late refused write never reaches the actual relay server');
assert.ok(linked.calls.some((call) => call.method === 'GET' && call.path === '/api/v1/boards/' + linkedId + '/state'),
'the relay board state is read through its relay transport');