GeezerVison is showing github.com — fix(app): binary file handling in file view by alexyaroshuk · Pull Request #11312 · anomalyco/opencode
Conversation
Related Issues
Addresses #11126 - Extension-based binary detection
Fixes app freeze for all binary files with recognized extensions (93 types).
Note: Extensionless binaries require content-based detection (follow-up needed).
What this PR addresses:
- Binary files with extensions (.exe, .apk, .bin, etc.) → Fixed
- Uppercase extensions → Fixed
- App freeze on binary files → Fixed for most cases
What remains for follow-up:
- Extensionless binaries (common on macOS/Linux)
- Content-based detection (null byte, non-printable ratio)
- See issue for full suggested implementation using tool/read.ts logic
What does this PR do?
1. Binary file handling
Prevents rendering garbage text and freezing when opening binary files. Added detection for 90+ binary extensions: exe, dll, pdb, apk, ipa, wav, mp3, mp4, avi, zip, tar, gz, pdf, doc, docx, and more.
- Backend returns type: "binary" immediately without loading file content
- Frontend displays "Binary file (content cannot be displayed)" with the filename
Before: App would freeze when clicking binaries (.exe, .apk, etc.) or on startup if these files were open in the previous session.
After: App instantly shows binary file placeholder without loading content.

Also prevents attempting to render video, audio, and other non-image binary content:
Before:

After:

- Uppercase/mixed case extension support
Fixes images with uppercase extensions (.PNG, .JPG, .GIF) or mixed case (pNG, JPg, etc.) not rendering
Added explicit image extension detection (png, jpg, gif, webp, svg, etc.)
Maps extensions to correct MIME types regardless of case
SDK type updates - Updated FileContent.type from "text" to "text" | "binary" to support new backend response
Before: extension case sensitive



After: no difference in file name extension case


-
SDK type updates
Updated FileContent.type from "text" to "text" | "binary" in SDK v1 and v2 to support the new backend response format.
-
Localization
Added translation key session.files.binaryContent for 15 languages
How did you verify your code works?
-
TypeScript: All packages pass typecheck
-
Test suite: 721 pass (+2), 61 fail (-2) — 2 previously failing tests now pass
loads config from .opencode directory (was timing out)
deduplicates duplicate instructions from global and local configs (was timing out)
-
E2E tests: All 22 tests pass
-
Manual testing:
- Clicking .exe, .apk, .zip shows "Binary file" message instantly
- .PNG, .JPG, .GIF, .pNG, jPG render correctly as images
- videos, audio files also render "Binary file"
- No app freeze when opening binary files or restarting with them open
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ng sent back as assistant message content (anomalyco#11270)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
No duplicate PRs found
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
(OC agent): conflicts resolved
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|