@@ -914,6 +914,143 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
914914 compactEditor . isExpanded ? { flex : 0 , width : 0 } : undefined ,
915915 ] }
916916 > </ Animated . View >
917+ { /* TalkBack orders siblings by position; outside this row the editor reads after Send. */ }
918+ < Animated . View
919+ style = { [
920+ compactEditor . editorStyle ,
921+ showsCompactDictation ? { display : "none" } : undefined ,
922+ ] }
923+ >
924+ < ComposerEditor
925+ hidden = { props . hidden }
926+ draftKey = { composerDraftKey }
927+ environmentId = { props . environmentId }
928+ onOpenMention = { ( path ) => {
929+ Keyboard . dismiss ( ) ;
930+ if ( props . isDraft ) {
931+ navigation . navigate ( "NewTaskFile" , {
932+ environmentId : String ( props . environmentId ) ,
933+ cwd : props . projectCwd ?? undefined ,
934+ path : fileRoutePathSegments ( path ) ,
935+ } ) ;
936+ } else {
937+ navigation . navigate ( "ThreadFile" , {
938+ environmentId : String ( props . environmentId ) ,
939+ threadId : String ( props . selectedThread . id ) ,
940+ path : fileRoutePathSegments ( path ) ,
941+ } ) ;
942+ }
943+ } }
944+ onOpenAttachment = { openDraftDocument }
945+ chipsInert = { ! isExpanded }
946+ onInertChipPress = { ( ) => inputRef . current ?. focus ( ) }
947+ ref = { inputRef }
948+ multiline
949+ value = { draftMessage }
950+ // The save uses a draft snapshot; further typing would be discarded on success.
951+ readOnly = { isSubmissionLocked }
952+ skills = { composerMenu . skills }
953+ selection = { composerMenu . selection }
954+ onChangeText = { ( text ) => {
955+ if ( ! isSubmissionLocked ) props . onChangeDraftMessage ( text ) ;
956+ } }
957+ onSelectionChange = { composerMenu . onSelectionChange }
958+ onPasteImages = { ( uris ) => {
959+ if ( isSubmissionLocked ) return ;
960+ pendingNativeImagePasteCountRef . current += 1 ;
961+ void props . onNativePasteImages ( uris ) . finally ( ( ) => {
962+ pendingNativeImagePasteCountRef . current -= 1 ;
963+ } ) ;
964+ } }
965+ onPasteText = { ( paste ) => {
966+ if ( isSubmissionLocked ) return ;
967+ const insertPaste = ( ) => {
968+ const insertion = replaceTextSelection ( {
969+ value : paste . value ,
970+ selection : paste . selection ,
971+ text : paste . text ,
972+ } ) ;
973+ const selection = { start : insertion . cursor , end : insertion . cursor } ;
974+ props . onChangeDraftMessage ( insertion . value ) ;
975+ composerMenu . onSelectionChange ( selection ) ;
976+ } ;
977+ const capabilities = props . serverConfig ?. environment . capabilities ;
978+ const advertisedMax = capabilities ?. fileAttachments ?. maxUploadBytes ;
979+ const maxBytes =
980+ advertisedMax === undefined
981+ ? null
982+ : clampFileAttachmentUploadBytes ( advertisedMax ) ;
983+ const wouldExceedInputLimit =
984+ paste . value . length -
985+ Math . max ( 0 , paste . selection . end - paste . selection . start ) +
986+ paste . text . length >
987+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS ;
988+ const canAttach =
989+ maxBytes !== null &&
990+ countComposerDraftAttachmentsAfterSelection ( composerDraftKey , {
991+ text : paste . value ,
992+ ...paste . selection ,
993+ } ) < PROVIDER_SEND_TURN_MAX_ATTACHMENTS &&
994+ new TextEncoder ( ) . encode ( paste . text ) . byteLength <= maxBytes ;
995+ if (
996+ pastedTextDisposition ( {
997+ text : paste . text ,
998+ wouldExceedInputLimit,
999+ canAttach : true ,
1000+ } ) === "attachment"
1001+ ) {
1002+ if ( canAttach ) {
1003+ pendingPastedTextAttachmentCountRef . current += 1 ;
1004+ setPendingPastedTextAttachmentCount (
1005+ pendingPastedTextAttachmentCountRef . current ,
1006+ ) ;
1007+ const finishAttachment = ( ) => {
1008+ pendingPastedTextAttachmentCountRef . current = Math . max (
1009+ 0 ,
1010+ pendingPastedTextAttachmentCountRef . current - 1 ,
1011+ ) ;
1012+ setPendingPastedTextAttachmentCount (
1013+ pendingPastedTextAttachmentCountRef . current ,
1014+ ) ;
1015+ } ;
1016+ void props
1017+ . onNativePasteText ( paste )
1018+ . then ( finishAttachment , finishAttachment ) ;
1019+ } else if ( ! wouldExceedInputLimit ) {
1020+ insertPaste ( ) ;
1021+ } else {
1022+ Dialog . alert (
1023+ "Pasted text is too large for this message" ,
1024+ "Remove some text or an attachment, then paste again." ,
1025+ ) ;
1026+ }
1027+ return ;
1028+ }
1029+ insertPaste ( ) ;
1030+ } }
1031+ placeholder = { props . placeholder }
1032+ onFocus = { handleFocus }
1033+ onBlur = { handleBlur }
1034+ onSubmit = { ( alternate ) =>
1035+ void handleSend (
1036+ alternate && sendPresentation . alternate !== null
1037+ ? sendPresentation . alternate
1038+ : undefined ,
1039+ )
1040+ }
1041+ submitTitle = { sendPresentation . label }
1042+ alternateSubmitTitle = {
1043+ sendPresentation . alternate === null
1044+ ? sendPresentation . label
1045+ : FOLLOW_UP_ACTION_LABEL [ sendPresentation . alternate ]
1046+ }
1047+ { ...compactEditor . editorProps }
1048+ textStyle = { {
1049+ ...bodyText ,
1050+ color : foregroundColor ,
1051+ } }
1052+ />
1053+ </ Animated . View >
9171054 { ! isExpanded && stripAttachments . length > 0 ? (
9181055 < View className = "h-[44px] shrink-0 flex-row items-center gap-1 pl-1" >
9191056 { stripAttachments . slice ( 0 , compactAttachmentLimit ) . map ( ( attachment ) => (
@@ -980,140 +1117,6 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
9801117 ) }
9811118 </ View >
9821119 </ ComposerDictationDraftContent >
983- < Animated . View
984- style = { [
985- compactEditor . editorStyle ,
986- showsCompactDictation ? { display : "none" } : undefined ,
987- ] }
988- >
989- < ComposerEditor
990- hidden = { props . hidden }
991- draftKey = { composerDraftKey }
992- environmentId = { props . environmentId }
993- onOpenMention = { ( path ) => {
994- Keyboard . dismiss ( ) ;
995- if ( props . isDraft ) {
996- navigation . navigate ( "NewTaskFile" , {
997- environmentId : String ( props . environmentId ) ,
998- cwd : props . projectCwd ?? undefined ,
999- path : fileRoutePathSegments ( path ) ,
1000- } ) ;
1001- } else {
1002- navigation . navigate ( "ThreadFile" , {
1003- environmentId : String ( props . environmentId ) ,
1004- threadId : String ( props . selectedThread . id ) ,
1005- path : fileRoutePathSegments ( path ) ,
1006- } ) ;
1007- }
1008- } }
1009- onOpenAttachment = { openDraftDocument }
1010- chipsInert = { ! isExpanded }
1011- onInertChipPress = { ( ) => inputRef . current ?. focus ( ) }
1012- ref = { inputRef }
1013- multiline
1014- value = { draftMessage }
1015- // The save uses a draft snapshot; further typing would be discarded on success.
1016- readOnly = { isSubmissionLocked }
1017- skills = { composerMenu . skills }
1018- selection = { composerMenu . selection }
1019- onChangeText = { ( text ) => {
1020- if ( ! isSubmissionLocked ) props . onChangeDraftMessage ( text ) ;
1021- } }
1022- onSelectionChange = { composerMenu . onSelectionChange }
1023- onPasteImages = { ( uris ) => {
1024- if ( isSubmissionLocked ) return ;
1025- pendingNativeImagePasteCountRef . current += 1 ;
1026- void props . onNativePasteImages ( uris ) . finally ( ( ) => {
1027- pendingNativeImagePasteCountRef . current -= 1 ;
1028- } ) ;
1029- } }
1030- onPasteText = { ( paste ) => {
1031- if ( isSubmissionLocked ) return ;
1032- const insertPaste = ( ) => {
1033- const insertion = replaceTextSelection ( {
1034- value : paste . value ,
1035- selection : paste . selection ,
1036- text : paste . text ,
1037- } ) ;
1038- const selection = { start : insertion . cursor , end : insertion . cursor } ;
1039- props . onChangeDraftMessage ( insertion . value ) ;
1040- composerMenu . onSelectionChange ( selection ) ;
1041- } ;
1042- const capabilities = props . serverConfig ?. environment . capabilities ;
1043- const advertisedMax = capabilities ?. fileAttachments ?. maxUploadBytes ;
1044- const maxBytes =
1045- advertisedMax === undefined
1046- ? null
1047- : clampFileAttachmentUploadBytes ( advertisedMax ) ;
1048- const wouldExceedInputLimit =
1049- paste . value . length -
1050- Math . max ( 0 , paste . selection . end - paste . selection . start ) +
1051- paste . text . length >
1052- PROVIDER_SEND_TURN_MAX_INPUT_CHARS ;
1053- const canAttach =
1054- maxBytes !== null &&
1055- countComposerDraftAttachmentsAfterSelection ( composerDraftKey , {
1056- text : paste . value ,
1057- ...paste . selection ,
1058- } ) < PROVIDER_SEND_TURN_MAX_ATTACHMENTS &&
1059- new TextEncoder ( ) . encode ( paste . text ) . byteLength <= maxBytes ;
1060- if (
1061- pastedTextDisposition ( {
1062- text : paste . text ,
1063- wouldExceedInputLimit,
1064- canAttach : true ,
1065- } ) === "attachment"
1066- ) {
1067- if ( canAttach ) {
1068- pendingPastedTextAttachmentCountRef . current += 1 ;
1069- setPendingPastedTextAttachmentCount (
1070- pendingPastedTextAttachmentCountRef . current ,
1071- ) ;
1072- const finishAttachment = ( ) => {
1073- pendingPastedTextAttachmentCountRef . current = Math . max (
1074- 0 ,
1075- pendingPastedTextAttachmentCountRef . current - 1 ,
1076- ) ;
1077- setPendingPastedTextAttachmentCount (
1078- pendingPastedTextAttachmentCountRef . current ,
1079- ) ;
1080- } ;
1081- void props . onNativePasteText ( paste ) . then ( finishAttachment , finishAttachment ) ;
1082- } else if ( ! wouldExceedInputLimit ) {
1083- insertPaste ( ) ;
1084- } else {
1085- Dialog . alert (
1086- "Pasted text is too large for this message" ,
1087- "Remove some text or an attachment, then paste again." ,
1088- ) ;
1089- }
1090- return ;
1091- }
1092- insertPaste ( ) ;
1093- } }
1094- placeholder = { props . placeholder }
1095- onFocus = { handleFocus }
1096- onBlur = { handleBlur }
1097- onSubmit = { ( alternate ) =>
1098- void handleSend (
1099- alternate && sendPresentation . alternate !== null
1100- ? sendPresentation . alternate
1101- : undefined ,
1102- )
1103- }
1104- submitTitle = { sendPresentation . label }
1105- alternateSubmitTitle = {
1106- sendPresentation . alternate === null
1107- ? sendPresentation . label
1108- : FOLLOW_UP_ACTION_LABEL [ sendPresentation . alternate ]
1109- }
1110- { ...compactEditor . editorProps }
1111- textStyle = { {
1112- ...bodyText ,
1113- color : foregroundColor ,
1114- } }
1115- />
1116- </ Animated . View >
11171120 </ View >
11181121 < Animated . View
11191122 accessibilityElementsHidden = { ! isToolbarVisible }
0 commit comments