The best way to control Claude Code, Codex and more from any computer or phone
fix(web): instructed compact runs without a bare compaction first (#24008)
Co-authored-by: fixfon <12512757+fixfon@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Julius Marminge committed
Oct 23, 2026 at 04:40 UTC
16aaf5ba7d75538c9c004ea7fb7ed62cd6b65e5b
2 files changed
+20
-9
apps/web/src/components/ChatView.logic.test.ts
+15
-8
@@ -1102,14 +1102,21 @@ describe("planComposerTurn", () => {
1102
});
1103
1104
it("queues behind a compaction of a stale session, except for /compact itself", () => {
1105
- expect(planComposerTurn({ ...base, resumeCompactionTokens: 120_000 })).toMatchObject({
1106
- compactBeforeSend: true,
1107
- turnDispatchMode: "queue",
1108
- shouldQueueBehindActiveRun: true,
1109
- });
1110
- expect(
1111
- planComposerTurn({ ...base, resumeCompactionTokens: 120_000, messageText: "/COMPACT" }),
1112
- ).toMatchObject({ compactBeforeSend: false, turnDispatchMode: "auto" });
1105
+ const stale = { ...base, resumeCompactionTokens: 120_000 };
1106
+ for (const messageText of ["hello", "/compactfoo"]) {
1107
+ expect(planComposerTurn({ ...stale, messageText })).toMatchObject({
1108
+ compactBeforeSend: true,
1109
+ turnDispatchMode: "queue",
1110
+ shouldQueueBehindActiveRun: true,
1111
+ });
1112
+ }
1113
+ for (const messageText of ["/COMPACT", "/compact keep the API notes", "/compact\n tests"]) {
1114
+ expect(planComposerTurn({ ...stale, messageText })).toMatchObject({
1115
+ compactBeforeSend: false,
1116
+ turnDispatchMode: "auto",
1117
+ shouldQueueBehindActiveRun: false,
1118
+ });
1119
+ }
1120
});
1121
1122
it("queues behind a running turn only when asked to", () => {
apps/web/src/components/ChatView.logic.ts
+5
-1
@@ -931,6 +931,10 @@ export function shouldShowPlanFollowUpPrompt(input: {
931
);
932
}
933
934
+// A typed `/compact`, with or without instructions, is already the compaction. Queueing a
935
+// bare one ahead of it would run an uninstructed compaction first and charge for two.
936
+const COMPACT_COMMAND_PATTERN = /^\/compact(?:\s|$)/i;
937
+
938
const sessionDismissedBranchMismatchKeys = new Set<string>();
939
940
export function dismissBranchMismatchForSession(key: string): void {
@@ -1541,7 +1545,7 @@ export function planComposerTurn(input: {
1545
const compactBeforeSend =
1546
input.resumeCompactionTokens !== null &&
1547
!input.keepFullHistory &&
1544
- input.messageText.toLowerCase() !== "/compact";
1548
+ !COMPACT_COMMAND_PATTERN.test(input.messageText);
1549
return {
1550
// In worktree mode, require an explicit base branch so we don't silently
1551
// fall back to local execution when branch selection is missing.