Collapse read output by default

closes #4916
This commit is contained in:
Mario Zechner
2026-05-23 11:40:54 +02:00
parent 8100046cb8
commit 373bd1282e
3 changed files with 30 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
### Changed
- Changed collapsed read tool cards to show only the read line until expanded ([#4916](https://github.com/earendil-works/pi/issues/4916)).
- Changed the root development install documentation to use `npm install --ignore-scripts` ([#4868](https://github.com/earendil-works/pi/issues/4868)).
### Fixed

View File

@@ -170,10 +170,10 @@ function formatReadResult(
options: ToolRenderResultOptions,
theme: Theme,
showImages: boolean,
cwd: string,
_cwd: string,
isError: boolean,
): string {
if (!options.expanded && !isError && getCompactReadClassification(args, cwd)) {
if (!options.expanded && !isError) {
return "";
}

View File

@@ -191,6 +191,7 @@ describe("ToolExecutionComponent parity", () => {
process.cwd(),
);
component.updateResult({ content: [{ type: "text", text: "hello" }], details: undefined, isError: false }, false);
component.setExpanded(true);
const rendered = stripAnsi(component.render(120).join("\n"));
expect(rendered).toContain("override call");
expect(rendered).toContain("hello");
@@ -362,12 +363,38 @@ describe("ToolExecutionComponent parity", () => {
{ content: [{ type: "text", text: "one\ntwo\n" }], details: undefined, isError: false },
false,
);
component.setExpanded(true);
const rendered = stripAnsi(component.render(120).join("\n"));
expect(rendered).toContain("one");
expect(rendered).toContain("two");
expect(rendered).not.toContain("two\n\n");
});
test("collapses ordinary read results until expanded", () => {
const component = new ToolExecutionComponent(
"read",
"tool-ordinary-read-collapsed",
{ path: "notes.txt" },
{},
createReadToolDefinition(process.cwd()),
createFakeTui(),
process.cwd(),
);
component.updateResult(
{ content: [{ type: "text", text: "hidden content" }], details: undefined, isError: false },
false,
);
const collapsed = stripAnsi(component.render(120).join("\n"));
expect(collapsed).toContain("read");
expect(collapsed).toContain("notes.txt");
expect(collapsed).not.toContain("hidden content");
component.setExpanded(true);
const expanded = stripAnsi(component.render(120).join("\n"));
expect(expanded).toContain("hidden content");
});
for (const scenario of [
{
title: "SKILL.md",