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: ignore expired pairing for authorized browsers [H5,H17,N26]

Corey Olson292ba9d81349
diff --git a/relay/browser-client.js b/relay/browser-client.js
index acb1cf74..df304433 100644
--- a/relay/browser-client.js
+++ b/relay/browser-client.js
@@ -736,12 +736,28 @@ export async function createTransport({ onUpdate = () => {}, onOpenBoard = () =>
} finally { approvedBoards.delete(context.board); notice(); }
}
+ /** Discard expired enrollment without withholding an already authorized browser's boards. */
+ async function pairAndList() {
+ try {
+ if (await enrollPhone((path, options) => documentAt(path, denied, options))) keepPairingStorage();
+ } catch (error) {
+ if (error?.code !== 'DEVICE_PAIR_EXPIRED') throw error;
+ try { await listing(); }
+ catch { // Preserve the actionable expiry unless normal authorization detected access loss.
+ if (accessLost) throw accessError;
+ throw error;
+ }
+ if (browserPaired) return;
+ throw error;
+ }
+ await listing();
+ }
+
/** Pair a link opened in this already-loaded page as well as one opened on a fresh visit. */
async function pairingChanged() {
try {
rememberPairing(); pair = takePairing() ?? pair;
- if (await enrollPhone((path, options) => documentAt(path, denied, options))) keepPairingStorage();
- await listing(); onUpdate();
+ await pairAndList(); onUpdate();
}
catch { failure = 'The pairing link is invalid. Get a new link from a linked machine.'; failureBoard = null; notice(); }
}
@@ -754,14 +770,9 @@ export async function createTransport({ onUpdate = () => {}, onOpenBoard = () =>
try { devicePairing ||= sessionStorage.getItem('pullboard.relay.device-pair.v1') !== null; } catch { /* No storage: no saved pairing. */ }
if (!pair && !devicePairing && !Object.keys(keys).length) showRelayScreen(document.documentElement, 'share');
try {
- if (await enrollPhone((path, options) => documentAt(path, denied, options))) keepPairingStorage();
- await listing();
+ await pairAndList();
} catch (error) {
- if (error?.code === 'DEVICE_PAIR_EXPIRED') {
- // A stale local enrollment must not hide a newer revocation of this browser.
- try { await documentAt('/api/v1/devices/session', denied); } catch { /* Keep the original pairing error unless access was lost. */ }
- if (accessLost) throw accessError;
- }
+ if (accessLost) throw accessError;
failure = error.message || 'Your boards did not open. Try opening this page again.';
notice();
throw error;
diff --git a/test/hosted-shapes.test.js b/test/hosted-shapes.test.js
index 6a1f89e9..1e4b2813 100644
--- a/test/hosted-shapes.test.js
+++ b/test/hosted-shapes.test.js
@@ -1133,11 +1133,17 @@ test('an expired saved pairing preserves a valid identity when its session probe
} });
try {
await page.navigate(HOSTED + '/');
- const failure = await page.poll(`(() => { const node = document.querySelector('#relay-screen .relay-live span');
- return node?.textContent.includes('fresh phone pairing link') && node.textContent; })()`, 8_000); // budget: existing hosted blocker-settle ceiling.
- assert.ok(failure, 'the original expired pairing guidance remains observable on the phone');
- assert.match(failure, /pullboard relay on --all/u);
- assert.doesNotMatch(failure, /fixture session probe unavailable/u, 'probe errors do not replace the original pairing refusal');
+ if (unavailable) {
+ const failure = await page.poll(`(() => { const node = document.querySelector('#relay-screen .relay-live span');
+ return node?.textContent.includes('fresh phone pairing link') && node.textContent; })()`, 8_000); // budget: existing hosted blocker-settle ceiling.
+ assert.ok(failure, 'unavailable authorization retains the original expired pairing guidance');
+ assert.match(failure, /pullboard relay on --all/u);
+ assert.doesNotMatch(failure, /fixture session probe unavailable/u, 'probe errors do not replace the original pairing refusal');
+ } else {
+ // #982 intentionally replaces the former expired-link blocker for an authorized paired browser.
+ assert.ok(await page.poll(`(${READ_SCREEN}).board`, 8_000), 'valid paired identity opens its board despite the expired link'); // budget: fixture settle ceiling.
+ assert.doesNotMatch((await page.evaluate(READ_SCREEN)).words, /fresh phone pairing link/u);
+ }
assert.equal(probes, 1, 'only the cause-specific session probe ran');
const screen = await page.evaluate(READ_SCREEN);
assert.doesNotMatch(screen.words, /browser was removed/iu, 'a valid or unavailable session is not a revocation');