@@ -8145,6 +8145,21 @@ export default function ChatView(props: ChatViewProps) {
81458145 onAdvanceActivePendingUserInput ( ) ;
81468146 return ;
81478147 }
8148+ // Sending past the resume banner compacts first so the turn does not resend the stale
8149+ // history. The message queues behind the /compact run; steering into it is rejected.
8150+ // The composer is read after the wait, so edits made meanwhile go out with the message.
8151+ const promptBeforeCompaction = promptRef . current . trim ( ) ;
8152+ const compactBeforeSend =
8153+ resumeCompactionBannerItem !== null &&
8154+ ! compactDisabled &&
8155+ editingQueuedRun === null &&
8156+ ( promptBeforeCompaction . length > 0 || composerHasNonPromptContent || ! ! directAnnotation ) &&
8157+ promptBeforeCompaction . toLowerCase ( ) !== "/compact" &&
8158+ composerRef . current ?. getSendContext ( ) . multipleModelSelections === null ;
8159+ if ( compactBeforeSend ) {
8160+ if ( ! ( await onCompactContext ( ) ) ) return ;
8161+ if ( currentRouteThreadKeyRef . current !== routeThreadKey ) return ;
8162+ }
81488163 const sendCtx = composerRef . current ?. getSendContext ( ) ;
81498164 if ( ! sendCtx ?. providerAvailable ) {
81508165 notifyDirectAnnotationAttached ( ) ;
@@ -8588,13 +8603,6 @@ export default function ChatView(props: ChatViewProps) {
85888603 ) ;
85898604 const messageIdForSend = newMessageId ( ) ;
85908605 const messageCreatedAt = new Date ( ) . toISOString ( ) ;
8591- // Sending past the resume banner compacts first so the turn does not resend the stale
8592- // history. The message queues behind the /compact run; steering into it is rejected.
8593- const compactBeforeSend =
8594- resumeCompactionBannerItem !== null &&
8595- ! compactDisabled &&
8596- multipleModelSelections === null &&
8597- messageTextForSend . toLowerCase ( ) !== "/compact" ;
85988606 const turnDispatchMode = compactBeforeSend ? "queue" : dispatchMode ;
85998607 const shouldQueueBehindActiveRun =
86008608 compactBeforeSend || ( phase === "running" && dispatchMode === "queue" ) ;
@@ -8670,7 +8678,6 @@ export default function ChatView(props: ChatViewProps) {
86708678 } ) ;
86718679 }
86728680
8673- if ( compactBeforeSend && ! ( await onCompactContext ( ) ) ) return ;
86748681 sendInFlightRef . current = true ;
86758682 const sendGeneration = ++ composerSendGenerationRef . current ;
86768683 const attachmentCapabilitiesBeforeUpload = readLiveAttachmentCapabilities ( ) ;
0 commit comments