feat(macos): migrate menu to SwiftUI App + .commands#2842
Open
Saadnajmi wants to merge 1 commit into
Open
Conversation
Collaborator
Author
07a3f47 to
5dfb2e1
Compare
Replace the programmatic AppKit menu bar (added in microsoft#2836) with the SwiftUI App lifecycle. SwiftUI provides the standard App/File/Edit/View/Window/Help menus for free, so the ~320 lines of makeMainMenu/make*MenuItem in WindowController.swift are deleted. The dynamic "React" menu is now declarative: ReactCommands renders a CommandMenu("React") driven by an observable AppModel. Publishing components/componentsEnabled/rememberLastComponent rebuilds the menu, so the manual NSMenuItem add/remove bookkeeping is gone. An AppDelegate is kept via @NSApplicationDelegateAdaptor for RN setup and lifecycle notifications. - AppDelegate.swift: @main App struct + adaptor + AppModel - ReactCommands.swift: dynamic React menu (Cmd-Shift-1..9 component shortcuts) - ViewController.swift: SwiftUI content hosting + placeholder - WindowController.swift: deleted - project.pbxproj / pack.test.mts: swap WindowController.swift for ReactCommands.swift Both ENABLE_SINGLE_APP_MODE and multi-app behavior are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5dfb2e1 to
7a0d41e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Move the Template macOS window to SwiftUI, which has the benefit of default menu bars. Create a React Command Group, that observes a new "AppModel" to determine its' menu items
Verified
Screenshot in comment