diff --git a/crates/engine/src/cmd/buffer.rs b/crates/engine/src/cmd/buffer.rs index ac67b30..21a618e 100644 --- a/crates/engine/src/cmd/buffer.rs +++ b/crates/engine/src/cmd/buffer.rs @@ -196,7 +196,7 @@ impl Command for Close { &CommandSpec { id: "buffer.close", label: "Close Buffer", - menu_path: None, + menu_path: Some("File/Close Tab"), default_shortcut: Some("Mod+W"), params: "{ id: number, force?: bool (discard unsaved changes) }; returns null; fails with unsaved_changes if the buffer is dirty and force is not set", } diff --git a/docs/architecture.md b/docs/architecture.md index 7f8a065..5169849 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,6 +1,6 @@ # Architecture -> **Status:** M0 decisions recorded, M1 workspace, desktop bridge, tabs and editor, message catalog, engine construction, settings, themes, the recovery journal, notifications, UI commands, the palette, the settings dialog, the app icon and the syntax layer documented; M2 highlighting and `editor.reveal`, plus the search backend, the Find tool window, the symbol index, the Structure tool window and the go-to popup; M3 CLI and single instance, LSP client library · **Last updated:** 2026-10-18 +> **Status:** M0 decisions recorded, M1 workspace, desktop bridge, tabs and editor, message catalog, engine construction, settings, themes, the recovery journal, notifications, UI commands, the palette, the settings dialog, the app icon and the syntax layer documented; M2 highlighting and `editor.reveal`, plus the search backend, the Find tool window, the symbol index, the Structure tool window and the go-to popup; M3 CLI and single instance, LSP client library, the app menu · **Last updated:** 2026-10-19 ## Overview @@ -192,7 +192,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - **Listing:** `listCommands` returns one list in id order: engine commands and UI commands. `CommandInfo` has `ui: bool`; UI commands also carry `labelKey`, use it as `label` (the engine has no English for them) and are always `enabled` as far as the engine knows. - **Running from outside:** `Engine::execute` on a UI command id queues `uiCommand {id, params}` and returns `null` (params are passed on unchanged). The desktop publishes the event to the window and to control subscribers like any other. The frontend runs the command, so `engine.execute palette.open` over the control channel opens the palette. A `uiCommand` the frontend cannot run (no handler, or disabled) becomes a warning toast. - **Frontend:** `ui/src/commands/`: - - `uiCommands.ts` lists the UI commands: `editor.reveal` (no shortcut, M2.2), `find.open` `Mod+Alt+F` (M2.4), `palette.open` `Mod+Shift+P`, `settings.open` `Mod+,`, `view.toggleProjectTree` `Mod+1`. + - `uiCommands.ts` lists the UI commands: `editor.reveal` (no shortcut, M2.2), `find.open` `Mod+Alt+F` (M2.4), `menu.open` `Alt+M` (M3.9), `palette.open` `Mod+Shift+P`, `settings.open` `Mod+,`, `view.toggleProjectTree` `Mod+1`. Since M3.9 the user-facing ones carry a `menuPath`. - `keymap.ts` parses Lutra notation and matches by key code (letters, digits and US punctuation by `code`, so Alt and Shift layout effects don't matter). It also formats shortcuts for display with catalog modifier names. - `rank.ts` ranks for the palette. - `store.ts` (Pinia `commands`) holds the merged list, the keymap, the handlers and the recent commands. @@ -213,6 +213,16 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - **Rows:** disabled rows are dimmed with `aria-disabled`. - **Accessibility:** combobox with listbox and `aria-activedescendant`. +### App menu (M3.9) + +- **Where:** `MainLayout.vue` has a slim header bar (28 px, `--lt-bg`, a `header` slot) whose default content is `ui/src/components/menu/AppMenu.vue`: a button with the Lucide `menu` icon top left. +- **Contents (`menu.ts`):** every command in the store's entries with a `menuPath` (engine and UI), grouped by the path's first segment. Groups in Lutra's order File, Edit, View, Go, Help (unknown groups before Help, empty ones hidden), group headings from the catalog (`menu.group.*`). Items follow a fixed id order, others sorted by label after them. A UI command shows its catalog label; an engine command shows the rest of its path (the engine has no catalog, and the path is written for menus), so `buffer.close` reads Close Tab. Deeper paths are flattened as `A › B`. +- **Paths:** File (`project.openDialog`, `file.save`, `file.saveAll`, `buffer.close` → `File/Close Tab`, `project.close`, `app.quit`), View (`palette.open`, `view.toggleProjectTree`, `view.toggleStructure`, `find.open`, `settings.open`), Go (`goto.fileOpen`, `goto.classOpen`, `goto.symbolOpen`), Help (`app.about`). Edit stays empty until there are edit commands; the terminal toggle gets `View/Terminal` when M3.6 lands (its id is already in the order list). +- **Opening:** the button (a second click closes) or `menu.open` (`Alt+M`, Lutra's own; also as `uiCommand`). It refreshes the enabled states and focuses the first item. +- **Keyboard:** WAI-ARIA menu with roving focus: arrows wrap, Home/End, Enter/Space runs, Escape or Tab closes, printable keys type ahead (500 ms buffer; one letter cycles through items with that initial). Disabled items are focusable, dimmed (`aria-disabled`) and do nothing. +- **Modal rule:** `menu` is an exclusive `ModalId`; the menu is a launcher like the palette: `commands/store.ts` › `execute` closes it for every command but `menu.open`, so a shortcut, a palette command or an agent's `uiCommand` never leaves it open. A chosen command runs after the menu closed and returned the focus. +- **Why a dropdown with headings instead of a menu bar:** one keyboard path (open, type, Enter) like the palette, no nested popups to manage, and it fits the slim header. A native macOS menu bar and a display-mode setting are follow-ups. + ### Settings dialog (M1.9b) - **Store:** `ui/src/stores/settings.ts` (Pinia `settings`, started by `App.vue`) loads `settings.list` and `settings.get`, reads both defensively (unknown types and malformed entries dropped, values must be scalars), changes values through `settings.set`/`settings.reset` and keeps a refused change's message per key. `settingsChanged` reloads the named keys with `settings.get {keys}` and drops their errors, so changes from the control channel or an agent show at once. @@ -320,6 +330,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat | Date | Change | Summary | |---|---|---| +| 2026-10-19 | minor | M3.9: app menu (header bar, `menu.open`, grouping by `menuPath`, launcher under the modal rule); menu paths for user commands | | 2026-10-18 | minor | M3.2: LSP client library (`crates/lsp`: framing, supervision and restart, initialize, requests with timeout and cancel, server requests, document sync, fake server tests) | | 2026-10-17 | minor | M3.7: `lutra` CLI, single instance, rendezvous file and token listener, `app.auth`/`app.focus`, CLI to L6 | | 2026-10-17 | minor | M2.6: go-to popup (store, debounce and stale drop, modes, `editor.reveal`), `library` on `goto.file` items | diff --git a/docs/gaps.md b/docs/gaps.md index 2daff6d..8ddac8a 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Gaps -> **Status:** M0 closed G1; G2 under way (text buffer, engine buffers, tabs and editor in the app, recovery journal); G3 M1 part done (project tree, palette, settings dialog, themes); G4 under way (tree-sitter outline and folding library, Lezer highlighting, Structure tool window); G5 under way (search backend, Find tool window, symbol index, go-to popup); G6 under way (LSP client library); G7 under way (`lutra` CLI and single instance); G14 English UI catalog in place · **Last updated:** 2026-10-18 +> **Status:** M0 closed G1; G2 under way (text buffer, engine buffers, tabs and editor in the app, recovery journal); G3 M1 part done (project tree, palette, settings dialog, themes) plus the app menu (M3.9); G4 under way (tree-sitter outline and folding library, Lezer highlighting, Structure tool window); G5 under way (search backend, Find tool window, symbol index, go-to popup); G6 under way (LSP client library); G7 under way (`lutra` CLI and single instance); G14 English UI catalog in place · **Last updated:** 2026-10-19 Every known shortfall, ranked. This is the work list: unless the owner gives a task, take the highest open gap. Hours are agent wall-clock hours for one agent, all estimated. @@ -8,7 +8,7 @@ Every known shortfall, ranked. This is the work list: unless the owner gives a t |---|---|---|---| | G1 | ~~Foundation: workspace, quality gate, command registry, guard, control channel~~ closed 2026-10-14 | M0 | done (~2 h measured) | | G2 | Editor core: ~~engine buffers, save~~ (M1.3), ~~editor UI with tabs, undo, multi-caret~~ (M1.6, CodeMirror basics), ~~recovery journal~~ (M1.7), tab management (preview, pin, split, close others, reopen), conflict UI for files changed on disk, autosave option | M1 | ~16 h | -| G3 | Project model: ~~VFS~~ (M1.2: listing, ignore rules, native file watching with polling fallback, safe file IO), ~~project tree wiring~~ (M1.5 UI, M1.3 engine, M1.4 bridge: folder picker, live tree), tree toolbar and options, ~~showing truncated listings~~ (M1.13), ~~error notifications for the folder picker~~ (M1.12), ~~tabs~~ (M1.6), ~~command palette~~ (M1.8: commands only, global keymap, UI commands over the control channel); ~~settings~~ (backend: M1.9a; dialog with search: M1.9b), ~~theme switching~~ (M1.10: light/dark, live, system mode; picker in the dialog, M1.9b) | M1 | ~24 h | +| G3 | Project model: ~~VFS~~ (M1.2: listing, ignore rules, native file watching with polling fallback, safe file IO), ~~project tree wiring~~ (M1.5 UI, M1.3 engine, M1.4 bridge: folder picker, live tree), tree toolbar and options, ~~showing truncated listings~~ (M1.13), ~~error notifications for the folder picker~~ (M1.12), ~~tabs~~ (M1.6), ~~command palette~~ (M1.8: commands only, global keymap, UI commands over the control channel); ~~settings~~ (backend: M1.9a; dialog with search: M1.9b), ~~theme switching~~ (M1.10: light/dark, live, system mode; picker in the dialog, M1.9b), ~~main menu~~ (M3.9: hamburger dropdown from `menuPath`s; native macOS menu bar and display modes open) | M1 | ~24 h | | G4 | Syntax and structure: tree-sitter PHP, ~~Lezer highlighting~~ (M2.2: PHP with embedded HTML plus HTML, CSS, JS/TS, JSON, YAML, Markdown; `--lt-syntax-*` tokens; `editor.reveal`), ~~file structure~~ (M2.7: Structure tool window, `syntax.outline`), semantic highlighting, folding in the editor | M2 | ~8 h | | G5 | Search and navigation: find in files, go to file/class/symbol, first index | M2 | ~35 h | | G6 | Language server: completion, diagnostics, definition, hover, rename via Phpactor | M3 | ~45 h | @@ -50,6 +50,7 @@ G6 progress: M3.2 landed the LSP client library in `crates/lsp`: JSON-RPC framin | Date | Change | Summary | |---|---|---| +| 2026-10-19 | minor | G3: app menu (M3.9) | | 2026-10-18 | minor | G6: LSP client library (M3.2) | | 2026-10-18 | minor | G17–G21 from the full PhpStorm inventory (deployment, editor productivity, remote, AI, breadth) | | 2026-10-17 | minor | G7: `lutra` CLI and single instance (M3.7); out-of-project files and `lutra diff` listed | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index a921e25..de9d1ae 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,10 +1,12 @@ # UI parity checklist -> **Status:** main window layout (M1.5), project tree running against the engine (M1.4), editor tabs with a CodeMirror editor (M1.6), light and dark themes (M1.10), restore dialog for unsaved changes (M1.7), notification toasts (M1.12), command palette and global keymap (M1.8), settings dialog with search (M1.9b), syntax highlighting and `editor.reveal` (M2.2), Find tool window in the bottom panel (M2.4), go-to popup (M2.6), left stripe and Structure tool window (M2.7) · **Last updated:** 2026-10-17 +> **Status:** main window layout (M1.5), project tree running against the engine (M1.4), editor tabs with a CodeMirror editor (M1.6), light and dark themes (M1.10), restore dialog for unsaved changes (M1.7), notification toasts (M1.12), command palette and global keymap (M1.8), settings dialog with search (M1.9b), syntax highlighting and `editor.reveal` (M2.2), Find tool window in the bottom panel (M2.4), go-to popup (M2.6), left stripe and Structure tool window (M2.7), app menu (M3.9) · **Last updated:** 2026-10-19 - [ ] Main window: tool window stripes, editor area, status bar, navigation bar - M2.7 (2026-10-17): a left stripe with one tab per left tool window (Project, Structure); the shown one is marked, clicking it again hides the window. Still missing: right docking, several bottom tool windows, drag to rearrange, navigation bar, layout persistence. - M1.5 (2026-10-14): left tool window with header, hide button, collapsed stripe with a show button, resizable by pointer and keyboard; editor area placeholder; status bar. Missing: stripes with several tool windows, bottom/right docking, navigation bar, layout persistence. Not checked in the running app yet (needs M1.4). +- [ ] Main menu + - M3.9 (2026-10-19): a slim header bar with a menu button (Lucide `menu`) top left; its dropdown lists every command with a `menuPath` (engine and UI), grouped File, Edit, View, Go, Help in Lutra's own order, with shortcuts; disabled entries dimmed and not runnable. Keyboard: `Alt+M` (`menu.open`, also over `uiCommand`), arrows, Home/End, Enter/Space, Escape/Tab, type-ahead. An exclusive modal and launcher (one-modal rule). Vitest; live check on Windows 11 (port 7939). Missing: a display-mode option (always visible menu bar), native macOS menu bar, submenus and separators, an Edit group (no edit commands yet), an About window. Behaviour notes: `plan/phpstorm/14-main-menu.md`. - [ ] Project tool window (tree, scroll from source, file operations) - M1.5 (2026-10-14): tree of the open folder with lazy `project.children` listings, folders and PHP files with Lucide icons, ignored/excluded entries dimmed, keyboard navigation (WAI-ARIA tree: arrows, Home/End, Enter), double-click opens, refresh on `TreeChanged`, listing errors shown in the tree, empty state with Open Folder…. Vitest only, against a mocked engine. - M1.4 (2026-10-15): runs against the real engine in the app: projects open from the folder picker or the command line, the tree updates live when files change on disk; checked with `ui.screenshot` on Windows 11. M1.13 (2026-10-16): a partly listed folder ends with a "Listing truncated" note; opening a file that is already open (tree, control channel) switches to its tab (Vitest; live check pending (gaming mode)). Missing: scroll from source (Select Opened File), expand/collapse all, views list, sort options, speed search, file colours, file operations. Behaviour notes: `plan/phpstorm/02-project-view.md`. @@ -38,6 +40,7 @@ | Date | Change | Summary | |---|---|---| +| 2026-10-19 | minor | Main menu partial (M3.9) | | 2026-10-17 | minor | Go-to popup partial (M2.6) | | 2026-10-17 | minor | Structure tool window partial, left stripe (M2.7) | | 2026-10-17 | minor | Find tool window partial, bottom panel (M2.4) | diff --git a/ui/src/commands/modals.ts b/ui/src/commands/modals.ts index 51bba41..94cedbf 100644 --- a/ui/src/commands/modals.ts +++ b/ui/src/commands/modals.ts @@ -2,7 +2,7 @@ * The modal rule (M1.15): at most one modal is open at a time. * * - **Exclusive modals:** the command palette, the go-to popup (M2.6), the - * settings dialog and the close question of a dirty tab. Opening one closes the one that is open + * app menu (M3.9), the settings dialog and the close question of a dirty tab. Opening one closes the one that is open * (the close question closes as Cancel). Each reports itself with * {@link useModalsStore}'s `opened` and `closed`; the close question is * followed from the editor store, so the editor needs no code for it. @@ -15,14 +15,15 @@ * `palette.open` closes it first (see `store.ts` › `execute`), so a * `uiCommand` from the control channel never leaves it open behind * what the command shows. The go-to popup is a launcher too: any command - * but the go-to open commands closes it. + * but the go-to open commands closes it. So is the app menu (M3.9): any + * command but `menu.open` closes it. */ import { defineStore } from "pinia"; import { ref, watch } from "vue"; import { useEditorStore } from "../stores/editor"; /** The exclusive modals. */ -export type ModalId = "palette" | "goto" | "settings" | "closePrompt"; +export type ModalId = "palette" | "goto" | "menu" | "settings" | "closePrompt"; /** Store of the open exclusive modal. */ export const useModalsStore = defineStore("modals", () => { diff --git a/ui/src/commands/store.ts b/ui/src/commands/store.ts index 43b003a..2147a33 100644 --- a/ui/src/commands/store.ts +++ b/ui/src/commands/store.ts @@ -15,7 +15,8 @@ * commands run with empty params. * - **Errors:** a failed command raises an error toast (M1.12). * - **Palette:** running any command but `palette.open` closes the palette - * first (the modal rule, `modals.ts`). + * first (the modal rule, `modals.ts`); likewise any command but + * `menu.open` closes the app menu (M3.9). */ import { defineStore } from "pinia"; import { computed, ref, shallowReactive } from "vue"; @@ -49,11 +50,18 @@ export interface PaletteEntry { shortcut: string | null; /** Whether it can run now. */ enabled: boolean; + /** Menu path with `/` separators, or null if the command is in no menu (M3.9). */ + menuPath: string | null; + /** Whether the frontend runs it (a UI command, label from the catalog). */ + ui: boolean; } /** Most recently run commands remembered. */ export const MAX_RECENT = 20; +/** The UI command that opens the app menu, which therefore keeps it open. */ +const MENU_OPEN = "menu.open"; + /** The UI commands that open the go-to popup, which therefore keep it open. */ const GOTO_OPEN = new Set(["goto.fileOpen", "goto.classOpen", "goto.symbolOpen"]); @@ -151,6 +159,8 @@ export const useCommandsStore = defineStore("commands", () => { label: labelOf(info), shortcut: typeof info.defaultShortcut === "string" ? formatShortcut(info.defaultShortcut, mac) : null, enabled: isEnabled(info.id), + menuPath: typeof info.menuPath === "string" && info.menuPath !== "" ? info.menuPath : null, + ui: info.ui === true, })), ); @@ -187,8 +197,9 @@ export const useCommandsStore = defineStore("commands", () => { * Runs a command the user chose (keyboard or palette): through its * handler if a component supplied one, else through the engine. A * disabled command does nothing. A failure raises an error toast. Any - * command but `palette.open` closes the palette before it runs, and any - * command but the go-to open commands closes the go-to popup. + * command but `palette.open` closes the palette before it runs, any + * command but the go-to open commands closes the go-to popup, and any + * command but `menu.open` closes the app menu. * * @param id - the command id. * @param params - the params. @@ -204,6 +215,9 @@ export const useCommandsStore = defineStore("commands", () => { if (!GOTO_OPEN.has(id)) { modals.dismiss("goto"); } + if (id !== MENU_OPEN) { + modals.dismiss("menu"); + } const handler = handlers.get(id); if (handler) { try { diff --git a/ui/src/commands/uiCommands.ts b/ui/src/commands/uiCommands.ts index fbdcfec..4823be3 100644 --- a/ui/src/commands/uiCommands.ts +++ b/ui/src/commands/uiCommands.ts @@ -22,12 +22,13 @@ export interface UiCommandSpec { /** The frontend's UI commands. */ export const UI_COMMANDS: readonly UiCommandSpec[] = [ { id: "editor.reveal", labelKey: "command.editor.reveal" }, - { id: "find.open", labelKey: "command.find.open", defaultShortcut: "Mod+Alt+F" }, - { id: "goto.classOpen", labelKey: "command.goto.classOpen", defaultShortcut: "Mod+Alt+C" }, - { id: "goto.fileOpen", labelKey: "command.goto.fileOpen", defaultShortcut: "Mod+P" }, - { id: "goto.symbolOpen", labelKey: "command.goto.symbolOpen", defaultShortcut: "Mod+T" }, - { id: "palette.open", labelKey: "command.palette.open", defaultShortcut: "Mod+Shift+P" }, - { id: "settings.open", labelKey: "command.settings.open", defaultShortcut: "Mod+," }, - { id: "view.toggleProjectTree", labelKey: "command.view.toggleProjectTree", defaultShortcut: "Mod+1" }, - { id: "view.toggleStructure", labelKey: "command.view.toggleStructure", defaultShortcut: "Mod+2" }, + { id: "find.open", labelKey: "command.find.open", menuPath: "View/Find in Files…", defaultShortcut: "Mod+Alt+F" }, + { id: "goto.classOpen", labelKey: "command.goto.classOpen", menuPath: "Go/Class…", defaultShortcut: "Mod+Alt+C" }, + { id: "goto.fileOpen", labelKey: "command.goto.fileOpen", menuPath: "Go/File…", defaultShortcut: "Mod+P" }, + { id: "goto.symbolOpen", labelKey: "command.goto.symbolOpen", menuPath: "Go/Symbol…", defaultShortcut: "Mod+T" }, + { id: "menu.open", labelKey: "command.menu.open", defaultShortcut: "Alt+M" }, + { id: "palette.open", labelKey: "command.palette.open", menuPath: "View/Command Palette", defaultShortcut: "Mod+Shift+P" }, + { id: "settings.open", labelKey: "command.settings.open", menuPath: "View/Settings…", defaultShortcut: "Mod+," }, + { id: "view.toggleProjectTree", labelKey: "command.view.toggleProjectTree", menuPath: "View/Project", defaultShortcut: "Mod+1" }, + { id: "view.toggleStructure", labelKey: "command.view.toggleStructure", menuPath: "View/Structure", defaultShortcut: "Mod+2" }, ]; diff --git a/ui/src/components/layout/MainLayout.vue b/ui/src/components/layout/MainLayout.vue index 595c04d..d204649 100644 --- a/ui/src/components/layout/MainLayout.vue +++ b/ui/src/components/layout/MainLayout.vue @@ -19,6 +19,9 @@ * appears with the UI command `find.open` (`Mod+Alt+F`, supplied here so it * works before the panel exists), collapses to its header and closes from * its header; the Find store keeps the results while it is closed. + * + * A slim header bar along the top (M3.9) holds the app menu + * ({@link AppMenu}); its `header` slot can replace it. */ import { FolderTree, ListTree } from "@lucide/vue"; import { computed, onBeforeUnmount, onMounted, ref } from "vue"; @@ -29,6 +32,7 @@ import FindToolWindow from "../find/FindToolWindow.vue"; import ProjectToolWindow from "../project/ProjectToolWindow.vue"; import StatusBar from "../StatusBar.vue"; import StructureToolWindow from "../structure/StructureToolWindow.vue"; +import AppMenu from "../menu/AppMenu.vue"; import BottomPanel from "./BottomPanel.vue"; import ToolWindow from "./ToolWindow.vue"; @@ -100,6 +104,14 @@ onBeforeUnmount(() => {