diff --git a/packages/coding-agent/src/tools/browser.ts b/packages/coding-agent/src/tools/browser.ts index 02cdbbcdf..83128037e 100644 --- a/packages/coding-agent/src/tools/browser.ts +++ b/packages/coding-agent/src/tools/browser.ts @@ -23,6 +23,7 @@ import { formatDimensionNote, resizeImage } from "../utils/image-resize"; import { htmlToBasicMarkdown } from "../web/scrapers/types"; import type { OutputMeta } from "./output-meta"; import { expandPath } from "./path-utils"; +import { formatSavedScreenshotLine } from "./render-utils"; import stealthTamperingScript from "./puppeteer/00_stealth_tampering.txt" with { type: "text" }; import stealthActivityScript from "./puppeteer/01_stealth_activity.txt" with { type: "text" }; import stealthHairlineScript from "./puppeteer/02_stealth_hairline.txt" with { type: "text" }; @@ -1394,7 +1395,7 @@ export class BrowserTool implements AgentTool { it("deduplicates parse errors while preserving order", () => { @@ -30,3 +32,19 @@ describe("parse error formatting", () => { ]); }); }); + +describe("browser screenshot path formatting", () => { + it("shows home-relative saved paths with tilde shorthand", () => { + const filePath = path.join(os.homedir(), "screenshots", "capture.png"); + + expect(formatSavedScreenshotLine("image/png", 2048, filePath)).toBe( + "Saved: image/png (2.00 KB) to ~/screenshots/capture.png", + ); + }); + + it("keeps non-home saved paths unchanged", () => { + expect(formatSavedScreenshotLine("image/png", 2048, "/tmp/capture.png")).toBe( + "Saved: image/png (2.00 KB) to /tmp/capture.png", + ); + }); +});