test(coding-agent): repair stale CI contracts

This commit is contained in:
Mathews-Tom
2026-07-15 20:56:42 +05:30
parent 6cb27f7945
commit 63ece0218a
3 changed files with 24 additions and 30 deletions
@@ -1,11 +1,11 @@
import { afterEach, describe, expect, it, vi } from "bun:test";
import type { Api, Model } from "@oh-my-pi/pi-ai";
import { buildModel } from "@oh-my-pi/pi-catalog/build";
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import * as sdkModule from "@oh-my-pi/pi-coding-agent/sdk";
import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { runSubprocess } from "@oh-my-pi/pi-coding-agent/task/executor";
import type { AgentDefinition } from "@oh-my-pi/pi-coding-agent/task/types";
import { Settings } from "../src/config/settings";
import * as sdkModule from "../src/sdk";
import type { AgentSession } from "../src/session/agent-session";
import { runSubprocess } from "../src/task/executor";
import type { AgentDefinition } from "../src/task/types";
function model(provider: string, id: string): Model<Api> {
return buildModel({
@@ -30,6 +30,7 @@ function createYieldingSession(): AgentSession {
extensionRunner: undefined,
sessionManager: { appendSessionInit: () => {} },
getActiveToolNames: () => ["yield"],
getEnabledToolNames: () => ["yield"],
setActiveToolsByName: async () => {},
subscribe: (listener: (event: { type: string; [key: string]: unknown }) => void) => {
listeners.push(listener);
@@ -37,12 +38,6 @@ function createYieldingSession(): AgentSession {
},
prompt: async () => {
for (const listener of listeners) {
listener({
type: "retry_fallback_applied",
from: "primary/bad-runtime-model",
to: "fallback/working-model",
role: "subagent:issue-2750",
});
listener({
type: "tool_execution_end",
toolCallId: "tool-yield",
@@ -50,6 +45,12 @@ function createYieldingSession(): AgentSession {
result: { content: [{ type: "text", text: "Result submitted." }], details: { status: "success" } },
isError: false,
});
listener({
type: "retry_fallback_applied",
from: "primary/bad-runtime-model",
to: "fallback/working-model",
role: "subagent:issue-2750",
});
}
},
waitForIdle: async () => {},
@@ -421,10 +421,7 @@ describe("streaming tool call preview height (bounded across renderers)", () =>
expect(visibleWidth(topBorder ?? "")).toBe(width);
});
test("bash/ssh pending previews stay short even with very long multiline args", () => {
// bash/ssh window the collapsed command to a viewport-sized TAIL: the end
// (the live edge while args stream) stays visible behind an "… N earlier
// lines" marker on top; the head is elided.
test("bash pending previews stay short even with very long multiline args", () => {
const window = previewWindowRows();
const total = window + 5;
const longLines = Array.from({ length: total }, (_, i) => `line-${i}`);
@@ -433,10 +430,7 @@ describe("streaming tool call preview height (bounded across renderers)", () =>
const lastHidden = `line-${hidden - 1}`;
const firstVisible = `line-${hidden}`;
const lastVisible = `line-${total - 1}`;
const cases: Array<{ name: string; args: unknown }> = [
{ name: "bash", args: { command: longLines.join("\n") } },
{ name: "ssh", args: { host: "example", command: longLines.join("\n") } },
];
const cases: Array<{ name: string; args: unknown }> = [{ name: "bash", args: { command: longLines.join("\n") } }];
for (const testCase of cases) {
const { lines, text } = renderPending(testCase.name, testCase.args);
@@ -453,10 +447,10 @@ describe("streaming tool call preview height (bounded across renderers)", () =>
}, 30_000);
test("eval pending preview windows the code to the viewport tail", () => {
// Eval cell code is capped to the same viewport-sized TAIL window as
// bash/ssh: the live edge stays visible behind an "… N earlier lines"
// marker on top; ctrl+o uncaps. Unlike bash, the marker row sits above
// the window, so previewWindowRows() code lines stay visible.
// Eval code is capped to the same viewport-sized tail window as bash:
// the live edge stays visible behind an "… N earlier lines" marker;
// ctrl+o uncaps. Unlike bash, the marker row sits above the window, so
// previewWindowRows() code lines stay visible.
const window = previewWindowRows();
const total = window + 5;
const hidden = total - window;
@@ -4,24 +4,23 @@ import type { TaskItem } from "@oh-my-pi/pi-coding-agent/task/types";
import { prompt } from "@oh-my-pi/pi-utils";
import subagentSystemPromptTemplate from "../../src/prompts/system/subagent-system-prompt.md" with { type: "text" };
// Contract: a multi-sibling spawn with spawn capacity and IRC available draws
// a proactive coordinate-via-irc suggestion, and the subagent COOP prompt
// actively tells peers to coordinate before overlapping edits.
// Contract: a multi-sibling spawn with capacity and hub available draws
// a proactive coordination suggestion, and the subagent prompt tells peers
// to coordinate before overlapping edits.
const item = (): TaskItem => ({ task: "do the thing" });
describe("buildCoordinationAdvisory", () => {
it("suggests irc coordination for >=2 siblings with capacity and irc enabled", () => {
it("suggests hub coordination for >=2 siblings with capacity and hub enabled", () => {
const advice = buildCoordinationAdvisory([item(), item()], true, true);
expect(advice).toBeDefined();
expect(advice).toContain("`irc`");
expect(advice).toContain("`hub`");
});
it("stays silent for a single spawn", () => {
expect(buildCoordinationAdvisory([item()], true, true)).toBeUndefined();
});
it("stays silent when irc is unavailable", () => {
it("stays silent when hub is unavailable", () => {
expect(buildCoordinationAdvisory([item(), item()], true, false)).toBeUndefined();
});