Files
oh-my-pi/packages/coding-agent/test/slash-commands/retry.test.ts
T
can1357 741558a6d4 feat(coding-agent): removed background mode command and runtime plumbing
- Removed the built-in `background` (`bg`) slash command and its `handleBackgroundCommand` path from the interactive flow.
- Deleted background event subscription and shutdown handling by removing `handleBackgroundEvent` from the event, input, and interactive controllers.
- Simplified `InteractiveModeContext` by dropping background-only fields and helpers such as `isBackgrounded`, background UI context creation, and background event callbacks.
2026-06-07 05:43:59 +02:00

46 lines
1.4 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { executeBuiltinSlashCommand } from "@oh-my-pi/pi-coding-agent/slash-commands/builtin-registry";
function createRuntime(didRetry: boolean) {
const retry = vi.fn(async () => didRetry);
const showStatus = vi.fn();
const setText = vi.fn();
return {
retry,
showStatus,
setText,
runtime: {
ctx: {
session: { retry } as unknown as InteractiveModeContext["session"],
editor: { setText } as unknown as InteractiveModeContext["editor"],
showStatus,
} as unknown as InteractiveModeContext,
},
};
}
describe("/retry slash command", () => {
it("clears the editor after starting a retry", async () => {
const harness = createRuntime(true);
const handled = await executeBuiltinSlashCommand("/retry", harness.runtime);
expect(handled).toBe(true);
expect(harness.retry).toHaveBeenCalledTimes(1);
expect(harness.showStatus).not.toHaveBeenCalled();
expect(harness.setText).toHaveBeenCalledWith("");
});
it("reports when there is no failed turn to retry", async () => {
const harness = createRuntime(false);
const handled = await executeBuiltinSlashCommand("/retry", harness.runtime);
expect(handled).toBe(true);
expect(harness.retry).toHaveBeenCalledTimes(1);
expect(harness.showStatus).toHaveBeenCalledWith("Nothing to retry");
expect(harness.setText).toHaveBeenCalledWith("");
});
});