Skip to content

refactor: replace hacks with native macOS patterns and clean up concurrency#830

Merged
datlechin merged 2 commits into
mainfrom
refactor/native-patterns-cleanup
Apr 22, 2026
Merged

refactor: replace hacks with native macOS patterns and clean up concurrency#830
datlechin merged 2 commits into
mainfrom
refactor/native-patterns-cleanup

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • Toolbar: Replace .opacity() / .allowsHitTesting() hacks with conditional if rendering for database switcher, import button, and results button. Merge connection + database into a single toolbar item group so non-switching databases (libSQL, SQLite, Redis) show no gap. Hide "Switch Database" hint in empty state for non-switching databases.
  • SSH dialogs: Replace DispatchSemaphore blocking pattern with DispatchQueue.main.sync in PromptPassphraseProvider and PromptTOTPProvider — same semantics, no thread waste.
  • Terminal: Replace @State NSObjectProtocol? observer with .task using NotificationCenter.default.notifications(named:) async stream for SSH tunnel waiting — auto-cancelled on view disappear, no manual lifecycle.
  • Concurrency: Remove redundant Task { @MainActor in } across 28 files where the enclosing type is already @MainActor. Keep @MainActor annotation in @Sendable closure contexts (NotificationCenter callbacks, KVO observers, DispatchSource handlers, Timer blocks).
  • Timers: Replace DispatchQueue.main.asyncAfter with Task.sleep in MCPSection (copy confirmation) and FavoritesSidebarViewModel (folder rename delay).

Test plan

  • Connect to MySQL/PostgreSQL — verify connection, queries, data editing
  • Connect to libSQL/SQLite/Redis — verify no database switcher gap in toolbar
  • Connect via SSH with encrypted key — passphrase dialog appears and works
  • Connect via SSH with TOTP — verification code dialog appears and works
  • Cancel SSH dialogs — fails gracefully, no hang
  • Open terminal tab on SSH connection — waits for tunnel, then connects
  • Close terminal tab while waiting — no crash or leak
  • Export table data to CSV/JSON/SQL
  • Import a SQL file
  • Favorites sidebar — create folder, rename, add favorite
  • Quick Switcher (Cmd+P) — search and select
  • Settings > MCP section — copy button shows checkmark then resets
  • Settings > Plugins — install/uninstall plugin
  • Welcome window — open, create connection
  • About window — open About TablePro
  • ER diagram — open and view
  • Switch between query and table tabs — results button visibility
  • Multiple windows with different connections

…rrency

- Toolbar: replace opacity/hitTesting hacks with conditional rendering for
  database switcher, import button, and results button; merge connection +
  database into single toolbar item group
- Toolbar: hide "Switch Database" hint in empty state for non-switching databases
- SSH: replace DispatchSemaphore blocking with DispatchQueue.main.sync in
  PromptPassphraseProvider and PromptTOTPProvider
- Terminal: replace @State NSObjectProtocol observer with .task async
  notification stream for tunnel waiting
- Concurrency: remove redundant Task { @mainactor in } across 28 files where
  enclosing type is already @mainactor; keep @mainactor in @sendable closures
- Replace DispatchQueue.main.asyncAfter with Task.sleep in MCPSection and
  FavoritesSidebarViewModel
@datlechin datlechin merged commit fa72ea3 into main Apr 22, 2026
1 check passed
@datlechin datlechin deleted the refactor/native-patterns-cleanup branch April 22, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant