Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions extensions/file-mutation-display/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function renderCollapsed(
result?: AgentToolResult<any>,
isError = false,
width = 120,
renderTheme = theme,
) {
const state = {};
const context = {
Expand All @@ -178,14 +179,14 @@ function renderCollapsed(
showImages: false,
isError,
};
const call = definition.renderCall?.(args, theme, context);
const call = definition.renderCall?.(args, renderTheme, context);
assert.ok(call);
let resultComponent: Component | undefined;
if (result) {
resultComponent = definition.renderResult?.(
result,
{ expanded: false, isPartial: false },
theme,
renderTheme,
{ ...context, isPartial: false, isError },
);
}
Expand All @@ -195,6 +196,21 @@ function renderCollapsed(
].filter((line) => line.trim().length > 0);
}

function recordingTheme(calls: Array<[string, string]>) {
return new Proxy(
{},
{
get: (_target, property) =>
property === "fg" || property === "bg"
? (color: string, text: string) => {
calls.push([color, text]);
return text;
}
: (text: string) => text,
},
) as Theme;
}

test("all activity tools render one semantic success row", () => {
for (const fixture of fixtures) {
const definition = withActivityRenderer(fixture.definition);
Expand All @@ -207,6 +223,58 @@ test("all activity tools render one semantic success row", () => {
}
});

test("completed targets are muted without weakening pending or failed targets", () => {
const definition = withActivityRenderer(createBashToolDefinition(cwd));
const args = { command: "bun run check" };

const successColors: Array<[string, string]> = [];
renderCollapsed(
definition,
args,
{ content: [{ type: "text", text: "ok" }], details: undefined },
false,
120,
recordingTheme(successColors),
);
assert.ok(
successColors.some(
([color, text]) => color === "muted" && text === args.command,
),
);

const cases: Array<{
label: string;
result?: AgentToolResult<any>;
isError: boolean;
}> = [
{ label: "pending", isError: false },
{
label: "failed",
result: {
content: [{ type: "text", text: "failed" }],
details: undefined,
},
isError: true,
},
];
for (const { label, result, isError } of cases) {
const calls: Array<[string, string]> = [];
renderCollapsed(
definition,
args,
result,
isError,
120,
recordingTheme(calls),
);
assert.equal(
calls.some(([color, text]) => color === "muted" && text === args.command),
false,
label,
);
}
});

test("wrapping changes only renderer slots and shell ownership", () => {
for (const fixture of fixtures) {
const native = fixture.definition;
Expand Down
8 changes: 6 additions & 2 deletions extensions/file-mutation-display/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ function activityText(
: row.verb
).padEnd(8);
const verb = theme.fg(
state.status === "error" ? "error" : "toolTitle",
state.status === "error"
? "error"
: state.status === "success"
? "muted"
: "toolTitle",
verbText,
);
if (state.status === "pending") {
Expand All @@ -274,7 +278,7 @@ function activityText(
}
if (elapsed) parts.push(theme.fg("dim", elapsed));
const detail = parts.join(theme.fg("dim", " · "));
return `${theme.fg("dim", activityIcon(name))} ${verb} ${row.target}${detail ? ` ${detail}` : ""}`;
return `${theme.fg("dim", activityIcon(name))} ${verb} ${theme.fg("muted", row.target)}${detail ? ` ${detail}` : ""}`;
}

function activityComponent(
Expand Down
Loading