Skip to content

Bridge the Windows clipboard in the headless host - #5

Draft
joepio wants to merge 1 commit into
mainfrom
claude/project-thread-8qcsvo
Draft

joepio wants to merge 1 commit into
mainfrom
claude/project-thread-8qcsvo

Conversation

@joepio

@joepio joepio commented Nov 5, 2026

Copy link
Copy Markdown
Member

Requested by Joep · project thread

Why

Text clipboard sync (wire + app shell, 2026-07-17) only works when the Flutter app is the host, because the Dart shell is what polls the OS clipboard and calls publish_clipboard / take_remote_clipboard. A real Windows host (Mancave) runs the streambeam-svc-supervised streambeam-host.exe worker, and the in-app host stands down while the service runs. That binary never touched the Windows clipboard, so sync silently did nothing in either direction.

What

  • crates/host/src/clipboard.rs: platform-neutral ClipboardBridge over a SystemClipboard trait, plus a Win32 CF_UNICODETEXT backend (windows-sys). 750 ms poll like the app shell, skips reads while GetClipboardSequenceNumber is unchanged, de-duplicates to prevent echo, retries a write if another process holds the clipboard.
  • Spawned from run_cli (Windows only; elsewhere a no-op).
  • Syncs only while a viewer owns the stream, and under the SYSTEM worker only while the input desktop is Default. The clipboard is per window station, so otherwise the lock screen could hand out what was copied before locking. Viewer text received while locked is applied after unlock.
  • desktop_win::input_desktop_name() helper.
  • No wire change. PROGRESS decision line + a PROTOCOL note on the lock-screen behavior.

Verification

  • cargo test -p streambeam-host: all pass, including 6 new bridge tests.
  • The Win32 FFI block type-checks (clippy clean) against windows-sys 0.61 for x86_64-pc-windows-msvc in an isolated crate. The full host crate could not be checked for Windows from Linux (ring needs MSVC headers), so CI's Windows build is the real check.
  • Not verified on real hardware. Needs a copy/paste round trip Mac ↔ Mancave, plus a check that nothing syncs while Mancave is locked.

Generated by Claude Code

Text clipboard sync only worked when the Flutter app was the host, since
its Dart shell is what polls the OS clipboard. The svc-supervised
streambeam-host.exe worker (what a real Windows box runs) never touched
the clipboard, so sync did nothing in either direction there.

Add a platform-neutral ClipboardBridge over a SystemClipboard trait with
a Win32 CF_UNICODETEXT backend, run on its own thread from run_cli. It
syncs only while a viewer owns the stream and, under the SYSTEM worker,
only while the input desktop is Default (never on the lock screen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHutN2ijFMPqmJ98kBAEH3
@joepio joepio self-assigned this Nov 5, 2026

joepio commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

The Android release and scanner regression check failed, but the cause isn't this PR's code. The Gradle wrapper download returned HTTP 504 (https://github.com/gradle/gradle-distributions/releases/download/v9.1.0/gradle-9.1.0-all.zip) before any build or test ran. This PR only touches the Windows host crate and docs. I'll re-run the failed job once the rest of the workflow run finishes.


Generated by Claude Code

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