fix: clear stale in-flight state
This commit is contained in:
@@ -225,6 +225,7 @@ export type Event =
|
||||
reason: string;
|
||||
};
|
||||
}
|
||||
| { "event": "in_flight_cleared" }
|
||||
| { "event": "text_delta"; "data": { text: string } }
|
||||
| { "event": "text_done"; "data": { text: string } }
|
||||
| { "event": "thinking_start" }
|
||||
|
||||
@@ -859,6 +859,53 @@ Deno.test("projectConsole renders snapshot entries and in-flight output", () =>
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("projectConsole clears transient in-flight rows", () => {
|
||||
const projection = projectConsole([
|
||||
{
|
||||
eventId: "20",
|
||||
event: {
|
||||
event: "snapshot",
|
||||
data: {
|
||||
entries: [
|
||||
{
|
||||
kind: "assistant_item",
|
||||
ts: 1,
|
||||
item: {
|
||||
kind: "message",
|
||||
role: "assistant",
|
||||
content: [{ kind: "text", text: "latest committed" }],
|
||||
},
|
||||
},
|
||||
],
|
||||
greeting: {
|
||||
worker_name: "Worker",
|
||||
cwd: "/repo",
|
||||
provider: "provider",
|
||||
model: "model",
|
||||
scope_summary: "bounded",
|
||||
tools: [],
|
||||
context_window: 100,
|
||||
context_tokens: 20,
|
||||
},
|
||||
status: "running",
|
||||
in_flight: {
|
||||
blocks: [{ kind: "text", text: "stale partial" }],
|
||||
},
|
||||
},
|
||||
} satisfies Event,
|
||||
},
|
||||
{
|
||||
eventId: "21",
|
||||
event: { event: "in_flight_cleared" } satisfies Event,
|
||||
},
|
||||
]);
|
||||
|
||||
assertEquals(
|
||||
projection.lines.map((line) => `${line.kind}:${line.body}`),
|
||||
["assistant:latest committed"],
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("projectConsole reseeds visible rows from segment rotation", () => {
|
||||
const projection = projectConsole([
|
||||
{
|
||||
|
||||
@@ -303,6 +303,9 @@ export function applyProtocolEvent(
|
||||
next.lines.push(inFlightLine(envelope.eventId, block, next.cwd));
|
||||
}
|
||||
break;
|
||||
case "in_flight_cleared":
|
||||
next.lines = next.lines.filter((line) => line.kind !== "in_flight");
|
||||
break;
|
||||
case "status":
|
||||
next.status = event.data.status;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user