@@ -223,6 +223,7 @@ import { cn, isMacPlatform, randomUUID } from "~/lib/utils";
223223import {
224224 getComposerPromptLengthValidationMessage ,
225225 getComposerSubmissionValidationMessage ,
226+ isComposerSubmissionBlocked ,
226227 submitComposerDraft ,
227228} from "./composerSubmission" ;
228229import { ComposerPromptLengthValidation } from "./ComposerPromptLengthValidation" ;
@@ -1823,8 +1824,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
18231824 } ,
18241825 } ) ;
18251826 const { blocksSubmission : voiceInputActive , submitAfterDictation } = speechInput ;
1826- const voiceSendDisabledReason =
1827- sendDisabledReason ?? ( speechInput . preparing ? "Preparing voice input" : null ) ;
1827+ const submissionTarget = activePendingProgress ? "pending-user-input" : "provider-turn" ;
1828+ const submissionBlocked = isComposerSubmissionBlocked ( {
1829+ submissionTarget,
1830+ noProviderAvailable,
1831+ sendDisabledReason,
1832+ attachmentBlockReason,
1833+ environmentUnavailable : environmentUnavailable !== null ,
1834+ } ) ;
1835+ // The pending Submit button follows the answer's own blockers, matching submitComposer.
1836+ const primaryActionSendDisabledReason =
1837+ ( activePendingProgress ? attachmentBlockReason : sendDisabledReason ) ??
1838+ ( speechInput . preparing ? "Preparing voice input" : null ) ;
1839+ const primaryActionEnvironmentUnavailable =
1840+ environmentUnavailable !== null ||
1841+ ( ! activePendingProgress && ( noProviderAvailable || projectSelectionRequired ) ) ;
18281842 const dictationShortcutLabel = useDictationShortcut ( {
18291843 keybindings,
18301844 speech : speechInput ,
@@ -2070,13 +2084,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
20702084
20712085 const shouldBlurMobileComposerOnSubmit = ( ) => {
20722086 if ( ! isSoftwareKeyboardOpen ) return false ;
2073- if (
2074- isSendBusy ||
2075- isSendDisabled ||
2076- noProviderAvailable ||
2077- environmentUnavailable !== null ||
2078- phase === "running"
2079- ) {
2087+ if ( isSendBusy || submissionBlocked || environmentUnavailable !== null || phase === "running" ) {
20802088 return false ;
20812089 }
20822090 if ( activePendingProgress ) {
@@ -2098,11 +2106,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
20982106 submitAfterDictation ( ( ) => submitComposerRef . current ( dispatchMode , submissionIntent ) ) ;
20992107 return false ;
21002108 }
2101- if (
2102- noProviderAvailable ||
2103- isSendDisabled ||
2104- ! readEnvironmentScope ( environmentId , AuthOrchestrationOperateScope )
2105- ) {
2109+ if ( submissionBlocked || ! readEnvironmentScope ( environmentId , AuthOrchestrationOperateScope ) ) {
21062110 event ?. preventDefault ( ) ;
21072111 return false ;
21082112 }
@@ -2129,7 +2133,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
21292133 }
21302134 const submission = submitComposerDraft ( {
21312135 prompt : promptRef . current ,
2132- submissionTarget : activePendingProgress ? "pending-user-input" : "provider-turn" ,
2136+ submissionTarget,
21332137 event,
21342138 onSend : ( sendEvent ) => {
21352139 providerInputRejectedRef . current = false ;
@@ -3518,12 +3522,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
35183522 isRunning = { false }
35193523 canInterrupt = { false }
35203524 isSendBusy = { isSendBusy }
3521- sendDisabledReason = { voiceSendDisabledReason }
3522- isEnvironmentUnavailable = {
3523- environmentUnavailable !== null ||
3524- noProviderAvailable ||
3525- projectSelectionRequired
3526- }
3525+ sendDisabledReason = { primaryActionSendDisabledReason }
3526+ isEnvironmentUnavailable = { primaryActionEnvironmentUnavailable }
35273527 isPreparingWorktree = { false }
35283528 hasSendableContent = { false }
35293529 preserveComposerFocusOnPointerDown
@@ -3602,12 +3602,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
36023602 ) }
36033603 voiceInputActive = { voiceInputActive }
36043604 isSendBusy = { isSendBusy }
3605- sendDisabledReason = { voiceSendDisabledReason }
3606- isEnvironmentUnavailable = {
3607- environmentUnavailable !== null ||
3608- noProviderAvailable ||
3609- projectSelectionRequired
3610- }
3605+ sendDisabledReason = { primaryActionSendDisabledReason }
3606+ isEnvironmentUnavailable = { primaryActionEnvironmentUnavailable }
36113607 isPreparingWorktree = { isPreparingWorktree }
36123608 hasSendableContent = { composerSendState . hasSendableContent || voiceInputActive }
36133609 canResume = { showResumeAction }
0 commit comments