Skip to content

feat(macos): migrate menu to SwiftUI App + .commands#2842

Open
Saadnajmi wants to merge 1 commit into
microsoft:trunkfrom
Saadnajmi:saadnajmi/swiftui-macos-menu
Open

feat(macos): migrate menu to SwiftUI App + .commands#2842
Saadnajmi wants to merge 1 commit into
microsoft:trunkfrom
Saadnajmi:saadnajmi/swiftui-macos-menu

Conversation

@Saadnajmi

@Saadnajmi Saadnajmi commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

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

@Saadnajmi

Copy link
Copy Markdown
Collaborator Author
image

@Saadnajmi Saadnajmi force-pushed the saadnajmi/swiftui-macos-menu branch from 07a3f47 to 5dfb2e1 Compare July 7, 2026 23:16
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>
@Saadnajmi Saadnajmi force-pushed the saadnajmi/swiftui-macos-menu branch from 5dfb2e1 to 7a0d41e Compare July 7, 2026 23:30
@Saadnajmi Saadnajmi marked this pull request as ready for review July 7, 2026 23:31
@Saadnajmi Saadnajmi requested review from JasonVMo and tido64 as code owners July 7, 2026 23:31
@Saadnajmi Saadnajmi marked this pull request as draft July 7, 2026 23:31
@Saadnajmi Saadnajmi marked this pull request as ready for review July 8, 2026 06:46
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.

1 participant