Repository navigation
Stop GTK file copies from looping, and store received bundles by content - #16
Open
jondkinney wants to merge 2 commits into
Open
jondkinney wants to merge 2 commits into
jondkinney wants to merge 2 commits into
Conversation
GTK 4 file copies (Gdk.FileList) also offer the XDG document portal's application/vnd.portal.filetransfer and application/vnd.portal.files formats. Each read of those registers a fresh transfer key, so the captured snapshot's fingerprint changed on every poll and an unchanged file clipboard was broadcast as a new clip roughly 13 times a second. Every peer then materialized each clip again. Copying one GIF from a GTK 4 GIF picker on Linux left the clipboard in that state and wrote 189,000 copies of it to a paired Mac's state directory (263 GB) before the disk filled. The keys are only redeemable on the copying machine, and the file already travels as text/uri-list plus the bundle, so skip both formats at capture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YWDws5xQ8VkLWBi9SLC7ih
Each received file clip was extracted to files/<clip id>, so the same files copied again added another full copy every time, and nothing ever removes them. Name the directory after the bundle's SHA-256 instead, like the Linux image cache, so repeats reuse one copy. Any future echo loop then costs one directory instead of filling the disk. Reuse now checks the existing copy against the bundle and rebuilds it if a pasted file was edited or deleted in place, where it previously returned the stale copy or failed with "existing copied-file bundle is incomplete". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YWDws5xQ8VkLWBi9SLC7ih
jondkinney
force-pushed
the
fix/file-clip-echo-loop
branch
from
November 23, 2026 16:55
27ffb8d to
f4d3377
Compare
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.
Problem
Copying a GIF from a GTK 4 app on Linux (a GIF picker that uses
Gdk.FileList) put the daemon into a loop: it re-broadcast the unchanged clipboard as a new clip about 13 times a second. The paired Mac extracted every one to~/.local/state/ssh-clipboard/files/<clip id>/, and over a few weeks that reached 189,000 copies of the same GIF (263 GB) and filled the disk.Cause
GTK 4 file copies also offer the XDG document portal's
application/vnd.portal.filetransferandapplication/vnd.portal.files. Every read of those registers a fresh transfer key:Capture includes every offered format in the snapshot fingerprint, so the fingerprint changed on every poll and
previous.fingerprint == snapshot.fingerprintnever matched.Fix
is_host_local_format). The keys can only be redeemed on the copying machine, and the file already travels astext/uri-listplus the bundle.files/<sha256 of bundle>replacesfiles/<clip id>, the same approach as the Linux image cache (Clipboard-<sha256>.<ext>). Repeats of the same files reuse one copy, so a future echo loop costs one directory, not the disk. Reusing an existing copy now checks it against the bundle and rebuilds it if a pasted file was edited or deleted in place. Previously that returned the stale copy or failed withexisting copied-file bundle is incomplete.filebundle::materializeno longer takes a clip id. The daemon andtests/headless_x11.rsare updated.Testing
ssh-clipboard monitor --jsonshowed 80 local clips in 6 s on v0.2.18 and exactly 1 with this branch, which still carriestext/uri-list, the file bundle, andimage/gif.cargo test --lib --bins: 92 pass. New tests:portal_transfer_keys_are_not_captured,identical_bundles_share_one_directory,reuses_an_intact_copy_and_rebuilds_a_changed_one.cargo clippy --all-targetsis clean and all integration tests compile. I couldn't runheadless_x11orcontainer_servicelocally (no Xvfb).🤖 Generated with Claude Code
https://claude.ai/code/session_01YWDws5xQ8VkLWBi9SLC7ih