Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

test(coding-agent): promote routing and notice coverage (#500)

Sebastian Müller82a4ee24ee25
diff --git a/packages/coding-agent/test/fixtures/owned-session-worker-fixture.ts b/packages/coding-agent/test/fixtures/owned-session-worker-fixture.ts
index c80f51a74c..db76aa3192 100644
--- a/packages/coding-agent/test/fixtures/owned-session-worker-fixture.ts
+++ b/packages/coding-agent/test/fixtures/owned-session-worker-fixture.ts
@@ -7,13 +7,17 @@ import {
import { attachJsonlLineReader, serializeJsonLine } from "../../src/modes/rpc/jsonl.js";
const args = process.argv.slice(2);
+if (process.env.PRIME_AGENT_TEST_STDIN_TTY) {
+ Object.defineProperty(process.stdin, "isTTY", { value: process.env.PRIME_AGENT_TEST_STDIN_TTY === "1" });
+}
const pidPath = process.env.PRIME_AGENT_TEST_OWNED_PID_PATH;
installOwnedSessionWorkerOwnerWatch();
if (process.env.PRIME_AGENT_INTERNAL_OWNED_WORKER === "1") {
if (pidPath) {
- writeFileSync(pidPath, `${process.pid}\n`);
writeFileSync(`${pidPath}.ppid`, `${process.ppid}\n`);
+ writeFileSync(`${pidPath}.profile`, `${process.env.PRIME_AGENT_INTERNAL_OWNED_PROFILE ?? ""}\n`);
+ writeFileSync(pidPath, `${process.pid}\n`);
process.once("SIGTERM", () => {
writeFileSync(`${pidPath}.terminated`, "terminated\n");
process.exit(0);
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index 1c57981cc3..5874ddbdca 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -183,13 +183,7 @@ describe("InteractiveMode update notifications", () => {
const output = normalizeRenderedOutput(chatContainer);
expect(chatContainer.children).toHaveLength(1);
- expect(output.split("\n")).toHaveLength(1);
- expect(output).toContain("Update available:");
- expect(output).toContain("v1.2.3");
- expect(output).toContain("/update");
- expect(output).not.toContain("prime-agent update");
- expect(output).not.toContain("pi update");
- expect(output).not.toContain("Changelog:");
+ expect(output).toBe("Update available: v1.2.3. Run /update");
});
test("shows package updates in one compact line", () => {
@@ -199,16 +193,11 @@ describe("InteractiveMode update notifications", () => {
ui: { requestRender: vi.fn() },
} as unknown as InteractiveMode;
- InteractiveMode.prototype.showPackageUpdateNotification.call(fakeThis, ["npm:@foo/bar"]);
+ InteractiveMode.prototype.showPackageUpdateNotification.call(fakeThis, ["npm:@foo/bar", "npm:@baz/qux"]);
const output = normalizeRenderedOutput(chatContainer);
expect(chatContainer.children).toHaveLength(1);
- expect(output.split("\n")).toHaveLength(1);
- expect(output).toContain("Package updates available:");
- expect(output).toContain("npm:@foo/bar");
- expect(output).toContain("/update --extensions");
- expect(output).not.toContain("prime-agent update");
- expect(output).not.toContain("pi update");
+ expect(output).toBe("Package updates available: npm:@foo/bar, npm:@baz/qux. Run /update --extensions");
});
});
diff --git a/packages/coding-agent/test/owned-session-worker-process.test.ts b/packages/coding-agent/test/owned-session-worker-process.test.ts
index ab73026ab2..0b661ff631 100644
--- a/packages/coding-agent/test/owned-session-worker-process.test.ts
+++ b/packages/coding-agent/test/owned-session-worker-process.test.ts
@@ -120,6 +120,35 @@ async function waitForProcessGone(pid: number): Promise<void> {
}
describe("owned session worker processes", () => {
+ it("routes every headless surface through its real worker profile", async () => {
+ const cases: Array<[string[], string | undefined, string, boolean?]> = [
+ [["-p", "hello"], undefined, "print"],
+ [[], "hello", "print", false],
+ [["--mode", "json"], "", "json"],
+ [["--mode", "rpc"], `${JSON.stringify({ id: "state", type: "get_state" })}\n`, "rpc"],
+ [["--no-session"], undefined, "interactive-ephemeral", true],
+ ];
+ for (const [args, stdin, profile, tty] of cases) {
+ const root = mkdtempSync(join(tmpdir(), "prime-owned-worker-routing-"));
+ tempDirs.push(root);
+ const pidPath = join(root, "worker.pid");
+ const frontend = spawnFrontend(
+ args,
+ pidPath,
+ tty === false,
+ tty === undefined ? {} : { PRIME_AGENT_TEST_STDIN_TTY: tty ? "1" : "0" },
+ );
+ if (stdin !== undefined) frontend.stdin?.write(stdin);
+ const workerPid = await waitForWorkerPid(pidPath);
+ expect(readFileSync(`${pidPath}.profile`, "utf8").trim()).toBe(profile);
+ frontend.stdin?.end();
+ if (tty === false) process.kill(workerPid, "SIGKILL");
+ await waitForExit(frontend);
+ children.delete(frontend);
+ await waitForProcessGone(workerPid);
+ }
+ });
+
it("keeps RPC framing in the frontend and exits its worker on stdin EOF", async () => {
const root = mkdtempSync(join(tmpdir(), "prime-owned-worker-test-"));
tempDirs.push(root);
diff --git a/packages/coding-agent/test/owned-session-worker.test.ts b/packages/coding-agent/test/owned-session-worker.test.ts
index 6b0eeb756f..797ff92d04 100644
--- a/packages/coding-agent/test/owned-session-worker.test.ts
+++ b/packages/coding-agent/test/owned-session-worker.test.ts
@@ -8,14 +8,6 @@ import {
} from "../src/cli/owned-session-worker.js";
describe("owned session worker CLI routing", () => {
- it("routes every headless surface to an owned worker", () => {
- expect(classifyOwnedSessionWorkerInvocation(["-p", "hello"], true, {})).toBe("print");
- expect(classifyOwnedSessionWorkerInvocation([], false, {})).toBe("print");
- expect(classifyOwnedSessionWorkerInvocation(["--mode", "json", "hello"], true, {})).toBe("json");
- expect(classifyOwnedSessionWorkerInvocation(["--mode", "rpc"], true, {})).toBe("rpc");
- expect(classifyOwnedSessionWorkerInvocation(["--no-session"], true, {})).toBe("interactive-ephemeral");
- });
-
it("leaves resident interactive and non-session operations in the frontend", () => {
expect(classifyOwnedSessionWorkerInvocation([], true, {})).toBeUndefined();
expect(classifyOwnedSessionWorkerInvocation(["--mode", "daemon"], false, {})).toBeUndefined();
diff --git a/packages/coding-agent/test/startup-notices.test.ts b/packages/coding-agent/test/startup-notices.test.ts
index 6bf6babac9..c139bff623 100644
--- a/packages/coding-agent/test/startup-notices.test.ts
+++ b/packages/coding-agent/test/startup-notices.test.ts
@@ -1,10 +1,6 @@
import { beforeAll, describe, expect, test } from "vitest";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
-import {
- formatPackageUpdateNotice,
- formatTmuxWarningNotice,
- formatUpdateAvailableNotice,
-} from "../src/modes/shared/startup-notices.js";
+import { formatTmuxWarningNotice } from "../src/modes/shared/startup-notices.js";
const ANSI_PATTERN = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
@@ -17,19 +13,6 @@ describe("startup notice formatters", () => {
initTheme("dark");
});
- test("update notice mentions the version and slash update command", () => {
- const output = stripAnsi(formatUpdateAvailableNotice("1.2.3"));
- expect(output).toBe("Update available: v1.2.3. Run /update");
- expect(output).not.toContain("prime-agent update");
- expect(output).not.toContain("pi update");
- });
-
- test("package update notice lists packages and the extensions command", () => {
- const output = stripAnsi(formatPackageUpdateNotice(["npm:@foo/bar", "npm:@baz/qux"]));
- expect(output).toBe("Package updates available: npm:@foo/bar, npm:@baz/qux. Run /update --extensions");
- expect(output).not.toContain("prime-agent update");
- });
-
test("tmux warning notice is prefixed with the warning glyph", () => {
const output = stripAnsi(formatTmuxWarningNotice("tmux extended-keys is off."));
expect(output).toBe("⚠ tmux extended-keys is off.");