-
-
Notifications
You must be signed in to change notification settings - Fork 50
Revert "Fix launch compatibility on macOS 14 and 15" #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,64 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| /// File overview: | ||
| /// Declares Cotabby's AppKit entry point. `AppDelegate` owns the long-lived dependency graph and | ||
| /// `MenuBarController` owns the status item/popover, so launch never has to instantiate SwiftUI's | ||
| /// `App`/`Scene` graph. That boundary matters for macOS 14 and early macOS 15 releases, where an | ||
| /// Xcode 26-built `MenuBarExtra(.window)` can abort inside AttributeGraph before AppKit delivers a | ||
| /// lifecycle callback (issue #767). | ||
| /// Declares the SwiftUI app entry point and hosts the optional menu-bar scene that renders | ||
| /// Cotabby's compact status UI. Shared services are injected through `AppDelegate`. | ||
| /// | ||
| /// The enum has no instances. Its one static delegate reference keeps the weak `NSApplication` | ||
| /// delegate alive until the run loop exits. | ||
| /// `@main` marks the single process entry point for a Swift app. | ||
| @main | ||
| enum CotabbyApp { | ||
| private static var appDelegate: AppDelegate? | ||
| struct CotabbyApp: App { | ||
| /// Bridges old-style AppKit lifecycle callbacks into a SwiftUI app. | ||
| @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate | ||
| /// Scene declarations cannot directly observe the delegate's nested settings object. This | ||
| /// projection watches the same durable key so SwiftUI re-evaluates status-item insertion as | ||
| /// soon as Settings changes it; the settings model remains the app-facing preference API. | ||
| @AppStorage(SuggestionSettingsStore.menuBarIconVisibleDefaultsKey) | ||
| private var isMenuBarIconVisible = true | ||
|
|
||
| @MainActor | ||
| static func main() { | ||
| let application = NSApplication.shared | ||
| let delegate = AppDelegate() | ||
| appDelegate = delegate | ||
| application.delegate = delegate | ||
| application.run() | ||
| /// Defines the menu bar extra that surfaces Cotabby's runtime, focus, and suggestion state. | ||
| var body: some Scene { | ||
| MenuBarExtra(isInserted: menuBarIconVisibilityBinding) { | ||
| MenuBarView( | ||
| permissionManager: appDelegate.permissionManager, | ||
| runtimeModel: appDelegate.runtimeModel, | ||
| modelDownloadManager: appDelegate.modelDownloadManager, | ||
| focusModel: appDelegate.focusModel, | ||
| permissionGuidanceController: appDelegate.permissionGuidanceController, | ||
| suggestionSettings: appDelegate.suggestionSettings, | ||
| foundationModelAvailabilityService: appDelegate.foundationModelAvailabilityService, | ||
| powerSourceMonitor: appDelegate.powerSourceMonitor, | ||
| appUpdateManager: appDelegate.appUpdateManager, | ||
| onOpenSettings: { | ||
| appDelegate.settingsCoordinator.showSettings() | ||
| }, | ||
| onReportFeedback: { | ||
| guard let baseURL = URL(string: "https://www.cotabby.app/feedback") else { | ||
| return | ||
| } | ||
| // Attach host details so the landing form can pre-fill the Environment block | ||
| // (Cotabby + macOS + hardware) and the user only has to write the actual report. | ||
| let url = DeviceInfo.snapshot().appending(to: baseURL) | ||
| NSWorkspace.shared.open(url) | ||
| } | ||
| ) | ||
| } label: { | ||
| MenuBarStatusLabelView( | ||
| suggestionCoordinator: appDelegate.suggestionCoordinator, | ||
| suggestionSettings: appDelegate.suggestionSettings | ||
| ) | ||
| } | ||
| .menuBarExtraStyle(.window) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The app still targets macOS 14.0, but this restores the |
||
|
|
||
| /// SwiftUI owns insertion/removal of the status item, while the settings model remains the | ||
| /// single durable source of truth. The setter writes only through the model; `@AppStorage` | ||
| /// observes the same `UserDefaults` key, so the getter and the scene re-evaluate off that one | ||
| /// write instead of persisting the value twice (which could drift if model-side validation is | ||
| /// ever added). | ||
| private var menuBarIconVisibilityBinding: Binding<Bool> { | ||
| Binding( | ||
| get: { isMenuBarIconVisible }, | ||
| set: { appDelegate.suggestionSettings.setMenuBarIconVisible($0) } | ||
| ) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
-cotabby-compatibility-smoke-testargument is no longer checked before normal startup. A compatibility runner that launches the built app with that flag now enters full app startup and stays open instead of constructing the menu graph and exiting cleanly, so the launch check times out rather than reporting success or failure.