Refactor: extract Sparkle self-update into CmuxUpdater package (WIP)
Wave 3 of the modular refactor: extract the Sparkle self-update domain out of the flat app target into a new CmuxUpdater package (a later CmuxUpdaterUI package will follow for the views).
Draft / not ready. This is a checkpoint so the shape is visible. So far it lands only the parts with no remaining app-target coupling; the package builds and tests green standalone but is not yet wired into the app, so it changes no runtime behavior.
This is a redesign, not a lift: the existing state model is ObservableObject/@Published and the controller drives it through Combine, both forbidden in packages. The extraction rebuilds state propagation on @Observable + the sanctioned concurrency primitives while preserving behavior exactly (critical user path).
Landed in this commit (swift build + swift test green):
Package.swift— Sparkle from 2.5.1 (resolves 2.9.2), Swift 6 mode.UpdateTiming— display/timeout constants.UpdateFeedResolver— redesigned from a namespace-enum into an injectable struct returning a namedResolution(+ 4 Swift Testing behavioral tests).UpdateLogging— protocol seam so the package logs through the app's existingUpdateLogStore(which stays in the app target) instead of a.sharedsingleton.UpdateState— the phase enum lifted into its own public file.UpdateStateModel—ObservableObject→@MainActor @Observable. All state writes funnel throughsetState/setOverrideState, which emit on astateChanges()AsyncStream<Void>(the@Observable-native replacement for$state.sink/CombineLatest). SwiftUIColorcomputeds are deferred toCmuxUpdaterUI.
Still to do before this leaves draft:
UpdateController— replace the three Combine observers (force-install, attempt-update, no-update auto-dismiss) with one long-lived@MainActor TaskoverstateChanges(); relocate theasyncAftertiming sites behind one-shotDispatchSourcetimers.UpdateDriver(SPUUserDriver) +UpdateSettings+ test support; invert theAppDelegate/TerminalControllerreach-ins behind seams.CmuxUpdaterUIpackage (UpdatePill,UpdatePopoverView,UpdateBadge+ the Color computeds + anUpdateActionsHostseam).- Wire both packages into
cmux.xcodeproj(cmux+cmux-unit);AppDelegatebecomes the composition root + one-line forwards; splitFocusLogStoreinto the app target. - Build
cmux+cmux-unitgreen; dogfood the update pill/popover.
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.
Summary by cubic
Extracted Sparkle self-update into CmuxUpdater and CmuxUpdaterUI, fully wired into the app with an @MainActor controller/driver. Added UI tests and localized error copy; builds/tests are green locally and in CI with Sparkle 2.8.1.
-
Refactors
- Integrated
CmuxUpdater+CmuxUpdaterUIintocmux.xcodeproj; removed legacySources/Update/*and the Combine-based controller. AppDelegate: ownsUpdateLogStore; constructsUpdateController(log:); conforms toUpdateActionDelegateandUpdateActionsHost.- UI:
ContentViewusesUpdateStateModel;UpdatePill/UpdatePopoverViewcall intoUpdateActionsHostand useUpdateAppearance(accent:); titlebar accessory now takesUpdateLogStore. - Seams/timing:
UpdateLogging,UpdateClock/SystemUpdateClock,UpdateActionDelegate,UpdateSettings; bounded, cancellable delays for min-display, no-update auto-dismiss, and readiness. - UI tests: coverage for error and downloading/extracting/installing states via
CMUX_UI_TEST_*. - Injected
FileManagerand hostBundleintoUpdateControllerfor testability;ensureSparkleInstallationCachekeys by bundle id.
- Integrated
-
Bug Fixes
- Matched CI under
Sparkle2.8.1 by adding@preconcurrencyimports and pinning versions in both packages. - Reliable re-checks: restored a bounded 100 ms post-dismiss delay and now cancel the deferred re-check on all paths to prevent duplicate checks.
- Safer errors: sanitized the fallback error message and added localized
update.error.failed.messageandupdate.error.notReady(en/ja); full details stay in the log and “Copy Details.” - Emitted a single state-change signal when resetting for a new check; fixed
cmux-unitby using an instanceUpdateFeedResolverand updated readiness docs. - Stabilized UI tests by using consistent
waitForExistenceassertions.
- Matched CI under
Summary by CodeRabbit
-
New Features
- Public in-app update UI (pill, badge, popover) plus packaged updater modules and a host-driven update actions API.
-
Improvements
- More testable, cancellable clock-driven timing for update checks and auto-dismiss behavior.
- Richer error details now expose an explicit log path for diagnostics.
- Deterministic feed resolution (stable/nightly/fallback) and clearer retry/dismiss/update flows.
-
Documentation
- Developer timing/synchronization guidance clarified and tightened.