Repository navigation
fix(media): preserve correct filenames for transparent image attachments - #128902
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 7:46 PM ET / 23:46 UTC. ClawSweeper reviewWhat this changesThis PR makes optimized image attachment filenames match the emitted image MIME type and adds transparent-WebP-to-PNG coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main can emit PNG bytes for transparent images while retaining the source WebP filename in both optimized-image owners; this PR repairs both paths with one shared mapper and focused direct/local coverage. No blocking patch defect found; the maintainer label and exact-head CI/rebase state require normal human landing review. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe shared web-media loader accepts direct buffers and local files, optimizes images, and returns bytes, MIME type, and filename to channel adapters. Telegram uses that filename for multipart uploads, while Discord uses it as the attachment name. flowchart LR
A[Direct buffer or local file] --> B[Web media loader]
B --> C[Image optimization]
C --> D[Output MIME and filename]
D --> E[Telegram multipart upload]
D --> F[Discord attachment]
E --> G[Visible attachment]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +29. Total +29 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Mantis proof suggestionA Telegram Desktop upload can directly show that converted transparent WebP media now carries a .png attachment filename. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one MIME-derived filename mapper at the shared media owner, retain the direct/local regression, and land only after a fresh exact-head validation. Do we have a high-confidence way to reproduce the issue? Yes in source: current main produces transparent PNG output but retains the source WebP filename in both optimized-image result paths; the PR adds a direct/local regression for that case. Is this the best way to solve the issue? Yes: moving filename selection to one shared MIME-based mapper repairs the owner boundary and avoids channel-specific duplicate policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1edbbc9dd72c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Mantis Telegram proof — PASSSummary: A real Telegram user invoked the same fixture-plugin command against exact main and candidate SUTs. Main converted a genuine transparent WebP to PNG bytes and image/png while retaining the stale wide-transparent.WebP filename; the candidate returned the same PNG bytes and MIME with the corrected wide-transparent.png filename. The pull request fixes the reported filename/encoded-byte mismatch.
Motion-trimmed clips: |
|
Merged via squash.
|


Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where users sending transparent WebP images would receive attachments with a misleading
.webpfilename after OpenClaw resized and converted the actual image bytes to PNG. The incorrect filename reached both Telegram multipart uploads and Discord attachments.Why This Change Was Made
The shared image loader now derives attachment extensions from the actual encoded image MIME type across both direct-buffer and file-loading paths. It generalizes the existing private JPEG filename helper without changing image admission, security policy, public types, configuration, or production line count.
User Impact
Transparent WebP images converted to PNG arrive as correctly named
.pngattachments. Existing JPEG.jpgnaming, original mixed-case PNG filenames, unchanged WebP images, nameless attachments, GIF passthrough, and SVG rejection are preserved.Evidence
expected "portrait.png", received "portrait.WebP", then passed across both image-loading paths.InputFileand Discord multipart attachment construction, verifying PNG bytes, preserved alpha, dimensions, and the.pngfilename.markdown-it, and TUI dependency diagnostics; neither changed file produces a type error.