xonecas.io
64875
Mc

mini-coder / commit dd4d034

refactor: render user prompts in the conversation log

xonecas2026-03-14 dd4d034e2b9b0d0dc48aeb9e40c8fb330ff998d0 parent db0bdc0

4 files changed

src/cli/input-loop.ts+3−1
@@ -8,7 +8,7 @@ import { handleCommand } from "./commands.ts";
88 import { resolveFileRefs } from "./file-refs.ts";
99 import { createGitBranchCache } from "./git-branch-cache.ts";
1010 import { type InputResult, readline } from "./input.ts";
11-import { tildePath } from "./output.ts";
11+import { renderUserMessage, tildePath } from "./output.ts";
1212 import { buildStatusBarSignature } from "./status-bar.ts";
1313
1414 import type { CommandContext } from "./types.ts";
@@ -80,6 +80,7 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
8080 return;
8181 }
8282 if (result.type === "inject-user-message") {
83+ renderUserMessage(result.text);
8384 const { text: resolvedText, images: refImages } =
8485 await resolveFileRefs(result.text, cwd);
8586 try {
@@ -102,6 +103,7 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
102103 }
103104
104105 case "submit": {
106+ renderUserMessage(input.text);
105107 const { text: resolvedText, images: refImages } = await resolveFileRefs(
106108 input.text,
107109 cwd,
src/cli/output.test.ts+39−0
@@ -0,0 +1,39 @@
1+import { afterEach, describe, expect, test } from "bun:test";
2+import { renderUserMessage } from "./output.ts";
3+import { terminal } from "./terminal-io.ts";
4+
5+let stdout = "";
6+const originalStdoutWrite = terminal.stdoutWrite.bind(terminal);
7+
8+afterEach(() => {
9+ stdout = "";
10+ terminal.stdoutWrite = originalStdoutWrite;
11+});
12+
13+function captureStdout(): void {
14+ terminal.stdoutWrite = (text: string) => {
15+ stdout += text;
16+ };
17+}
18+
19+function stripAnsi(text: string): string {
20+ return text.replace(/\x1b\[[0-9;]*m/g, "");
21+}
22+
23+describe("renderUserMessage", () => {
24+ test("renders a compact single-line prompt entry", () => {
25+ captureStdout();
26+
27+ renderUserMessage("ship it");
28+
29+ expect(stripAnsi(stdout)).toBe("› ship it\n");
30+ });
31+
32+ test("preserves multiline prompts as an indented history block", () => {
33+ captureStdout();
34+
35+ renderUserMessage("plan\nstep 1\n\nstep 2");
36+
37+ expect(stripAnsi(stdout)).toBe("› plan\n step 1\n \n step 2\n");
38+ });
39+});
src/cli/output.ts+13−0
@@ -47,6 +47,19 @@ export function write(text: string): void {
4747 terminal.stdoutWrite(text);
4848 }
4949
50+export function renderUserMessage(text: string): void {
51+ const lines = text.split("\n");
52+ if (lines.length === 0) {
53+ writeln(`${G.prompt}`);
54+ return;
55+ }
56+
57+ writeln(`${G.prompt} ${lines[0] ?? ""}`);
58+ for (const line of lines.slice(1)) {
59+ writeln(` ${line}`);
60+ }
61+}
62+
5063 // ─── Glyph vocabulary ─────────────────────────────────────────────────────────
5164 // All from the 16-color ANSI palette — inherits terminal theme.
5265
src/index.ts+2−0
@@ -17,6 +17,7 @@ import {
1717 registerTerminalCleanup,
1818 renderBanner,
1919 renderError,
20+ renderUserMessage,
2021 writeln,
2122 } from "./cli/output.ts";
2223 import { resolvePromptInput } from "./cli/stdin-prompt.ts";
@@ -182,6 +183,7 @@ async function main(): Promise<void> {
182183 const { runner, cmdCtx } = await initAgent(agentOpts);
183184
184185 if (prompt) {
186+ renderUserMessage(prompt);
185187 const { text: resolvedText, images: refImages } = await resolveFileRefs(
186188 prompt,
187189 args.cwd,