feat(images): open image files as pictures, not binary refusals - #3
Open
letrquan wants to merge 1 commit into
Open
feat(images): open image files as pictures, not binary refusals#3letrquan wants to merge 1 commit into
letrquan wants to merge 1 commit into
Conversation
Clicking an image in the changes list, palette or commit panel landed on a "Binary file" notice; images only ever rendered inside markdown previews. They now open in their own view mode. - New "image" view mode: the backend inlines the file as a data URI via the existing getAsset endpoint, and the pane renders it centred on a checkerboard so transparency reads as transparency. - getAsset is scope-aware: Committed and Last views show the image as that comparison ends (raw bytes via git show), not whatever the working tree holds now. New DiffService.GetBytesAtAsync reads bytes at a revision without a text decode. - The Diff/Code switch hides for images, and Ctrl+D and the hunk bar stand down, since neither has anything to act on.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Opening an image file in Chapter used to hit a dead end — the changes list, the Ctrl+P palette and the commit panel all routed images into a diff or code view, which can only answer with a "Binary file" notice. Images rendered solely as assets inside markdown previews.
This adds a first-class image view: clicking an image file (png/jpg/jpeg/gif/webp/avif/bmp/ico/svg) now opens it as a picture in its own tab.
How
Frontend (
Chapter.Web)imageview mode alongside diff/code/preview. The image is fetched as a data URI through the existinggetAssetbridge endpoint and rendered centred in a new#image-hostpane, on a checkerboard background so PNG/SVG transparency reads as transparency rather than as the theme colour.Backend (
Chapter.Core)getAssetis now scope-aware, mirroringgetFileContent: Branch/Uncommitted read from disk; Committed/LastCommit resolve where the comparison ends and serve the image as that revision has it — an edited picture can no longer leak into a review of older work.DiffService.GetBytesAtAsyncreturns raw bytes at a revision (git show rev:path, null when absent) for content that must not pass through a text decode —GetContentAtAsyncclassifies images as binary and would hand back an empty string.AssetPayloadreason ("not found", "too large to preview", …) rather than thrown, so the UI can show an honest refusal; the one new throw path (git failure on committed scopes) is caught by the existing per-call error handling, matchinggetFileContentbehaviour.Verification
dotnet test: 441 passed (2 asset tests updated for the instance API; newOpened_images_follow_the_scope_not_the_working_treeproves a Committed-scope image serves the committed bytes, not the working tree).tsc --noEmitclean;npm run buildclean.Notes for reviewers
Mode(main.ts) andViewMode(editor.ts) are parallel unions; drift is caught at compile time at theshowMode/revealPositioncall sites.