Files
oh-my-pi/packages/coding-agent/test/issue-interrupt-and-flush-empty-messages.test.ts
T
can1357 705750453d fix(coding-agent-turn-interrupt/queue-ux): resolved steering abort state
- Replaced queued-message interrupt flow with session abort calls on empty submit and escape.
- Removed interrupting state and notifyInterrupting teardown paths from abort handling.
- Updated AgentSession queue operations to use shared steering and follow-up queue views.
- Propagated isAborting through session state and collab payloads to suppress late updates.
2026-06-13 17:31:25 +02:00

67 lines
2.0 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import { InputController } from "@oh-my-pi/pi-coding-agent/modes/controllers/input-controller";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { USER_INTERRUPT_LABEL } from "@oh-my-pi/pi-coding-agent/session/messages";
function createContext() {
let editorText = "";
const abort = vi.fn(async () => {});
const prompt = vi.fn(async () => {});
const updatePendingMessagesDisplay = vi.fn();
const requestRender = vi.fn();
const showError = vi.fn();
const ctx = {
editor: {
setText(text: string) {
editorText = text;
},
getText() {
return editorText;
},
addToHistory: vi.fn(),
},
ui: { requestRender },
session: {
isStreaming: true,
isCompacting: false,
isBashRunning: false,
isEvalRunning: false,
queuedMessageCount: 1,
extensionRunner: undefined,
abort,
prompt,
},
get viewSession() {
return (this as typeof ctx).session;
},
pendingImages: [],
pendingImageLinks: [],
compactionQueuedMessages: [],
locallySubmittedUserSignatures: new Set<string>(),
isBashMode: false,
isPythonMode: false,
loopModeEnabled: false,
updatePendingMessagesDisplay,
showError,
hasActiveBtw: () => false,
hasActiveOmfg: () => false,
} as unknown as InteractiveModeContext;
return { ctx, abort, prompt, updatePendingMessagesDisplay, requestRender, showError };
}
describe("empty submit with queued messages", () => {
it("aborts the active stream instead of eagerly prompting a drained queue", async () => {
const { ctx, abort, prompt, updatePendingMessagesDisplay, requestRender, showError } = createContext();
const controller = new InputController(ctx);
controller.setupEditorSubmitHandler();
await ctx.editor.onSubmit?.("");
expect(abort).toHaveBeenCalledWith({ reason: USER_INTERRUPT_LABEL });
expect(prompt).not.toHaveBeenCalled();
expect(showError).not.toHaveBeenCalled();
expect(updatePendingMessagesDisplay).toHaveBeenCalledTimes(1);
expect(requestRender).toHaveBeenCalledTimes(1);
});
});