From 229458ebf56d5a805c5cb0c758a73a5534a469af Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Sat, 23 May 2026 21:11:10 -0500 Subject: [PATCH] fix(tui): preserve reasoning body indentation --- packages/opencode/src/cli/cmd/tui/context/thinking.ts | 2 +- packages/opencode/test/cli/tui/thinking.test.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/context/thinking.ts b/packages/opencode/src/cli/cmd/tui/context/thinking.ts index b9d8e182ef..bb1c2a6929 100644 --- a/packages/opencode/src/cli/cmd/tui/context/thinking.ts +++ b/packages/opencode/src/cli/cmd/tui/context/thinking.ts @@ -13,7 +13,7 @@ export function reasoningSummary(text: string) { const content = text.trim() const match = content.match(/^\*\*([^*\n]+)\*\*(?:\r?\n\r?\n|$)/) if (!match) return { title: null, body: content } - return { title: match[1].trim(), body: content.slice(match[0].length).trim() } + return { title: match[1].trim(), body: content.slice(match[0].length).trimEnd() } } export function isThinkingMode(value: unknown): value is ThinkingMode { diff --git a/packages/opencode/test/cli/tui/thinking.test.ts b/packages/opencode/test/cli/tui/thinking.test.ts index 2c0f0ef53d..7f8af1a5f3 100644 --- a/packages/opencode/test/cli/tui/thinking.test.ts +++ b/packages/opencode/test/cli/tui/thinking.test.ts @@ -16,6 +16,13 @@ describe("reasoningSummary", () => { }) }) + test("preserves markdown-significant indentation in the extracted body", () => { + expect(reasoningSummary("**Continuing Quality Review**\n\n const value = true\n")).toEqual({ + title: "Continuing Quality Review", + body: " const value = true", + }) + }) + test("does not consume ordinary leading bold content", () => { expect(reasoningSummary("**Important:** keep this in the body.")).toEqual({ title: null,