Repository navigation
Bound clipboard history and safely collect removed captures - #14919
thebytorsnowdog wants to merge 1 commit into
Conversation
|
| if not stat.S_ISREG(info.st_mode) or info.st_size > IMAGE_BYTES: | ||
| return None |
There was a problem hiding this comment.
Legacy images disappear on load
A saved image over 16 MiB is deleted during load, without Clear. The old capture script allowed these images, and their history records can fit below 8 MiB. image_size returns None, bounded drops the entry, and transact rewrites history and deletes the saved copy.
Treat oversized legacy images as blocked history before writing or collecting, so users can preserve them before explicitly clearing.
| fd = os.open(name, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, | ||
| 0o600, dir_fd=self.images) | ||
| except FileExistsError: | ||
| info = os.stat(name, dir_fd=self.images, follow_symlinks=False) | ||
| if not stat.S_ISREG(info.st_mode) or info.st_uid != os.getuid() or info.st_size != len(data): | ||
| raise HistoryBlocked("The captured image could not be stored safely.") | ||
| else: | ||
| with os.fdopen(fd, "wb") as stream: | ||
| stream.write(data) |
There was a problem hiding this comment.
Interrupted writes block image retries
add_image writes directly to the final filename. If writing fails or the process stops midway, a partial file remains. Copying the same image again fails the existing-file size check before cleanup runs, so repeated copies are not recorded until another successful storage operation removes it.
Write to a private temporary file, rename it after the write succeeds, and clean up failed writes.
| } catch (error) { | ||
| console.warn("Clipboard history storage did not return a valid response") | ||
| } |
There was a problem hiding this comment.
If the initial storage request times out or returns invalid JSON, acceptStorage only logs a warning. storageBlocked stays false and history stays empty, so the picker says the clipboard is empty and rejects Clear. Reopening does not retry the load.
Mark failed replies as blocked and provide a retry or reload when the picker opens.
|
Looked at this far enough to classify it, and no further this time. I (Claude Opus 5.5) read it as a bug fix: on Two things that will matter whoever picks it up next: it no longer merges cleanly into It goes round again in a later run, when both models can classify it; until then it waits on that, not on you. |
Clipboard history currently allows large inputs to drive unbounded storage/parsing work, and removed image captures can remain on disk. Move persistence into one locked helper with bounded reads and writes, atomic publication and collection of unreferenced owned captures. QML requests storage operations asynchronously instead of parsing and rewriting the entire history for each event.
Enforce 1 MiB per text entry, 8 MiB serialized history, 16 MiB per image, 128 MiB retained images and 500 entries. Oversized captures are omitted with a notification; accepted content keeps all bytes, including trailing newlines. Oversized or unreadable legacy history remains intact until explicit Clear, which stays available when history cannot render.
Stable private entry IDs preserve selection across asynchronous updates. Clear invalidates captures already in flight, and image copying shares the collector lock so eviction cannot cause an older clipboard value to be pasted. Collection is confined to owned captures; new storage files are private. Existing sensitive-MIME exclusions remain, and failed MIME enumeration skips recording.
Validation: all 84 existing clipboard checks and 13 new storage groups pass. Coverage includes exact size boundaries, sparse oversized history under a memory limit, concurrent capture/clear, path confinement, complete-byte selection, private IDs, failed copies and legacy CLI readers. Qt 6 compiled the changed QML to bytecode; Python/Bash syntax and command metadata checks pass.
Release still needs live Quickshell acceptance for picker bindings, text/image copy, Clear, error presentation and responsiveness. No desktop latency improvement is claimed from fixture tests. History remains enabled by default; deletion does not erase independent snapshots or backups.