The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { compactionBlocksSteering, composerRunsDraftLocally } from "./composerDispatch.ts"; |
| 4 | |
| 5 | it("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 | }); |
| 50 | |
| 51 | it("treats only the commands the composer runs itself as local", () => { |
| 52 | const none = { |
| 53 | holdsOnlyText: true, |
| 54 | sideChat: false, |
| 55 | usageLimits: false, |
| 56 | codexFeedback: false, |
| 57 | freshSession: false, |
| 58 | }; |
| 59 | const all = { |
| 60 | ...none, |
| 61 | sideChat: true, |
| 62 | usageLimits: true, |
| 63 | codexFeedback: true, |
| 64 | freshSession: true, |
| 65 | }; |
| 66 | for (const text of ["/btw why?", "/usage-limits", "/feedback slow", "/clear"]) { |
| 67 | expect(composerRunsDraftLocally({ ...all, text })).toBe(true); |
| 68 | expect(composerRunsDraftLocally({ ...none, text })).toBe(false); |
| 69 | } |
| 70 | expect(composerRunsDraftLocally({ ...all, text: "fix the bug" })).toBe(false); |
| 71 | expect(composerRunsDraftLocally({ ...all, holdsOnlyText: false, text: "/clear" })).toBe(false); |
| 72 | expect(composerRunsDraftLocally({ ...all, holdsOnlyText: false, text: "/side why?" })).toBe(true); |
| 73 | }); |