Skip to content

Commit cb7ecb3

Browse files
committed
fix: explicitly attach new windows to existing tab group
openWindow creates the window before tabbingIdentifier is set, so macOS automatic tabbing doesn't group them. Use addTabbedWindow to explicitly attach new windows to the connection's existing tab group.
1 parent e269dda commit cb7ecb3

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

TablePro/AppDelegate+WindowConfig.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,25 @@ extension AppDelegate {
239239
let existingIdentifier = NSApp.windows
240240
.first { $0 !== window && isMainWindow($0) && $0.isVisible }?
241241
.tabbingIdentifier
242-
window.tabbingIdentifier = TabbingIdentifierResolver.resolve(
242+
let resolvedIdentifier = TabbingIdentifierResolver.resolve(
243243
pendingConnectionId: pendingId,
244244
existingIdentifier: existingIdentifier
245245
)
246+
window.tabbingIdentifier = resolvedIdentifier
246247
configuredWindows.insert(windowId)
247248

248249
if !NSWindow.allowsAutomaticWindowTabbing {
249250
NSWindow.allowsAutomaticWindowTabbing = true
250251
}
252+
253+
// Explicitly attach to existing tab group — automatic tabbing
254+
// doesn't work when tabbingIdentifier is set after window creation.
255+
if let existingWindow = NSApp.windows.first(where: {
256+
$0 !== window && isMainWindow($0) && $0.isVisible
257+
&& $0.tabbingIdentifier == resolvedIdentifier
258+
}) {
259+
existingWindow.addTabbedWindow(window, ordered: .above)
260+
}
251261
}
252262
}
253263

0 commit comments

Comments
 (0)