Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions apps/web/src/components/ChatView.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,21 @@ describe("planComposerTurn", () => {
});

it("queues behind a compaction of a stale session, except for /compact itself", () => {
expect(planComposerTurn({ ...base, resumeCompactionTokens: 120_000 })).toMatchObject({
compactBeforeSend: true,
turnDispatchMode: "queue",
shouldQueueBehindActiveRun: true,
});
expect(
planComposerTurn({ ...base, resumeCompactionTokens: 120_000, messageText: "/COMPACT" }),
).toMatchObject({ compactBeforeSend: false, turnDispatchMode: "auto" });
const stale = { ...base, resumeCompactionTokens: 120_000 };
for (const messageText of ["hello", "/compactfoo"]) {
expect(planComposerTurn({ ...stale, messageText })).toMatchObject({
compactBeforeSend: true,
turnDispatchMode: "queue",
shouldQueueBehindActiveRun: true,
});
}
for (const messageText of ["/COMPACT", "/compact keep the API notes", "/compact\n tests"]) {
expect(planComposerTurn({ ...stale, messageText })).toMatchObject({
compactBeforeSend: false,
turnDispatchMode: "auto",
shouldQueueBehindActiveRun: false,
});
}
});

it("queues behind a running turn only when asked to", () => {
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/ChatView.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,10 @@ export function shouldShowPlanFollowUpPrompt(input: {
);
}

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

const sessionDismissedBranchMismatchKeys = new Set<string>();

export function dismissBranchMismatchForSession(key: string): void {
Expand Down Expand Up @@ -1541,7 +1545,7 @@ export function planComposerTurn(input: {
const compactBeforeSend =
input.resumeCompactionTokens !== null &&
!input.keepFullHistory &&
input.messageText.toLowerCase() !== "/compact";
!COMPACT_COMMAND_PATTERN.test(input.messageText);
return {
// In worktree mode, require an explicit base branch so we don't silently
// fall back to local execution when branch selection is missing.
Expand Down
Loading