Skip to content

feat: hand a reconnecting phone the clipboard it missed - #338

Closed
fernando2393 wants to merge 1 commit into
zackb:mainfrom
fernando2393:pr/clipboard-reconnect-catch-up
Closed

fernando2393 wants to merge 1 commit into
zackb:mainfrom
fernando2393:pr/clipboard-reconnect-catch-up

Conversation

@fernando2393

Copy link
Copy Markdown
Contributor

Problem

iOS closes the TCP session as soon as the app leaves the foreground, so text copied on the computer while the phone is away was never delivered. Opening the app reconnected, but nobody told it what it had missed.

Change

The daemon remembers, per paired peer (certificate fingerprint), the last clipboard text it sent to or received from that peer. After a paired client's hello, it sends one clipboard_updated with the current Host clipboard if that peer has not got it. Not sent when clipboard_auto_share is off or the clipboard is an image. A phone that just sent the text is not sent it back.

broadcast_clipboard_text() replaces three copies of the same JSON-building code and records delivery.

Testing

Existing suite passes on this branch alone (638 tests). By hand with a real iPhone: copy on the computer with the app closed, open the app, the text arrives and pastes.
Not unit-tested: the hello handler lives inside the TLS session loop; happy to extract it if you want a test.

🤖 Generated with Claude Code

Note: this touches net.cpp and daemon/main.cpp like #324, but a different feature (clipboard text, not MAP messages); happy to rebase whichever lands second.

iOS closes the connection when the app leaves the foreground, so text copied on
the computer while the phone is away was never delivered. Remember what each
paired phone last received or sent, by certificate fingerprint, and after the
phone's hello send it the current clipboard text if it has not seen it.

A phone that just sent the text, and one that already has it, are not sent it
again.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@zackb

zackb commented Nov 23, 2026

Copy link
Copy Markdown
Owner

I appreciate the effort, but I don't think this is what users want or expect. Since the daemon can't see what's going on on the iPhone this can overwrite new iphone clipboard entries with ancient stuff from the daemon. I think if people do want this it should be a setting on the phone app, not memory in the daemon. The app can already request the clipboard so we could give the user a setting to re-fetch (requestClipboard / clibpoard_get) on app startup.

@zackb zackb closed this Nov 23, 2026
@fernando2393

Copy link
Copy Markdown
Contributor Author

That's fair. The daemon can't see what was copied on the phone while the app was away, so it could replace something newer with something old, and a phone-side setting to re-fetch on startup is the right place for it. Closing this one. Thanks for taking the time to explain.

@fernando2393
fernando2393 deleted the pr/clipboard-reconnect-catch-up branch November 23, 2026 22:13
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.

2 participants