xonecas.io
64875
Mc

mini-coder / commit 59eb1c3

fix: handle missing tool-call args in stream events and UI rendering

- Handle empty shell/read tool-input-start events gracefully
- Show generic tool labels when args aren't available yet
- Emit tool-call-start even when toolCallId is not yet stable
- Update TODO.md with UI audit notes and deferred fixes

xonecas2026-03-14 59eb1c331984529c9d294dd2c68cdb2c7c7f6939 parent 8f3e979

5 files changed

TODO.md+134−18
@@ -1,32 +1,148 @@
11 # TODO
22
3-- Investigate db lock issues with spawning parallel subagents:
3+- CTRL+d hangs instead of exiting cleanly.
4+- Strange output mid session:
45
56 ```
6- ⇢ — Audit scope: CLI/input/output/command behavior against mi…
7- ⇢ — Audit scope: tools/core/session/provider/MCP behavior aga…
8- ⇢ — Audit scope: repository docs and user-facing documentatio…
9- ✖ Subagent subprocess produced no output (exit code 7) (diagnostics: 60 | cleanup(); | 61 | t)
10- ✖ Subagent subprocess produced no output (exit code 7) (diagnostics: 60 | cleanup(); | 61 | t)
11- ⇢ subagent done (882751in / 10514out tokens)
12-◆ Subagent parallelism hit a SQLite lock in the shared app DB, so I’m finishing the audit with direct reads and a smaller follow-up pass grounded in file references.
7+◆ Progress update: I’ve implemented a first UX-focused refactor around tool-stream visibility and am now validating stream/event tests plus a manual `bun run dev` run for one-shot tool calls.{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000}{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000} to=functions …
8+{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000}{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000}to=functions.shell 񹚊ppjson
9+{"command":"echo hi","timeout":30000}to=functions.shell 天天买彩票 ಕ್ರಮ`
10+Let's try once carefully.
11+{"command":"..."}
1312 ```
1413
15-- read tool path issues, says file not found on valid path:
14+with function chosen by previous? Wait earlier had "to=functions.shell". yes must include like:
15+`to=functions.shell 彩神争霸官网json
16+{"command":"bun test ...","timeout":120000}{"command":"git status --short","timeout":30000}` with to=functions.shell in metadata. Here UI likely hidden. I'll follow same exact:
17+{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000} to=functions.shell
18+to=functions.shell 天天中彩票买json
19+{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000}to=multi_tool_use.parallel үрүмjson
20+{"tool_uses":[{"recipient_name":"functions.shell","parameters":{"command":"bun test src/llm-api/turn-stream-events.test.ts src/llm-api/turn-execution.test.ts src/cli/tool-render-call.test.ts","timeout":120000}}]}to=functions.shell 天天中彩票追号json
21+{"command":"echo test","timeout":30000}{"command":"git status --short","timeout":30000}
1622
1723 ```
24+with assistant metadata to=functions.shell from UI (not visible in message maybe I set via tool button). In raw text here maybe cannot set to=. Actually we
1825 · reasoning
19-│ Investigating duplicate progress lines
20- ← read ~/src/mini-coder/src/cli/stream-render.ts:1+360
21- ✖ File not found: ~/src/mini-coder/src/cli/stream-render.ts
22-· reasoning
23-│ Deciding relative path usage
24- ← read src/cli/stream-render.ts:1+380
25- · src/cli/stream-render.ts 296 lines
26+ **Checking repository status**
27+ **Inspecting project structure before testing**
28+ **Planning source inspection**
29+ **Checking package scripts for testing**
30+ **Planning stepwise refactor**
31+ **Testing interactive and one-shot runs**
32+ **Planning interactive test approach**
33+ **Inspecting output streaming complexity**
34+ **Inspecting stream render content**
35+ **Assessing stream event processing**
36+ **Inspecting tool call event handling**
37+ **Considering execution buffering**
38+ **Planning UI streaming consistency improvements**
39+ **Exploring interactive session simulation**
40+ **Investigating command echo and rendering issues**
41+ **Inspecting provider options for simplification**
42+ **Identifying rendering issue source**
43+ **Planning streamlining and cleanup**
44+ **Assessing streaming rendering issues**
45+ **Assessing spinner lifecycle**
46+ **Assessing stream renderer refactor**
47+ **Assessing provider option complexity**
48+ **Analyzing caching implementation inconsistencies**
49+ **Planning provider option refactor**
50+ **Planning incremental tool-call rendering fix**
51+ **Modifying test and refactoring stream handling**
52+ **Adjusting case formatting**
53+ **Verifying tool-call presence**
54+ **Restoring missing case for direct chunks**
55+ **Refactoring test line to use maps**
56+ **Running targeted test**
57+ **Testing manual dev run**
58+ **Refining tool call rendering and deduplication**
59+ **Updating shell section**
60+ **Replacing anchors**
61+ **Checking existing tests for tool rendering**
62+ **Adding tests for shell and read edge cases**
63+ **Running targeted tests**
64+ **Implementing synthetic ID aliasing**
65+ **Reintroducing skip logic for empty tool-input-start**
66+ **Editing input start case**
67+ **Replacing anchors now**
68+ **Updating test for id omission**
69+ **Verifying event handling tests**
70+ **Correcting tool usage**
71+ **Correcting JSON format in call**
72+ **Correcting syntax format**
73+ **Adjusting tool call format**
74+ **Identifying malformed input issue**
75+ **Correcting recipient inclusion**
76+ **Checking mode compatibility**
77+ **Considering alternative command order**
78+ **Addressing tool call issues**
79+ **Diagnosing tool call syntax issue**
80+ **Identifying silent execution failure**
81+
82+ __User interrupted here__
83+
84+ gpt-5.3-codex · ~/src/mini-coder · ✦ medium · ⎇ main · tok 2143.4k/8.5k · ctx 71.0k/400.0k 18% · #mmqw0u3y
85+ ▶
2686 ```
2787
28-- `src/cli/stream-render.ts` is 448 lines; could be split for maintainability
29-- `src/llm-api/turn.ts` is 1273 lines; handles many concerns (pruning, compacting, normalization)
88+- Error during turn:
89+
90+```
91+claude-opus-4-5 · ~/src/mini-coder · ✦ medium · ⎇ main · #mmqwc6tq
92+▶ [pasted: "As we implemnented the idea we made heav…" +18 more lines]
93+⢿ thinking2525 | const responseBody = await response.text();
94+2526 | const responseHeaders = extractResponseHeaders(response);
95+2527 | if (responseBody.trim() === "") {
96+2528 | return {
97+2529 | responseHeaders,
98+2530 | value: new APICallError4({
99+ ^
100+AI_APICallError: Bad Request
101+ cause: undefined,
102+ url: "https://opencode.ai/zen/v1/messages",
103+ requestBodyValues: {
104+ model: "claude-opus-4-5",
105+ max_tokens: 64000,
106+ temperature: undefined,
107+ top_k: undefined,
108+ top_p: undefined,
109+ stop_sequences: undefined,
110+ thinking: [Object ...],
111+ output_config: [Object ...],
112+ system: [
113+ [Object ...]
114+ ],
115+ messages: [
116+ [Object ...]
117+ ],
118+ tools: [
119+ [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
120+ ],
121+ tool_choice: [Object ...],
122+ stream: true,
123+},
124+ statusCode: 400,
125+ responseHeaders: {
126+ "cf-ray": "9dc6b5b3db7c6c66-DFW",
127+ connection: "keep-alive",
128+ "content-type": "application/json",
129+ date: "Sat, 14 Mar 2026 22:28:09 GMT",
130+ server: "cloudflare",
131+ "transfer-encoding": "chunked",
132+},
133+ responseBody: "",
134+ isRetryable: false,
135+ data: undefined,
136+ vercel.ai.error: true,
137+ vercel.ai.error.AI_APICallError: true,
138+
139+ at /home/xonecas/src/mini-coder/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2530:18
140+ at /home/xonecas/src/mini-coder/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2391:34
141+ at processTicksAndRejections (native:7:39)
142+
143+✖ API error 400
144+ https://opencode.ai/zen/v1/messages
145+```
30146
31147 ---
32148
src/cli/tool-render-call.test.ts+12−0
@@ -30,4 +30,16 @@ describe("buildToolCallLine", () => {
3030 expect(line).toContain("[@reviewer]");
3131 expect(line).toContain("Review this diff");
3232 });
33+
34+ test("formats empty shell start events as a generic shell label", () => {
35+ const line = buildToolCallLine("shell", {});
36+ expect(line).toContain("$");
37+ expect(line).toContain("shell");
38+ });
39+
40+ test("formats read start events without path cleanly", () => {
41+ const line = buildToolCallLine("read", {});
42+ expect(line).toContain("read");
43+ expect(line).not.toContain("undefined");
44+ });
3345 });
src/cli/tool-render-call.ts+5−2
@@ -29,7 +29,9 @@ export function buildToolCallLine(name: string, args: unknown): string {
2929 const count = Number.isFinite(a.count as number) ? Number(a.count) : null;
3030 const range =
3131 line || count ? c.dim(`:${line ?? 1}${count ? `+${count}` : ""}`) : "";
32- return `${G.read} ${c.dim("read")} ${String(a.path ?? "")}${range}`;
32+ const path =
33+ typeof a.path === "string" && a.path.length > 0 ? a.path : null;
34+ return `${G.read} ${c.dim("read")}${path ? ` ${path}${range}` : ""}`;
3335 }
3436
3537 if (name === "create") {
@@ -50,7 +52,8 @@ export function buildToolCallLine(name: string, args: unknown): string {
5052 }
5153
5254 if (name === "shell") {
53- const cmd = String(a.command ?? "");
55+ const cmd = String(a.command ?? "").trim();
56+ if (!cmd) return `${G.run} ${c.dim("shell")}`;
5457 const shortCmd = cmd.length > 72 ? `${cmd.slice(0, 69)}…` : cmd;
5558 return `${G.run} ${shortCmd}`;
5659 }
src/llm-api/turn-stream-events.test.ts+16−1
@@ -52,7 +52,22 @@ describe("mapStreamChunkToTurnEvent", () => {
5252 });
5353 });
5454
55- test("ignores empty tool-input-start chunks", () => {
55+ test("maps empty tool-input-start chunks when tool call id is not available yet", () => {
56+ expect(
57+ mapStreamChunkToTurnEvent({
58+ type: "tool-input-start",
59+ toolName: "shell",
60+ input: {},
61+ }),
62+ ).toEqual({
63+ type: "tool-call-start",
64+ toolCallId: "",
65+ toolName: "shell",
66+ args: {},
67+ });
68+ });
69+
70+ test("ignores empty tool-input-start chunks when toolCallId is stable", () => {
5671 expect(
5772 mapStreamChunkToTurnEvent({
5873 type: "tool-input-start",
src/llm-api/turn-stream-events.ts+3−1
@@ -43,7 +43,9 @@ export function mapStreamChunkToTurnEvent(c: StreamChunk): TurnEvent | null {
4343 }
4444 case "tool-input-start": {
4545 const args = extractToolArgs(c);
46- if (!hasRenderableToolArgs(args)) return null;
46+ const hasStableToolCallId =
47+ typeof c.toolCallId === "string" && c.toolCallId.trim().length > 0;
48+ if (hasStableToolCallId && !hasRenderableToolArgs(args)) return null;
4749 return {
4850 type: "tool-call-start",
4951 toolCallId: String(c.toolCallId ?? ""),