| ... | @@ -8733,7 +8733,18 @@ export default function ChatView(props: ChatViewProps) { | ... | @@ -8733,7 +8733,18 @@ export default function ChatView(props: ChatViewProps) { |
| 8733 | ); | 8733 | ); |
| 8734 | const messageIdForSend = newMessageId(); | 8734 | const messageIdForSend = newMessageId(); |
| 8735 | const messageCreatedAt = new Date().toISOString(); | 8735 | 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"); |
| 8737 | const outgoingMessageText = formatOutgoingPrompt({ | 8748 | const outgoingMessageText = formatOutgoingPrompt({ |
| 8738 | provider: ctxSelectedProvider, | 8749 | provider: ctxSelectedProvider, |
| 8739 | model: ctxSelectedModel, | 8750 | model: ctxSelectedModel, |
| ... | @@ -9299,6 +9310,22 @@ export default function ChatView(props: ChatViewProps) { | ... | @@ -9299,6 +9310,22 @@ export default function ChatView(props: ChatViewProps) { |
| 9299 | failure = turnAttachmentsResult; | 9310 | failure = turnAttachmentsResult; |
| 9300 | } | 9311 | } |
| 9301 | | 9312 | |
| | 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 | |
| 9302 | let backgroundDraftOpened = false; | 9329 | let backgroundDraftOpened = false; |
| 9303 | let turnStartSucceeded = false; | 9330 | let turnStartSucceeded = false; |
| 9304 | if (failure === null && turnAttachmentsResult._tag === "Success") { | 9331 | if (failure === null && turnAttachmentsResult._tag === "Success") { |
| ... | @@ -9376,7 +9403,7 @@ export default function ChatView(props: ChatViewProps) { | ... | @@ -9376,7 +9403,7 @@ export default function ChatView(props: ChatViewProps) { |
| 9376 | titleSeed: title, | 9403 | titleSeed: title, |
| 9377 | runtimeMode, | 9404 | runtimeMode, |
| 9378 | interactionMode: sendInteractionMode, | 9405 | interactionMode: sendInteractionMode, |
| 9379 | dispatchMode, | 9406 | dispatchMode: turnDispatchMode, |
| 9380 | ...(bootstrap ? { bootstrap } : {}), | 9407 | ...(bootstrap ? { bootstrap } : {}), |
| 9381 | createdAt: messageCreatedAt, | 9408 | createdAt: messageCreatedAt, |
| 9382 | }, | 9409 | }, |