Files
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

43 lines
1.2 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 createRuntimeHarness(handleFreshCommand: InteractiveModeContext["handleFreshCommand"]) {
const setText = vi.fn();
return {
setText,
handleFreshCommand,
runtime: {
ctx: {
editor: { setText } as unknown as InteractiveModeContext["editor"],
handleFreshCommand,
} as InteractiveModeContext,
},
};
}
describe("/fresh slash command", () => {
it("awaits provider-state refresh before resolving", async () => {
const deferred = Promise.withResolvers<void>();
const handleFreshCommand = vi.fn(() => deferred.promise);
const harness = createRuntimeHarness(handleFreshCommand);
let settled = false;
const execution = executeBuiltinSlashCommand("/fresh", harness.runtime).then(result => {
settled = true;
return result;
});
await Promise.resolve();
expect(harness.setText).toHaveBeenCalledWith("");
expect(handleFreshCommand).toHaveBeenCalledTimes(1);
expect(settled).toBe(false);
deferred.resolve();
expect(await execution).toBe(true);
expect(settled).toBe(true);
});
});