Skip to content

fix: build the macOS menu from the action list - #897

Merged
EVWorth merged 2 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h
Oct 25, 2026
Merged

EVWorth merged 2 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h

Conversation

@EVWorth

@EVWorth EVWorth commented Oct 25, 2026

Copy link
Copy Markdown
Owner

The macOS native menu was a hand-built copy of the in-app menu, and the two had drifted apart:

The native menu is now built from the same ACTIONS and MENUS the in-app menu uses. Written by the implementer-rust subagent.

Design

  • New command set_native_menu(menus). Each menu has a label and entries; an entry is an item (id, label, accelerator, enabled), a separator, or a submenu.
    • The command is synchronous on purpose: Tauri runs sync commands on the main thread, so updates apply in the order they were sent.
  • menu.rs has a platform-independent plan() step, with 14 unit tests.
    • It validates ids and labels, rejects reserved __tauri ids, and limits nesting depth.
    • It maps undo, redo, cut, copy, paste and select-all to the system's own items, so text fields keep working.
    • It builds a proper macOS application menu (About, Check for Updates, Services, Hide, Quit).
    • It tidies stray separators and empty menus.
  • realize() turns the plan into Tauri menu objects. Only the app.set_menu calls are macOS-only.
  • Startup menu. default_menus() stands in until the window sends its own menu. Actions that need a connection start disabled.
  • Frontend: useNativeMenu(). It only runs on macOS.
    • It builds the description from MENUS/ACTIONS and isEnabled.
    • It adds a "Connect to" submenu after New Connection….
      • Open profiles are disabled.
      • Profiles that are still connecting are labelled "(connecting…)".
      • "No saved connections" appears when there are none.
    • It resends only when something visible changed.
    • Clicks still arrive through the existing menu-action event, which already handled connect:<profileId> after feat: UX review fixes for connections and app shell #891.
  • Fixed along the way.
    • The old menu put File first, which macOS treats as the app menu, so File's items appeared under the app name.
    • The dead Compare Schemas item is gone.

Closes #863. Closes #892.

Not verifiable here

None of the macOS-only code has run, because CI and this container are Linux. Only compiling and the platform-independent tests ran. Before release, check on a Mac:

  • The menu bar builds, and updates when a connection opens or closes.
  • The system Undo/Copy still work in Monaco.
  • No zoom key fires twice. The new menu adds Cmd+=, Cmd+-, Cmd+0 and Cmd+Shift+P accelerators that the webview also handles.
  • Rebuilding the menu while one is open behaves sensibly.

Test plan

  • cargo fmt --all --check and cargo clippy --workspace --all-targets --all-features -- -D warnings are clean.
  • cargo test -p sqlpilot --lib: 82 passed, including 14 plan() tests.
  • src/hooks/__tests__/useNativeMenu.test.ts:
    • The native menu matches MENUS in order, and its disabled states match ACTIONS.
    • It covers the Connect to cases and accelerators.
    • It checks that the menu is sent once and resent only on change.
    • A drift guard checks that every default_menus() id has a case in AppLayout, and that the list matches MENUS.
  • On the merged branch: vitest for hooks, layout, mock and lib (1,534 tests) passes, tsc and dprint are clean, and check-documented-commands.sh passes with §5.8 updated.

Generated by Claude Code

The native menu in menu.rs was a hand-kept copy of the in-app menu and
had drifted: Backup, Restore, New Table, Agents, the View menu and the
command palette were missing, Compare Schemas sent an id nothing
handled, nothing could be greyed out, and saved profiles could not be
listed at all.

The frontend now describes the menu from MENUS and ACTIONS, with each
action's enabled state and a Connection > Connect to submenu of saved
profiles, and sends it through a new set_native_menu command whenever
that changes. Rust validates the description on every platform and
rebuilds the menu bar on macOS, with an application menu first (macOS
takes the first menu as the app menu, which hid File) and the system's
own clipboard items. A static default, checked against AppLayout's
handlers by a test, covers the time before the window loads.

Closes #863.
Closes #892.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
@EVWorth
EVWorth merged commit 2119f66 into main Oct 25, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/hopeful-bardeen-1k4d1h branch October 25, 2026 02:54
@github-actions github-actions Bot mentioned this pull request Nov 8, 2026
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.

fix: macOS native menu is missing items and one is dead macOS native menu has no "Connect to" submenu

2 participants