From 5ea8a276eb2186919c59545d86a898020ef023bf Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 20 Apr 2026 14:46:18 +0200 Subject: [PATCH] fix(coding-agent): preserve share page tool output indentation closes #3440 --- packages/coding-agent/CHANGELOG.md | 1 + .../coding-agent/src/core/export-html/template.css | 1 + .../coding-agent/test/export-html-whitespace.test.ts | 12 ++++++++++++ 3 files changed, 14 insertions(+) create mode 100644 packages/coding-agent/test/export-html-whitespace.test.ts diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 113d29c2..b45624eb 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Fixed shared/exported plain-text tool output to preserve indentation instead of collapsing leading whitespace in the web share page ([#3440](https://github.com/badlogic/pi-mono/issues/3440)) - Fixed skill resolution to dedupe symlinked aliases by canonical path, so `pi config` no longer shows duplicate skill entries when `~/.pi/agent/skills` points to `~/.agents/skills` ([#3405](https://github.com/badlogic/pi-mono/issues/3405)) - Fixed OpenRouter request attribution to include Pi app headers (`HTTP-Referer: https://pi.dev`, `X-OpenRouter-Title: pi`, `X-OpenRouter-Categories: cli-agent`) when sessions are created through the coding-agent SDK and install telemetry is enabled ([#3414](https://github.com/badlogic/pi-mono/issues/3414)) diff --git a/packages/coding-agent/src/core/export-html/template.css b/packages/coding-agent/src/core/export-html/template.css index b3a4e39b..857fa25d 100644 --- a/packages/coding-agent/src/core/export-html/template.css +++ b/packages/coding-agent/src/core/export-html/template.css @@ -510,6 +510,7 @@ margin: 0; padding: 0; line-height: var(--line-height); + white-space: pre-wrap; } .tool-output pre { diff --git a/packages/coding-agent/test/export-html-whitespace.test.ts b/packages/coding-agent/test/export-html-whitespace.test.ts new file mode 100644 index 00000000..dc00de0d --- /dev/null +++ b/packages/coding-agent/test/export-html-whitespace.test.ts @@ -0,0 +1,12 @@ +import { readFileSync } from "fs"; +import { describe, expect, it } from "vitest"; + +describe("export HTML tool output whitespace", () => { + it("preserves whitespace for plain-text tool output containers", () => { + const css = readFileSync(new URL("../src/core/export-html/template.css", import.meta.url), "utf-8"); + + expect(css).toMatch( + /\.tool-output > div,\s*\.output-preview,\s*\.output-full\s*\{[\s\S]*?white-space:\s*pre-wrap;/, + ); + }); +});