fix: keep in-flight cleanup internal

This commit is contained in:
Keisuke Hirata 2026-07-27 16:38:47 +09:00
parent 1dc6429b87
commit 5d1950647e
No known key found for this signature in database
6 changed files with 3 additions and 70 deletions

View File

@ -363,10 +363,6 @@ pub enum Event {
max_attempts: u32,
reason: String,
},
/// Any transient streaming blocks that were not committed to history were
/// discarded at a run boundary. Clients should remove live in-flight lines
/// without modifying persisted transcript entries.
InFlightCleared,
TextDelta {
text: String,
},

View File

@ -1030,12 +1030,6 @@ impl App {
"LLM stream interrupted; continuing generation ({attempt}/{max_attempts}): {reason}"
));
}
Event::InFlightCleared => {
self.assistant_streaming = false;
self.latest_llm_wait_event = None;
self.mark_orphan_tool_calls_incomplete();
self.current_tool = None;
}
Event::TextDelta { text } => {
self.latest_llm_wait_event = None;
self.append_assistant_text(&text);

View File

@ -202,13 +202,8 @@ impl InFlightEvents {
}
pub(crate) fn clear(&self) {
let cleared = {
let mut inner = self.lock();
inner.clear()
};
if cleared {
let _ = self.event_tx.send(Event::InFlightCleared);
}
inner.clear();
}
fn lock(&self) -> MutexGuard<'_, InFlightInner> {
@ -589,7 +584,7 @@ mod tests {
}
#[test]
fn clear_discards_uncommitted_blocks_and_notifies_clients() {
fn clear_discards_uncommitted_blocks_without_protocol_event() {
let (event_tx, _) = broadcast::channel(16);
let mut rx = event_tx.subscribe();
let in_flight = InFlightEvents::new(event_tx);
@ -615,7 +610,6 @@ mod tests {
rx.try_recv().unwrap(),
Event::ToolCallArgsDelta { .. }
));
assert!(matches!(rx.try_recv().unwrap(), Event::InFlightCleared));
assert!(rx.try_recv().is_err());
}

View File

@ -225,7 +225,6 @@ export type Event =
reason: string;
};
}
| { "event": "in_flight_cleared" }
| { "event": "text_delta"; "data": { text: string } }
| { "event": "text_done"; "data": { text: string } }
| { "event": "thinking_start" }

View File

@ -859,53 +859,6 @@ 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([
{

View File

@ -303,9 +303,6 @@ 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;