feat(app): wire native cancel and track complete port acceptance
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user