[Bug]: iOS file viewer can't select text in files without a Preview mode (JSON, YAML, code)#33178

opened1d agobyMmmahmad-bot

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
  • #30178 reports the same file-viewer selection problem on Android: selection can't go past a single line.
  • PR #31286 fixes #30178. Long-pressing a source line opens the whole file as selectable text. It is limited to Android on purpose (Platform.OS === "android", and its description says "iOS keeps its existing renderer"), so this iOS case stays open after it merges.
  • This is likely the same underlying problem on the other platform. Extending #31286's long-press flow to iOS, where SourceFileSurface already has a document-wide selectable text view, would probably fix this too. Happy to fold this into that work rather than a separate fix if maintainers prefer.
  • Not the same as #15927, which is about partial copies in the desktop/web Files panel.

Area

apps/mobile

Steps to reproduce

  1. In the iOS app, open a workspace file that has no Preview mode, for example a .json file linked from a thread.
  2. Long-press or drag over a value to select part of it.
  3. Optionally, turn on word wrap from the file's ⋯ menu and repeat.

Expected behavior

Being able to select part of the file's text and copy it, as in Markdown Preview or in chat attachments, for example to copy a single value out of a JSON file.

Actual behavior

  • With word wrap off, no text can be selected at all.
  • With word wrap on, long-pressing a line shows a Copy menu for that whole line, but there are no selection handles to narrow it to part of the line or extend it across lines.
  • The only other option is ⋯ → Copy contents, which copies the whole file.

Markdown files are fine in practice, because switching them to Preview gives selectable text. Files without a Preview mode (JSON, YAML, .env, source code) only have this Source view. It doesn't matter whether the app is connected to a local or a remote server.

Likely cause (reading main at d0f1f7200d):

  • SourceFileSurface already supports a selectable mode: a single native text view that allows selection across the whole document, with boundedSelectableSourceTokens keeping highlighting bounded.
  • Attachments use it: apps/mobile/src/features/files/AttachmentDocumentBody.tsx:82 passes selectable.
  • The workspace file screen doesn't: apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx:311 renders <SourceFileSurface> without selectable. On iOS with word wrap off this picks NativeSourceFileSurface (the native review-diff view), which has no text selection. With word wrap on it uses the virtualized FlatList, where each line is its own selectable Text, which matches the whole-line Copy shown below.

A possible fix is letting the file screen turn on selectable, either from a "Select text" item next to "Copy contents" or automatically for small files. I'm glad to send a small PR if maintainers agree on the direction.

Impact

Minor bug or occasional failure

Version or commit

iOS TestFlight build as of 2026-11-08; server 0.1.6. Code references are from main at d0f1f7200d.

Environment

iPhone (iOS, dark theme), app connected to a remote T3 server.

Logs or stack traces

None, since nothing errors.

Screenshots, recordings, or supporting files

Values and paths in the screenshots are redacted.

File menu (word wrap toggle, Copy path, Copy contents)Word wrap on: long-press offers Copy for the whole line only
External imageExternal image