Chat 2.0.30: never downscale a dropped image — inline only what already fits - #137
Merged
Merged
Conversation
…dy fits Owner report 2026-09-16: a 1.9 MB PNG dragged into Chat was sent as a ~3 KB thumbnail (2.0.26's encodeInlineImage shrank any image to ≤160 px and re-encoded it until it fit the 4 000-byte cap), so "expand" had nothing to show and the original bytes never went anywhere. The intended rule was "inline only if it already fits, otherwise publish to QDN". encodeInlineImage now inlines the file AS GIVEN when its base64 length fits the budget (checked on file.size before any decode; webp/jpeg/png only — the markup grammar's encodings) and returns null otherwise, so stageFileOrInline takes the attachment path with the ORIGINAL file. No canvas, no resizing, no re-encoding. Tests: 1.9 MB refused, just-over-budget refused, gif/bmp refused. README corrected; version 2.0.30. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018XinKVAUP29uVw5C4SRwLz
QuickMythril
force-pushed
the
fix/inline-image-no-downscale
branch
from
September 16, 2026 12:50
88896ba to
d919594
Compare
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.
Owner report: dragging a 1.9 MB
polar-drag.pnginto Chat "embedded" it — as a ~3 KB thumbnail. Expanding showed nothing bigger because nothing bigger was ever sent.Cause: 2.0.26's
encodeInlineImagetried inline first and downscaled any image (160 → 48 px, WebP/JPEG quality 0.6 → 0.15) until a preview fit the 4 000-byte CHAT cap. That contradicts the intended rule ("inline only if it already fits, otherwise publish to QDN") and silently replaced the user's image with a thumbnail.Fix:
encodeInlineImageinlines the file as given when its base64 length fits the budget — decided onfile.sizebefore any decode, so a large image costs nothing — and only for the encodings the markup grammar accepts (webp/jpeg/png). Anything else returns null andstageFileOrInlinetakes the existing attachment path with the original bytes. No canvas, no resizing, no re-encoding anywhere. Practical effect: only a genuinely tiny image (≈2.8 KB or less) ever travels inline.Tests: 1.9 MB PNG refused; just-over-budget refused; gif/bmp refused (never inlinable). 921/921, build clean. README corrected (it described the downscaling as a feature); version 2.0.30.
Stacked on #136 (2.0.29) so one publish carries both; if #136 waits for beta.12, this can be rebased onto main and shipped first — say which.
🤖 Generated with Claude Code
https://claude.ai/code/session_018XinKVAUP29uVw5C4SRwLz