feat(app): wire native cancel and track complete port acceptance

This commit is contained in:
2026-10-21 20:04:38 +01:00
parent 0eb3e23fc8
commit e20ac9f5a1
10 changed files with 295 additions and 13 deletions
+26
View File
@@ -377,6 +377,16 @@ try {
if ((await path()) !== '/settings') throw new Error('Settings did not update route');
captures.push(await capture('settings-cupertino-registered-phone'));
await clickText('Runs');
await clickText('Fixture cancel run', { contains: true });
await assertBody('Original prompt');
await clickText('Cancel run');
await assertBody('Cancel run 4?');
captures.push(await capture('cancel-cupertino-confirm'));
await clickText('Keep');
const kept = await (await fetch(`${fixture.url}/fixture/state`)).json();
if (kept.cancelRequests.length) throw new Error('Keep sent a cancellation');
// Material host: the same deep link and route must render standard Material
// controls (the Cupertino host was selected by the macOS browser above).
await send(
@@ -408,7 +418,23 @@ try {
}
captures.push(await capture('settings-material-registered-phone'));
await clickText('Runs');
await clickText('Fixture cancel run', { contains: true });
await assertBody('Original prompt');
await clickText('Cancel run');
await assertBody('Cancel run 4?');
captures.push(await capture('cancel-material-confirm'));
await clickText('Cancel run');
await assertBody('canceled');
captures.push(await capture('cancel-material-accepted'));
await clickText('Back to list');
await assertBody('Fixture cancel run');
await assertBody('canceled');
const fixtureState = await (await fetch(`${fixture.url}/fixture/state`)).json();
if (JSON.stringify(fixtureState.cancelRequests) !== JSON.stringify([{ run_id: 4 }])) {
throw new Error('Cancel sent the wrong payload or repeated the request');
}
if (fixtureState.subscribed < 2) throw new Error(`App never resubscribed: ${JSON.stringify(fixtureState)}`);
if (fixtureState.listRuns < 2) throw new Error(`App never reloaded: ${JSON.stringify(fixtureState)}`);
if (fixtureState.getRun < 2) throw new Error(`Detail was not rehydrated: ${JSON.stringify(fixtureState)}`);
+21 -4
View File
@@ -45,6 +45,11 @@ const RUNS = [
created_at: '2026-10-21T10:00:00Z',
pipeline_id: 10,
},
{
id: 4, title: 'Fixture cancel run', name: 'fixture-cancel',
status: 'running', executing: true,
created_at: '2026-10-21T09:00:00Z', pipeline_id: 10,
},
];
const LIVE_EVENT = {
@@ -57,13 +62,15 @@ const LIVE_EVENT = {
finished_at: '2026-10-21T12:05:00Z',
};
function detail(id, live) {
const status = id === 1 && live ? 'succeeded' : id === 3 ? 'failed' : 'running';
function detail(id, live, canceled = false) {
const status = canceled ? 'canceled'
: id === 1 && live ? 'succeeded' : id === 3 ? 'failed' : 'running';
return {
id,
title: RUNS.find((run) => run.id === id)?.title ?? `Run ${id}`,
name: 'fixture-pipeline',
status,
executing: status === 'running',
input: {
prompt: ' fixture prompt with spaces ',
note: 'input payload',
@@ -260,6 +267,8 @@ export async function startFixture({ root }) {
let dropped = 0;
let listRuns = 0;
let getRun = 0;
const canceled = new Set();
const cancelRequests = [];
const dropConnections = () => {
for (const connection of connections) connection.close();
@@ -306,6 +315,7 @@ export async function startFixture({ root }) {
dropped,
listRuns,
getRun,
cancelRequests,
}));
return;
}
@@ -355,7 +365,8 @@ export async function startFixture({ root }) {
}
if (request.type === 'list_runs') {
listRuns++;
client.send({ id: request.id, type: 'runs', runs: RUNS, usage: null });
client.send({ id: request.id, type: 'runs', runs: RUNS.map((run) =>
canceled.has(run.id) ? { ...run, status: 'canceled', executing: false } : run), usage: null });
return;
}
if (request.type === 'get_run') {
@@ -377,7 +388,13 @@ export async function startFixture({ root }) {
});
return;
}
client.send({ id: request.id, type: 'run', run_detail: detail(id, live) });
client.send({ id: request.id, type: 'run', run_detail: detail(id, live, canceled.has(id)) });
return;
}
if (request.type === 'cancel_run' && request.run_id === 4) {
cancelRequests.push({ run_id: request.run_id });
canceled.add(4);
client.send({ id: request.id, type: 'run', run_detail: detail(4, live, true) });
return;
}
client.send({