Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

macOS 15 introduced system-level menu bar icon controls (Settings > Desktop & Dock > Menu Bar). When the system toggles Easydict's icon to visible, the app's internal hideMenuBarIcon setting remains stale, causing state desync.

Changes

  • Added onAppear handler to MenuBarExtra label that detects system-initiated visibility changes
  • When label appears while hideMenuBarIcon is true, sync internal state to false
  • Guarded with @available(macOS 15.0, *) for backward compatibility

Implementation

.onAppear {
    syncMenuBarVisibilityIfNeeded()
}

private func syncMenuBarVisibilityIfNeeded() {
    guard #available(macOS 15.0, *) else { return }
    
    if hideMenuBar {
        DispatchQueue.main.async {
            hideMenuBar = false
        }
    }
}

The fix leverages SwiftUI's lifecycle: when macOS system settings make the icon visible, onAppear fires on the label, triggering the sync. No polling required.

Original prompt

This section details on the original issue you should resolve

<issue_title>🐞 反馈问题:MACos 26系统自带的[允许菜单栏图标显示/隐藏],与Easydict2.16自带的[允许菜单栏图标显示/隐藏],两者无法联动</issue_title>
<issue_description>

当macos26设置为隐藏,则Easydict状态被改为隐藏,

当macos26设置从隐藏改为显示,则Easydict状态依然为隐藏

两者无法联动

Image

<agent_instructions>帮我检查这个问题,并修复。</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@tisfeng 很奇怪的新功能,我都没注意到。。。

感觉这里好像有新的 API 控制应用在菜单栏的图标显示,可能得去调研适配一下。</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Add sync mechanism to detect when macOS system settings make the menu bar icon visible and update the app's internal state accordingly. This fixes the issue where toggling the system menu bar settings doesn't sync with Easydict's internal hideMenuBarIcon setting.

Co-authored-by: tisfeng <25194972+tisfeng@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix menu bar icon interactivity between macOS and Easydict Sync app menu bar visibility state with macOS 15 system controls Nov 16, 2025
Copilot AI requested a review from tisfeng November 16, 2025 17:02
Copilot finished work on behalf of tisfeng November 16, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants