feat(codex-fleet): robust pane paste helper with MIME validation + structured logging#148
Merged
Conversation
…ructured logging PR #140's inline image-paste in pane-context-menu.sh only matched png/jpeg/gif/webp/bmp and didn't validate the captured payload, causing silent "didn't quite work" failures when modern browsers/screenshots provided avif/heic/svg, when wl-paste exited zero with empty output, or when the wrong MIME landed first in --list-types output. Extract a single source-of-truth helper that drives both the bash menu (pane-context-menu.sh) and the tmux display-menu (style-tabs.sh): - pane-menu-paste.sh (new): enumerates MIME types once, walks an extended image preference list (png > webp > jpeg > avif > heic > heif > gif > bmp > tiff > svg+xml > x-icon), validates each saved image by size guard (>100 bytes) + magic-byte sniff (PNG/JPEG/GIF/ WebP/BMP/TIFF/ICO/AVIF/HEIC ftyp box/SVG xml header), falls through to the next MIME on failure, then to text/uri-list (pastes file paths from file managers), then text/plain. Saves images under /tmp/codex-fleet-clipboard/ (mode 700, auto-prunes >1h files), logs every invocation to /tmp/codex-fleet-paste.log with mime/size/path/error for tail -f debugging, caps the log at 100KB. Falls back to tmux's own paste-buffer when wl-paste is missing entirely. - pane-context-menu.sh: replaces the 30-line inline p) case with a one-line shellout. - style-tabs.sh: rewires the MouseDown3Pane Paste row to call the same helper so the two menu surfaces stay behaviorally identical. Verification: bash -n + shellcheck (docker koalaman/shellcheck:stable) clean on all three files (only pre-existing SC1091 source-resolution info on pane-context-menu.sh remains). Smoke tests covered text/empty-clipboard/PNG-too-small/PNG-magic-validated paths against a fake pane id; helper exits cleanly with structured log lines in all cases. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
NagyVikt
added a commit
that referenced
this pull request
May 16, 2026
#153) The PR #148 helper iterates `wl-paste --type <mime>` for each advertised image MIME. That works for most sources, but hits an intermittent gnome-screenshot quirk where `wl-paste --type image/png` returns the literal text "No suitable type of content copied" (35 bytes, no PNG magic) even though `image/png` is in --list-types and plain `wl-paste` DOES return the actual PNG bytes. Also: Wayland clipboard sources can be one-shot — once `wl-paste --type X` consumes the source, a subsequent plain `wl-paste` returns 0 bytes. So the fallback HAS to run BEFORE the --type loop, not after. New section (1a) before the existing (1) IMG_PREF loop: - Gated on at least one image MIME being advertised (so we don't swallow text content here) - Single plain `wl-paste` call into a temp file - Magic-byte sniff for PNG/JPEG/GIF/WebP/BMP/AVIF/HEIC/HEIF - On match: save with detected extension, paste the path, log outcome=image-no-type, exit 0 - On no match / empty / too-small: fall through to the existing (1) IMG_PREF loop which still works for sources that allow re-reads Smoke-tested against the project's actual clipboard mid-session. Synthetic `wl-copy --type X` doesn't repro the real bug cleanly, so relied on field repro via the user's prior `/tmp/clipboard-img-...png` that captured 35 bytes of the error text. Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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.
Automated by gx branch finish (PR flow).