Skip to content

Commit a976f8c

Browse files
maria-rcksclaude
andauthored
fix(web): sending past the resume banner compacts first (#15290)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 5108c97 commit a976f8c

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8733,7 +8733,18 @@ export default function ChatView(props: ChatViewProps) {
87338733
);
87348734
const messageIdForSend = newMessageId();
87358735
const messageCreatedAt = new Date().toISOString();
8736-
const shouldQueueBehindActiveRun = phase === "running" && dispatchMode === "queue";
8736+
// Sending past the resume banner compacts first so the turn does not resend the stale
8737+
// history. The message queues behind the /compact run; steering into it is rejected,
8738+
// and a held queue would strand it.
8739+
const compactBeforeSend =
8740+
resumeCompactionBannerItem !== null &&
8741+
!compactDisabled &&
8742+
!hasHeldQueuedRuns &&
8743+
multipleModelSelections === null &&
8744+
messageTextForSend.toLowerCase() !== "/compact";
8745+
const turnDispatchMode = compactBeforeSend ? "queue" : dispatchMode;
8746+
const shouldQueueBehindActiveRun =
8747+
compactBeforeSend || (phase === "running" && dispatchMode === "queue");
87378748
const outgoingMessageText = formatOutgoingPrompt({
87388749
provider: ctxSelectedProvider,
87398750
model: ctxSelectedModel,
@@ -9299,6 +9310,22 @@ export default function ChatView(props: ChatViewProps) {
92999310
failure = turnAttachmentsResult;
93009311
}
93019312

9313+
if (failure === null && compactBeforeSend) {
9314+
const compactResult = await startThreadTurn({
9315+
environmentId,
9316+
input: {
9317+
threadId: threadIdForSend,
9318+
message: { messageId: newMessageId(), role: "user", text: "/compact", attachments: [] },
9319+
modelSelection: ctxSelectedModelSelection,
9320+
runtimeMode,
9321+
interactionMode: sendInteractionMode,
9322+
},
9323+
});
9324+
if (compactResult._tag === "Failure") {
9325+
failure = compactResult;
9326+
}
9327+
}
9328+
93029329
let backgroundDraftOpened = false;
93039330
let turnStartSucceeded = false;
93049331
if (failure === null && turnAttachmentsResult._tag === "Success") {
@@ -9376,7 +9403,7 @@ export default function ChatView(props: ChatViewProps) {
93769403
titleSeed: title,
93779404
runtimeMode,
93789405
interactionMode: sendInteractionMode,
9379-
dispatchMode,
9406+
dispatchMode: turnDispatchMode,
93809407
...(bootstrap ? { bootstrap } : {}),
93819408
createdAt: messageCreatedAt,
93829409
},

0 commit comments

Comments
 (0)