xonecas.io
64875
Mc

mini-coder / commit 86247fa

fix: eliminate duplicate stdout in single-line failing shell results

When a shell command failed with exactly 1 line of stdout and no stderr,
the stdout content was displayed twice: once inlined in the summary badge
('out: <line>') and again as a separate 'stdout (1 lines)' preview block.

Fixed shouldPreviewShellStdout to skip the preview when stdout was already
inlined in the summary (single line, no stderr). Added 2 tests.

xonecas2026-03-16 86247fa5e3ee93afd90066ce6cd9d2bb5a65dee2 parent de290c3

3 files changed

UI-AUDIT-PROMPT.md+6−1
@@ -35,7 +35,7 @@ We're on branch `refactor/ui-audit` doing the UI Audit from TODO.md.
3535 - [x] Manual one-shot script (scripts/ui-oneshot.ts, 14 scenarios) — run: bun run ui-oneshot
3636 - [x] Identify inconsistencies and issues from one-shot output
3737 - [x] Refactor rendering for consistency
38-- [x] Verify all tests pass
38+- [x] Verify all tests pass (33 UI audit tests + 392 total)
3939
4040 ## Issues found and fixed
4141
@@ -49,3 +49,8 @@ We're on branch `refactor/ui-audit` doing the UI Audit from TODO.md.
4949
5050 3. **Missing one-shot scenarios** — added scenarios 15-17 for webSearch, webContent, and
5151 listSkills to ensure visual coverage of all tool types.
52+
53+4. **Duplicate stdout for single-line failing shell commands** — when a shell command failed
54+ with exactly 1 line of stdout and no stderr, the stdout was shown both inline in the
55+ summary badge (`out: <line>`) AND as a separate `stdout (1 lines)` preview block.
56+ Fixed by skipping the preview when stdout is already inlined in the summary.
src/cli/tool-result-renderers.ts+2−0
@@ -106,6 +106,8 @@ function shouldPreviewShellStdout(opts: {
106106 stdoutSingleLine: string | null;
107107 }): boolean {
108108 if (opts.stdoutLines === 0) return false;
109+ // Single-line stdout with no stderr is already inlined in the summary badge
110+ if (opts.stdoutSingleLine !== null && opts.stderrLines === 0) return false;
109111 if (!opts.success || opts.stderrLines > 0) return true;
110112 return opts.stdoutSingleLine === null;
111113 }
src/cli/ui-audit.test.ts+36−0
@@ -786,6 +786,42 @@ describe("UI audit: consistent indentation depths", () => {
786786 }
787787 });
788788
789+ test("single-line failing shell does not duplicate stdout", () => {
790+ captureStdout();
791+ renderToolResult(
792+ "shell",
793+ shellResult({
794+ stdout: "error TS2322: Type mismatch",
795+ exitCode: 1,
796+ success: false,
797+ }),
798+ false,
799+ );
800+ const plain = stripAnsi(getCapturedStdout());
801+ // Summary line should inline the single stdout line
802+ expect(plain).toContain("out: error TS2322");
803+ // Should NOT also show a separate stdout preview block
804+ expect(plain).not.toContain("stdout (1 lines)");
805+ expect(plain.match(/error TS2322/g)?.length).toBe(1);
806+ });
807+
808+ test("multi-line failing shell still shows stdout preview", () => {
809+ captureStdout();
810+ renderToolResult(
811+ "shell",
812+ shellResult({
813+ stdout: "line1\nline2\nline3",
814+ exitCode: 1,
815+ success: false,
816+ }),
817+ false,
818+ );
819+ const plain = stripAnsi(getCapturedStdout());
820+ expect(plain).toContain("stdout 3L");
821+ expect(plain).toContain("stdout (3 lines)");
822+ expect(plain).toContain("│ line1");
823+ });
824+
789825 test("all tool result types start at 4-space indent", () => {
790826 const results: Array<{ name: string; result: unknown }> = [
791827 { name: "shell", result: shellResult({ stdout: "ok" }) },