From 2c2190b231458c04e2a95e18bdce4e42b5cf0d6e Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Mon, 23 Feb 2026 18:33:19 -0800 Subject: [PATCH] Block tab drags across cmux app instances --- Sources/ContentView.swift | 26 ++++++++++++++++++++++++-- vendor/bonsplit | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 9c73af0e..50ebfd3c 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -7194,6 +7194,7 @@ private enum SidebarTabDragPayload { private enum BonsplitTabDragPayload { static let typeIdentifier = "com.splittabbar.tabtransfer" + private static let currentProcessId = Int32(ProcessInfo.processInfo.processIdentifier) struct Transfer: Decodable { struct TabInfo: Decodable { @@ -7202,6 +7203,25 @@ private enum BonsplitTabDragPayload { let tab: TabInfo let sourcePaneId: UUID + let sourceProcessId: Int32 + + private enum CodingKeys: String, CodingKey { + case tab + case sourcePaneId + case sourceProcessId + } + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.tab = try container.decode(TabInfo.self, forKey: .tab) + self.sourcePaneId = try container.decode(UUID.self, forKey: .sourcePaneId) + // Legacy payloads won't include this field. Treat as foreign process. + self.sourceProcessId = try container.decodeIfPresent(Int32.self, forKey: .sourceProcessId) ?? -1 + } + } + + private static func isCurrentProcessTransfer(_ transfer: Transfer) -> Bool { + transfer.sourceProcessId == currentProcessId } static func currentTransfer() -> Transfer? { @@ -7209,13 +7229,15 @@ private enum BonsplitTabDragPayload { let type = NSPasteboard.PasteboardType(typeIdentifier) if let data = pasteboard.data(forType: type), - let transfer = try? JSONDecoder().decode(Transfer.self, from: data) { + let transfer = try? JSONDecoder().decode(Transfer.self, from: data), + isCurrentProcessTransfer(transfer) { return transfer } if let raw = pasteboard.string(forType: type), let data = raw.data(using: .utf8), - let transfer = try? JSONDecoder().decode(Transfer.self, from: data) { + let transfer = try? JSONDecoder().decode(Transfer.self, from: data), + isCurrentProcessTransfer(transfer) { return transfer } diff --git a/vendor/bonsplit b/vendor/bonsplit index 1ec5120d..f24ba922 160000 --- a/vendor/bonsplit +++ b/vendor/bonsplit @@ -1 +1 @@ -Subproject commit 1ec5120d94126f5c78e20618d426ee4ef5593c70 +Subproject commit f24ba9222651ecc170869662eec9a5880404a82c