xonecas.io
64875
Mc

mini-coder / commit 9f76dd6

fix(cli): deduplicate repeated tool start events

xonecas2026-03-14 9f76dd64bdb821e9e01f4e6bf73749ca093eac9d parent 57bd6e2

2 files changed

src/cli/stream-render.test.ts+33−0
@@ -414,4 +414,37 @@ describe("renderTurn", () => {
414414 const plain = strip(stdout);
415415 expect(plain).toContain("· skill deploy · local · Deploy app");
416416 });
417+
418+ test("deduplicates repeated tool-call-start events for the same toolCallId", async () => {
419+ captureStdout();
420+
421+ await renderTurn(
422+ eventsFrom([
423+ {
424+ type: "tool-call-start",
425+ toolName: "read",
426+ args: { path: "a.ts" },
427+ toolCallId: "tool-dup",
428+ },
429+ {
430+ type: "tool-call-start",
431+ toolName: "read",
432+ args: { path: "a.ts" },
433+ toolCallId: "tool-dup",
434+ },
435+ {
436+ type: "tool-result",
437+ toolName: "read",
438+ toolCallId: "tool-dup",
439+ isError: false,
440+ result: "ok",
441+ },
442+ done(),
443+ ]),
444+ new Spinner(),
445+ );
446+
447+ const plain = strip(stdout);
448+ expect(countOccurrences(plain, "← read")).toBe(1);
449+ });
417450 });
src/cli/stream-render.ts+6−0
@@ -49,6 +49,7 @@ export async function renderTurn(
4949 let outputTokens = 0;
5050 let contextTokens = 0;
5151 let newMessages: CoreMessage[] = [];
52+ const startedToolCalls = new Set<string>();
5253
5354 /**
5455 * Render a single raw line, updating shared fence/blank-run state.
@@ -224,6 +225,10 @@ export async function renderTurn(
224225 }
225226
226227 case "tool-call-start": {
228+ if (startedToolCalls.has(event.toolCallId)) {
229+ break;
230+ }
231+ startedToolCalls.add(event.toolCallId);
227232 flushAnyText();
228233 spinner.stop();
229234 renderToolCall(event.toolName, event.args);
@@ -233,6 +238,7 @@ export async function renderTurn(
233238 }
234239
235240 case "tool-result": {
241+ startedToolCalls.delete(event.toolCallId);
236242 spinner.stop();
237243 renderToolResult(event.toolName, event.result, event.isError);