feat: inject toolset swap and slash-command context reminders (#1022)
This commit is contained in:
@@ -75,6 +75,27 @@ describe("commandRunner", () => {
|
||||
});
|
||||
expect(buffers.order).toEqual(["cmd-1"]);
|
||||
});
|
||||
|
||||
test("onCommandFinished fires once on running->finished transition", () => {
|
||||
const buffers = createBuffers();
|
||||
const buffersRef = { current: buffers };
|
||||
const finishedEvents: Array<{ input: string; output: string }> = [];
|
||||
const runner = createCommandRunner({
|
||||
buffersRef,
|
||||
refreshDerived: () => {},
|
||||
createId: () => "cmd-1",
|
||||
onCommandFinished: (event) => {
|
||||
finishedEvents.push({ input: event.input, output: event.output });
|
||||
},
|
||||
});
|
||||
|
||||
const cmd = runner.start("/model", "Opening model selector...");
|
||||
cmd.update({ output: "Still opening...", phase: "running" });
|
||||
cmd.finish("Switched", true);
|
||||
cmd.finish("Switched again", true);
|
||||
|
||||
expect(finishedEvents).toEqual([{ input: "/model", output: "Switched" }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("command input preservation in handlers", () => {
|
||||
|
||||
35
src/tests/cli/interaction-reminder-wiring.test.ts
Normal file
35
src/tests/cli/interaction-reminder-wiring.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
function readAppSource(): string {
|
||||
const appPath = fileURLToPath(new URL("../../cli/App.tsx", import.meta.url));
|
||||
return readFileSync(appPath, "utf-8");
|
||||
}
|
||||
|
||||
describe("interaction reminder wiring", () => {
|
||||
test("command runner finish events are wired into shared reminder state", () => {
|
||||
const source = readAppSource();
|
||||
expect(source).toContain("const recordCommandReminder = useCallback(");
|
||||
expect(source).toContain(
|
||||
"enqueueCommandIoReminder(sharedReminderStateRef.current",
|
||||
);
|
||||
expect(source).toContain("onCommandFinished: recordCommandReminder");
|
||||
});
|
||||
|
||||
test("model/toolset handlers enqueue toolset change reminder snapshots", () => {
|
||||
const source = readAppSource();
|
||||
expect(source).toContain(
|
||||
"const maybeRecordToolsetChangeReminder = useCallback(",
|
||||
);
|
||||
expect(source).toContain(
|
||||
"const previousToolNamesSnapshot = getToolNames();",
|
||||
);
|
||||
expect(source).toContain('source: "/model (auto toolset)"');
|
||||
expect(source).toContain('source: "/model (manual toolset override)"');
|
||||
expect(source).toContain('source: "/toolset"');
|
||||
expect(source).toContain(
|
||||
"enqueueToolsetChangeReminder(sharedReminderStateRef.current",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user