Skip to content

Comments

feat(app): add workspace file browser to session files screen#709

Open
seibe wants to merge 3 commits intoslopus:mainfrom
seibe:feat/file-browser
Open

feat(app): add workspace file browser to session files screen#709
seibe wants to merge 3 commits intoslopus:mainfrom
seibe:feat/file-browser

Conversation

@seibe
Copy link

@seibe seibe commented Feb 21, 2026

Summary

Extends the existing session Files screen from a git-changes-only view into a dual-mode screen with "Changes" and "Browse" tabs. Users can now navigate the full workspace directory tree, not just view staged/unstaged git changes.

Also fixes UTF-8 handling for both file paths and file content, which caused crashes and garbled text with non-ASCII filenames and multi-byte content (CJK, Cyrillic, emoji).

Related issues

  • File browser #361 — file browser feature request. The existing Files screen shows git changes and supports file search, but has no directory browsing capability. This PR adds interactive directory navigation.
  • Chinese characters display as garbled text when viewing Git filechanges on Android app #199 — Chinese characters display as garbled text when viewing git file changes. Root cause: atob() only supports Latin-1 and corrupts multi-byte UTF-8 sequences. This PR replaces atob() with TextDecoder('utf-8') for file content and adds URL-safe UTF-8 base64 encoding for file paths, fixing the exact issue reported.

What's new

Browse mode

  • Directory-based file browsing with path history (back navigation)
  • Auto-activates for non-git workspaces (replaces the previous "not under git" error screen)
  • File size display, binary file detection by extension (~35 known binary types)
  • Hidden files (. prefixed) filtered out
  • Mode toggle ("Changes" / "Browse") shown in git repos; non-git defaults to Browse
  • Directory listing refreshes on screen focus

UTF-8 path encoding (fixes #199 partially)

  • Replaces btoa()/atob() with URL-safe UTF-8 base64 encoding/decoding (utf8ToBase64 / base64ToUtf8 in stringUtils.ts)
  • Legacy atob() fallback for paths encoded before this change

UTF-8 content decoding (fixes #199)

  • File content now decoded via TextDecoder('utf-8', { fatal: true }) instead of raw atob() binary string
  • Invalid UTF-8 sequences are reclassified as binary (prevents mojibake)
  • Reduced memory allocation in binary detection (loop vs split().filter())
  • Proper empty file handling

Changes by file

  • files.tsx: Add Browse mode with directory navigation, mode toggle UI, path bar, auto-switch for non-git workspaces
  • file.tsx: UTF-8 safe path decoding with legacy fallback; UTF-8 content decoding via TextDecoder
  • stringUtils.ts: New utf8ToBase64() and base64ToUtf8() utilities
  • Translation files (10 locales): Add browseTab, changesTab, directory, emptyDirectory keys

Test plan

  • Open Files tab in a git repo → "Changes" and "Browse" tabs visible
  • Switch to Browse → directory listing loads, can navigate into subdirectories and back
  • Open Files tab in a non-git workspace → auto-enters Browse mode, no error screen
  • Tap a file with CJK/emoji characters in the path → opens correctly without crash
  • View a file with Japanese/Chinese text content → displays correctly, no garbled characters
  • View a binary file (image, etc.) → detected as binary, not rendered as text
  • Return to Files tab from another screen → directory listing refreshes

Add directory-based file browsing mode alongside the existing git
changes view. Users can now navigate all workspace files regardless
of git status. Non-git workspaces default to browse mode instead of
showing an error.
Replace btoa/atob with utf8ToBase64/base64ToUtf8 to prevent crashes
on non-ASCII file paths (CJK, Cyrillic, emoji). Output is URL-safe
(uses - and _ instead of + and /). Decoder includes legacy atob
fallback for backward compatibility.
atob() only produces a binary string where each byte maps to one char,
so multi-byte UTF-8 text (e.g. Japanese) was garbled. Use TextDecoder
with fatal:true as the primary decoder and decodeURIComponent as
fallback. Also switch binary detection from split/filter to a for-loop
to avoid large intermediate allocations, handle empty files explicitly,
and treat non-UTF-8 text as binary instead of showing mojibake.
@seibe seibe force-pushed the feat/file-browser branch from 4f430df to 66f7cb6 Compare February 22, 2026 09:01
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.

Chinese characters display as garbled text when viewing Git filechanges on Android app

1 participant