Open History to see the last commit
1import { expect, it } from "vite-plus/test";
2
3import { compactionBlocksSteering } from "./composerDispatch.ts";
4
5it("blocks steering for explicit compaction, and for automatic compaction unless the provider takes steers then", () => {
6 const during = (
7 text: string | undefined,
8 attachments: ReadonlyArray<unknown> = [],
9 steersDuringCompaction = true,
10 ) =>
11 compactionBlocksSteering({
12 compactCommandIsActive: false,
13 compactionRunning: true,
14 steersDuringCompaction,
15 run: { userMessageId: "user" },
16 messages: [
17 ...(text === undefined ? [] : [{ id: "user", text, attachments }]),
18 { id: "later", text: "/compact" },
19 ],
20 });
21
22 for (const text of ["/compact", " /COMPACT ", "/compact keep the debugging notes"]) {
23 expect(during(text)).toBe(true);
24 }
25 for (const text of ["Read the code", "/compactify", "please /compact", undefined]) {
26 expect(during(text)).toBe(false);
27 }
28 expect(during("/compact", [{}])).toBe(false);
29 expect(during("Read the code", [], false)).toBe(true);
30
31 expect(
32 compactionBlocksSteering({
33 compactCommandIsActive: true,
34 compactionRunning: false,
35 steersDuringCompaction: true,
36 run: undefined,
37 messages: undefined,
38 }),
39 ).toBe(true);
40 expect(
41 compactionBlocksSteering({
42 compactCommandIsActive: false,
43 compactionRunning: false,
44 steersDuringCompaction: false,
45 run: { userMessageId: "user" },
46 messages: [{ id: "user", text: "/compact" }],
47 }),
48 ).toBe(false);
49});