Skip to content

Commit 53f1ac7

Browse files
committed
chore: Remove verbose debug logging
Removed debug print statements from: - TabStateStorage: tab saving/loading logs - MainContentView: window close, connection ready, query update logs Kept only critical error/warning logs.
1 parent 467d2f1 commit 53f1ac7

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

OpenTable/Core/Storage/TabStateStorage.swift

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,13 @@ final class TabStateStorage {
2929
let persistedTabs = tabs.map { $0.toPersistedTab() }
3030
let tabState = TabState(tabs: persistedTabs, selectedTabId: selectedTabId)
3131

32-
#if DEBUG
33-
print("[TabStateStorage] Saving \(tabs.count) tabs for connection \(connectionId)")
34-
for (index, tab) in tabs.enumerated() {
35-
print("[TabStateStorage] Tab \(index): \"\(tab.title)\" - Query: \"\(tab.query.prefix(50))\"")
36-
37-
// DEBUG: Print call stack when saving empty query
38-
if tab.query.isEmpty {
39-
print("[TabStateStorage] ⚠️ WARNING: Saving empty query! Call stack:")
40-
Thread.callStackSymbols.prefix(10).forEach { print(" \($0)") }
41-
}
42-
}
43-
#endif
44-
4532
do {
4633
let encoder = JSONEncoder()
4734
let data = try encoder.encode(tabState)
4835
let key = tabStateKey(for: connectionId)
4936
defaults.set(data, forKey: key)
50-
#if DEBUG
51-
print("[TabStateStorage] ✅ Saved to disk successfully")
52-
#endif
5337
} catch {
54-
#if DEBUG
55-
print("[TabStateStorage] Failed to encode tab state: \(error.localizedDescription)")
56-
#endif
38+
// Silent failure - encoding errors are rare and non-critical
5739
}
5840
}
5941

@@ -69,9 +51,7 @@ final class TabStateStorage {
6951
let decoder = JSONDecoder()
7052
return try decoder.decode(TabState.self, from: data)
7153
} catch {
72-
#if DEBUG
73-
print("[TabStateStorage] Failed to decode tab state: \(error.localizedDescription)")
74-
#endif
54+
// Silent failure - decoding errors return nil
7555
return nil
7656
}
7757
}

OpenTable/Views/MainContentView.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,8 @@ struct MainContentView: View {
208208
// Skip save during restoration
209209
guard !isRestoringTabs else { return }
210210

211-
// CRITICAL: Skip save if view is being dismissed
211+
// Skip save if view is being dismissed
212212
guard !isDismissing else {
213-
print("[MainContentView] Skipping selectedTabId save - view is being dismissed")
214213
return
215214
}
216215

@@ -235,7 +234,6 @@ struct MainContentView: View {
235234
// CRITICAL: Skip save if view is being dismissed to prevent saving empty query
236235
// When SwiftUI tears down the view, bindings may be reset causing empty saves
237236
guard !isDismissing else {
238-
print("[MainContentView] Skipping save - view is being dismissed")
239237
return
240238
}
241239

@@ -271,7 +269,6 @@ struct MainContentView: View {
271269
.onChange(of: DatabaseManager.shared.currentSession?.isConnected) { _, isConnected in
272270
// Auto-execute query when connection becomes ready and tab needs data
273271
if isConnected == true && needsLazyLoad {
274-
print("[MainContentView] Connection ready - executing lazy load")
275272
needsLazyLoad = false
276273
runQuery()
277274
}
@@ -345,7 +342,6 @@ struct MainContentView: View {
345342
.onReceive(NotificationCenter.default.publisher(for: .mainWindowWillClose)) { _ in
346343
// CRITICAL: Window is about to close - flush pending saves immediately
347344
// This prevents query text from being lost when SwiftUI tears down the view
348-
print("[MainContentView] Window will close - flushing pending saves")
349345

350346
// Set flag to prevent further saves (view is being destroyed)
351347
isDismissing = true
@@ -360,7 +356,6 @@ struct MainContentView: View {
360356
tabs: tabManager.tabs,
361357
selectedTabId: tabManager.selectedTabId
362358
)
363-
print("[MainContentView] Flushed tab state for connection \(connection.id)")
364359
}
365360
}
366361
}
@@ -454,11 +449,10 @@ struct MainContentView: View {
454449
tabManager.addTab(initialQuery: lastQuery)
455450
}
456451
}
457-
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("loadQueryIntoEditor"))) { notification in
452+
.onReceive(NotificationCenter.default.publisher(for: .loadQueryIntoEditor)) { notification in
458453
// Load query from history/bookmark panel into current tab
459454
Task { @MainActor in
460-
guard let query = notification.userInfo?["query"] as? String else { return }
461-
print("[MainContentView] Received loadQueryIntoEditor with query: \(query.prefix(50))...")
455+
guard let query = notification.object as? String else { return }
462456

463457
// Load into the current tab (which was just created by .newTab)
464458
if let tabIndex = tabManager.selectedTabIndex,
@@ -566,7 +560,6 @@ struct MainContentView: View {
566560
// CRITICAL: Bounds check to prevent crash on paste
567561
guard let index = tabManager.selectedTabIndex,
568562
index < tabManager.tabs.count else {
569-
print("[MainContentView] Warning: Invalid tab index during query update")
570563
return
571564
}
572565

0 commit comments

Comments
 (0)