Skip to content

#416 Add read-only File Browser opened from Session Chat - #651

Merged
ivanfenenko merged 3 commits into
mainfrom
feature/ope-78-file-browser
Oct 11, 2026
Merged

ivanfenenko merged 3 commits into
mainfrom
feature/ope-78-file-browser

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Entry points (Session Chat only): "Browse files" in the overflow menu right after "Review changes", and a Files tile right after Terminal in the Commands sheet (/files). No Home entry.
  • Browser: opens at the session's folder. It shows a tree that loads each folder when you open it, and a find field that uses server fuzzy find. Dotfiles are hidden behind "Show hidden files". On v1, ignored entries are dimmed and tagged. There is no size column and no 200-entry cap, and Add Project's DirectoryListingPolicy is unchanged.
  • Viewer:
    • Line numbers and highlighting through the shared TextMate engine. The user's TextMate on/off setting is respected; when it is off, the viewer uses the semantic fallback highlighter.
    • Markdown opens rendered, with a Preview/Source toggle.
    • Text over 1 MiB is truncated with a banner.
    • PNG, JPG, GIF and WebP files show an image preview, up to 10 MiB.
    • Binary, empty and error states, with Retry.
    • Overflow menu: Copy path and Wrap lines.
  • Tablet: new files split-pane screen. Opening it collapses the Home sidebar, puts the tree on the left, and shows a tabbed viewer on the right.
  • Protocols:
    • v1: GET /file, /file/content, /find/file, with directory fixed to the worktree.
    • v2: GET /api/fs/list, /api/fs/read/<encoded path>, /api/fs/find. Reads are streamed and capped, and non-image reads send Range: bytes=0-1048575. A NUL byte or invalid UTF-8 means the file is treated as binary.
  • Design system: new OpenCodeCodeFile and OpenCodeTreeRow components on both platforms, each with a Component Gallery entry.

Checks

  • Android:
    • ./gradlew --offline :app:assembleDebug passes.
    • :app:testDebugUnitTest passes (1934 tests, 0 failures, 1 skipped). A focused rerun of the file-browser, slash-catalog and split-pane tests also passes (78 tests).
    • ktlintMainSourceSetCheck and ktlintTestSourceSetCheck: no violations in new files. Both tasks still fail on violations that were already in untouched files.
  • iOS:
    • xcodebuild build passes.
    • The full unit target passes: 1,842 Swift Testing tests in 192 suites and 45 XCTest tests, 0 failures. After the last fix, the Files suites were rerun and passed (33 tests).
  • Real apps against a local opencode serve (1.18.35, v1):
    • Android phone (Pixel 9a): both entry points, the tree with ignored rows, find, a highlighted Kotlin file, and the PNG preview.
    • Android tablet (Pixel Tablet): the split pane, tabs, Markdown preview, and back to the session in the Home pane.
    • iPhone: both entry points, the 1 MB truncation banner on a 2.4 MB file, Markdown, image and binary states, and the copy-path snackbar.
    • iPad Pro 13": the split pane, tabs, closing a tab, the empty-file state, and back to the session.

Issue

Risks / Follow-ups

  • v2 has not been exercised in the running apps. The local server is v1. v2 is covered by unit tests on both platforms (request shapes, envelope, Range 206/200, caps), and the v2 endpoints were also checked with curl.
  • Platform layout differences:
    • The tablet tab strip sits above the file header on Android and below it on iOS.
    • The "ignored" tag is right-aligned on Android and sits right after the name on iOS.
    • iOS cuts display lines longer than 5,000 characters; Android does not.
  • Android image files use the generic file icon. Adding an image icon needs an entry in the root icons/ manifest.
  • v1 server quirks: the server trims text content, so leading and trailing blank lines are dropped. A missing file comes back as empty text, which the app shows as "Empty file".
  • Follow-up: "Mention in prompt" from the viewer is deferred until OPE-75: '@ File Mentions #413 (file mentions) lands.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.


Note

Medium Risk
Large new surface area (remote file I/O, v1/v2 protocol branching, and streaming/size limits) but read-only with extensive unit tests; v2 behavior is not fully validated on device per PR notes.

Overview
Adds a read-only project File Browser rooted at the session worktree, reachable from Session Chat via overflow Browse files and the /files command tile (alongside Terminal).

Navigation & layout: New FileBrowser route hosts FilesScreen. On phones the tree pushes a file viewer; on wide layouts it uses a new Files split pane (tree + tabbed viewer) that collapses the Home sidebar like Changes/Terminals.

Data layer: Extends FilesystemApi and adds ProjectFilesRepository with v1 (/file, /file/content, /find/file) and v2 (/api/fs/list, /api/fs/read, /api/fs/find) paths, streaming reads, byte caps, and decoding into text/image/binary preview models (1 MiB text truncation, image size limits).

UI: Lazy expandable tree with server find, hidden-file toggle, and a viewer with syntax highlighting (TextMate or semantic fallback), Markdown preview/source, wrap/copy path, and analytics. New design-system pieces OpenCodeCodeFile and OpenCodeTreeRow plus gallery entries on Android (and matching gallery/DTO hooks on iOS in this diff).

Reviewed by Cursor Bugbot for commit 060f508. Bugbot is set up for automated code reviews on this repo. Configure here.

Browse the session's project as a tree with server find, and view files
with line numbers and TextMate highlighting, Markdown preview, image
preview, 1 MiB truncation, and binary/empty/error states. Opens from the
Session Chat overflow menu ("Browse files") and a Files tile in the
Commands sheet. Tablets get a Files split pane with tabbed viewer.
Supports v1 (/file, /file/content, /find/file) and v2 (/api/fs/list,
/api/fs/read, /api/fs/find). Adds OpenCodeCodeFile and OpenCodeTreeRow
design-system components with gallery entries on both platforms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@linear-code

linear-code Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
OPE-78 File Browser

Browse and inspect project files from the mobile app against the connected opencode server.

Shell scope:

  • Navigate directories and list files for the active/added project
  • Open/read file contents (viewer; editing out of scope unless planning expands)
  • Reuse or extend existing /path + /file filesystem APIs already used by Add Project

Remaining:

  • ☐ Define entry points (home project, Session Chat, or both)
  • ☐ Directory listing + file viewer on iOS and Android
  • ☐ Large-file / binary / permission failure handling
  • ☐ Feature docs under docs/features/file-browser/ when planning starts

Notes:
Placeholder shell. Distinct from Add Project directory navigator and from @ file mentions; those may share filesystem APIs.

Review in Linear

@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor

cursor Bot commented Oct 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 3ce0f922-a088-447f-a1fc-3e14ea9e3133)

@ivanfenenko
ivanfenenko marked this pull request as ready for review October 11, 2026 20:45

@ivanfenenko ivanfenenko left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the File Browser. I left 10 inline comments, ordered by severity:

  • Possible crashes or memory pressure: a 206 UTF-8 split makes text files show as Binary (Android), there is no line-length cap on Android, and iOS image previews are decoded at full resolution.
  • Cancellation and highlighting: Task.detached drops cancellation on iOS, Android ignores the TextMate outcome, and iOS chunking breaks multi-line grammar state.
  • Cross-platform drift and smaller issues: the language tables differ (.m), files over 16 MiB on v1 are labeled "Binary", the tab strip is feature-local UI, and iOS reads the body byte by byte.

ivanfenenko and others added 2 commits October 11, 2026 22:52
- Split SessionChatView body into small modifier steps so the merged
  chain type-checks in time on CI.
- Android: keep UTF-8 boundaries on 206/truncated reads, cap display
  lines at 5,000 chars, fall back to semantic highlighting when the
  TextMate outcome is not attachable.
- iOS: downsample image previews to 4096 px, drop Task.detached so
  cancellation reaches reads, highlight the whole file in one pass with
  fallback, read bodies in chunks instead of byte by byte.
- Both: "Too large to preview" state, OpenCodeFileTabs design-system
  component above the viewer header, OpenCodeFilterTabs for the Markdown
  toggle, trailing "ignored" tag, and one shared extension-to-language
  table (shared/file-languages) tested on both platforms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 234e9e1 into main Oct 11, 2026
@ivanfenenko
ivanfenenko deleted the feature/ope-78-file-browser branch October 11, 2026 22:36

This branch was previously deployed

1 inactive deployment
android-release — 3b0e2d8e Deployed Oct 11, 2026 by ivanfenenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPE-78: File Browser

1 participant