Skip to content

Fix clipboard history startup race, image cleanup, and capture permissions - #19966

Merged
dhh merged 2 commits into
quattrofrom
audit/shell-plugins-clipboard
Nov 24, 2026
Merged

dhh merged 2 commits into
quattrofrom
audit/shell-plugins-clipboard

Conversation

@dhh

@dhh dhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Fixes four issues in the clipboard plugin:

  • Prevent startup history wipe race: Clipboard.qml previously started currentProc and the wl-paste watchers before FileView finished loading clipboard-history.json, so an early capture could overwrite the file with only the new entry. Incoming captures before load are now queued and merged once history loads.
  • Stop redundant reload loop: Clipboard.qml is the sole writer of clipboard-history.json; removing watchChanges avoids re-reading and re-parsing the full history on every own write or unrelated write under ~/.local/state/omarchy/.
  • Clean up removed/evicted clipboard images safely: Removing an entry, clearing history, or evicting past historyLimit now deletes unreferenced cached image files under clipboard-images/. Captures atomically replace files under flock and record their inode so a delayed prune never deletes a concurrently recaptured image of the same hash (and legacy entries without an inode are never unlinked unconditionally).
  • Harden capture permissions and MIME handling: Prepare clipboard-history.json at 0600 (unlinking symlinks first), enforce umask 077 and 0700 on clipboard-images/ in capture.sh, and reject non-alphanumeric image MIME subtypes to prevent path traversal.

Verified by Codex

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes since the previous review appear safe to merge.

Summary

The PR queues early captures, removes redundant history reloads, cleans up cached images, and tightens capture permissions.

The latest changes:

  • Clipboard history loads saved entries before early captures are written.
  • Removed clipboard images are cleaned up without deleting a newer capture.
  • Clipboard history and image files stay private, and MIME names cannot add path parts.

No new actionable findings were accepted. Checks were based on source review; no tests were run.

Reviews (2) · Last reviewed commit: "Guard pre-ready FileView signals and pre..." · Reviewed by Greptile

Comment thread shell/plugins/clipboard/capture.sh Resolved
@omarchybot omarchybot added the bug Something isn't working label Nov 23, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex High reviewed 10b61667132d2f34deac4439e00bde063e4d1b95 and ran 139 CLI checks and 80 clipboard checks on a disposable Omarchy ISO worker; all passed. The running shell used 0600 for history and 0700 for the image directory. Base/head/revert reproduction and visual verification remain incomplete.

The required second code review did not run: Opus 5.5 High hit its weekly usage limit, confirmed by the reviewer availability check. The image cleanup also overlaps #14266 and #14819, which use different implementations. This is waiting on a second review and the maintainer’s decision about combining those fixes. No code changes were pushed.

@dhh
dhh merged commit 7db136a into quattro Nov 24, 2026
3 checks passed
@dhh
dhh deleted the audit/shell-plugins-clipboard branch November 24, 2026 06:44
dhh added a commit that referenced this pull request Nov 24, 2026
Reclaim pre-existing orphaned files in clipboard-images/ (accumulated
before #19966, left behind by legacy inode-less history entries, or
orphaned by a crash) once on clipboard plugin initialization before
watchers start. Serializes on the same .lock file as capture.sh, skips
recent files, dotfiles, temp files, and symlinks, and bails out without
deleting if clipboard-history.json is missing or unreadable.

Co-authored-by: AnPod <[email protected]>
Co-authored-by: JJDizz1L <[email protected]>
cursor Bot pushed a commit to mark-groves/omarchy that referenced this pull request Nov 24, 2026
…sions (omacom#19966)

* Fix clipboard history startup race, image cleanup, and capture permissions

* Guard pre-ready FileView signals and preserve latest image generation on out-of-order captures
cursor Bot pushed a commit to mark-groves/omarchy that referenced this pull request Nov 24, 2026
Reclaim pre-existing orphaned files in clipboard-images/ (accumulated
before omacom#19966, left behind by legacy inode-less history entries, or
orphaned by a crash) once on clipboard plugin initialization before
watchers start. Serializes on the same .lock file as capture.sh, skips
recent files, dotfiles, temp files, and symlinks, and bails out without
deleting if clipboard-history.json is missing or unreadable.

Co-authored-by: AnPod <[email protected]>
Co-authored-by: JJDizz1L <[email protected]>
@emirb emirb added this to the 4.6.0 milestone Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants