@@ -4,6 +4,8 @@ import { DESKTOP_PASTE_AS_TEXT_EVENT } from "../../lib/desktopPasteAsText";
44import { runtimeModeConfig , runtimeModeOptions as runtimeModes } from "./runtimeModeConfig" ;
55import { isLocalEnvironmentDisabled } from "../../localEnvironment" ;
66import { usePrimaryEnvironmentId } from "../../state/environments" ;
7+ import { useDesktopVoiceInputFork } from "../../voice-input/useVoiceInput.fork" ; // fork-hook: voice-input/composer-import
8+ import { VoiceComposerFooterFork } from "../../voice-input/VoiceComposerControls.fork" ; // fork-hook: voice-input/footer-import
79import { useRightPanelStore } from "~/rightPanelStore" ;
810import { importPastedComposerText , readPastedComposerContext } from "../composerInlineTokenPaste" ;
911import {
@@ -945,6 +947,24 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
945947 selectedProviderEntry ?. snapshot ,
946948 selectedModel ,
947949 ) ;
950+ const desktopVoiceFork = useDesktopVoiceInputFork ( {
951+ environmentId,
952+ ownerKey : composerDraftTargetKey ,
953+ enabled : canOperateThread && ! activePendingProgress && pendingApprovals . length === 0 ,
954+ readDraft : ( ) => ( {
955+ ownerKey : composerDraftTargetKeyRef . current ,
956+ text : promptRef . current ,
957+ selection : composerEditorRef . current ?. readSelectionRange ( ) ?? {
958+ start : promptRef . current . length ,
959+ end : promptRef . current . length ,
960+ } ,
961+ } ) ,
962+ commitDraft : ( text , cursor ) => {
963+ const collapsedCursor = collapseExpandedComposerCursor ( text , cursor ) ;
964+ onPromptChange ( text , collapsedCursor , cursor , false , collectInlineContextIds ( text ) ) ;
965+ requestAnimationFrame ( ( ) => composerEditorRef . current ?. focusAt ( collapsedCursor ) ) ;
966+ } ,
967+ } ) ; // fork-hook: voice-input/composer-controller
948968 const sendDisabledReason =
949969 externalSendDisabledReason ??
950970 ( multipleModelSelections ?. length === 0 ? "Select at least one model." : null ) ??
@@ -1658,6 +1678,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
16581678 ) => {
16591679 expandComposerForEditorChange ( ) ;
16601680 refreshWorkspaceSnapshotOnTyping ( ) ;
1681+ desktopVoiceFork . markDraftChanged ( ) ; // fork-hook: voice-input/draft-revision
16611682 if ( activePendingProgress ?. activeQuestion && pendingUserInputs . length > 0 ) {
16621683 if ( activePendingProgress . activeQuestion . allowCustomAnswer === false ) return ;
16631684 setComposerCursor ( nextCursor ) ;
@@ -2119,6 +2140,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
21192140 dispatchMode ?: ComposerDispatchMode ,
21202141 submissionIntent ?: ComposerSubmissionIntent ,
21212142 ) => {
2143+ if ( desktopVoiceFork . blocksSubmission ( ) ) {
2144+ return ;
2145+ } // fork-hook: voice-input/submission-guard
21222146 if (
21232147 noProviderAvailable ||
21242148 isSendDisabled ||
@@ -3430,6 +3454,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34303454 } }
34313455 className = "mx-auto w-full min-w-0 max-w-(--chat-content-max-width)"
34323456 data-chat-composer-form = "true"
3457+ { ...{
3458+ "data-voice-input-presented-fork" : desktopVoiceFork . presented ? "true" : undefined ,
3459+ "data-voice-input-compact-fork" : isComposerResting ? "true" : undefined ,
3460+ } } /* fork-hook: voice-input/presentation */
34333461 { ...threadContextDropTargetProps ( ) }
34343462 >
34353463 { composerControlsCollapsed && restingControlsHost
@@ -3439,6 +3467,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34393467 data-chat-composer-resting-controls = "true"
34403468 aria-hidden = { restingControlsVisible ? undefined : true }
34413469 inert = { restingControlsVisible ? undefined : true }
3470+ { ...( desktopVoiceFork . presented
3471+ ? { "data-voice-input-hidden-fork" : "true" , "aria-hidden" : true , inert : true }
3472+ : { } ) } /* fork-hook: voice-input/resting-presentation */
34423473 className = { cn (
34433474 "relative flex w-max min-w-0 max-w-full items-center gap-1 font-normal text-muted-foreground/70 [&_button]:text-xs!" ,
34443475 ! restingControlsVisible && "invisible" ,
@@ -3600,6 +3631,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
36003631 } ;
36013632 } }
36023633 data-chat-composer-body = "true"
3634+ { ...{
3635+ inert :
3636+ desktopVoiceFork . busy || ( desktopVoiceFork . presented && isComposerResting )
3637+ ? true
3638+ : undefined ,
3639+ "aria-hidden" : desktopVoiceFork . presented && isComposerResting ? true : undefined ,
3640+ } } /* fork-hook: voice-input/editor-presentation */
36033641 className = { cn (
36043642 "relative px-3 pb-2 sm:px-4" ,
36053643 "pt-3.5 sm:pt-4" ,
@@ -3764,6 +3802,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
37643802 promptHasText = { false }
37653803 isSendBusy = { isSendBusy }
37663804 sendDisabledReason = { sendDisabledReason }
3805+ { ...desktopVoiceFork . sendProps } /* fork-hook: voice-input/mobile-send */
37673806 isConnecting = { isConnecting }
37683807 isEnvironmentUnavailable = {
37693808 environmentUnavailable !== null ||
@@ -3789,6 +3828,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
37893828 { isComposerCollapsedMobile ? null : (
37903829 < div
37913830 data-chat-composer-footer = "true"
3831+ { ...{
3832+ inert : desktopVoiceFork . presented ? true : undefined ,
3833+ "aria-hidden" : desktopVoiceFork . presented ? true : undefined ,
3834+ } } /* fork-hook: voice-input/footer-presentation */
37923835 data-chat-composer-footer-compact = { isComposerFooterCompact ? "true" : "false" }
37933836 className = { cn (
37943837 "flex min-w-0 flex-nowrap items-center justify-between gap-2 overflow-visible px-3 pb-3 sm:px-4 sm:pb-4" ,
@@ -3823,6 +3866,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
38233866 className = "flex shrink-0 flex-nowrap items-center justify-end gap-2"
38243867 >
38253868 { composerAttachButton }
3869+ { /* fork-hook: voice-input/composer-controls */ }
3870+ { desktopVoiceFork . controls }
3871+ { /* fork-hook-end */ }
38263872 < ComposerFooterPrimaryActions
38273873 compact = { isComposerResting || isComposerPrimaryActionsCompact }
38283874 canOperateThread = { canOperateThread }
@@ -3857,6 +3903,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
38573903 promptHasText = { prompt . trim ( ) . length > 0 }
38583904 isSendBusy = { isSendBusy }
38593905 sendDisabledReason = { sendDisabledReason }
3906+ { ...desktopVoiceFork . sendProps } /* fork-hook: voice-input/primary-send */
38603907 isConnecting = { isConnecting }
38613908 isEnvironmentUnavailable = {
38623909 environmentUnavailable !== null ||
@@ -3888,7 +3935,12 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
38883935 </ div >
38893936 ) }
38903937 { showInlineRestingControls ? (
3891- < div className = "h-8" >
3938+ < div
3939+ className = "h-8"
3940+ { ...{
3941+ "data-voice-input-resting-fork" : "true" ,
3942+ } } /* fork-hook: voice-input/inline-resting */
3943+ >
38923944 < div
38933945 ref = { setInlineRestingControlsHost }
38943946 className = "absolute bottom-2 inset-x-4 min-w-0"
@@ -3908,6 +3960,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
39083960 </ div >
39093961 </ div >
39103962 ) : null }
3963+ { /* fork-hook: voice-input/footer */ }
3964+ < VoiceComposerFooterFork
3965+ toolbar = { desktopVoiceFork . toolbar }
3966+ compact = { isComposerResting }
3967+ presented = { desktopVoiceFork . presented }
3968+ />
3969+ { /* fork-hook-end */ }
39113970 </ div >
39123971 </ ComposerSurface . Main >
39133972 </ div >
0 commit comments