Skip to content

fix: prevent hang on coordinator dealloc and concurrent WindowOpener waits#601

Merged
datlechin merged 4 commits intomainfrom
fix/perf-audit-tier1
Apr 7, 2026
Merged

fix: prevent hang on coordinator dealloc and concurrent WindowOpener waits#601
datlechin merged 4 commits intomainfrom
fix/perf-audit-tier1

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Two fixes from the performance audit (Tier 1 critical items):

  • saveCompletionContinuation hangMainContentCoordinator.deinit now resumes the pending save continuation with false before cleanup. Previously, if the coordinator was deallocated mid-save (force close, SwiftUI view discard), the awaiting Task in MainContentCommandActions.closeAfterSave() would hang forever.

  • WindowOpener concurrent waitersreadyContinuation (single CheckedContinuation?) replaced with readyContinuations: [CheckedContinuation]. Multiple subsystems can now await waitUntilReady() concurrently at cold launch without the second caller overwriting and orphaning the first caller's continuation.

The third audit item (usleep in AutoTOTPProvider) was re-assessed as correct — it runs on a dedicated detached thread, not the cooperative pool.

Test plan

  • Edit cells → Cmd+W → save prompt works, window closes after save
  • Force-close window mid-save → no hang, app stays responsive
  • Cold launch with queued deep link URLs → all processed correctly
  • Multiple simultaneous connection attempts at startup → all connect

…waits

- Resume saveCompletionContinuation in MainContentCoordinator.deinit to
  prevent permanent hang if coordinator deallocates during save
- Support multiple concurrent waitUntilReady() callers in WindowOpener
  by using an array of continuations instead of a single optional
…flow

saveAndClose() checked rightPanelState.editState.hasEdits before
changeManager.hasChanges, causing it to take the sidebar-only save path
(which doesn't execute SQL) when the inspector panel reflected data grid
edits. This matched the user's report: Cmd+W → Save behaved identically
to Cmd+W → Don't Save.

The regular saveChanges() already had the correct priority order (data
grid first, sidebar second). This aligns saveAndClose() with that logic.
@datlechin datlechin force-pushed the fix/perf-audit-tier1 branch from 121deb4 to 52dccf5 Compare April 7, 2026 02:57
@datlechin datlechin merged commit a55d41d into main Apr 7, 2026
2 checks passed
@datlechin datlechin deleted the fix/perf-audit-tier1 branch April 7, 2026 02:57
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