Skip to content

fix(desktop): restore the native application menu and unify platform command routing #2088

Closed

Description

@Colafornia
English

Context

Child of #2084.

#399 intentionally removed the Electron application menu while consolidating shell chrome. Since then, #669 added Cmd/Ctrl+N in the renderer, alongside the existing Cmd/Ctrl+, Settings shortcut. The application actions work, but the native menu surface and standard platform commands remain absent.

Restore the native application menu and route menu items and keyboard shortcuts through the existing renderer actions without creating duplicate command implementations or double dispatch.

Current behavior

  • apps/desktop/src/main/main-window.ts calls Menu.setApplicationMenu(null).
  • apps/desktop/src/renderer/app-shell-effects.ts owns Cmd/Ctrl+N and Cmd/Ctrl+, through a global renderer keydown listener.
  • window.maka.appWindow.subscribeOpenSettings() and the window:openSettings preload channel already provide a main-to-renderer Settings route, but main does not currently dispatch it.
  • Standard App, Edit, Window, and Help menu behavior is unavailable. On macOS this also removes discoverable system entry points such as Dictation and Emoji & Symbols.

Scope

  • Build a platform-appropriate Electron application menu using native roles where available.
  • Restore standard App, Edit, View, Window, and Help behavior. Add a File menu when needed for application commands such as New Task and Close Window.
  • Expose New Task (Cmd/Ctrl+N) and Settings (Cmd/Ctrl+,) through the native menu.
  • Route both commands to the existing createSession() and openSettings() behavior in the renderer.
  • Keep exactly one active accelerator owner per platform so a keypress dispatches each command once.
  • Keep Reload and DevTools development-only.
  • Preserve standard text-editing behavior when an editable control is focused.
  • Use platform-specific menu structure and labels rather than forcing the macOS hierarchy onto Windows or Linux.

Acceptance criteria

  • A supported packaged macOS build exposes a native application menu with standard App, Edit, View, Window, and Help behavior.
  • New Task and Settings are discoverable from the menu and retain Cmd/Ctrl+N and Cmd/Ctrl+,.
  • Menu clicks and keyboard accelerators invoke the existing renderer actions exactly once.
  • Standard Close, Minimize, Hide, and Quit behavior works in the platform states where each command applies.
  • Undo, Redo, Cut, Copy, Paste, Select All, Dictation, and Emoji & Symbols remain available to focused editable controls where macOS provides them.
  • Reload and DevTools are absent from production menus and remain available in development.
  • No-window, pre-reveal, focused-editor, minimized, hidden, and closed-window states do not throw or leave duplicate listeners.
  • Windows and Linux retain their existing shell chrome and working Ctrl+N / Ctrl+, behavior unless a deliberate platform-native menu change is documented and verified.

Verification

  • Add focused tests for menu-template composition and semantic command dispatch; avoid source-regex-only assertions.
  • Run the desktop main and renderer builds plus the targeted command-routing tests.
  • Verify the supported packaged macOS build with real menu clicks and accelerators, including a focused text editor and the window states listed above.
  • Smoke-test Windows/Linux command behavior when the routing ownership changes.

Out of scope

References

简体中文

背景

#2084 的子任务。

#399 在收敛 shell chrome 时有意删除了 Electron application menu。之后,#669 在 renderer 中加入了 Cmd/Ctrl+N,同一位置此前已经处理 Cmd/Ctrl+, Settings 快捷键。应用动作本身可用,但原生菜单入口和标准平台命令仍然缺失。

本 issue 恢复原生 application menu,并让菜单项和键盘快捷键复用现有 renderer 动作,不创建重复命令实现,也不产生双重触发。

当前行为

  • apps/desktop/src/main/main-window.ts 调用 Menu.setApplicationMenu(null)。
  • apps/desktop/src/renderer/app-shell-effects.ts 通过全局 renderer keydown listener 处理 Cmd/Ctrl+N 和 Cmd/Ctrl+,。
  • window.maka.appWindow.subscribeOpenSettings() 和 window:openSettings preload channel 已经提供 main 到 renderer 的 Settings 路由,但 main 当前没有发送该事件。
  • 标准 App、Edit、Window 和 Help 菜单行为不可用;在 macOS 上,这也移除了 Dictation、Emoji & Symbols 等系统入口的可发现性。

范围

  • 使用 Electron native role 构建符合各平台习惯的 application menu。
  • 恢复标准 App、Edit、View、Window 和 Help 行为;需要承载 New Task、Close Window 等应用命令时加入 File 菜单。
  • 在原生菜单中提供 New Task(Cmd/Ctrl+N)和 Settings(Cmd/Ctrl+,)。
  • 两个命令都路由到 renderer 中现有的 createSession() 和 openSettings() 行为。
  • 每个平台只保留一个生效的 accelerator owner,确保一次按键只触发一次命令。
  • Reload 和 DevTools 仅在开发环境出现。
  • 编辑控件聚焦时保留标准文本编辑行为。
  • 使用平台特定的菜单结构和文案,不把 macOS 菜单层级强加到 Windows 或 Linux。

验收条件

  • 受支持的 packaged macOS 构建提供原生 application menu,包含标准 App、Edit、View、Window 和 Help 行为。
  • New Task 和 Settings 可从菜单发现,并保留 Cmd/Ctrl+N 和 Cmd/Ctrl+,。
  • 点击菜单和使用键盘 accelerator 都只调用一次现有 renderer 动作。
  • Close、Minimize、Hide 和 Quit 在各自适用的平台状态下正常工作。
  • 编辑控件聚焦时,Undo、Redo、Cut、Copy、Paste、Select All,以及 macOS 提供的 Dictation 和 Emoji & Symbols 均可用。
  • Production 菜单不包含 Reload 和 DevTools;开发环境中仍可使用。
  • 无窗口、首帧 reveal 前、编辑控件聚焦、最小化、隐藏和窗口关闭状态不会抛错或遗留重复 listener。
  • Windows 和 Linux 保留现有 shell chrome 及可用的 Ctrl+N / Ctrl+,;如有明确的平台原生菜单变化,必须记录并验证。

验证

  • 为 menu template 组合和语义命令派发增加聚焦测试,避免只检查源码文本的断言。
  • 运行 desktop main、renderer build 和相关 command-routing 测试。
  • 在受支持的 packaged macOS 构建中,用真实菜单点击和 accelerator 验证,并覆盖编辑控件聚焦及上述窗口状态。
  • 命令路由 ownership 变化时,对 Windows/Linux 行为做 smoke test。

不在范围内

关联

Activity

  1. Astro-Han commented on Aug 4, 2026

    @Astro-Han
    Contributor

    User-reported evidence (macOS, packaged 0.1.4, Electron 43.1.1):

    Cmd+Q is completely dead, not merely undiscoverable: with setApplicationMenu(null) there is no Quit menu item, so the accelerator has no handler (same mechanism as electron/electron#49807 — keyboard shortcuts are tied to menu items; removing the menu leaves nothing to handle them). Cmd+C/Cmd+V/Cmd+A are equally dead in editable controls.

    Observed consequences on a real machine today:

    1. The only exit paths are the red button (window closes, but window-all-closed is a no-op on darwin, so the process stays alive in the Dock with no windows and no way to quit) or force-quit from the Dock.
    2. Force-quit strands in-flight runs: 4 runs parked on AskUserQuestion were left waiting_for_user with no terminal fact, exactly the class of stuck run documented in bug(runtime): a stopped run parked on AskUserQuestion never lands a terminal fact, and prior-run context then silently drops the whole turn #2074. A subsequent launch's recovery marked them app_restarted.

    Note that an AppleScript quit event (Cocoa terminate) still works because it bypasses the menu accelerator — the before-quit coordinator itself is fine; only the accelerator path is broken. This makes the Quit acceptance criterion in this issue a functional requirement, not polish.

    Is anyone already working on this? If not, I'd like to pick it up.

  2. Colafornia commented on Aug 4, 2026

    @Colafornia
    MemberAuthor

    @Astro-Han Confirmed — no one else is working on this. Please go ahead.

    Thanks for validating the impact on a packaged macOS build.

  3. self-assigned this
    on Aug 4, 2026
  4. added a commit that references this issue on Aug 4, 2026
    121bbe7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions