From f92279c2a58449a67fe16bf5a60d9e42cdf001a8 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Wed, 18 Feb 2026 23:31:59 -0800 Subject: [PATCH] fix: compact plan and todo tool header args (#1031) --- src/cli/helpers/formatArgsDisplay.ts | 18 ++++++++++++ src/tests/cli/formatArgsDisplay.test.ts | 39 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/tests/cli/formatArgsDisplay.test.ts diff --git a/src/cli/helpers/formatArgsDisplay.ts b/src/cli/helpers/formatArgsDisplay.ts index 79f6996..abf0799 100644 --- a/src/cli/helpers/formatArgsDisplay.ts +++ b/src/cli/helpers/formatArgsDisplay.ts @@ -7,13 +7,19 @@ import { isFileReadTool, isFileWriteTool, isPatchTool, + isPlanTool, isShellTool, + isTodoTool, } from "./toolNameMapping.js"; // Small helpers const isRecord = (v: unknown): v is Record => typeof v === "object" && v !== null; +function formatItemCount(count: number): string { + return `${String(count)} item${count === 1 ? "" : "s"}`; +} + /** * Formats a file path for display (matches Claude Code style): * - Files within cwd: relative path without ./ prefix @@ -280,6 +286,18 @@ export function formatArgsDisplay( return { display, parsed }; } + // Plan tools: only show compact plan item count. + if (isPlanTool(toolName) && Array.isArray(parsed.plan)) { + display = formatItemCount(parsed.plan.length); + return { display, parsed }; + } + + // Todo tools: only show compact todo item count. + if (isTodoTool(toolName) && Array.isArray(parsed.todos)) { + display = formatItemCount(parsed.todos.length); + return { display, parsed }; + } + // Shell/Bash tools: show just the command if (isShellTool(toolName) && parsed.command) { // Handle both string and array command formats diff --git a/src/tests/cli/formatArgsDisplay.test.ts b/src/tests/cli/formatArgsDisplay.test.ts new file mode 100644 index 0000000..6f542d9 --- /dev/null +++ b/src/tests/cli/formatArgsDisplay.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, test } from "bun:test"; +import { formatArgsDisplay } from "../../cli/helpers/formatArgsDisplay"; + +describe("formatArgsDisplay compact plan/todo headers", () => { + test("shows only plan item count for update_plan", () => { + const args = JSON.stringify({ + explanation: "Investigating restart regression", + plan: [ + { step: "Step 1", status: "pending" }, + { step: "Step 2", status: "pending" }, + { step: "Step 3", status: "pending" }, + ], + }); + + expect(formatArgsDisplay(args, "update_plan").display).toBe("3 items"); + }); + + test("handles singular plan item count for UpdatePlan", () => { + const args = JSON.stringify({ + explanation: "One-step fix", + plan: [{ step: "Step 1", status: "pending" }], + }); + + expect(formatArgsDisplay(args, "UpdatePlan").display).toBe("1 item"); + }); + + test("shows only todo item count for TODO tools", () => { + const args = JSON.stringify({ + todos: [ + { content: "First", status: "pending" }, + { content: "Second", status: "in_progress" }, + ], + note: "extra metadata", + }); + + expect(formatArgsDisplay(args, "TodoWrite").display).toBe("2 items"); + expect(formatArgsDisplay(args, "write_todos").display).toBe("2 items"); + }); +});