@@ -326,6 +326,7 @@ import {
326326import {
327327 latestCompletedToolActivityId ,
328328 type QueuedComposerMessage ,
329+ type QueuedMessageSendSettings ,
329330 useQueuedMessages ,
330331 useQueuedMessageStore ,
331332} from "../queuedMessageStore" ;
@@ -7248,6 +7249,22 @@ export default function ChatView(props: ChatViewProps) {
72487249 } ;
72497250
72507251 const queuedMessages = useQueuedMessages ( activeThreadKey ?? "" ) ;
7252+ // The composer's model and modes, as a queued message keeps them for its send.
7253+ const readComposerSendSettings = (
7254+ sendCtx : ReturnType < ChatComposerHandle [ "getSendContext" ] > ,
7255+ ) : QueuedMessageSendSettings => ( {
7256+ modelSelection : sendCtx . selectedModelSelection ,
7257+ runtimeMode,
7258+ interactionMode : sendCtx . interactionMode ,
7259+ promptEffort : resolvePromptInjectedEffort (
7260+ getProviderModelCapabilities (
7261+ sendCtx . selectedProviderModels ,
7262+ sendCtx . selectedModel ,
7263+ sendCtx . selectedProvider ,
7264+ ) ,
7265+ sendCtx . selectedPromptEffort ,
7266+ ) ,
7267+ } ) ;
72517268 // Puts queued messages back into the composer after Stop or Cancel. Prompts
72527269 // join with blank lines; attachments and contexts are added.
72537270 const restoreQueuedMessagesToComposer = ( messages : ReadonlyArray < QueuedComposerMessage > ) => {
@@ -7280,14 +7297,16 @@ export default function ChatView(props: ChatViewProps) {
72807297 if ( restoredImages . length > 0 ) addComposerDraftImages ( composerDraftTarget , restoredImages ) ;
72817298 if ( restoredFiles . length > 0 ) addComposerDraftFiles ( composerDraftTarget , restoredFiles ) ;
72827299 if ( overflow . length > 0 && activeThreadKey ) {
7300+ // The overflow is the rest of the restored draft, so it follows the composer.
7301+ const sendCtx = composerRef . current ?. getSendContext ( ) ;
72837302 useQueuedMessageStore . getState ( ) . enqueue ( activeThreadKey , {
72847303 prompt : "" ,
72857304 images : overflow . filter ( ( attachment ) => attachment . type === "image" ) ,
72867305 files : overflow . filter ( ( attachment ) => attachment . type === "file" ) ,
72877306 terminalContexts : [ ] ,
72887307 previewAnnotations : [ ] ,
72897308 reviewComments : [ ] ,
7290- sendSettings : firstMessage . sendSettings ,
7309+ sendSettings : sendCtx ? readComposerSendSettings ( sendCtx ) : firstMessage . sendSettings ,
72917310 queuedAfterToolActivityId : latestCompletedToolActivityId ( threadActivities ) ,
72927311 // Restoration is not a send. The user decides when the overflow goes.
72937312 holdUntilUserAction : true ,
@@ -7664,23 +7683,24 @@ export default function ChatView(props: ChatViewProps) {
76647683 ) ;
76657684 return ;
76667685 }
7686+ // A queued message that will still leave on its own goes first, so a new
7687+ // send lines up behind it instead of overtaking it.
7688+ const queueStillSending =
7689+ activeThreadKey !== null &&
7690+ ( useQueuedMessageStore . getState ( ) . queuesByThreadKey [ activeThreadKey ] ?? [ ] ) . some (
7691+ ( message ) => message . sending !== undefined || ! message . holdUntilUserAction ,
7692+ ) ;
76677693 if (
76687694 ! directAnnotation &&
7669- phase === "running" &&
76707695 activeThreadKey &&
7671- ( settings . followUpBehavior === "queue" ) !== ( submissionIntent === "alternate" )
7696+ ( queueStillSending ||
7697+ ( phase === "running" &&
7698+ ( settings . followUpBehavior === "queue" ) !== ( submissionIntent === "alternate" ) ) )
76727699 ) {
7673- const promptEffort = resolvePromptInjectedEffort (
7674- getProviderModelCapabilities (
7675- ctxSelectedProviderModels ,
7676- ctxSelectedModel ,
7677- ctxSelectedProvider ,
7678- ) ,
7679- ctxSelectedPromptEffort ,
7680- ) ;
7700+ const sendSettings = readComposerSendSettings ( sendCtx ) ;
76817701 if (
76827702 composerRef . current ?. validateProviderInput (
7683- applyClaudePromptEffortPrefix ( promptForSend , promptEffort ) ,
7703+ applyClaudePromptEffortPrefix ( promptForSend , sendSettings . promptEffort ) ,
76847704 ) === false
76857705 ) {
76867706 return ;
@@ -7692,12 +7712,7 @@ export default function ChatView(props: ChatViewProps) {
76927712 terminalContexts : [ ...composerTerminalContexts ] ,
76937713 previewAnnotations : [ ...composerPreviewAnnotations ] ,
76947714 reviewComments : [ ...composerReviewComments ] ,
7695- sendSettings : {
7696- modelSelection : ctxSelectedModelSelection ,
7697- runtimeMode,
7698- interactionMode : sendInteractionMode ,
7699- promptEffort,
7700- } ,
7715+ sendSettings,
77017716 queuedAfterToolActivityId : latestCompletedToolActivityId ( threadActivities ) ,
77027717 createdAt : new Date ( ) . toISOString ( ) ,
77037718 } ) ;
0 commit comments