Skip to content

feat(macos): add 'Check for Updates...' menu item#4666

Open
interrobangdev wants to merge 1 commit intoBasedHardware:mainfrom
interrobangdev:feature/check-for-updates-menu
Open

feat(macos): add 'Check for Updates...' menu item#4666
interrobangdev wants to merge 1 commit intoBasedHardware:mainfrom
interrobangdev:feature/check-for-updates-menu

Conversation

@interrobangdev
Copy link

Summary

Adds a manual "Check for Updates..." menu item to the macOS app, allowing users to trigger update checks on demand.

Fixes #4550

Changes

Swift (AppDelegate.swift)

  • Added updateChannel for Flutter communication
  • Added checkForUpdates: IBAction triggered by menu
  • Added setupUpdateChannel() to lazily initialize the method channel

XIB (MainMenu.xib)

  • Added "Check for Updates..." menu item after "About" separator
  • Wired to checkForUpdates: selector on AppDelegate

Dart (desktop_update_service.dart)

  • Added MethodChannel('com.omi/updates')
  • Added _handleMethodCall to receive native calls and trigger checkForUpdates()

Testing

  • Menu item appears under Omi menu after "About Omi"
  • Clicking triggers Sparkle update check dialog
  • Works when app is up to date (shows "up to date" message)
  • Works when update is available (shows update dialog)

Screenshots

(Menu item location: Omi > Check for Updates...)

Fixes BasedHardware#4550

- Add 'Check for Updates...' menu item to app menu (MainMenu.xib)
- Add IBAction in AppDelegate.swift to handle menu selection
- Set up FlutterMethodChannel to communicate with Dart
- Add method channel handler in DesktopUpdateService to trigger checkForUpdates()

Users can now manually check for updates via Omi > Check for Updates...
instead of waiting for the 3-hour background check interval.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully adds a 'Check for Updates...' menu item to the macOS application, integrating it with the Flutter update service. The changes involve setting up a Flutter MethodChannel in both Swift and Dart to facilitate communication between the native macOS menu and the Flutter update logic. The XIB file is correctly updated to include the new menu item and wire it to the AppDelegate's action. The overall implementation is clear and follows standard patterns for Flutter-native integration.

Comment on lines +121 to +131
private func setupUpdateChannel() {
guard updateChannel == nil else { return }

if let mainWindow = NSApp.windows.first(where: { $0 is MainFlutterWindow }) as? MainFlutterWindow,
let flutterViewController = mainWindow.contentViewController as? FlutterViewController {
updateChannel = FlutterMethodChannel(
name: "com.omi/updates",
binaryMessenger: flutterViewController.engine.binaryMessenger
)
NSLog("DEBUG: Created updates method channel")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The setupUpdateChannel method relies on finding the MainFlutterWindow and its FlutterViewController at the time it's called. While this might work in most cases, there's a potential for the updateChannel to remain nil if the main window or its content view controller isn't fully initialized or available when the menu item is first clicked. This could lead to the 'Check for Updates' functionality not working as expected. Consider initializing the updateChannel earlier in the app lifecycle, perhaps in applicationDidFinishLaunching, to ensure it's always ready when needed, or add more robust error handling/retries if the window is not found.

    private func setupUpdateChannel() {
        guard updateChannel == nil else { return }
        
        // Attempt to get the FlutterViewController from the main window
        // A more robust approach might involve storing a direct reference to the FlutterViewController
        // during its initial setup, or ensuring this method is called only after the Flutter engine is fully ready.
        if let mainWindow = NSApp.windows.first(where: { $0 is MainFlutterWindow }) as? MainFlutterWindow,
           let flutterViewController = mainWindow.contentViewController as? FlutterViewController {
            updateChannel = FlutterMethodChannel(
                name: "com.omi/updates",
                binaryMessenger: flutterViewController.engine.binaryMessenger
            )
            NSLog("DEBUG: Created updates method channel")
        } else {
            NSLog("ERROR: Could not find MainFlutterWindow or FlutterViewController to set up update channel.")
        }
    }

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.

macOS app lacks manual 'Check for Updates' option - users can't trigger updates

1 participant