Skip to content

Commit 8a1d6df

Browse files
committed
Revert "fix: infer connection for macOS native tab bar "+" button (#576)"
This reverts commit 95570fb.
1 parent 95570fb commit 8a1d6df

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

TablePro/ContentView.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,11 @@ struct ContentView: View {
3636
private let storage = ConnectionStorage.shared
3737

3838
init(payload: EditorTabPayload?) {
39-
// When payload is nil (macOS native tab bar "+" button), infer
40-
// the connectionId from the key window so the new tab inherits
41-
// the correct connection instead of showing an empty state.
42-
var effectivePayload = payload
43-
if effectivePayload == nil, let keyWindow = NSApp.keyWindow,
44-
let connectionId = WindowLifecycleMonitor.shared.connectionIdFromWindow(keyWindow) {
45-
effectivePayload = EditorTabPayload(
46-
connectionId: connectionId,
47-
tabType: .query,
48-
isNewTab: true
49-
)
50-
}
51-
self.payload = effectivePayload
52-
39+
self.payload = payload
5340
let defaultTitle: String
54-
if let tableName = effectivePayload?.tableName {
41+
if let tableName = payload?.tableName {
5542
defaultTitle = tableName
56-
} else if let connectionId = effectivePayload?.connectionId,
43+
} else if let connectionId = payload?.connectionId,
5744
let connection = DatabaseManager.shared.activeSessions[connectionId]?.connection {
5845
let langName = PluginManager.shared.queryLanguageName(for: connection.type)
5946
defaultTitle = "\(langName) Query"
@@ -65,15 +52,15 @@ struct ContentView: View {
6552
// For Cmd+T (new tab), the session already exists. Resolve synchronously
6653
// to avoid the "Connecting..." flash while waiting for async onChange.
6754
var resolvedSession: ConnectionSession?
68-
if let connectionId = effectivePayload?.connectionId {
55+
if let connectionId = payload?.connectionId {
6956
resolvedSession = DatabaseManager.shared.activeSessions[connectionId]
7057
}
7158
_currentSession = State(initialValue: resolvedSession)
7259

7360
if let session = resolvedSession {
7461
_rightPanelState = State(initialValue: RightPanelState())
7562
_sessionState = State(initialValue: SessionStateFactory.create(
76-
connection: session.connection, payload: effectivePayload
63+
connection: session.connection, payload: payload
7764
))
7865
} else {
7966
_rightPanelState = State(initialValue: nil)

TablePro/Core/Services/Infrastructure/WindowLifecycleMonitor.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ internal final class WindowLifecycleMonitor {
119119
return entries[windowId]?.connectionId
120120
}
121121

122-
/// Look up the connectionId for a given NSWindow by matching its reference.
123-
internal func connectionIdFromWindow(_ window: NSWindow) -> UUID? {
124-
purgeStaleEntries()
125-
return entries.values.first { $0.window === window }?.connectionId
126-
}
127-
128122
/// Check if any windows are registered for a connection.
129123
internal func hasWindows(for connectionId: UUID) -> Bool {
130124
purgeStaleEntries()

0 commit comments

Comments
 (0)