


























@@ -1,6 +1,10 @@
1+import type { TUI } from "@earendil-works/pi-tui";
12import { describe, expect, it, vi } from "vitest";
3+import { CustomEditor } from "./components/custom-editor.js";
4+import { editorTheme } from "./theme/theme.js";
25import { createSubmitHarness } from "./tui-submit-test-helpers.js";
36import {
7+createEditorSubmitHandler,
48createSubmitBurstCoalescer,
59shouldEnableWindowsGitBashPasteFallback,
610} from "./tui-submit.js";
@@ -54,14 +58,36 @@ describe("createEditorSubmitHandler", () => {
54585559onSubmit(" wait, use c++ instead ");
566057-expect(editor.setText).not.toHaveBeenCalled();
61+expect(editor.setText).toHaveBeenCalledWith("wait, use c++ instead");
5862expect(editor.addToHistory).not.toHaveBeenCalled();
5963expect(sendMessage).not.toHaveBeenCalled();
6064expect(handleCommand).not.toHaveBeenCalled();
6165expect(handleBangLine).not.toHaveBeenCalled();
6266expect(onBlockedMessageSubmit).toHaveBeenCalledWith("wait, use c++ instead");
6367});
646869+it("restores the real editor value after pi-tui clears a busy submit", () => {
70+const tui = { requestRender: vi.fn() } as unknown as TUI;
71+const editor = new CustomEditor(tui, editorTheme);
72+const sendMessage = vi.fn();
73+const onBlockedMessageSubmit = vi.fn();
74+editor.setText("wait, use c++ instead");
75+editor.onSubmit = createEditorSubmitHandler({
76+ editor,
77+handleCommand: vi.fn(),
78+ sendMessage,
79+handleBangLine: vi.fn(),
80+canSubmitMessage: () => false,
81+ onBlockedMessageSubmit,
82+});
83+84+editor.handleInput("\r");
85+86+expect(editor.getText()).toBe("wait, use c++ instead");
87+expect(sendMessage).not.toHaveBeenCalled();
88+expect(onBlockedMessageSubmit).toHaveBeenCalledWith("wait, use c++ instead");
89+});
90+6591it("continues to route slash commands while chat is busy", () => {
6692const { editor, handleCommand, sendMessage, onBlockedMessageSubmit, onSubmit } =
6793createSubmitHarness({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。