@@ -546,10 +546,12 @@ function ChatInput({
546546 } , [ ] ) ;
547547
548548 const handleKeyDown = useCallback ( ( e : React . KeyboardEvent < HTMLTextAreaElement > ) => {
549- if ( e . key === "Enter" && ! e . shiftKey ) {
549+ const isOpen = mentionQuery !== null && filteredFiles . length > 0 ;
550+ // An Enter consumed by the mention overlay must not record queue intent —
551+ // the next submit may be a button click that can't overwrite the flag.
552+ if ( ! isOpen && e . key === "Enter" && ! e . shiftKey ) {
550553 queueIntentRef . current = e . altKey ;
551554 }
552- const isOpen = mentionQuery !== null && filteredFiles . length > 0 ;
553555 if ( ! isOpen ) return ;
554556 if ( e . key === "ArrowDown" ) {
555557 e . preventDefault ( ) ;
@@ -914,6 +916,10 @@ export const ChatTab = forwardRef<ChatTabHandle, ChatTabProps>(function ChatTab(
914916 const [ selectedSkills , setSelectedSkills ] = useState < Skill [ ] > ( [ ] ) ;
915917 const [ messageQueue , setMessageQueue ] = useState < QueuedMessage [ ] > ( [ ] ) ;
916918 const queueIdCounter = useRef ( 0 ) ;
919+ // Mirrored every render so async continuations (the steer fallback) read
920+ // the CURRENT queue length, not the one closed over before the await.
921+ const messageQueueLengthRef = useRef ( 0 ) ;
922+ messageQueueLengthRef . current = messageQueue . length ;
917923 const composerRestoreRef = useRef < ( ( text : string ) => void ) | null > ( null ) ;
918924 const [ steerError , setSteerError ] = useState < string | null > ( null ) ;
919925
@@ -1063,7 +1069,7 @@ export const ChatTab = forwardRef<ChatTabHandle, ChatTabProps>(function ChatTab(
10631069 if ( result === "ok" ) return ;
10641070 if ( result === "not_streaming" ) {
10651071 // The run ended while we typed: keep ordering behind any queue.
1066- if ( steerNotStreamingFallback ( messageQueue . length ) === "queue" ) enqueue ( trimmed ) ;
1072+ if ( steerNotStreamingFallback ( messageQueueLengthRef . current ) === "queue" ) enqueue ( trimmed ) ;
10671073 else void sendNow ( ) ;
10681074 return ;
10691075 }
@@ -1084,7 +1090,6 @@ export const ChatTab = forwardRef<ChatTabHandle, ChatTabProps>(function ChatTab(
10841090 selectedDbs ,
10851091 selectedSkills ,
10861092 attachedFiles ,
1087- messageQueue . length ,
10881093 ] ,
10891094 ) ;
10901095
0 commit comments