Skip to content

Strict concurrency: MenubucketApp from 331 diagnostics to 1, enforced in CI - #299

Merged
jiunbae merged 16 commits into
mainfrom
chore/app-strict-concurrency
Nov 16, 2026
Merged

jiunbae merged 16 commits into
mainfrom
chore/app-strict-concurrency

Conversation

@jiunbae

@jiunbae jiunbae commented Nov 16, 2026

Copy link
Copy Markdown
Member

Takes MenubucketApp from 331 strict-concurrency diagnostics to 1 and enforces that in CI.

  • Main-thread-only types say so: WidgetInstaller, MenuBarController, Scheduler, the watchers, popup/pager/panels, SharedShelfPublisher, WidgetPrefs, AppPrefs, and in BarShelfDock the store, hotkeys and actions (that target is now at 0 locally).
  • Callbacks carry their real isolation (@MainActor @Sendable completions for images, vault prompts, drops).
  • Cleanup that used to live in deinit moved into small owners that undo themselves when released (ScopedObservation.swift: event monitors, notification observers, timers).
  • MainActor.assumeIsolated only where delivery on the main thread is guaranteed (main-run-loop timers, queue: .main observers, the main-run-loop event tap, AppKit animation completions), each with a comment.
  • No new @unchecked Sendable, nonisolated(unsafe), @preconcurrency or Task.detached; one existing @unchecked Sendable removed. No real data race was found.

The one diagnostic left is VaultResume.swift: the Touch ID prompt's onCancel shares an LAContext with evaluatePolicy; fixing it needs @unchecked Sendable or a slower cancel. It is documented in place and is the only one CI allows.

CI: new step "MenubucketApp (own files, enforced)" fails on any strict diagnostic in Sources/MenubucketApp/ beyond that one. It counts rather than using -warnings-as-errors, which would stop in BarShelfAutomation (23 remaining, untouched here).

Behavior nuances: the Esc monitor of a released popover is now removed; DockHotkeys no longer clears the shared status sets when released (the app keeps one instance for its lifetime). Full suite: Core 941 / App 1007 / CLI 86, 0 failures.

🤖 Generated with Claude Code

jiunbae and others added 15 commits November 16, 2026 19:06
…the main actor

Both were main-thread-only by comment; the annotation makes the compiler
check it. The download progress callback is now @sendable, which is what
it always had to be: the download runs off the main actor.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every entry point already ran on the main queue. The animation timers
say why their callbacks are on the main thread, and the appearance
observation hands its callback only the look's name instead of reading
the button from a Sendable closure. Tests and the landing-media cluster
that call its drawing helpers are main-actor too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…the main actor

WidgetInstallURLPrompt, MenuBarStyleControls, PopupSurface/PopoverSurface,
PagerState and AccessibilityHelper only ever ran on the main thread; they
now say so. EventMonitor and NotificationObservation own an event monitor
or a block observer and remove it when released, so a main-actor owner no
longer has to reach a non-Sendable token from its deinit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Scheduler, DirectoryWatcher and PointerWatcher ran on the main queue by
convention. Now the compiler checks it:

- timers, observers, the App Nap activity, the event tap and the FSEvents
  stream are held by small objects that undo them when released, so no
  main-actor deinit reaches non-Sendable state;
- DirectoryWatcher's FSEvents box is Sendable (`weak let`) and only
  carries the callback from the FSEvents queue to the main queue;
- StatusItemController and MenuBarClusterController hold their monitors
  and Carbon references the same way.

The same teardown happens at the same moment; owners that used to cancel
a watcher in their deinit now rely on the watcher's own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ThumbnailService and RemoteImageService always deliver on the main queue;
their completion type now says so (@mainactor @sendable), and the Quick
Look generator callback, which arrives on another thread, is @sendable.
WidgetImageLoader, which receives them, is main-actor.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…in-actor

SharedShelfPublisher was main-thread only by comment. Its thumbnail
export stays off the main actor (nonisolated), as before. The vault
broker's prompt hooks are main-actor function types, matching the
prompts they default to.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he main actor

AppPrefs, WidgetPrefs, MenuBarVisibility and HotkeyRegistrationCoordinator
are observable stores read and written by the UI. DockView's drop helper
collects file URLs behind an OSAllocatedUnfairLock instead of an NSLock
around a captured var, and its pure constants and `==` are nonisolated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- DockMenuRouter, SearchField.Coordinator and CardFreshness are
  main-actor; DockPanelController's mouse monitors remove themselves
  (EventMonitor) and its slide-out completion is a main-actor callback.
- CardDrag hands the dragged id to a main-actor callback.
- Gallery pack text closures are @sendable; UndoAnchor is Sendable (it
  has no state); the action environment's default is made on request.
- PermissionWaitingBanner.message is nonisolated (a pure string).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every stored property already was; the conformance lets the app's
snapshot disk cache hand a snapshot to its write queue under strict
concurrency checking.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Covers the by-name observation that replaced the key-path one: it
reports light and dark as a view's appearance changes, and stops once
released.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main-actor AppPrefs makes `appPrefs: AppPrefs = .shared` a warning in
the normal build wherever it is a default argument, and one of those is
WidgetRuntime.init, which is being rewritten elsewhere. Its one strict
diagnostic (the shared instance) stays until that default can change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…in actor

DockStore, DockHotkeys, DockHotkeyStatus, RunningApps, DockActions, its
file presentation cache and FolderMenuTarget are all used from the main
thread; BarShelfDock now has no strict-concurrency diagnostics.

- DockHotkeys holds its Carbon registrations, its handler and its
  Automation observer in objects that undo them when released, so it
  needs no deinit. The status shown in settings is no longer reset when
  a DockHotkeys goes away (the app keeps one for as long as it runs).
- RunningApps reads the launched app's path before entering the
  main-actor block of its workspace observer.
- The file-drop helper's completion is a main-actor callback, so the
  dock's drop handlers no longer carry the store across threads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AppPrefs is an observable store the UI reads and writes. The places
that took `AppPrefs = .shared` as a default argument (WidgetRuntime.init,
UpdateChecker.check/skipVersion, AppSettingsWindowController.show) take
nil and resolve it inside: a default argument is evaluated outside the
main actor. WorkflowWatch is main-actor like DirectoryWatcher, which
conforms to it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… diagnostic

The cancellation handler invalidates the LAContext the prompt runs on,
and LAContext is not Sendable. Comment only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A new step builds the app target with -strict-concurrency=complete and
fails on any diagnostic located in Sources/MenubucketApp, except the one
documented in VaultResume (allowed by file and wording). It counts
instead of using -warnings-as-errors because that flag would also stop
on BarShelfAutomation, a dependency that is not clean yet. It runs after
the report-only step so that step still compiles, and counts, its own
targets.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jiunbae
jiunbae enabled auto-merge November 16, 2026 10:07
Swift 6.3 reports the captured LAContext and its import where 6.4 reports the
sent closure. Same single case; everything else stays enforced.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jiunbae
jiunbae added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 6f3a2c6 Nov 16, 2026
6 checks passed
@jiunbae
jiunbae deleted the chore/app-strict-concurrency branch November 16, 2026 10:54
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