Skip to content

Sweep orphaned clipboard image files on shell startup - #20001

Merged
dhh merged 1 commit into
quattrofrom
extract/clipboard-orphan-sweep
Nov 24, 2026
Merged

dhh merged 1 commit into
quattrofrom
extract/clipboard-orphan-sweep

Conversation

@dhh

@dhh dhh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Extracted from #14266 by @AnPod and #14819 by @JJDizz1L.

#19966 added inode-checked pruning when newly captured image entries leave clipboard-history.json, but existing installations still keep pre-#19966 orphaned images in clipboard-images/ indefinitely, along with legacy inode-less entries after deletion/clear and any files orphaned by a shell crash before history is saved.

This runs a lightweight startup sweep (shell/plugins/clipboard/sweep.sh) from Clipboard.qml's initProc before watchers start:

  • Only runs when clipboard-history.json already existed and clipboard-images/ has non-hidden files.
  • Serializes with capture.sh and pruneRemovedImages via flock on .lock (opened O_NOFOLLOW, 0600).
  • Bails out without deleting if clipboard-history.json is unreadable, malformed, or not a JSON array, and preserves both type: "image" and legacy kind: "image" references.
  • Skips dotfiles (.lock, .gen), in-flight clipboard.* temp files, symlinks/non-regular files, and files modified within the last 60 seconds.

Verified by Codex and Claude.

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]>
@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds a startup sweep for old clipboard image files that history no longer references.

  • Clipboard startup removes old image files that history no longer references.

Intentional behavior acknowledged by dhh: skip clipboard.* files to protect in-flight captures, even when those files are old.

Reviews (1) · Last reviewed commit: "Sweep orphaned clipboard image files on ..." · Reviewed by Greptile

@omarchybot

Copy link
Copy Markdown
Collaborator

Classification is unsettled. GPT-6 in Codex classifies this as a bug fix because older orphaned clipboard images remain on disk after their history entries are gone; deepseek-v4p1-flash classifies it as an enhancement. Neither model’s effort setting is exposed in this result.

I read the diff, discussion, and surrounding capture/history cleanup code. No code was changed or run on a worker, and no verification labels were added. This remains open at the classification-disagreement stage before verification can proceed.

@dhh
dhh merged commit 568235c into quattro Nov 24, 2026
3 checks passed
@dhh
dhh deleted the extract/clipboard-orphan-sweep branch November 24, 2026 08:02
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants