Files
oh-my-pi/packages/coding-agent/test/task/render-report-finding.test.ts
T
can1357 a88dd79f9c feat(task): surface explicit abort reasons for subagent results
- Add a dedicated abortReason field to SingleResult and thread it through task execution paths so aborted subagents show actionable context instead of a generic badge.
- Populate abortReason for signal cancellation, pre-start cancellation, submit_result aborted status, and missing submit_result after reminders

Fixes #248
2026-03-03 04:14:04 +01:00

88 lines
2.0 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();
});
it("renders abort reason inline for aborted subagent results", async () => {
const theme = await getThemeByName("dark");
expect(theme).toBeDefined();
const uiTheme = theme!;
const details: TaskToolDetails = {
projectAgentsDir: null,
results: [
{
index: 0,
id: "1-Reviewer",
agent: "reviewer",
agentSource: "bundled",
task: "Review patch",
exitCode: 1,
output: "",
stderr: "",
truncated: false,
durationMs: 42,
tokens: 0,
aborted: true,
abortReason: "blocked by permissions",
},
],
totalDurationMs: 42,
};
const rendered = taskToolRenderer.renderResult(
{
content: [{ type: "text", text: "" }],
details,
},
{ expanded: false, isPartial: false },
uiTheme,
);
const lines = rendered.render(120);
expect(lines.join("\n")).toContain("blocked by permissions");
});
});