Skip to content

Chat 2.0.30: never downscale a dropped image — inline only what already fits - #137

Merged
QuickMythril merged 1 commit into
mainfrom
fix/inline-image-no-downscale
Sep 16, 2026
Merged

QuickMythril merged 1 commit into
mainfrom
fix/inline-image-no-downscale

Conversation

@QuickMythril

Copy link
Copy Markdown
Member

Owner report: dragging a 1.9 MB polar-drag.png into Chat "embedded" it — as a ~3 KB thumbnail. Expanding showed nothing bigger because nothing bigger was ever sent.

Cause: 2.0.26's encodeInlineImage tried 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: encodeInlineImage inlines the file as given when its base64 length fits the budget — decided on file.size before any decode, so a large image costs nothing — and only for the encodings the markup grammar accepts (webp/jpeg/png). Anything else returns null and stageFileOrInline takes 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

…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
QuickMythril force-pushed the fix/inline-image-no-downscale branch from 88896ba to d919594 Compare September 16, 2026 12:50
@QuickMythril
QuickMythril merged commit 9063146 into main Sep 16, 2026
@QuickMythril
QuickMythril deleted the fix/inline-image-no-downscale branch September 16, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant