Skip to content

Commit 45626e0

Browse files
committed
fix: resolve 21 build warnings across 9 source files
1 parent cd53240 commit 45626e0

9 files changed

Lines changed: 68 additions & 67 deletions

TablePro/Core/AI/InlineSuggestionManager.swift

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// ghost text as a CATextLayer overlay on the text view.
88
//
99

10-
import AppKit
10+
@preconcurrency import AppKit
1111
import CodeEditSourceEditor
1212
import CodeEditTextView
1313
import os
@@ -374,35 +374,38 @@ final class InlineSuggestionManager {
374374

375375
private func installKeyEventMonitor() {
376376
removeKeyEventMonitor()
377-
_keyEventMonitor.withLock { $0 = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
378-
guard let self, self.isEditorFocused else { return event }
377+
_keyEventMonitor.withLock { $0 = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] nsEvent in
378+
nonisolated(unsafe) let event = nsEvent
379+
return MainActor.assumeIsolated {
380+
guard let self, self.isEditorFocused else { return event }
379381

380-
guard AppSettingsManager.shared.ai.inlineSuggestEnabled else { return event }
382+
guard AppSettingsManager.shared.ai.inlineSuggestEnabled else { return event }
381383

382-
guard self.currentSuggestion != nil else { return event }
384+
guard self.currentSuggestion != nil else { return event }
383385

384-
guard let textView = self.controller?.textView,
385-
event.window === textView.window,
386-
textView.window?.firstResponder === textView else { return event }
386+
guard let textView = self.controller?.textView,
387+
event.window === textView.window,
388+
textView.window?.firstResponder === textView else { return event }
387389

388-
switch event.keyCode {
389-
case 48: // Tab — accept suggestion
390-
Task { @MainActor [weak self] in
391-
self?.acceptSuggestion()
392-
}
393-
return nil
390+
switch event.keyCode {
391+
case 48: // Tab — accept suggestion
392+
Task { @MainActor [weak self] in
393+
self?.acceptSuggestion()
394+
}
395+
return nil
394396

395-
case 53: // Escape — dismiss suggestion
396-
Task { @MainActor [weak self] in
397-
self?.dismissSuggestion()
398-
}
399-
return nil
397+
case 53: // Escape — dismiss suggestion
398+
Task { @MainActor [weak self] in
399+
self?.dismissSuggestion()
400+
}
401+
return nil
400402

401-
default:
402-
Task { @MainActor [weak self] in
403-
self?.dismissSuggestion()
403+
default:
404+
Task { @MainActor [weak self] in
405+
self?.dismissSuggestion()
406+
}
407+
return event
404408
}
405-
return event
406409
}
407410
}
408411
}
@@ -419,11 +422,12 @@ final class InlineSuggestionManager {
419422

420423
private func installScrollObserver() {
421424
guard let scrollView = controller?.scrollView else { return }
425+
let contentView = scrollView.contentView
422426

423427
_scrollObserver.withLock {
424428
$0 = NotificationCenter.default.addObserver(
425429
forName: NSView.boundsDidChangeNotification,
426-
object: scrollView.contentView,
430+
object: contentView,
427431
queue: .main
428432
) { [weak self] _ in
429433
Task { @MainActor [weak self] in

TablePro/Core/Database/DatabaseManager.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ final class DatabaseManager {
645645

646646
// MARK: - Startup Commands
647647

648+
nonisolated private static let startupLogger = Logger(subsystem: "com.TablePro", category: "DatabaseManager")
649+
648650
nonisolated private func executeStartupCommands(
649651
_ commands: String?, on driver: DatabaseDriver, connectionName: String
650652
) async {
@@ -660,11 +662,11 @@ final class DatabaseManager {
660662
for statement in statements {
661663
do {
662664
_ = try await driver.execute(query: statement)
663-
Self.logger.info(
665+
Self.startupLogger.info(
664666
"Startup command succeeded for '\(connectionName)': \(statement)"
665667
)
666668
} catch {
667-
Self.logger.warning(
669+
Self.startupLogger.warning(
668670
"Startup command failed for '\(connectionName)': \(statement)\(error.localizedDescription)"
669671
)
670672
}

TablePro/Core/Plugins/Registry/PluginManager+Registry.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension PluginManager {
4242
}
4343

4444
// Use the registry client's configured session for consistent timeouts
45-
let session = await RegistryClient.shared.session
45+
let session = RegistryClient.shared.session
4646

4747
let (tempDownloadURL, response) = try await session.download(from: downloadURL)
4848

@@ -52,7 +52,7 @@ extension PluginManager {
5252
throw PluginError.downloadFailed("HTTP \(statusCode)")
5353
}
5454

55-
await progress(0.5)
55+
progress(0.5)
5656

5757
// Verify SHA-256 checksum
5858
let downloadedData = try Data(contentsOf: tempDownloadURL)
@@ -63,7 +63,7 @@ extension PluginManager {
6363
throw PluginError.checksumMismatch
6464
}
6565

66-
await progress(1.0)
66+
progress(1.0)
6767

6868
// Move to our temp directory for installPlugin
6969
try FileManager.default.moveItem(at: tempDownloadURL, to: tempZipURL)

TablePro/Core/Plugins/SqlFileImportSource.swift

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ final class SqlFileImportSource: PluginImportSource, @unchecked Sendable {
1414
private let encoding: String.Encoding
1515
private let parser = SQLFileParser()
1616

17-
private let lock = NSLock()
18-
private var decompressedURL: URL?
17+
private let _decompressedURL = OSAllocatedUnfairLock<URL?>(initialState: nil)
1918

2019
init(url: URL, encoding: String.Encoding) {
2120
self.url = url
@@ -43,23 +42,20 @@ final class SqlFileImportSource: PluginImportSource, @unchecked Sendable {
4342

4443
return AsyncThrowingStream { continuation in
4544
Task {
46-
do {
47-
for try await item in stream {
48-
continuation.yield(item)
49-
}
50-
continuation.finish()
51-
} catch {
52-
continuation.finish(throwing: error)
45+
for try await item in stream {
46+
continuation.yield(item)
5347
}
48+
continuation.finish()
5449
}
5550
}
5651
}
5752

5853
func cleanup() {
59-
lock.lock()
60-
let tempURL = decompressedURL
61-
decompressedURL = nil
62-
lock.unlock()
54+
let tempURL = _decompressedURL.withLock {
55+
let url = $0
56+
$0 = nil
57+
return url
58+
}
6359

6460
if let tempURL {
6561
do {
@@ -71,10 +67,7 @@ final class SqlFileImportSource: PluginImportSource, @unchecked Sendable {
7167
}
7268

7369
deinit {
74-
// Best-effort cleanup — decompressedURL is non-isolated, use lock
75-
lock.lock()
76-
let tempURL = decompressedURL
77-
lock.unlock()
70+
let tempURL = _decompressedURL.withLock { $0 }
7871
if let tempURL {
7972
try? FileManager.default.removeItem(at: tempURL)
8073
}
@@ -83,19 +76,14 @@ final class SqlFileImportSource: PluginImportSource, @unchecked Sendable {
8376
// MARK: - Private
8477

8578
private func decompressIfNeeded() async throws -> URL {
86-
lock.lock()
87-
if let existing = decompressedURL {
88-
lock.unlock()
79+
if let existing = _decompressedURL.withLock({ $0 }) {
8980
return existing
9081
}
91-
lock.unlock()
9282

9383
let result = try await FileDecompressor.decompressIfNeeded(url) { $0.path() }
9484

9585
if result != url {
96-
lock.lock()
97-
decompressedURL = result
98-
lock.unlock()
86+
_decompressedURL.withLock { $0 = result }
9987
}
10088

10189
return result

TablePro/Core/SSH/SSHTunnelManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ actor SSHTunnelManager {
8989

9090
private func handleTunnelDeath(connectionId: UUID) async {
9191
guard tunnels.removeValue(forKey: connectionId) != nil else { return }
92-
Self.processRegistry.withLock { $0.removeValue(forKey: connectionId) }
92+
Self.processRegistry.withLock { $0[connectionId] = nil }
9393
await notifyTunnelDied(connectionId: connectionId)
9494
}
9595

@@ -228,14 +228,14 @@ actor SSHTunnelManager {
228228
}
229229

230230
tunnels.removeValue(forKey: connectionId)
231-
Self.processRegistry.withLock { $0.removeValue(forKey: connectionId) }
231+
Self.processRegistry.withLock { $0[connectionId] = nil }
232232
}
233233

234234
/// Close all SSH tunnels
235235
func closeAllTunnels() async {
236236
let currentTunnels = tunnels
237237
tunnels.removeAll()
238-
Self.processRegistry.withLock { $0.removeAll() }
238+
Self.processRegistry.withLock { $0.removeAll(); return }
239239

240240
await withTaskGroup(of: Void.self) { group in
241241
for (_, tunnel) in currentTunnels where tunnel.process.isRunning {

TablePro/Core/Vim/VimKeyInterceptor.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Intercepts key events for Vim mode via NSEvent local monitor
66
//
77

8-
import AppKit
8+
@preconcurrency import AppKit
99
import CodeEditSourceEditor
1010
import os
1111

@@ -82,9 +82,12 @@ final class VimKeyInterceptor {
8282

8383
private func installMonitor() {
8484
_monitor.withLock {
85-
$0 = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
86-
guard let self, self.isEditorFocused else { return event }
87-
return self.handleKeyEvent(event)
85+
$0 = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] nsEvent in
86+
nonisolated(unsafe) let event = nsEvent
87+
return MainActor.assumeIsolated {
88+
guard let self, self.isEditorFocused else { return event }
89+
return self.handleKeyEvent(event)
90+
}
8891
}
8992
}
9093
}

TablePro/Views/Editor/EditorEventRouter.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// and dispatches to the correct editor by window, replacing per-editor monitors.
77
//
88

9-
import AppKit
9+
@preconcurrency import AppKit
1010
import CodeEditTextView
1111

1212
@MainActor
@@ -64,15 +64,17 @@ internal final class EditorEventRouter {
6464
// MARK: - Monitor Installation
6565

6666
private func installMonitors() {
67-
rightClickMonitor = NSEvent.addLocalMonitorForEvents(matching: .rightMouseDown) { [weak self] event in
68-
guard let self else { return event }
67+
rightClickMonitor = NSEvent.addLocalMonitorForEvents(matching: .rightMouseDown) { [weak self] nsEvent in
68+
guard let self else { return nsEvent }
69+
nonisolated(unsafe) let event = nsEvent
6970
return MainActor.assumeIsolated {
7071
self.handleRightClick(event)
7172
}
7273
}
7374

74-
clipboardMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
75-
guard let self else { return event }
75+
clipboardMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] nsEvent in
76+
guard let self else { return nsEvent }
77+
nonisolated(unsafe) let event = nsEvent
7678
return MainActor.assumeIsolated {
7779
self.handleKeyDown(event)
7880
}

TablePro/Views/Editor/SQLEditorCoordinator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ final class SQLEditorCoordinator: TextViewCoordinator {
150150
// MARK: - AI Context Menu
151151

152152
private func installAIContextMenu(controller: TextViewController) {
153-
guard let textView = controller.textView else { return }
153+
guard controller.textView != nil else { return }
154154
let menu = AIEditorContextMenu(title: "")
155155
menu.hasSelection = { [weak controller] in
156156
guard let controller else { return false }

TablePro/Views/Main/MainContentCoordinator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ final class MainContentCoordinator {
254254
pluginDriverObserver = NotificationCenter.default.addObserver(
255255
forName: .databaseDidConnect, object: nil, queue: .main
256256
) { [weak self] _ in
257-
self?.setupPluginDriver()
257+
MainActor.assumeIsolated {
258+
self?.setupPluginDriver()
259+
}
258260
}
259261
}
260262
}

0 commit comments

Comments
 (0)