Skip to content

feat: improve binary file handling#33

Merged
jmaxdev merged 3 commits intoTrixtyAI:mainfrom
matiaspalmac:feat/binary-file-placeholder
Apr 19, 2026
Merged

feat: improve binary file handling#33
jmaxdev merged 3 commits intoTrixtyAI:mainfrom
matiaspalmac:feat/binary-file-placeholder

Conversation

@matiaspalmac
Copy link
Copy Markdown
Contributor

@matiaspalmac matiaspalmac commented Apr 19, 2026

Changes

Bundles two related improvements for how the app handles non-UTF-8 / binary files clicked from the explorer.

1. Quieter error path (supersedes #31). read_file is now called with { silent: true }, and the caller distinguishes the expected UTF-8 decoding error from real failures:

  • UTF-8 error → open the tab as a "binary" type (see below).
  • Any other error (permission denied, file locked, etc.) → console.error from the caller so real failures stay visible instead of being swallowed.

Previously safeInvoke logged [Tauri Invoke Error] read_file: "stream did not contain valid UTF-8" for every binary-file click even though the flow was handled correctly — just noise.

2. Descriptive placeholder view. Instead of rendering --- BINARY --- as literal text inside Monaco (with cursor, minimap, line numbers), binary files now show a centered message in the editor area — same UX pattern as VS Code.

  • apps/desktop/src/context/AppContext.tsx: extends FileState.type and openFile to accept "binary" alongside "file" and "virtual".
  • apps/desktop/src/components/EditorArea.tsx: adds an isBinaryTab branch that renders a centered placeholder, skipping Monaco entirely.
  • apps/desktop/src/addons/builtin.git-explorer/GitExplorerComponent.tsx: silences read_file, routes UTF-8 errors to a "binary" tab, logs everything else.
  • apps/desktop/src/api/builtin.l10n.ts: rewrites editor.bin_file in en and es to a full-sentence, VS-Code-style message.

Net: 4 files, small additions.

Issues

Copilot AI review requested due to automatic review settings April 19, 2026 03:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated “binary” tab type so binary/unsupported-encoding files render a centered placeholder message instead of being shown inside Monaco as sentinel text.

Changes:

  • Extend FileState.type / openFile to support a new "binary" file type.
  • Render a centered translated placeholder in EditorArea for "binary" tabs (skips Monaco).
  • Open files as "binary" on UTF-8 decode failures and update editor.bin_file translations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
apps/desktop/src/context/AppContext.tsx Adds "binary" to the file/tab type union used throughout the app.
apps/desktop/src/components/EditorArea.tsx Renders a centered placeholder for binary tabs instead of mounting Monaco.
apps/desktop/src/addons/builtin.git-explorer/GitExplorerComponent.tsx Opens binary tabs on UTF-8 decode failures when reading files.
apps/desktop/src/api/builtin.l10n.ts Updates EN/ES editor.bin_file text to a full descriptive sentence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/desktop/src/context/AppContext.tsx
Comment thread apps/desktop/src/addons/builtin.git-explorer/GitExplorerComponent.tsx Outdated
Comment thread apps/desktop/src/addons/builtin.git-explorer/GitExplorerComponent.tsx Outdated
@matiaspalmac matiaspalmac changed the title feat: show descriptive placeholder for binary files feat: improve binary file handling Apr 19, 2026
@jmaxdev jmaxdev force-pushed the feat/binary-file-placeholder branch from 5d0fd1d to ccd05f0 Compare April 19, 2026 04:03
@jmaxdev jmaxdev merged commit 5499d26 into TrixtyAI:main Apr 19, 2026
4 checks passed
@matiaspalmac matiaspalmac deleted the feat/binary-file-placeholder branch April 19, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants