feat: inject toolset swap and slash-command context reminders (#1022)

This commit is contained in:
Charles Packer
2026-02-18 18:15:38 -08:00
committed by GitHub
parent f90244de82
commit a0a5bbfc72
10 changed files with 458 additions and 16 deletions

View File

@@ -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", () => {

View 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",
);
});
});