[v2, darwin] Fix updating menus - #4057
Conversation
WalkthroughThis pull request refactors the macOS menu update process in the darwin package. The Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Window
participant NSMenu as NewNSMenu
participant C as C API
Caller->>Window: Call SetApplicationMenu(menu)
Window->>Window: Store menu in applicationMenu
Window->>Window: Call UpdateApplicationMenu()
Window->>NSMenu: Create new menu (NewNSMenu)
NSMenu-->>Window: Return new Menu instance
Window->>C: Set new menu via SetAsApplicationMenu
Assessment against linked issues
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
v2/internal/frontend/desktop/darwin/window.go (1)
301-308: Consider adding error handlingWhile the implementation is good, consider adding error handling for potential edge cases:
- Error handling for NewNSMenu failure
- Validation of menu processing results
Example error handling:
func (w *Window) UpdateApplicationMenu() { + var err error mainMenu := NewNSMenu(w.context, "") + if mainMenu == nil { + log.Printf("Failed to create main menu") + return + } if w.applicationMenu != nil { - processMenu(mainMenu, w.applicationMenu) + if err = processMenu(mainMenu, w.applicationMenu); err != nil { + log.Printf("Failed to process menu: %v", err) + return + } } C.SetAsApplicationMenu(w.context, mainMenu.nsmenu) C.UpdateApplicationMenu(w.context) }website/src/pages/changelog.mdx (1)
36-36: Fix macOS spelling in changelogThe operating system name should be "macOS" instead of "MacOS" to align with Apple's branding.
-Fixed updating menus on MacOS by [@stffabi](https://github.com/stffabi) +Fixed updating menus on macOS by [@stffabi](https://github.com/stffabi)🧰 Tools
🪛 LanguageTool
[grammar] ~36-~36: The operating system from Apple is written “macOS”.
Context: .../leaanthony) - Fixed updating menus on MacOS by [@stffabi](https://github.com/stffab...(MAC_OS)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v2/internal/frontend/desktop/darwin/window.go(2 hunks)website/src/pages/changelog.mdx(1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/src/pages/changelog.mdx
[grammar] ~36-~36: The operating system from Apple is written “macOS”.
Context: .../leaanthony) - Fixed updating menus on MacOS by [@stffabi](https://github.com/stffab...
(MAC_OS)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
v2/internal/frontend/desktop/darwin/window.go (2)
33-37: LGTM: Added applicationMenu field to Window structThe addition of the
applicationMenufield to store the menu state is a good design choice, allowing for better state management and menu updates.
296-299: LGTM: Improved menu update logicThe refactored
SetApplicationMenumethod now properly separates concerns by:
- Storing the menu state
- Delegating the actual menu update to
UpdateApplicationMenuThis makes the code more maintainable and easier to understand.
Deploying wails with
|
| Latest commit: |
733cd24
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c77daaed.wails.pages.dev |
| Branch Preview URL: | https://feature-darwin-fix-menu-upda.wails.pages.dev |
Fixes #4053
Summary by CodeRabbit
Bug Fixes
New Features
Documentation