xonecas.io
64875
Mc

mini-coder / commit 209d29a

feat: add ↳ labels for parallel tool results and fix MCP result rendering

- Parallel tool call results now show a ↳ label identifying which
  call each result belongs to (only when 2+ calls were dispatched
  together). Sequential calls remain unlabeled.
- Fix renderMcpResult returning true even when no text blocks were
  rendered, causing non-text MCP results to silently vanish. Now
  falls through to the JSON fallback renderer.
- Add 2 new tests: parallel ↳ labels present, sequential ↳ absent
- Fix one-shot script's renderError call signature

xonecas2026-03-16 209d29a8a4a226369e5ac73a71d43b18fb6fb188 parent cc7ba08

4 files changed

scripts/ui-oneshot.ts+1−1
@@ -327,7 +327,7 @@ async function main() {
327327 separator("12. Error messages");
328328 renderError("API rate limit exceeded. Retrying in 30s...");
329329 writeln("");
330- renderError("Connection timed out after 60s", "Check your network connection and try again.");
330+ renderError("Connection timed out after 60s");
331331
332332 // ── MCP tool ───────────────────────────────────────────
333333 separator("13. MCP tool call");
src/cli/stream-render.ts+20−1
@@ -10,7 +10,11 @@ import {
1010 } from "./reasoning.ts";
1111 import type { Spinner } from "./spinner.ts";
1212 import { StreamRenderContent } from "./stream-render-content.ts";
13-import { renderToolCall, renderToolResult } from "./tool-render.ts";
13+import {
14+ buildToolCallLine,
15+ renderToolCall,
16+ renderToolResult,
17+} from "./tool-render.ts";
1418
1519 export async function renderTurn(
1620 events: AsyncIterable<TurnEvent>,
@@ -33,6 +37,8 @@ export async function renderTurn(
3337 let contextTokens = 0;
3438 let newMessages: CoreMessage[] = [];
3539 const startedToolCalls = new Set<string>();
40+ const toolCallInfo = new Map<string, { toolName: string; label: string }>();
41+ let parallelCallCount = 0;
3642 let renderedVisibleOutput = false;
3743
3844 let reasoningComputed = false;
@@ -73,6 +79,13 @@ export async function renderTurn(
7379 break;
7480 }
7581 startedToolCalls.add(event.toolCallId);
82+ toolCallInfo.set(event.toolCallId, {
83+ toolName: event.toolName,
84+ label: buildToolCallLine(event.toolName, event.args),
85+ });
86+ if (toolCallInfo.size > 1) {
87+ parallelCallCount = toolCallInfo.size;
88+ }
7689 liveReasoning.finish();
7790 content.flushOpenContent();
7891 spinner.stop();
@@ -86,8 +99,14 @@ export async function renderTurn(
8699
87100 case "tool-result": {
88101 startedToolCalls.delete(event.toolCallId);
102+ const callInfo = toolCallInfo.get(event.toolCallId);
103+ toolCallInfo.delete(event.toolCallId);
89104 liveReasoning.finish();
90105 spinner.stop();
106+ if (parallelCallCount > 1 && callInfo) {
107+ writeln(` ${c.dim("↳")} ${callInfo.label}`);
108+ }
109+ if (toolCallInfo.size === 0) parallelCallCount = 0;
91110 renderToolResult(event.toolName, event.result, event.isError, {
92111 verboseOutput,
93112 });
src/cli/tool-result-renderers.ts+3−1
@@ -340,6 +340,7 @@ function renderMcpResult(
340340 ): boolean {
341341 const content = Array.isArray(result) ? result : [result];
342342 const maxBlocks = opts?.verboseOutput ? content.length : 5;
343+ let rendered = false;
343344 for (const block of (
344345 content as Array<{ type?: string; text?: string }>
345346 ).slice(0, maxBlocks)) {
@@ -347,9 +348,10 @@ function renderMcpResult(
347348 const maxLines = opts?.verboseOutput ? Number.POSITIVE_INFINITY : 6;
348349 const lines = block.text.split("\n").slice(0, maxLines);
349350 for (const line of lines) writeln(` ${c.dim("│")} ${line}`);
351+ rendered = true;
350352 }
351353 }
352- return true;
354+ return rendered;
353355 }
354356
355357 const TOOL_RESULT_RENDERERS: Readonly<Record<string, ToolResultRenderer>> = {
src/cli/ui-audit.test.ts+82−0
@@ -592,6 +592,88 @@ describe("UI audit: parallel tool calls", () => {
592592 expect(plain).toContain("◆ Partial failure.");
593593 });
594594
595+ test("parallel results show ↳ label to identify which call each belongs to", async () => {
596+ captureStdout();
597+
598+ await renderTurn(
599+ eventsFrom([
600+ {
601+ type: "tool-call-start",
602+ toolName: "shell",
603+ toolCallId: "lbl1",
604+ args: { command: "echo first" },
605+ },
606+ {
607+ type: "tool-call-start",
608+ toolName: "shell",
609+ toolCallId: "lbl2",
610+ args: { command: "echo second" },
611+ },
612+ {
613+ type: "tool-result",
614+ toolName: "shell",
615+ toolCallId: "lbl1",
616+ isError: false,
617+ result: shellResult({ stdout: "first" }),
618+ },
619+ {
620+ type: "tool-result",
621+ toolName: "shell",
622+ toolCallId: "lbl2",
623+ isError: false,
624+ result: shellResult({ stdout: "second" }),
625+ },
626+ turnDone(),
627+ ]),
628+ new Spinner(),
629+ );
630+
631+ const plain = simulateTerminal(getCapturedStdout());
632+ // Both results get ↳ labels
633+ expect(plain).toContain("↳ $ echo first");
634+ expect(plain).toContain("↳ $ echo second");
635+ });
636+
637+ test("sequential tool results do NOT show ↳ labels", async () => {
638+ captureStdout();
639+
640+ await renderTurn(
641+ eventsFrom([
642+ {
643+ type: "tool-call-start",
644+ toolName: "shell",
645+ toolCallId: "seq1",
646+ args: { command: "echo one" },
647+ },
648+ {
649+ type: "tool-result",
650+ toolName: "shell",
651+ toolCallId: "seq1",
652+ isError: false,
653+ result: shellResult({ stdout: "one" }),
654+ },
655+ {
656+ type: "tool-call-start",
657+ toolName: "shell",
658+ toolCallId: "seq2",
659+ args: { command: "echo two" },
660+ },
661+ {
662+ type: "tool-result",
663+ toolName: "shell",
664+ toolCallId: "seq2",
665+ isError: false,
666+ result: shellResult({ stdout: "two" }),
667+ },
668+ turnDone(),
669+ ]),
670+ new Spinner(),
671+ );
672+
673+ const plain = simulateTerminal(getCapturedStdout());
674+ expect(plain).not.toContain("↳");
675+ });
676+
595677 test("reasoning → parallel calls → reasoning → reply", async () => {
596678 captureStdout();