Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TablePro/Core/SSH/Auth/PromptTOTPProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ internal final class PromptTOTPProvider: TOTPProvider, @unchecked Sendable {
return try handleResult(code)
}

// Note: runModal() is intentional here. This method runs on the main thread
// (via DispatchQueue.main.sync from provideCode), so beginSheetModal + semaphore would deadlock.
private func showAlert() -> String? {
let alert = NSAlert()
alert.messageText = String(localized: "Verification Code Required")
Expand Down
4 changes: 2 additions & 2 deletions TablePro/Core/SSH/HostKeyVerifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal enum HostKeyVerifier {
alert.addButton(withTitle: String(localized: "Trust"))
alert.addButton(withTitle: String(localized: "Cancel"))

if let window = NSApp.keyWindow {
if let window = NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: { $0.isVisible }) {
return await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response == .alertFirstButtonReturn)
Expand Down Expand Up @@ -155,7 +155,7 @@ internal enum HostKeyVerifier {
alert.buttons[1].keyEquivalent = "\r"
alert.buttons[0].keyEquivalent = ""

if let window = NSApp.keyWindow {
if let window = NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: { $0.isVisible }) {
return await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response == .alertFirstButtonReturn)
Expand Down
19 changes: 12 additions & 7 deletions TablePro/Core/Utilities/UI/AlertHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import AppKit
/// Provides consistent styling and behavior across the application
@MainActor
final class AlertHelper {
/// Tries multiple sources to find a presentable window, minimizing runModal() fallback usage.
private static func resolveWindow(_ window: NSWindow?) -> NSWindow? {
window ?? NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first { $0.isVisible }
}

// MARK: - Destructive Confirmations

/// Shows a destructive confirmation dialog (warning style)
Expand All @@ -37,7 +42,7 @@ final class AlertHelper {
alert.addButton(withTitle: cancelButton)

// Use sheet presentation when window is available (non-blocking, Swift 6 friendly)
if let window = window {
if let window = resolveWindow(window) {
return await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response == .alertFirstButtonReturn)
Expand Down Expand Up @@ -77,7 +82,7 @@ final class AlertHelper {
alert.addButton(withTitle: cancelButton)

// Use sheet presentation when window is available (non-blocking, Swift 6 friendly)
if let window = window {
if let window = resolveWindow(window) {
return await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response == .alertFirstButtonReturn)
Expand Down Expand Up @@ -123,7 +128,7 @@ final class AlertHelper {

let response: NSApplication.ModalResponse

if let window = window {
if let window = resolveWindow(window) {
response = await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { resp in
continuation.resume(returning: resp)
Expand Down Expand Up @@ -174,7 +179,7 @@ final class AlertHelper {
let response: NSApplication.ModalResponse

// Use sheet presentation when window is available (non-blocking, Swift 6 friendly)
if let window = window {
if let window = resolveWindow(window) {
response = await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { resp in
continuation.resume(returning: resp)
Expand Down Expand Up @@ -215,7 +220,7 @@ final class AlertHelper {
alert.alertStyle = .critical
alert.addButton(withTitle: String(localized: "OK"))

if let window = window {
if let window = resolveWindow(window) {
alert.beginSheetModal(for: window) { _ in
// Sheet dismissed, no action needed
}
Expand Down Expand Up @@ -243,7 +248,7 @@ final class AlertHelper {
alert.alertStyle = .informational
alert.addButton(withTitle: String(localized: "OK"))

if let window = window {
if let window = resolveWindow(window) {
alert.beginSheetModal(for: window) { _ in
// Sheet dismissed, no action needed
}
Expand Down Expand Up @@ -273,7 +278,7 @@ final class AlertHelper {
alert.addButton(withTitle: String(localized: "OK"))
alert.addButton(withTitle: String(localized: "Ask AI to Fix"))

if let window = window {
if let window = resolveWindow(window) {
return await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response == .alertSecondButtonReturn)
Expand Down
2 changes: 1 addition & 1 deletion TablePro/Core/Utilities/UI/PasswordPromptHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum PasswordPromptHelper {
alert.accessoryView = input
alert.window.initialFirstResponder = input

if let window {
if let window = window ?? NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: { $0.isVisible }) {
let response = await withCheckedContinuation { continuation in
alert.beginSheetModal(for: window) { response in
continuation.resume(returning: response)
Expand Down
5 changes: 3 additions & 2 deletions TablePro/ViewModels/WelcomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ final class WelcomeViewModel {
panel.allowedContentTypes = [.tableproConnectionShare]
panel.allowsMultipleSelection = false
panel.canChooseDirectories = false
guard let window = NSApp.keyWindow else { return }
guard let window = NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: { $0.isVisible })
else { return }
panel.beginSheetModal(for: window) { response in
guard response == .OK, let url = panel.url else { return }
self.activeSheet = .importFile(url)
Expand All @@ -406,7 +407,7 @@ final class WelcomeViewModel {
alert.informativeText = String(localized: "All selected connections were skipped.")
}
alert.addButton(withTitle: String(localized: "OK"))
if let window = NSApp.keyWindow {
if let window = NSApp.keyWindow ?? NSApp.mainWindow ?? NSApp.windows.first(where: { $0.isVisible }) {
alert.beginSheetModal(for: window)
} else {
alert.runModal()
Expand Down
10 changes: 3 additions & 7 deletions TablePro/Views/Editor/HistoryPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ private extension HistoryPanelView {
HistoryRowSwiftUI(entry: entry)
.tag(entry.id)
.contextMenu { contextMenu(for: entry) }
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) {
deleteEntry(entry)
} label: {
Label(String(localized: "Delete"), systemImage: "trash")
}
}
}
.listStyle(.plain)
.environment(\.defaultMinListRowHeight, ThemeEngine.shared.activeTheme.rowHeights.comfortable)
Expand Down Expand Up @@ -159,6 +152,7 @@ private extension HistoryPanelView {
Image(systemName: "magnifyingglass")
.font(.largeTitle)
.foregroundStyle(.tertiary)
.accessibilityHidden(true)
Text("No Matching Queries")
.font(.system(size: ThemeEngine.shared.activeTheme.typography.body, weight: .medium))
.foregroundStyle(.secondary)
Expand All @@ -170,6 +164,7 @@ private extension HistoryPanelView {
Image(systemName: "clock.arrow.circlepath")
.font(.largeTitle)
.foregroundStyle(.tertiary)
.accessibilityHidden(true)
Text("No Query History Yet")
.font(.system(size: ThemeEngine.shared.activeTheme.typography.body, weight: .medium))
.foregroundStyle(.secondary)
Expand Down Expand Up @@ -272,6 +267,7 @@ private extension HistoryPanelView {
Image(systemName: "doc.text")
.font(.largeTitle)
.foregroundStyle(.tertiary)
.accessibilityHidden(true)
Text("Select a Query")
.font(.system(size: ThemeEngine.shared.activeTheme.typography.title3, weight: .medium))
.foregroundStyle(.secondary)
Expand Down
1 change: 1 addition & 0 deletions TablePro/Views/Main/Child/MainEditorContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ struct MainEditorContentView: View {
Image(systemName: "tray")
.font(.largeTitle)
.foregroundStyle(.secondary)
.accessibilityHidden(true)
Text("No rows returned")
.font(.system(size: ThemeEngine.shared.activeTheme.typography.body, weight: .medium))
if let time = executionTime {
Expand Down
2 changes: 2 additions & 0 deletions TablePro/Views/Structure/ClickHousePartsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ClickHousePartsView: View {
Image(systemName: "exclamationmark.triangle")
.font(.largeTitle)
.foregroundStyle(Color(nsColor: .systemOrange))
.accessibilityHidden(true)
Text(error)
.foregroundStyle(.secondary)
}
Expand All @@ -37,6 +38,7 @@ struct ClickHousePartsView: View {
Image(systemName: "tray")
.font(.largeTitle)
.foregroundStyle(.secondary)
.accessibilityHidden(true)
Text("No parts found")
.foregroundStyle(.secondary)
}
Expand Down
1 change: 1 addition & 0 deletions TablePro/Views/Structure/CreateTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ struct CreateTableView: View {
Image(systemName: "doc.plaintext")
.font(.largeTitle)
.foregroundStyle(.secondary)
.accessibilityHidden(true)
Text("Add columns to see the CREATE TABLE statement")
.foregroundStyle(.secondary)
}
Expand Down
2 changes: 2 additions & 0 deletions TablePro/Views/Structure/TableStructureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct TableStructureView: View {
Image(systemName: "exclamationmark.triangle")
.font(.largeTitle)
.foregroundStyle(Color(nsColor: .systemOrange))
.accessibilityHidden(true)
Text(message)
.foregroundStyle(.secondary)
}
Expand All @@ -247,6 +248,7 @@ struct TableStructureView: View {
Image(systemName: "tray")
.font(.largeTitle)
.foregroundStyle(.secondary)
.accessibilityHidden(true)
Text(message)
.foregroundStyle(.secondary)
}
Expand Down
Loading