@@ -226,7 +226,7 @@ function FileSourceSurface(props: ComponentProps<typeof SourceFileSurface>) {
226226 < SourceFileSurface
227227 { ...props }
228228 initialLine = { selection ?. line ?? props . initialLine }
229- selectable = { selection ?. active === true }
229+ selectable = { props . selectable === true || selection ?. active === true }
230230 onLongPressLine = {
231231 Platform . OS === "android" ? ( line ) => setSelection ( { line, active : true } ) : undefined
232232 }
@@ -250,6 +250,7 @@ function FileContent(props: {
250250 readonly threadId : ThreadId | null ;
251251 readonly initialLine : number | null ;
252252 readonly truncated : boolean ;
253+ readonly selectable : boolean ;
253254 readonly onRefresh ?: ( ) => Promise < void > | void ;
254255} ) {
255256 // Reopening a mutable host file must not reuse a poster from an earlier visit.
@@ -351,6 +352,7 @@ function FileContent(props: {
351352 path = { props . relativePath }
352353 initialLine = { props . initialLine }
353354 headerInsetTop = { props . truncated ? 0 : undefined }
355+ selectable = { props . selectable }
354356 onRefresh = { props . onRefresh }
355357 />
356358 ) }
@@ -650,6 +652,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
650652 readonly path : string ;
651653 readonly mode : FileViewMode ;
652654 } | null > ( null ) ;
655+ const [ textSelectionPath , setTextSelectionPath ] = useState < string | null > ( null ) ;
653656 const [ previewRevision , setPreviewRevision ] = useState ( 0 ) ;
654657 const previewKey = JSON . stringify ( [ environmentId , cwd , relativePath , previewRevision ] ) ;
655658 const [ fullScreenPreview , setFullScreenPreview ] = useState < FilePreviewSource | null > ( null ) ;
@@ -749,6 +752,10 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
749752 : null ,
750753 ) ;
751754 const fileData = fileQuery . data as ProjectReadFileResult | null ;
755+ // iOS only: Android lays out a whole-file selectable TextView on the UI thread, which stalls.
756+ const canSelectText =
757+ Platform . OS === "ios" && resolvedActiveMode === "source" && fileData ?. contents != null ;
758+ const selectingText = canSelectText && textSelectionPath === relativePath ;
752759
753760 const handleSelectFile = ( path : string ) => {
754761 const targetPath =
@@ -837,6 +844,15 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
837844 onPress : ( ) => setCodeWordBreak ( ! appearance . codeWordBreak ) ,
838845 } as const )
839846 : null ,
847+ canSelectText
848+ ? ( {
849+ id : "select-text" ,
850+ title : selectingText ? "Done selecting" : "Select text" ,
851+ icon : "character.cursor.ibeam" ,
852+ inline : false ,
853+ onPress : ( ) => setTextSelectionPath ( selectingText ? null : relativePath ) ,
854+ } as const )
855+ : null ,
840856 ...( mediaSource
841857 ? mediaActions . actions
842858 . filter ( ( { id } ) => id !== "open-file" )
@@ -1046,6 +1062,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
10461062 relativePath = { relativePath }
10471063 threadId = { threadId }
10481064 truncated = { fileData ?. truncated ?? false }
1065+ selectable = { selectingText }
10491066 onRefresh = { ( ) => fileQuery . refresh ( ) }
10501067 />
10511068 </ ScreenContent >
0 commit comments