Skip to content

fix: identify file clips by bundle so other bridges cannot loop them - #18

Open
andrew-boyd wants to merge 1 commit into
mainfrom
fix/file-clipboard-echo-loop
Open

andrew-boyd wants to merge 1 commit into
mainfrom
fix/file-clipboard-echo-loop

Conversation

@andrew-boyd

Copy link
Copy Markdown
Contributor

Fixes #17.

Problem

When ssh-clipboard and a second clipboard bridge (here, Standard Code's clipboard sync) both connect the same two Macs, one copied screenshot loops between them at 2 to 3 clipboard writes per second. Each bridge stages a received file under a new directory. The file snapshot fingerprint included text/uri-list, which names that directory, so neither bridge recognized the other's rewrite as an echo. One Mac accumulated 17,509 staged copies (1.7 GB) of a single screenshot.

Change

  • fingerprint in src/clipboard.rs hashes only the application/x-ssh-clipboard-file-bundle representation when a snapshot has one. The bundle holds relative names, modes, and contents, and it is identical at every hop.
  • The capture loop's existing previous check then drops a restaged copy of the files the daemon just sent. Other clipboard values keep the full fingerprint.

Tests

  • clipboard::tests::file_fingerprint_ignores_where_the_files_were_staged
  • daemon::tests::does_not_resend_files_another_bridge_restaged fails without the fingerprint change and passes with it.
  • cargo test --all-targets, cargo fmt --check, cargo clippy --all-targets -D warnings, and npm test pass.

Verification status

An instrumented v0.2.18 build reproduced the loop on the Mac Studio: every capture had the same 3,932-byte bundle with a new Standard Code staging path, and each one was sent. A live run of this branch did not finish because the peer Mac went offline during the test. That check remains to do before release.

Follow-up

Standard Code's crates/standard-clipboard ports this code and has the same path-sensitive fingerprint. It needs the same change in its repository.

A file snapshot's fingerprint included its text/uri-list, which names the
local directory where a bridge staged the files. When a second clipboard
bridge (such as Standard Code's clipboard sync) also connects two machines,
each bridge restages the other's write under a new path. Neither bridge
recognized the result as an echo, so one screenshot looped at 2 to 3
writes per second and filled both staging directories.

File snapshots now take their fingerprint from the path-free file bundle
alone. The capture loop's existing previous-value check then drops a
restaged copy of the files it just sent.

Fixes #17
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
ssh-clipboard-site e00c04a Oct 08 2026, 09:30 PM

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.

Stop file clipboard loops between two clipboard bridges

1 participant