@@ -50,6 +50,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5050 }
5151 }
5252
53+ private var shouldRefreshTitleSubscription = false
54+
5355 private var watchCommunicatorService : WatchCommunicatorService ?
5456
5557 func application(
@@ -133,9 +135,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
133135
134136 #if targetEnvironment(macCatalyst)
135137 titleSubscription = manager. subscribeStatusItemTitle (
136- existing: titleSubscription,
138+ existing: shouldRefreshTitleSubscription ? nil : titleSubscription,
137139 update: Current . macBridge. configureStatusItem ( title: )
138140 )
141+ shouldRefreshTitleSubscription = false
139142 #endif
140143 }
141144 }
@@ -400,12 +403,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
400403 name: SettingsStore . menuRelatedSettingDidChange,
401404 object: nil
402405 )
406+ NotificationCenter . default. addObserver (
407+ self ,
408+ selector: #selector( apiDidConnect ( _: ) ) ,
409+ name: HomeAssistantAPI . didConnectNotification,
410+ object: nil
411+ )
403412 }
404413
405414 @objc private func menuRelatedSettingDidChange( _ note: Notification ) {
406415 UIMenuSystem . main. setNeedsRebuild ( )
407416 }
408417
418+ @objc private func apiDidConnect( _ note: Notification ) {
419+ // When API reconnects, rebuild the menu to refresh the status item title subscription
420+ // Force refresh by setting the flag that will cause the subscription to be recreated
421+ #if targetEnvironment(macCatalyst)
422+ shouldRefreshTitleSubscription = true
423+ #endif
424+ UIMenuSystem . main. setNeedsRebuild ( )
425+ }
426+
409427 private func setupUIApplicationShortcutItems( ) {
410428 if Current . isCatalyst {
411429 UIApplication . shared. shortcutItems = [ . init(
0 commit comments