Skip to content

Commit de326a8

Browse files
fix(web): /compact with instructions is the only compaction while the Compact chip is on
Compact-before-send matched only the exact text "/compact", so a typed "/compact <instructions>" queued a bare compaction ahead of it. The predicate now recognizes the command at a word boundary, case-insensitive, and the regression test is reduced to the one case that proves it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent eceb2ca commit de326a8

2 files changed

Lines changed: 5 additions & 28 deletions

File tree

‎apps/web/src/components/ChatView.logic.test.ts‎

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -512,38 +512,13 @@ describe("shouldShowPlanFollowUpPrompt", () => {
512512
});
513513

514514
describe("shouldCompactBeforeSend", () => {
515-
const chipOn = { resumeCompactionTokens: 120_000, keepFullHistory: false };
516-
517-
it("compacts before an ordinary message while the Compact chip is on", () => {
515+
it("lets /compact with instructions be the only compaction while the Compact chip is on", () => {
516+
const chipOn = { resumeCompactionTokens: 120_000, keepFullHistory: false };
518517
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "fix the failing test" })).toBe(true);
519518
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "/compactfoo" })).toBe(true);
520-
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "please /compact" })).toBe(true);
521-
});
522-
523-
it("sends a bare /compact once", () => {
524519
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "/compact" })).toBe(false);
525-
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "/COMPACT" })).toBe(false);
526-
});
527-
528-
it("sends /compact with instructions once so the instructions reach the only compaction", () => {
529-
expect(
530-
shouldCompactBeforeSend({ ...chipOn, messageText: "/compact keep the auth refactor notes" }),
531-
).toBe(false);
532-
expect(shouldCompactBeforeSend({ ...chipOn, messageText: "/Compact\nfocus on tests" })).toBe(
533-
false,
534-
);
535-
});
536-
537-
it("does not compact when the chip is off or the full history is kept", () => {
538-
expect(
539-
shouldCompactBeforeSend({
540-
resumeCompactionTokens: null,
541-
keepFullHistory: false,
542-
messageText: "fix the failing test",
543-
}),
544-
).toBe(false);
545520
expect(
546-
shouldCompactBeforeSend({ ...chipOn, keepFullHistory: true, messageText: "fix the test" }),
521+
shouldCompactBeforeSend({ ...chipOn, messageText: "/Compact keep the auth refactor notes" }),
547522
).toBe(false);
548523
});
549524
});

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ export function shouldShowPlanFollowUpPrompt(input: {
929929
);
930930
}
931931

932+
// A typed `/compact`, with or without instructions, is already the compaction. Queueing a
933+
// bare one ahead of it would run an uninstructed compaction first and charge for two.
932934
const COMPACT_COMMAND_PATTERN = /^\/compact(?:\s|$)/i;
933935

934936
export function shouldCompactBeforeSend(input: {

0 commit comments

Comments
 (0)