Skip to content

Record clipboard images copied in any stored format - #19149

Open
pedro757 wants to merge 2 commits into
omacom:quattrofrom
pedro757:clipboard-capture-any-image-type
Open

pedro757 wants to merge 2 commits into
omacom:quattrofrom
pedro757:clipboard-capture-any-image-type

Conversation

@pedro757

@pedro757 pedro757 commented Nov 16, 2026 •

Copy link
Copy Markdown

What changes

The clipboard history watches image/png, so an image offered only as JPEG, WebP, GIF, BMP or TIFF never reaches the history, even though capture.sh already stores those formats.

The watcher now uses wl-paste --type image --watch. Because it receives bytes without a MIME type, capture.sh identifies the captured file with file --mime-type instead of inferring its format from a separate query of the current clipboard. This keeps the saved MIME type and extension tied to the captured bytes even when another image is copied meanwhile. file is already a dependency of Arch's base package.

If the captured format is unsupported, such as SVG, the script explicitly requests a supported representation from the available types, preserving the existing SVG-before-PNG fallback. Empty or timed-out reads are dropped without taking this fallback, and temporary unsupported files are removed before retrying.

The explicit image/<type> argument still works, so watchers started before the update keep recording until the shell restarts.

#11715 changes the same watcher in the opposite direction: it removes image history. Its review could not reproduce the reported deadlock; this PR keeps the watcher and broadens the formats it records.

Verification

  • bash test/shell.d/clipboard-test.sh: all 74 checks pass.
  • Regression coverage uses real PNG/JPEG fixtures and the real MIME detector:
    • JPEG-only copies are stored with the correct bytes and .jpg extension.
    • PNG bytes received before the offered types change to JPEG stay image/png with a .png extension.
    • With SVG before PNG, the stored file contains the explicitly requested PNG bytes, not the SVG bytes.
    • Generic image reads remain bounded when the clipboard owner stalls.
  • The updated tests fail against the original PR head. A separate reproduction confirms that the original head labels PNG bytes as image/jpeg when the clipboard changes; the revised script labels them correctly.
  • Additional isolated checks generated PNG, JPEG, WebP, GIF, BMP and TIFF images. Each was captured with the correct MIME type and byte-identical contents despite the simulated current clipboard offering only JPEG.
  • Earlier live checks through the local plugin confirmed that a JPEG-only copy enters history and PNG/text copies still record. Those checks preceded this review fix; the revised detector was verified with isolated captures rather than changing the user's active clipboard.
  • Real applications offering only JPEG/WebP or SVG before PNG were not exercised; clipboard offers in the regression tests are simulated.

Screenshots

No visible change: the panel layout is unchanged; images copied in formats other than PNG now enter history.

The clipboard history watched only image/png, so an image an app offered as
JPEG, WebP, GIF, BMP or TIFF alone never reached the history. Watch for any
image type instead, and fall back to a stored format when the first one on
offer isn't, so an SVG offered ahead of PNG still records the PNG.
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are addressed.

Summary

The image watcher now accepts all image types instead of PNG alone.

  • Clipboard history records supported image copies beyond PNG.

Reviews (2) · Last reviewed commit: "Identify watched clipboard images from t..." · Reviewed by Greptile

Comment thread shell/plugins/clipboard/capture.sh Resolved
Comment thread test/shell.d/clipboard-test.sh Resolved
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed head 015d3f1966b7c5a19ea675506e7ad7739fcb3907. On a disposable Omarchy worker, a JPEG-only copy was missing from history on quattro, appeared with the correct MIME and identical bytes on this head, and disappeared again with the fix reverted. PNG, JPEG, WebP, GIF, BMP and TIFF all recorded correctly; copying the saved JPEG from the picker preserved its bytes. Real SVG-before-PNG and BMP-before-PNG offers also passed. The CLI suite passed 136 checks and the clipboard suite passed all 74 after installing its missing Node.js test dependency on the worker.

Codex High, Opus 5.5 High and muse-wonder via pi (thinking high) found no actionable defects. The reviewers agreed; their independence is not guaranteed. No code changes were needed. #11715 addresses a different reported symptom by removing image history, so it overlaps this watcher without being a duplicate. This is waiting on the maintainer's decision.

Before: the JPEG-only copy is absent from clipboard history on quattro

After: the same JPEG appears in history with its thumbnail and image preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants