clipboard: the policy bridge and its Engine wiring

ClipboardBridge ports CheckClipboardEx (Clipboard.cs:85-251), the in-band
chunking and reassembly (253-373), GetRemoteClipboard (377-449) and the
clipboard cases of Receiver.cs (273-380) and Event.cs (219-231). It is held
by the Engine actor and returns [ClipboardAction] the way Switcher returns
[SwitchAction]; ClipboardRelay is the Sendable sink the bulk channel and the
pasteboard watcher call.

Engine.swift: the bridge property and the authorised dispatch cases. Four
further lines (Engine.start/stop, EngineActions.applyConfiguration and the
.remoteClipboardWanted case) are beyond the letter of the brief and are
flagged in the feature README's Handshakes for the lead to rule on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 04:50:04 -07:00
1 parent 2276c20792
commit 386c915861
5 files changed
+533 -14

No files matched your search

+8 -2
View File
@@ -286,9 +286,11 @@ final class BulkConnection: @unchecked Sendable {
fail("\(peerName): \(parsed.name)")
return false
}
let isText = parsed.name.caseInsensitiveCompare(ClipboardCodec.textStreamName)
let isText =
parsed.name.caseInsensitiveCompare(ClipboardCodec.textStreamName)
== .orderedSame
let isImage = parsed.name.caseInsensitiveCompare(ClipboardCodec.imageStreamName)
let isImage =
parsed.name.caseInsensitiveCompare(ClipboardCodec.imageStreamName)
== .orderedSame
if isText || isImage {
@@ -313,6 +315,10 @@ final class BulkConnection: @unchecked Sendable {
private func openStagingFile(named headerName: String) -> Destination? {
let name = ClipboardCodec.fileName(fromHeaderName: headerName)
// The download folder is created here, not at startup: nothing appears
// on the user's Desktop until a file is actually on its way.
try? FileManager.default.createDirectory(
at: config.stagingDirectory, withIntermediateDirectories: true)
let url = stagingURL()
guard FileManager.default.createFile(atPath: url.path, contents: nil),
let handle = try? FileHandle(forWritingTo: url)