Skip to content

refactor: replace timing hacks with structured signals#600

Merged
datlechin merged 1 commit intomainfrom
refactor/timing-hacks
Apr 6, 2026
Merged

refactor: replace timing hacks with structured signals#600
datlechin merged 1 commit intomainfrom
refactor/timing-hacks

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Replaces 6 timing hacks (polling loops, arbitrary delays) with proper structured alternatives:

Site Before After
configureWelcomeWindow() 5x50ms polling for welcome window RemovedwindowDidBecomeKey already handles styling
Phase 2 queries 200ms Task.sleep before row count/enum fetch Task(priority: .background) — proper deprioritization
Tab switch 16ms Task.sleep for onChange settle Task.yield() — yields without fixed duration
Connection form focus 10x20ms polling NSApp.windows NSWindow.didBecomeKeyNotification observer
Share file import 300ms asyncAfter before notification Pending URL pattern — setUp() consumes stored URL
WindowOpener readiness 25x200ms polling for openWindow != nil CheckedContinuation with 5s timeout via TaskGroup

Test plan

  • Launch app → welcome window styled correctly (no polling needed)
  • Run a query → row count appears in status bar (background priority)
  • Switch between tabs → smooth, no delay
  • Click New Connection from welcome → connection form window focuses
  • Open .tablepro file → import sheet appears on welcome window
  • Deep link with connection URL → connects after window system ready
  • Launch with queued URLs → all processed correctly

- Remove redundant configureWelcomeWindow() polling (windowDidBecomeKey handles it)
- Replace Phase 2 query delays with Task(priority: .background)
- Replace 16ms tab-switch sleep with Task.yield()
- Replace connection form window polling with NSWindow.didBecomeKeyNotification
- Replace 300ms notification delay with pending URL pattern
- Replace WindowOpener 5s polling with continuation-based readiness signal
@datlechin datlechin merged commit 1c698c7 into main Apr 6, 2026
2 checks passed
@datlechin datlechin deleted the refactor/timing-hacks branch April 6, 2026 09:30
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