Files
oh-my-pi/packages/coding-agent/test/task/render-report-finding.test.ts
T
can1357 130b646d1d fix(coding-agent): guard report_finding extraction and rendering
Validate report_finding details before extraction and normalize findings before task rendering to avoid crashes when tool errors emit empty details.

Fixes #173
2026-02-26 10:07:02 +01:00

48 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { getThemeByName } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { taskToolRenderer } from "../../src/task/render";
import type { TaskToolDetails } from "../../src/task/types";
describe("taskToolRenderer report_finding safety", () => {
it("renders progress without crashing when report_finding payload is malformed", async () => {
const theme = await getThemeByName("dark");
expect(theme).toBeDefined();
const uiTheme = theme!;
const details: TaskToolDetails = {
projectAgentsDir: null,
results: [],
totalDurationMs: 42,
progress: [
{
index: 0,
id: "1-Reviewer",
agent: "reviewer",
agentSource: "bundled",
status: "running",
task: "Review patch",
recentTools: [],
recentOutput: [],
toolCount: 1,
tokens: 0,
durationMs: 42,
extractedToolData: {
report_finding: [{}],
},
},
],
};
const rendered = taskToolRenderer.renderResult(
{
content: [{ type: "text", text: "" }],
details,
},
{ expanded: false, isPartial: true },
uiTheme,
);
expect(() => rendered.render(120)).not.toThrow();
});
});