coalesce cursor thinking deltas in run log streaming

This commit is contained in:
Dotta
2026-03-05 08:35:00 -06:00
parent 8f70e79240
commit 1c9b7ef918
6 changed files with 73 additions and 13 deletions

View File

@@ -136,7 +136,7 @@ export interface ServerAdapterModule {
export type TranscriptEntry =
| { kind: "assistant"; ts: string; text: string }
| { kind: "thinking"; ts: string; text: string }
| { kind: "thinking"; ts: string; text: string; delta?: boolean }
| { kind: "user"; ts: string; text: string }
| { kind: "tool_call"; ts: string; name: string; input: unknown }
| { kind: "tool_result"; ts: string; toolUseId: string; content: string; isError: boolean }

View File

@@ -219,8 +219,10 @@ export function parseCursorStdoutLine(line: string, ts: string): TranscriptEntry
if (type === "thinking") {
const text = asString(parsed.text).trim() || asString(asRecord(parsed.delta)?.text).trim();
const subtype = asString(parsed.subtype).trim().toLowerCase();
const isDelta = subtype === "delta" || asRecord(parsed.delta) !== null;
if (!text) return [];
return [{ kind: "thinking", ts, text }];
return [{ kind: "thinking", ts, text, ...(isDelta ? { delta: true } : {}) }];
}
if (type === "tool_call") {