6ac73655c8
- Removed `resume` from task params and schema, requiring agent and assignment inputs. - Dropped resume continuation paths in task execution and call rendering, always spawning a new agent. - Removed the `irc.enabled` setting and computed IRC availability by task-depth rules. - Updated task follow-up guidance to use IRC messaging/history links instead of `task(resume:)`.
89 lines
2.8 KiB
TypeScript
89 lines
2.8 KiB
TypeScript
/**
|
|
* The job tool's TUI preview must not leak the model-facing `<task-result>`
|
|
* envelope (prompts/tools/task-summary.md): a settled task job previews the
|
|
* inner <output>/<preview> body, while non-envelope result text (bash jobs)
|
|
* passes through unchanged.
|
|
*/
|
|
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
|
|
import { resetSettingsForTest, Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
import { initTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
|
|
import { jobToolRenderer } from "@oh-my-pi/pi-coding-agent/tools/job";
|
|
import { prompt } from "@oh-my-pi/pi-utils";
|
|
import taskSummaryTemplate from "../src/prompts/tools/task-summary.md" with { type: "text" };
|
|
|
|
function renderLines(resultText: string): string {
|
|
const result = {
|
|
content: [{ type: "text", text: "" }],
|
|
details: {
|
|
jobs: [
|
|
{
|
|
id: "SpawnProbe",
|
|
type: "task" as const,
|
|
status: "completed" as const,
|
|
label: "SpawnProbe",
|
|
durationMs: 8_700,
|
|
resultText,
|
|
},
|
|
],
|
|
},
|
|
};
|
|
const component = jobToolRenderer.renderResult(
|
|
result,
|
|
{ expanded: true } as Parameters<typeof jobToolRenderer.renderResult>[1],
|
|
theme,
|
|
);
|
|
return (component.render(120) as readonly string[]).join("\n");
|
|
}
|
|
|
|
describe("job renderer task-result preview", () => {
|
|
beforeAll(async () => {
|
|
resetSettingsForTest();
|
|
await Settings.init({ inMemory: true });
|
|
await initTheme();
|
|
});
|
|
|
|
afterAll(() => {
|
|
resetSettingsForTest();
|
|
});
|
|
|
|
it("previews the envelope body, not the wrapper markup", () => {
|
|
const summary = prompt.render(taskSummaryTemplate, {
|
|
agentName: "quick_task",
|
|
id: "SpawnProbe",
|
|
status: "completed",
|
|
duration: "8.7s",
|
|
preview: "Probe finished: spawned worker, ping ok.",
|
|
truncated: false,
|
|
meta: { lineCount: 3, charSize: "120 B" },
|
|
mergeSummary: "",
|
|
});
|
|
const deliveryText = `${summary}\n\nSpawnProbe is now idle — message it via \`irc\` to follow up; transcript at history://SpawnProbe`;
|
|
|
|
const output = renderLines(deliveryText);
|
|
expect(output).toContain("Probe finished: spawned worker, ping ok.");
|
|
expect(output).not.toContain("<task-result");
|
|
expect(output).not.toContain("<output>");
|
|
});
|
|
|
|
it("previews the truncated <preview> body the same way", () => {
|
|
const summary = prompt.render(taskSummaryTemplate, {
|
|
agentName: "task",
|
|
id: "BigOne",
|
|
status: "completed",
|
|
duration: "2m",
|
|
preview: "first line of long output",
|
|
truncated: true,
|
|
mergeSummary: "",
|
|
});
|
|
|
|
const output = renderLines(summary);
|
|
expect(output).toContain("first line of long output");
|
|
expect(output).not.toContain("<task-result");
|
|
});
|
|
|
|
it("passes non-envelope result text through unchanged", () => {
|
|
const output = renderLines("42 pass, 0 fail (18.4s)");
|
|
expect(output).toContain("42 pass, 0 fail (18.4s)");
|
|
});
|
|
});
|