Skip to content

refactor: replace GCD dispatch patterns with Swift structured concurrency#538

Merged
datlechin merged 1 commit intomainfrom
refactor/gcd-to-structured-concurrency
Mar 31, 2026
Merged

refactor: replace GCD dispatch patterns with Swift structured concurrency#538
datlechin merged 1 commit intomainfrom
refactor/gcd-to-structured-concurrency

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Replaces DispatchQueue patterns with Swift structured concurrency (Task, Task.sleep) across 16 files. No behavior changes.

Critical fix

  • SQLDialectFactory.createDialect(for:) — removed @MainActor isolation (was only needed because it called through PluginManager.shared, now calls PluginMetadataRegistry.shared directly which is thread-safe)
  • SQLFormatterService.resolveDialectProvider — eliminated DispatchQueue.main.sync deadlock risk and Thread.isMainThread check, now a simple direct call

GCD → Task replacements (11 sites)

  • EditorEventRouter — next-run-loop deferral
  • SQLEditorCoordinator — 4 sites: prepareCoordinator, inline suggestions, throttled frame change (DispatchWorkItemTask + Task.sleep), selection scroll
  • DataGridCoordinator — settings observer callback
  • AppDelegate+WindowConfig — flattened nested DispatchQueue.main.async { Task {} } into single Task
  • MainEditorContentView — 4 sites: window dirty indicator, provider cache ops, column layout
  • MainContentView — sidebar sync

asyncAfter → Task.sleep (7 files)

HistoryPanelView, SQLPreviewSheet, SyncStatusIndicator, SQLReviewPopover, ConnectionExportOptionsSheet, WelcomeWindowView, AIChatCodeBlockView

Intentionally NOT changed

  • SSH/TOTP semaphores (synchronous blocking required by SSH handshake)
  • Storage init semaphores (synchronous init, not in async context)
  • AppKit delegate callbacks (dispatching to main from non-@mainactor contexts)

Test plan

  • Open editor, type SQL — verify autocomplete/inline suggestions work
  • Resize editor — verify frame change notifications fire correctly
  • Connect to database — verify auto-reconnect at startup works
  • Change DataGrid settings — verify row height/font changes apply
  • Edit column layout — verify layout saves persist
  • History panel, SQL preview, sync indicator — verify timing-based UI still works

@datlechin datlechin merged commit d001677 into main Mar 31, 2026
2 checks passed
@datlechin datlechin deleted the refactor/gcd-to-structured-concurrency branch March 31, 2026 10:00
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