Skip to content

fix(tui): read tool uppercase/mixed case image extensions#11333

Open
alexyaroshuk wants to merge 2 commits intoanomalyco:devfrom
alexyaroshuk:fix/read-tool-images-clean
Open

fix(tui): read tool uppercase/mixed case image extensions#11333
alexyaroshuk wants to merge 2 commits intoanomalyco:devfrom
alexyaroshuk:fix/read-tool-images-clean

Conversation

@alexyaroshuk
Copy link
Contributor

fixes #10916

What does this PR do?

  • Fixes the read tool (used in terminal/CLI) failing to read images with uppercase or mixed case extensions (.PNG, ., .pNG, .PnG etc.), showing 'canot read binary file' error
  • Additionally fixes mixed case (ie Png, PnG, etc.) which were failing previously

The problem:

read frame.PNG, .Png, .pNG, etc. returned "Cannot read binary file" error
read frame.png worked fine
Bun's MIME type detection doesn't handle uppercase extensions correctly

The fix: Added extension-based image detection before MIME type detection:

Check file extension (case-insensitive)
Map extension to correct MIME type (png→image/png, jpg→image/jpeg, etc.)
Handle image immediately if extension matches

How did you verify your code works?

  1. test suite: no regression
  2. manual testing in dev, and in standalone executable: test.PNG, test.pNg, test.JPG all work correctly, no longer causing an error

Before:

tool-image-file-name-capitalization_BEFORE1 tool-image-file-name-capitalization_BEFORE2 tool-image-file-name-capitalization_BEFORE3 tool-image-file-name-capitalization_BEFORE4

After

tool-image-file-name-capitalization_AFTER4 tool-image-file-name-capitalization_AFTER1 tool-image-file-name-capitalization_AFTER2 tool-image-file-name-capitalization_AFTER3

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #11312: fix(app): binary file handling in file view
#11312

This PR appears to be related as it also addresses binary file handling issues. However, it's focused on the file view in the app rather than the CLI/TUI read tool specifically. You should verify if this addresses the same underlying issue or if they're separate concerns.

The current PR #11333 is the primary match for your search terms, which is the PR you're currently checking (so not a duplicate of itself).

@alexyaroshuk alexyaroshuk marked this pull request as ready for review February 9, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode refuses to read ".PNG" images. Works when the extension is lowercase ".png". Error says "cannot read binary file.."

1 participant