From 197d5b7d278edce4119ef5d865a35127c19f0164 Mon Sep 17 00:00:00 2001 From: danny Date: Sun, 25 Oct 2026 13:10:19 +0100 Subject: [PATCH] H4: string and path settings controls, live completion and tooltip settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Settings dialog: every string setting gets a text field with in-place hints (quotes or spaces around a path, control characters, length); keys ending in path/executable also get "Browse…" through the dialog plugin's native picker (new desktop IPC pick_file). git.executable from M4.1 gets the control without UI changes. - settings.open {section?, query?} for agents and live checks. - New keys editor.completion.autoPopup, editor.completion.delayMs and editor.hover.delayMs; the assist module reads them live through CodeMirror compartments. - Tests: engine settings test, control/engine key lists, Vitest for the controls and the live wiring. Docs: architecture, ui-parity, parity Settings row, gaps. Co-Authored-By: Claude Opus 5.5 --- apps/lutra-desktop/src/main.rs | 16 +- crates/control/tests/events.rs | 5 +- crates/engine/src/settings.rs | 61 ++++ crates/engine/tests/settings.rs | 10 +- docs/architecture.md | 13 +- docs/gaps.md | 5 +- docs/target-app-parity.md | 7 +- docs/ui-parity.md | 6 +- ui/src/components/editor/assist/hover.ts | 11 +- ui/src/components/editor/assist/index.ts | 39 +- ui/src/components/editor/assist/settings.ts | 195 ++++++++++ ui/src/components/settings/SettingsDialog.vue | 159 ++++++++- ui/src/components/settings/stringSetting.ts | 91 +++++ ui/src/i18n/en.json | 15 + ui/src/ipc.ts | 17 + ui/src/stores/settings.ts | 6 +- ui/tests/editor/assist/settings.test.ts | 195 ++++++++++ ui/tests/i18n/catalog.test.ts | 6 + ui/tests/settings/StringSettings.test.ts | 333 ++++++++++++++++++ 19 files changed, 1149 insertions(+), 41 deletions(-) create mode 100644 ui/src/components/editor/assist/settings.ts create mode 100644 ui/src/components/settings/stringSetting.ts create mode 100644 ui/tests/editor/assist/settings.test.ts create mode 100644 ui/tests/settings/StringSettings.test.ts diff --git a/apps/lutra-desktop/src/main.rs b/apps/lutra-desktop/src/main.rs index 316b462..c12a493 100644 --- a/apps/lutra-desktop/src/main.rs +++ b/apps/lutra-desktop/src/main.rs @@ -79,7 +79,8 @@ fn run(args: &args::Args) -> Result<(), String> { engine_execute, engine_execute_waiting, engine_list_commands, - engine_ready + engine_ready, + pick_file ]) .setup(move |app| { let setup_host = setup_slot.get().ok_or("the host is not ready")?; @@ -235,6 +236,19 @@ fn engine_ready(host: tauri::State<'_, Arc>) { host.replay_to_window(); } +/// IPC: shows the native file picker for a path setting's "Browse…" +/// button and returns the chosen file, or `None` when the user cancels or +/// picks something that is not a local path. `async` keeps the blocking +/// picker off the main thread. The frontend stores the path through +/// `settings.set`, so the setting itself stays an engine command. +#[tauri::command(async)] +fn pick_file(app: tauri::AppHandle, title: String) -> Option { + use tauri_plugin_dialog::DialogExt; + let picked = app.dialog().file().set_title(title).blocking_pick_file()?; + let path = picked.into_path().ok()?; + Some(path.to_string_lossy().into_owned()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/control/tests/events.rs b/crates/control/tests/events.rs index fddf1ce..122c050 100644 --- a/crates/control/tests/events.rs +++ b/crates/control/tests/events.rs @@ -203,7 +203,10 @@ fn settings_changes_stream_and_persist() { "phpactor.autoDownload": true, "editor.autosave.onBlur": true, "editor.autosave.onTabSwitch": true, - "editor.autosave.idleSeconds": 15 + "editor.autosave.idleSeconds": 15, + "editor.completion.autoPopup": true, + "editor.completion.delayMs": 0, + "editor.hover.delayMs": 350 }), "{r}" ); diff --git a/crates/engine/src/settings.rs b/crates/engine/src/settings.rs index 02194b2..7bfeb2a 100644 --- a/crates/engine/src/settings.rs +++ b/crates/engine/src/settings.rs @@ -248,6 +248,33 @@ pub const DEFS: &[Def] = &[ description_key: "settings.editor.autosave.idleSeconds.description", section: "editor", }, + Def { + key: "editor.completion.autoPopup", + kind: Kind::Bool, + default: DefaultValue::Bool(true), + label_key: "settings.editor.completion.autoPopup.label", + description_key: "settings.editor.completion.autoPopup.description", + section: "editor", + }, + Def { + key: "editor.completion.delayMs", + kind: Kind::Int { min: 0, max: 2000 }, + default: DefaultValue::Int(0), + label_key: "settings.editor.completion.delayMs.label", + description_key: "settings.editor.completion.delayMs.description", + section: "editor", + }, + Def { + key: "editor.hover.delayMs", + kind: Kind::Int { + min: 100, + max: 3000, + }, + default: DefaultValue::Int(350), + label_key: "settings.editor.hover.delayMs.label", + description_key: "settings.editor.hover.delayMs.description", + section: "editor", + }, ]; /// Looks a known setting up by key. @@ -631,6 +658,40 @@ mod tests { } } + #[test] + fn assist_defaults_and_validation() { + let mut s = Settings::in_memory(); + assert_eq!(s.get("editor.completion.autoPopup"), Some(json!(true))); + assert_eq!(s.get("editor.completion.delayMs"), Some(json!(0))); + assert_eq!(s.get("editor.hover.delayMs"), Some(json!(350))); + assert_eq!(s.set("editor.completion.autoPopup", json!(false)), Ok(true)); + assert!(matches!( + s.set("editor.completion.autoPopup", json!("false")), + Err(SetError::Invalid(_)) + )); + for (key, min, max) in [ + ("editor.completion.delayMs", 0, 2000), + ("editor.hover.delayMs", 100, 3000), + ] { + assert!(s.set(key, json!(min)).is_ok(), "{key}"); + assert_eq!(s.get(key), Some(json!(min))); + assert_eq!(s.set(key, json!(max)), Ok(true), "{key}"); + for bad in [json!(min - 1), json!(max + 1), json!(500.5), json!("500")] { + assert!( + matches!(s.set(key, bad), Err(SetError::Invalid(_))), + "{key}" + ); + } + let info = serde_json::to_value(def(key).unwrap().info()).unwrap(); + assert_eq!(info["type"], json!("int")); + assert_eq!( + (info["min"].clone(), info["max"].clone()), + (json!(min), json!(max)) + ); + assert_eq!(info["section"], json!("editor")); + } + } + #[test] fn every_default_is_valid() { for d in DEFS { diff --git a/crates/engine/tests/settings.rs b/crates/engine/tests/settings.rs index 076191a..1e5fcf5 100644 --- a/crates/engine/tests/settings.rs +++ b/crates/engine/tests/settings.rs @@ -52,7 +52,10 @@ fn list_describes_the_c2_keys_with_catalog_keys_only() { "phpactor.autoDownload", "editor.autosave.onBlur", "editor.autosave.onTabSwitch", - "editor.autosave.idleSeconds" + "editor.autosave.idleSeconds", + "editor.completion.autoPopup", + "editor.completion.delayMs", + "editor.hover.delayMs" ] ); for s in list.as_array().unwrap() { @@ -118,7 +121,10 @@ fn get_set_reset_and_events() { "phpactor.autoDownload": true, "editor.autosave.onBlur": true, "editor.autosave.onTabSwitch": true, - "editor.autosave.idleSeconds": 15 + "editor.autosave.idleSeconds": 15, + "editor.completion.autoPopup": true, + "editor.completion.delayMs": 0, + "editor.hover.delayMs": 350 }) ); let out = e diff --git a/docs/architecture.md b/docs/architecture.md index 1361e7f..e842123 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, toolchain (PHP detection, Phpactor download), the app menu, MCP server, autosave and `flushDirty`, integrated terminal; engine ↔ Phpactor wiring and diagnostics (M3.3), pending outcomes (M3.5), completion, hover and signature help (M3.4); C5 child process groups (H1) · **Last updated:** 2026-10-24 +> **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, toolchain (PHP detection, Phpactor download), the app menu, MCP server, autosave and `flushDirty`, integrated terminal; engine ↔ Phpactor wiring and diagnostics (M3.3), pending outcomes (M3.5), completion, hover and signature help (M3.4); C5 child process groups (H1), settings dialog string and path controls and assist settings (H4) · **Last updated:** 2026-10-24 ## Overview @@ -167,7 +167,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - `/settings.json`, a flat JSON object of dotted keys, written with `lutra_vfs::write_atomic` on every change. Unknown keys are kept; a stored value that fails validation counts as unset. Read with a 1 MiB cap. - A file that is not a JSON object (invalid JSON, not UTF-8, too large) is renamed to `settings.json.bad-` (with `-n` if taken), the defaults are used and a `notification {level: "warning", messageKey: "notification.settings.corrupt", message, params: {reason, backup}}` is queued. If it cannot be moved, or the directory or file cannot be read, settings stay in memory for the session (`notification.settings.corruptNotMoved`, `notification.settings.unavailable`) so the file is never overwritten. -- Keys: `appearance.theme` (`lutra-dark|lutra-light|system`, default `system`), `editor.fontSize` (int 8–48, default 14), `ui.language` (`en`), the autosave keys `editor.autosave.onBlur`, `editor.autosave.onTabSwitch` (bool, default true) and `editor.autosave.idleSeconds` (int 0–600, default 15; M3.10). Defined in `lutra_engine::settings::DEFS`. +- Keys: `appearance.theme` (`lutra-dark|lutra-light|system`, default `system`), `editor.fontSize` (int 8–48, default 14), `ui.language` (`en`), the autosave keys `editor.autosave.onBlur`, `editor.autosave.onTabSwitch` (bool, default true) and `editor.autosave.idleSeconds` (int 0–600, default 15; M3.10), the assist keys `editor.completion.autoPopup` (bool, default true), `editor.completion.delayMs` (int 0–2000, default 0) and `editor.hover.delayMs` (int 100–3000, default 350; H4). Defined in `lutra_engine::settings::DEFS`. - Commands: `settings.list` → `[{key, type: enum|int, default, enumValues?, min?, max?, labelKey, descriptionKey, section}]` (catalog keys `settings..label` / `.description`; `section` is an id shown with `settings.section.`), `settings.get {keys?}` → `{values}`, `settings.set {key, value}` → `{value}`, `settings.reset {key}` → `{value}`. Unknown keys and bad values fail with `invalid_params`; a write failure fails with `failed` and changes nothing. - Events: `settingsChanged {keys}` when an effective value changes; `notification {id, level: info|warning|error, messageKey?, message?, params?}` (ids `n1`, `n2`…). @@ -247,7 +247,8 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - **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. - **Text:** labels, descriptions and section names come from the catalog keys the engine sends (`settings..label`, `.description`, `settings.section.`); enum values use `settings..value.`. A key the catalog lacks shows the setting key (or the raw value). These keys are in the catalog test's runtime list. - **Font size:** `theme.ts` has `setTokenOverride(name, value)`: a value above the theme's that `applyTheme` keeps across theme switches. The store sets `--lt-font-size-editor` to `editor.fontSize` px; the editor reads only that token. -- **Dialog:** `ui/src/components/settings/SettingsDialog.vue` (mounted in `App.vue`) provides `settings.open` (`Mod+,`, palette, `uiCommand`). Sections on the left, the chosen section's settings on the right; enum → select, int → number field (min/max, applied when committed; text that is no whole number in range is refused in place with `settings.error.intRange`), bool → switch. The theme picker is the `appearance.theme` select; the engine answers with `themeChanged`. +- **Dialog:** `ui/src/components/settings/SettingsDialog.vue` (mounted in `App.vue`) provides `settings.open` (`Mod+,`, palette, `uiCommand`). Sections on the left, the chosen section's settings on the right; enum → select, int → number field (min/max, applied when committed; text that is no whole number in range is refused in place with `settings.error.intRange`), bool → switch, string → text field (H4). The theme picker is the `appearance.theme` select; the engine answers with `themeChanged`. + - **String and path settings (H4, `stringSetting.ts`):** every `string` setting from `settings.list` gets a text field, applied when committed, so a new key (M4.1's `git.executable`) needs no UI change. A string setting whose key's last segment ends in `path` or `executable` is a path: it gets "Browse…", which calls the desktop's `pick_file {title}` IPC (the dialog plugin's native file picker, run off the main thread; `ipc.ts › pickFile`) and applies the chosen file through `settings.set`; a path with an empty default shows "Detected automatically" while empty. Checks before `settings.set`, each with its own catalog message: at most 4,096 UTF-8 bytes and no control characters (every string), no surrounding quotes and no spaces at either end (paths). The engine validates everything else. String rows stack the field under the label at full width. `settings.open {section?, query?}` opens on a section or with a search (for agents and live checks). - **Search** matches label, description, key and section name (every word, ignoring case); while it has text every match shows, grouped by section, and sections without matches are dimmed. - **Reset to default** per setting, enabled while the value differs from the default. - **Errors** show under the control (`role="alert"`, `aria-invalid`) and keep the typed text until the value changes. @@ -458,7 +459,8 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - The server's order becomes the boost. A complete list is filtered locally while typing; an incomplete one is asked again on each keystroke. - Applying an item uses its `textEdit` (else replaces the typed word with `insertText`) and its `additionalTextEdits` in one transaction. Text typed after the request is accounted for, and overlapping imports are skipped. - The kind icon is a Lucide component rendered into the list row. - - **Hover:** `hoverTooltip` after 350 ms; `editor.quickDocumentation` (`Mod+I`) shows the same tooltip at the cursor. + - **Hover:** `hoverTooltip` after `editor.hover.delayMs` (default 350 ms); `editor.quickDocumentation` (`Mod+I`) shows the same tooltip at the cursor. + - **Settings (H4, `assist/settings.ts`):** `editor.completion.autoPopup` (typing opens the list; the shortcut always does), `editor.completion.delayMs` (CodeMirror's `activateOnTypingDelay`) and `editor.hover.delayMs` (`hoverTime`), read from the settings store (defaults without a Pinia, numbers clamped to the engine's ranges). Completion and hover sit in compartments; a view plugin follows the store and reconfigures every open PHP editor when a value changes, and a state field remembers the values a state was built with, so a state shown again later catches up. A reconfiguration recreates the hover extension, which closes an open hover tooltip. - **Signature help:** - A state field holds the tooltip; a view plugin asks on `(` and `,`, and while open on every edit or cursor move (120 ms debounce), dropping stale answers. - `Escape` closes it, `Mod-Shift-Space` and `editor.parameterInfo` open it. @@ -522,7 +524,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat - **HTTP client:** `ureq` 3 with `rustls` (the `ring` provider) and the operating system's trusted roots loaded with `rustls-native-certs` (Windows store, macOS keychain, Linux files or `SSL_CERT_FILE`). `rustls-platform-verifier` and ureq's default `webpki-roots` were rejected: both pull a CDLA-Permissive-2.0 crate (`webpki-root-certs` / `webpki-roots`), outside the licence allow list. Proxies come from `HTTPS_PROXY`/`ALL_PROXY`/`NO_PROXY`. Timeouts: 15 s connect, 300 s per attempt. - **Download:** `download::install` reads the body into memory with a cap of 32 MiB (Content-Length checked first, then the bytes read), compares its SHA-256 with the pin and only then writes `/tools/phpactor//phpactor.phar` with `lutra_vfs::write_atomic`. A mismatch discards the body and leaves an existing file untouched; nothing unverified ever lies at the target path. `install_with_retry` retries network errors, 5xx, 408 and 429 up to 4 attempts with 2 s, 4 s, 8 s backoff; a mismatch, an oversized body and other client errors are final. A managed PHAR that no longer matches its hash counts as missing and is downloaded again. - **PHP detection:** `php::detect` resolves the setting (a path, or a bare name looked up in `PATH`; empty means `php`, on Windows `php.exe`, `php.bat`, `php.cmd`), runs `php -v` without a console window, with a 5 s timeout (killed after it) and at most 64 KiB of output read, and parses the first line starting with `PHP .[.]` (suffixes such as `-dev` or `-1ubuntu1` are ignored; property-tested with random bytes). -- **Engine:** settings `php.executable` (string, default `""`), `phpactor.path` (string, default `""`) and `phpactor.autoDownload` (bool, default `true`), section `php`; `settings.list` now has the types `bool` and `string` (the settings dialog shows bool switches; a text control for string settings is a UI follow-up). One worker thread (`lutra-toolchain`) runs checks and the download; commands and the pump only queue jobs (merged while it works, the strongest mode wins), and its reports reach the state through `Engine::pump_vfs` (`cmd::toolchain::pump`), like search results. Jobs start with the first `toolchain.status`, when a project opens (a download if the project has PHP files: a root `composer.json` or a `.php`/`.phtml`/`.inc` file within 6 levels, at most 20,000 entries, skipping `vendor`, `node_modules`, hidden and cache directories; PHP is usable; Phpactor is missing; auto-download is on), when one of the three settings changes after the first check, and with `toolchain.downloadPhpactor` (also with auto-download off; `failed` if the host allows no downloads). +- **Engine:** settings `php.executable` (string, default `""`), `phpactor.path` (string, default `""`) and `phpactor.autoDownload` (bool, default `true`), section `php`; `settings.list` now has the types `bool` and `string` (the settings dialog shows bool switches, and since H4 a text field with "Browse…" for the two paths). One worker thread (`lutra-toolchain`) runs checks and the download; commands and the pump only queue jobs (merged while it works, the strongest mode wins), and its reports reach the state through `Engine::pump_vfs` (`cmd::toolchain::pump`), like search results. Jobs start with the first `toolchain.status`, when a project opens (a download if the project has PHP files: a root `composer.json` or a `.php`/`.phtml`/`.inc` file within 6 levels, at most 20,000 entries, skipping `vendor`, `node_modules`, hidden and cache directories; PHP is usable; Phpactor is missing; auto-download is on), when one of the three settings changes after the first check, and with `toolchain.downloadPhpactor` (also with auto-download off; `failed` if the host allows no downloads). - **Commands and event:** `toolchain.status` → `{php: {found, path, version, error?}, phpactor: {state: missing|downloading|ready|failed|disabled, path?, version?, error?}}` as last checked (the first call starts a check); `toolchain.downloadPhpactor` → `{started}`; event `toolchainChanged` with the same shape whenever it changes. A `phpactor.path` PHAR is ready if it is a file, with no version and no hash check (the user chose it). - **Notifications:** `notification.toolchain.phpMissing {reason, min}` (warning, when the PHP result changes to unusable), `notification.toolchain.downloadStarted {version}` and `notification.toolchain.downloadDone {version, seconds}` (info), `notification.toolchain.downloadFailed {version, reason}` (error). - **Live check** (debug build, bundled UI, port 7931, Windows 11, PHP 8.4.24 from WinGet, a temp project with one PHP file, empty data directory): `project.open` → PHP found after 0.15 s, `downloadStarted` after 0.35 s, the real download from GitHub plus SHA-256 check took 2.8 s (notification to notification, measured), `toolchain.status` then `ready` with `/tools/phpactor/2026.06.25.0/phpactor.phar`, whose hash on disk equals the pin. A second run through `toolchain.downloadPhpactor` after deleting the PHAR took 0.3 s; both toasts showed in the window. @@ -556,6 +558,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat | Date | Change | Summary | |---|---|---| +| 2026-10-24 | minor | H4: string and path controls in the settings dialog (`pick_file` IPC), assist settings (auto popup, completion delay, hover delay) read live | | 2026-10-24 | minor | H1: `crates/proc` (L0), child processes in kill-on-close groups (Windows job objects, Unix process groups with a watchdog); Phpactor and the PHP probe use it | | 2026-10-22 | minor | M3.5: definition, references, rename (`lsp_nav`, workspace edits, undoable remote edits, nav UI) | | 2026-10-22 | minor | M3.4: code assistance (`lsp.completion`, `lsp.hover`, `lsp.signatureHelp` on pending outcomes; editor completion source, hover, signature help, safe Markdown, assist UI commands), Phpactor latency and resources | diff --git a/docs/gaps.md b/docs/gaps.md index 6a9f5de..948def1 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, autosave); 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, PHP detection, Phpactor download, engine wiring and diagnostics, completion and hover, definition, references and rename, Phpactor dies with Lutra); G7 under way (`lutra` CLI and single instance, MCP server, integrated terminal); G14 English UI catalog in place · **Last updated:** 2026-10-24 +> **Status:** M0 closed G1; G2 under way (text buffer, engine buffers, tabs and editor in the app, recovery journal, autosave); G3 M1 part done (project tree, palette, settings dialog with string and path controls, 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, PHP detection, Phpactor download, engine wiring and diagnostics, completion and hover, definition, references and rename, Phpactor dies with Lutra); G7 under way (`lutra` CLI and single instance, MCP server, integrated terminal); G14 English UI catalog in place · **Last updated:** 2026-10-24 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~~ (M3.10), local history | M1 | ~14 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 | +| 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; string and path controls: H4), ~~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, definition, hover, rename via Phpactor (~~PHP detection and Phpactor download~~, M3.1; ~~engine wiring and diagnostics~~, M3.3; ~~completion, hover, signature help~~, M3.4; ~~definition, references, rename~~, M3.5) | M3 | ~15 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-24 | patch | G3/G6: string and path settings in the dialog, completion and tooltip settings (H4) | | 2026-10-24 | minor | G6: Phpactor no longer outlives Lutra (H1) | | 2026-10-22 | minor | G6 shrunk: definition, references, rename (M3.5) | | 2026-10-22 | minor | G6 shrunk: completion, hover and signature help (M3.4) | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 4907af7..1e9c438 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Target-app parity -> **Status:** M1 done (text buffer, VFS, engine workspace, project tree, tabs and a plain-text editor, recovery, palette, settings and themes in the app); M2 started: PHP syntax highlighting, find in files with its tool window, the symbol index and the go-to popup, the Structure tool window; M3 started: the integrated terminal, go to definition, find references and rename through Phpactor · **Last updated:** 2026-10-22 · **Target:** PhpStorm 2026.x +> **Status:** M1 done (text buffer, VFS, engine workspace, project tree, tabs and a plain-text editor, recovery, palette, settings and themes in the app); M2 started: PHP syntax highlighting, find in files with its tool window, the symbol index and the go-to popup, the Structure tool window; M3 started: the integrated terminal, go to definition, find references and rename through Phpactor · **Last updated:** 2026-10-24 · **Target:** PhpStorm 2026.x ## How this is measured @@ -18,7 +18,7 @@ Hours are the estimated agent wall-clock hours for one agent to reach behaviour | Project view, VFS | 6 | 8% (est.) | views list (project / scopes), toolbar (Select Opened File, Expand/Collapse All), sort and display options, show/hide excluded, distinct icons for library and excluded folders, file colours, speed search, preview, file operations | ~37 (est.) | `lutra-vfs` (M1.2): lazy sorted listing, ignore rules (.gitignore, .ignore, info/exclude, global excludes, Lutra defaults), native file watching via `notify` with a polling fallback, capped UTF-8 reads, atomic writes; 34 tests on temp dirs, watcher tests run on both backends (`crates/vfs/tests`). M1.5: project tree UI (lazy listing, keyboard navigation, dimmed ignored entries, event refresh) in `ui/src/components/project/`, Vitest against a mocked engine. M1.3: `project.open`, `project.close`, `project.children` (watches listed directories, capped at 256 native / 32 polling, least recently listed dropped), `treeChanged` events from disk, `events.subscribe` on the control channel with a TCP test (`crates/control/tests/events.rs`). M1.4: the tree runs against the engine in the app: folder picker (`project.openDialog`) and `lutra-desktop --control PORT PATH` open a project, the tree lists it lazily with ignored (`var/` from `.gitignore`) and excluded (`node_modules`) entries dimmed, a file created on disk appears in an expanded folder within ~100 ms; verified with `ui.screenshot` on Windows 11 and Vitest (`ui/tests/project/`, `ui/tests/ipcEvents.test.ts`). M1.13: a directory listed only partly (more than 100,000 entries) ends with a "Listing truncated" note row (Vitest). M1.12: a folder that cannot be opened from the picker or the command line (including `unsaved_changes` when switching projects) and stopped file watching show as toasts instead of stderr (`apps/lutra-desktop/src/host.rs`, `ui/src/stores/notifications.ts`, `ui/tests/notifications/`, 19 Vitest tests; live check pending, gaming mode); score unchanged. Graded against `plan/phpstorm/02-project-view.md`: tool window, folder-first tree, dimmed ignored/excluded, keyboard navigation and live refresh exist; most toolbar, view and display options do not | | Navigation | 10 | 13% (est.) | go to declaration: type declaration, implementations, the hover link underline; find usages: popup variant, usages highlighted in the file, scopes, grouping options, read/write access; go-to: recent files on an empty query, a non-project toggle (library items always show), file-type filter, `:line` suffixes, actions and text tabs, sending the list to Find; recent files and locations, navigation history, File Structure popup, Structure speed search, sorting and filters (visibility, inherited members), autoscroll from the caret, navigation bar, bookmarks (M1.8: a command palette over commands only) | ~96 (est.) | M3.5: Go to Definition (`lsp.definition`, F12 or Mod+click with a pointer cursor while Mod is held) through Phpactor: one location revealed, several in a picker (one modal at a time), none as a toast; Find References (`lsp.references`, Shift+F12) in a References tab of the bottom panel, grouped by file with the line preview and the name marked, click or Enter reveals. Requests wait off the engine lock (pending outcomes) and see every edit sent before them. Live against Phpactor 2026.06.25.0 on Windows (port 7935, three-file temp project, debug build, tick on): class definition across files 93 ms cold, 7–18 ms warm; references (4 uses in 3 files, incl. a CRLF file) ~140 ms (measured). Tests: `crates/engine/tests/lsp_nav.rs` (fake server with scripted answers; an ignored real-Phpactor test), Vitest `ui/tests/nav/`. The F12 and F2 keys were not pressed in the live app (no key input without stealing the owner's focus); the key and click paths are covered by Vitest. M2.6: go-to popup `ui/src/components/goto/` with Files / Classes / Symbols tabs (Tab and Shift+Tab or a click switch, the text stays), UI commands `goto.fileOpen` `Mod+P`, `goto.classOpen` `Mod+Alt+C`, `goto.symbolOpen` `Mod+T` (optional `{query}` for agents), live query against `goto.*` (60 ms debounce, stale answers dropped), matched characters marked, directory / namespace / container column, library rows dimmed and labelled (`goto.file` items now carry `library`), an indexing hint with progress and a re-query on `indexReady`, Enter or a click opens through `editor.reveal`, Escape closes, one modal at a time; Vitest `ui/tests/goto/`, live-checked in the app (port 7826). M2.7: Structure tool window (`ui/src/components/structure/`) in a new left stripe with Project | Structure: the active tab's outline as a tree with Lucide kind icons and signatures, follows the active tab and edits (`outlineChanged`), click or Enter jumps through `editor.reveal`, arrows fold, `view.toggleStructure` `Mod+2`; engine `syntax.outline {id}` from a per-buffer tree-sitter tree reparsed off the engine lock on a worker thread (200 ms debounce). Tests: 11 engine unit tests, engine integration tests with a proptest of random edit sequences (end at a fresh parse's outline), a control-channel test (`crates/control/tests/syntax.rs`), 13 Vitest tests (`ui/tests/structure/`). Checked in the app on Windows 11 (bundled UI, control port 7827): a class file with namespace, interface, enum, trait, class with promoted property and a function; `outlineChanged` 149 ms after `file.open`, `view.toggleStructure` shows the tree, a jump to `find` centres line 62, an added method appears about 0.3 s after `buffer.edit` (debug build). Rows were not clicked in the app (the control channel has no input method); click and Enter are covered by Vitest. 1 MB file: `buffer.edit` ≤ 0.25 ms and `pump_vfs` ≤ 3.8 ms under the lock, edit to `outlineChanged` 0.43–0.76 s, `syntax.outline` 82 ms (release, measured). Graded against `plan/phpstorm/09-structure.md`. M2.5: symbol index in `crates/index` (every project file listed, `.php` parsed in parallel from tree-sitter outlines, vendor marked library, incremental on disk and buffer changes, capped at 200,000 files) and the engine commands `index.status`, `goto.file`, `goto.class`, `goto.symbol` (fuzzy, file names weighted, `Class::member`, project before library, partial results with `indexing: true`), events `indexProgress`/`indexReady`; 20k-file / 88 MB generated project indexed in 3.9–4.2 s (release, measured), queries 2–12 ms; tests `crates/index/tests/`, `crates/engine/tests/goto.rs`, `crates/control/tests/goto.rs`; reached from the UI by M2.6. M2.1: file outline in `crates/syntax` (namespaces braced and unbraced, classes, interfaces, traits, enums with cases, functions, methods, properties incl. promoted ones, constants; UTF-16 ranges and short signatures), the base for the Structure window (M2.7) and the symbol index (M2.5); not reachable from the UI yet, score unchanged. M1.8: `ui/src/components/palette/`, `ui/src/commands/` (fuzzy ranking, recent commands, global keymap), Vitest `ui/tests/palette/`, `ui/tests/commands/` | | Search and replace | 6 | 8% (est.) | find in the current file, replace in files and in a file, scopes (module, directory, open files, custom), comment/string filters, search history, a tab per search, grouping options, merging matches on one line, find in path from the tree, structural search | ~70 (est.) | M2.4 Find tool window in a new resizable, collapsible bottom panel: query with case / whole word / regex toggles, include and exclude globs, streamed results grouped by file (sorted) with the match highlighted in the line preview, counts and elapsed time, cancel, a truncated hint, a refused regex or glob shown in place; Enter or click opens the match through `editor.reveal`, arrow keys / Page / Home / End walk the results; `find.open` (`Mod+Alt+F`, Lutra's own) prefills the selection or the word at the cursor, `find.open {query}` from an agent searches at once; a new search cancels the running one. Tests: 26 Vitest store and component tests (`ui/tests/find/FindToolWindow.test.ts`). Live check (bundled-ui debug build, control port 7824, 3-file temp project): `find.open {query}` over `uiCommand` showed 14 matches in 3 files (vendor included) grouped and highlighted in 17 ms; with `*.php` include 2 matches; revealing a result's position opened the file at the match; `find.open` without params prefilled the word at the cursor; a bad regex showed the engine's message in place (screenshots read, measured). Opening a result by mouse or Enter is covered by Vitest only (the control channel cannot click). M2.3 backend: `crates/search` (parallel `ignore` walk + `grep-searcher`: literal/regex, case, whole word, include/exclude globs, project ignore rules with `vendor/` searched and `node_modules` skipped, binary and > 8 MiB files skipped, match cap, cancel) and engine `search.find` / `search.cancel` with `searchResults` / `searchDone` events through the pump; dirty buffers are searched in their buffer text. Tests: 9 library tests incl. a property test of random queries and file bytes (`crates/search/tests/search.rs`), 3 preview/column unit tests, 4 engine tests (`crates/engine/tests/search.rs`), a TCP control-channel test (find → results → done, invalid regex, cancel; `crates/control/tests/search.rs`). 20k-file generated tree, release: first result 10–43 ms, full walk 0.66–1.43 s (measured); live over the control channel against the running app: first result 55 ms, done 386 ms on a 5,900-file project (debug build, measured) | -| Code completion | 10 | 5% (est.) | type-matching and second-invocation completion, postfix completion, live templates, path completion, ranking options and the replace-on-accept variant, accept characters, auto-insert of a single suggestion, auto-import checked against the real Phpactor (applied when the server sends it; tested with the fake server only), completion settings (auto popup, delay, case), parameter info settings, a documentation tool window, type info, faster indexing on Windows (Phpactor's tick-driven loop takes ~65 s for 2,000 classes) | ~240 (est.) | M3.4: completion, hover and signature help from Phpactor. Engine `lsp.completion {id, position, triggerCharacter?}` (items with label, kind, detail, Markdown documentation, insertText, textEdit, additionalTextEdits, sortText; at most 500, sorted by sortText, `incomplete` when cut or when the server says so; snippets turned into plain text), `lsp.hover` (Markdown, range) and `lsp.signatureHelp` (UTF-16 parameter spans), sent off the engine lock through M3.5's pending outcomes (`crates/engine/src/cmd/lsp_assist.rs`). Editor (`ui/src/components/editor/assist/`): a CodeMirror completion source with Lutra's own triggers (identifiers, `$`, `->`, `?->`, `::`, namespace `\`; not in strings or comments unless asked), the server's ranking as boost, local filtering for complete lists, text edits and imports applied in UTF-16 (CRLF files too), Lucide kind icons; hover documentation after 350 ms and on demand (`editor.quickDocumentation` `Mod+I`); signature help on `(` and `,` that follows the cursor (`editor.parameterInfo`); `editor.complete`; Markdown rendered by Lutra's own renderer without any HTML (XSS-tested). Tests: 6 engine tests against the fake server, 9 unit tests, 29 Vitest tests, an ignored test against the real PHAR. Measured with the real Phpactor on Windows 11 (debug build, 25 ms tick): completion while typing 61–109 ms (median 76 ms; ~107 ms through the control channel in the app), hover 4–91 ms (median 15–16 ms), signature help 4–28 ms (median 16 ms); a useful list 2.3 s after opening a file of a 20-class project and 65 s for 2,000 classes (Phpactor indexes first and answers with an empty incomplete list until then). Checked in the app (port 7934): completion after `->`, quick documentation of a class, parameter info with the active parameter, screenshots read. Graded against `plan/phpstorm/12-completion.md`: the depth comes from Phpactor (members, classes, variables, keywords; detail and documentation often missing), Lutra has no type inference of its own | +| Code completion | 10 | 5% (est.) | type-matching and second-invocation completion, postfix completion, live templates, path completion, ranking options and the replace-on-accept variant, accept characters, auto-insert of a single suggestion, auto-import checked against the real Phpactor (applied when the server sends it; tested with the fake server only), completion settings beyond H4's auto popup and delays (case sensitivity, sorting), parameter info settings, a documentation tool window, type info, faster indexing on Windows (Phpactor's tick-driven loop takes ~65 s for 2,000 classes) | ~240 (est.) | M3.4: completion, hover and signature help from Phpactor. Engine `lsp.completion {id, position, triggerCharacter?}` (items with label, kind, detail, Markdown documentation, insertText, textEdit, additionalTextEdits, sortText; at most 500, sorted by sortText, `incomplete` when cut or when the server says so; snippets turned into plain text), `lsp.hover` (Markdown, range) and `lsp.signatureHelp` (UTF-16 parameter spans), sent off the engine lock through M3.5's pending outcomes (`crates/engine/src/cmd/lsp_assist.rs`). Editor (`ui/src/components/editor/assist/`): a CodeMirror completion source with Lutra's own triggers (identifiers, `$`, `->`, `?->`, `::`, namespace `\`; not in strings or comments unless asked), the server's ranking as boost, local filtering for complete lists, text edits and imports applied in UTF-16 (CRLF files too), Lucide kind icons; hover documentation after 350 ms and on demand (`editor.quickDocumentation` `Mod+I`); signature help on `(` and `,` that follows the cursor (`editor.parameterInfo`); `editor.complete`; Markdown rendered by Lutra's own renderer without any HTML (XSS-tested). Tests: 6 engine tests against the fake server, 9 unit tests, 29 Vitest tests, an ignored test against the real PHAR. Measured with the real Phpactor on Windows 11 (debug build, 25 ms tick): completion while typing 61–109 ms (median 76 ms; ~107 ms through the control channel in the app), hover 4–91 ms (median 15–16 ms), signature help 4–28 ms (median 16 ms); a useful list 2.3 s after opening a file of a 20-class project and 65 s for 2,000 classes (Phpactor indexes first and answers with an empty incomplete list until then). Checked in the app (port 7934): completion after `->`, quick documentation of a class, parameter info with the active parameter, screenshots read. Graded against `plan/phpstorm/12-completion.md`: the depth comes from Phpactor (members, classes, variables, keywords; detail and documentation often missing), Lutra has no type inference of its own | | Inspections and quick-fixes | 8 | 4% (est.) | Lutra's own inspections and their settings, severities per inspection, quick-fixes (LSP code actions), suppression, inspection profiles, running inspections on a scope, PHP lint syntax errors on Windows, the editor's problem counter and scrollbar marks, next/previous problem, a current-file Problems view and severity filters, external tools (PHPStan, Psalm, PHP_CodeSniffer) | ~290 (est.) | M3.3: diagnostics from Phpactor (worse reflection: missing members, unknown classes, …) as wavy underlines, gutter markers and hover messages in the editor (`ui/src/components/editor/lint.ts`, tokens only), and a Problems tab in the bottom panel grouped by file with click to reveal (`ui/src/components/problems/`, `problems.open` `Mod+Alt+P`); engine `diagnosticsChanged`, `diagnostics.list`, `lspStatus` (`crates/engine/src/lsp/`). Tests: 10 engine tests against a fake server incl. a sync proptest, a TCP test, 16 Vitest tests, an ignored test against the real PHAR. Checked in the app on Windows 11 with the real Phpactor (port 7933): five errors underlined and listed; first diagnostics 2.7 s after `file.open`, 2.7–2.9 s after an edit (debug build, measured, incl. Phpactor's 1 s debounce). Graded against `plan/phpstorm/11-problems.md`: the depth comes from Phpactor, Lutra has no inspections of its own | | Refactoring | 7 | 3% (est.) | rename: preview of all changes, comments/strings and text occurrences, scope, renaming files with classes, one undo across files (closed files written on disk are not undone by the editor); extract variable/method/constant, inline, move, change signature, safe delete, pull up/push down, introduce parameter | ~244 (est.) | M3.5: Rename (`lsp.prepareRename` then `lsp.rename`, F2) through Phpactor with an inline field over the symbol that shows how many uses in how many files change. The workspace edit is checked completely first (inside the project, ranges fit, open buffers unchanged since the request, no file operations); then closed files are written atomically through the VFS (written ones restored if a later write fails), open buffers change through `buffer.edit` (dirty, one undo step each in the editor), Phpactor reindexes the written files (sent as `didOpen`/`didSave`/`didClose`; its index followed in 140 ms, measured) and a summary notification follows. Live: renaming a method used in 3 files took 28 ms (open buffer + 2 closed files, CRLF kept). Tests: `crates/engine/tests/lsp_nav.rs` (multi-file rename incl. a closed CRLF file, an edit outside the project refused, a bad range refused, a buffer edited meanwhile refused; ignored real-Phpactor rename and rename back), Vitest `ui/tests/nav/`. | | Code style and formatting | 4 | 0% | everything | ~120 (est.) | — | @@ -33,7 +33,7 @@ Hours are the estimated agent wall-clock hours for one agent to reach behaviour | HTTP client | 1 | 0% | everything | ~60 (est.) | — | | Web languages | 2 | 0% | everything | ~200 (est.) | — | | Docker and remote | 1 | 0% | everything | ~120 (est.) | — | -| Settings, keymaps, themes | 1 | 7% (est.) | nested settings tree, project-level settings, export/import, keymaps (M1.8: one global keymap from the commands' default shortcuts, not editable), colour scheme editor, custom and imported themes, per-language colours (M1.9a: settings backend with 3 keys, persistence, `settings.*` commands, no UI yet; M1.10: light and dark themes with live switching and a system mode; M1.9b: settings dialog with search, controls by type, reset, live updates, theme picker, editor font size) | ~60 (est.) | — | +| Settings, keymaps, themes | 1 | 8% (est.) | nested settings tree, project-level settings, export/import, keymaps (M1.8: one global keymap from the commands' default shortcuts, not editable), colour scheme editor, custom and imported themes, per-language colours (M1.9a: settings backend with 3 keys, persistence, `settings.*` commands, no UI yet; M1.10: light and dark themes with live switching and a system mode; M1.9b: settings dialog with search, controls by type, reset, live updates, theme picker, editor font size) | ~58 (est.) | H4: every setting the engine has is editable in the dialog: string settings get a text field with in-place hints (quotes or spaces around a path, control characters, length), path settings (`php.executable`, `phpactor.path`, any key ending in `path`/`executable`, so M4.1's `git.executable` too) a "Browse…" button through the dialog plugin's native picker (desktop IPC `pick_file`); three new settings `editor.completion.autoPopup`, `editor.completion.delayMs` (0–2000), `editor.hover.delayMs` (100–3000) applied live to open editors through CodeMirror compartments; `settings.open {section?, query?}`. Tests: engine `settings::tests::assist_defaults_and_validation`, control `events.rs` defaults, Vitest `ui/tests/settings/StringSettings.test.ts` (12) and `ui/tests/editor/assist/settings.test.ts` (6, fake timers). Checked in the app on Windows 11 (bundled UI, control port 7954, screenshots read); "Browse…" not clicked live (no synthetic input), covered by Vitest | | Plug-ins | 0.5 | 0% | everything | ~120 (est.) | — | | AI features | 0.5 | 0% | everything | ~60 (est.) | — | @@ -65,6 +65,7 @@ The project tree is the first user-visible feature (Project view 8%, estimated); | Date | Change | Summary | |---|---|---| +| 2026-10-24 | minor | H4: Settings 7% → 8% (est.), string and path controls, completion and tooltip settings; hours 60 → 58 | | 2026-10-22 | minor | C4 review: breadth recounted against the feature map, 32/155 | | 2026-10-22 | minor | M3.5: Navigation 10% → 13% (est.), go to definition and find references; Refactoring 0% → 3% (est.), rename; hours 102 → 96 and 250 → 244 | | 2026-10-22 | minor | M3.4: Code completion 0% → 5% (est.), completion, hover and signature help from Phpactor; hours 250 → 240; breadth 26/155 | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 3d35a8e..6d745f8 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # 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), app menu (M3.9), Terminal tool window and bottom panel tabs (M3.6), Problems tool window and editor diagnostics (M3.3), completion, quick documentation and parameter info (M3.4) · **Last updated:** 2026-10-22 +> **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), Terminal tool window and bottom panel tabs (M3.6), Problems tool window and editor diagnostics (M3.3), completion, quick documentation and parameter info (M3.4), string and path settings with completion and tooltip settings (H4) · **Last updated:** 2026-10-24 - [ ] 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. @@ -20,6 +20,7 @@ - M1.8 (2026-10-16): command palette (`Mod+Shift+P`) over every user-facing command, engine and UI (commands with a menu path or default shortcut, plus UI commands): fuzzy ranking on the label and the id (prefix, word prefix, word starts, substring, in-order characters), recently run commands first, shortcuts shown, disabled commands dimmed and not runnable, arrow keys, Enter, Escape, focus returned on close; a failing command raises an error toast. One global keymap (`ui/src/commands/`) matches every command's default shortcut by key code; UI commands `palette.open`, `settings.open` (`Mod+,`, opens the settings dialog since M1.9b) and `view.toggleProjectTree` (`Mod+1`). Vitest (keymap, ranking, store, palette, App); live check pending (gaming mode). Missing: files, classes, symbols and text tabs (search everywhere), settings in the results, synonyms and abbreviations, inline toggles, assigning a shortcut from the palette, recent commands across restarts. M1.15: one modal at a time; running any command (also as a `uiCommand`) closes the palette, opening the palette closes the settings dialog and the close question. Behaviour notes: `plan/phpstorm/05-palette.md`. - [ ] Settings dialog with search - M1.9b (2026-10-16): dialog (`Mod+,`, palette, control channel) built from `settings.list`: sections on the left, controls by type (select, number with min/max, switch), labels and descriptions from the catalog, search over label, description, key and section with matches grouped by section, Reset to default per setting, changes applied at once with inline errors, live updates on `settingsChanged`, theme picker (`appearance.theme`, switches at once), editor font size applied to the editor; Escape closes, focus trapped, every control reachable by Tab. Vitest (14 tests); live check pending (gaming mode). Missing: a tree of nested categories, project-level settings and their marker, modified markers, highlighting matches, export/import, more settings (keymap, code style, inspections). Behaviour notes: `plan/phpstorm/06-settings.md`. + - H4 (2026-10-24): every string setting gets a text field (applied on Enter or leaving it; refused in place with a catalog hint for quotes or spaces around a path, control characters, more than 4,096 bytes); a path setting (key ending in `path`/`executable`: `php.executable`, `phpactor.path`, and M4.1's `git.executable` without UI changes) also gets "Browse…" with the native file picker and "Detected automatically" while empty; string rows stack the field under the text at full width. New Editor settings: completion auto popup, completion popup delay, documentation tooltip delay, read live by the editor. `settings.open {section?, query?}` for agents. Vitest (12 control tests, 6 live-wiring tests). Checked in the app (bundled UI, control port 7954): PHP section with both path fields, a value set over the control channel shown at once (plus the toolchain's PHP toast), the new Editor settings changed live, an out-of-range hover delay refused by the engine, search "delay"; screenshots read; the user's settings restored afterwards. "Browse…" was not clicked in the app (no synthetic input); Vitest covers it with a mocked picker. - [ ] Keymap editor (Lutra's own default keymap; no copied keymaps) - M1.8 (2026-10-16): the global keymap built from the default shortcuts of engine and UI commands; no user keymap and no editor yet. - [ ] Light and dark themes from theme tokens @@ -31,7 +32,7 @@ - [ ] Problems tool window - M3.3 (2026-10-21): a Problems tab in the bottom panel (next to Find and Terminal): the language server's diagnostics of every reported file, grouped by file (name, directory, count), errors first, then by position; each row with a Lucide severity icon in a token colour (error `--lt-error`, warning `--lt-accent`, info and hint `--lt-fg-muted`), the message, source and code, and the 1-based position; a status line with totals or the server state (starting, restarting, failed, not running). Click or Enter reveals the position (`editor.reveal`), arrows / Page / Home / End move. `problems.open` `Mod+Alt+P` (Lutra's own), menu View/Problems. In the editor: wavy underlines per severity, a gutter dot and the message with source and code on hover (CodeMirror lint, tokens only), mapped through edits until the next publication. Diagnostics come from Phpactor, not from Lutra's own inspections. Vitest; live check with the real Phpactor on Windows 11. Missing: a current-file tab or filter, severity filters, sort and group options, quick-fixes (code actions), the editor's problem counter, scrollbar marks, next/previous problem. Behaviour notes: `plan/phpstorm/11-problems.md`. - [ ] Code completion popup, quick documentation, parameter info - - M3.4 (2026-10-22): CodeMirror's completion list with Lutra's triggers, a Lucide icon per kind (with the kind's catalog name as tooltip), the matched characters in `--lt-accent`, detail on the right, documentation beside the list; quick documentation as a tooltip on hover (350 ms) and on `editor.quickDocumentation` `Mod+I`; parameter info above the cursor with the active parameter bold in `--lt-accent`, a counter for overloads and the parameter's documentation; `editor.complete` and `editor.parameterInfo` in the palette and the Edit menu. Markdown rendered without HTML, tokens only. Checked in the app with the real Phpactor (screenshots). Missing: the documentation popup's toolbar and links, a documentation tool window, completion and tooltip settings, type info. Behaviour notes: `plan/phpstorm/12-completion.md`. + - M3.4 (2026-10-22): CodeMirror's completion list with Lutra's triggers, a Lucide icon per kind (with the kind's catalog name as tooltip), the matched characters in `--lt-accent`, detail on the right, documentation beside the list; quick documentation as a tooltip on hover (350 ms) and on `editor.quickDocumentation` `Mod+I`; parameter info above the cursor with the active parameter bold in `--lt-accent`, a counter for overloads and the parameter's documentation; `editor.complete` and `editor.parameterInfo` in the palette and the Edit menu. Markdown rendered without HTML, tokens only. Checked in the app with the real Phpactor (screenshots). Missing: the documentation popup's toolbar and links, a documentation tool window, type info, completion settings beyond auto popup and delays (case sensitivity, sorting). H4: auto popup on/off, popup delay and hover delay from Settings › Editor, applied live to open editors. Behaviour notes: `plan/phpstorm/12-completion.md`. - [ ] Go to file / class / symbol popup - M2.6 (2026-10-17): one popup with Files / Classes / Symbols tabs (Tab / Shift+Tab or a click; the text stays), opened by `goto.fileOpen` `Mod+P`, `goto.classOpen` `Mod+Alt+C`, `goto.symbolOpen` `Mod+T` (Lutra's own keys) or by an agent with `{query}`; live fuzzy results (60 ms debounce, stale answers dropped) with matched characters marked, a Lucide icon per kind, the directory, namespace or container beside the name, library (vendor) rows dimmed with a label; an indexing hint with progress, re-queried on `indexReady`; arrows / Page keys move, Enter or a click opens through `editor.reveal`, Escape or a click outside closes; an exclusive modal. Checked in the running app. Missing: recent files on an empty query, a non-project toggle, file-type filter, `:line` suffixes, preview, more tabs (actions, text), sending results to Find. - [ ] Find tool window @@ -44,6 +45,7 @@ | Date | Change | Summary | |---|---|---| +| 2026-10-24 | minor | Settings dialog: string and path controls, completion and tooltip settings (H4) | | 2026-10-22 | minor | Completion popup, quick documentation and parameter info partial (M3.4) | | 2026-10-21 | minor | Problems tool window partial, editor diagnostics (M3.3) | | 2026-10-19 | minor | Main menu partial (M3.9) | diff --git a/ui/src/components/editor/assist/hover.ts b/ui/src/components/editor/assist/hover.ts index b25f17a..fbbb8b7 100644 --- a/ui/src/components/editor/assist/hover.ts +++ b/ui/src/components/editor/assist/hover.ts @@ -10,7 +10,7 @@ import { renderMarkdown } from "./markdown"; import { engineAssistTransport, queryAt } from "./request"; import { toHover, type AssistBuffer, type AssistTransport } from "./types"; -/** Milliseconds the pointer rests before the hover is asked for. */ +/** Default milliseconds the pointer rests before the hover is asked for (`editor.hover.delayMs`). */ export const HOVER_DELAY = 350; /** @@ -60,10 +60,15 @@ export async function hoverAt( * * @param buffer - the buffer the editor state shows. * @param transport - how to reach the engine. + * @param delay - milliseconds the pointer rests before the hover is asked for. */ -export function lspHover(buffer: AssistBuffer, transport: AssistTransport = engineAssistTransport): Extension { +export function lspHover( + buffer: AssistBuffer, + transport: AssistTransport = engineAssistTransport, + delay: number = HOVER_DELAY, +): Extension { return hoverTooltip((view, pos) => hoverAt(view, pos, buffer, transport), { - hoverTime: HOVER_DELAY, + hoverTime: delay, hideOnChange: true, }); } diff --git a/ui/src/components/editor/assist/index.ts b/ui/src/components/editor/assist/index.ts index c5984ec..58714c8 100644 --- a/ui/src/components/editor/assist/index.ts +++ b/ui/src/components/editor/assist/index.ts @@ -5,8 +5,10 @@ * queries, see `request.ts`). * * {@link assistExtensions} is the hook the editor uses: PHP files of a - * buffer get the extensions, everything else none. Colours come from - * `--lt-*` tokens only; strings from the catalog. + * buffer get the extensions, everything else none. Completion and hover + * follow the assist settings live (`settings.ts`: auto popup, completion + * delay, hover delay). Colours come from `--lt-*` tokens only; strings + * from the catalog. */ import { autocompletion } from "@codemirror/autocomplete"; import type { Extension } from "@codemirror/state"; @@ -17,6 +19,7 @@ import { itemOf, lspCompletionSource } from "./completion"; import { lspHover } from "./hover"; import { kindIcon } from "./icons"; import { engineAssistTransport } from "./request"; +import { liveAssistSettings, storeAssistSettings, type AssistSettings, type AssistSettingsSource } from "./settings"; import { lspSignatureHelp } from "./signature"; import type { AssistBuffer, AssistTransport } from "./types"; @@ -122,30 +125,48 @@ const assistTheme: Extension = EditorView.theme({ }, }); +/** + * The completion extension for given settings: typing opens the list only + * with auto popup on, after the completion delay. + * + * @param buffer - the buffer the editor state shows. + * @param transport - how to reach the engine. + * @param settings - the assist settings. + */ +function completionExtension(buffer: AssistBuffer, transport: AssistTransport, settings: AssistSettings): Extension { + return autocompletion({ + override: [lspCompletionSource(buffer, transport)], + activateOnTyping: settings.autoPopup, + activateOnTypingDelay: settings.completionDelay, + icons: false, + addToOptions: [{ render: (completion) => kindIcon(completion.type ?? "text"), position: 20 }], + optionClass: (completion) => (itemOf.get(completion)?.deprecated === true ? "lt-assist-deprecated" : ""), + }); +} + /** * The assist extensions of an editor state. * * @param path - project-relative path of the file. * @param buffer - the buffer it shows; none for states without one. * @param transport - how to reach the engine. + * @param settings - where the assist settings come from; the settings store by default. * @returns the extensions; empty unless a PHP file of a buffer. */ export function assistExtensions( path: string, buffer: AssistBuffer | undefined, transport: AssistTransport = engineAssistTransport, + settings: AssistSettingsSource = storeAssistSettings, ): Extension { if (!buffer || languageOf(path) !== "php") { return []; } return [ - autocompletion({ - override: [lspCompletionSource(buffer, transport)], - icons: false, - addToOptions: [{ render: (completion) => kindIcon(completion.type ?? "text"), position: 20 }], - optionClass: (completion) => (itemOf.get(completion)?.deprecated === true ? "lt-assist-deprecated" : ""), - }), - lspHover(buffer, transport), + liveAssistSettings(settings, [ + (values) => completionExtension(buffer, transport, values), + (values) => lspHover(buffer, transport, values.hoverDelay), + ]), lspSignatureHelp(buffer, transport), assistTracker(buffer, transport), assistTheme, diff --git a/ui/src/components/editor/assist/settings.ts b/ui/src/components/editor/assist/settings.ts new file mode 100644 index 0000000..68f097b --- /dev/null +++ b/ui/src/components/editor/assist/settings.ts @@ -0,0 +1,195 @@ +/** + * The settings of code assistance (H4), read live from the settings store: + * + * - `editor.completion.autoPopup` (bool, default true): whether typing + * opens the completion list; the completion shortcut always does. + * - `editor.completion.delayMs` (0–2000, default 0): how long typing has + * to pause before completion is asked for. + * - `editor.hover.delayMs` (100–3000, default 350): how long the pointer + * rests before the hover documentation is asked for. + * + * {@link liveAssistSettings} keeps an editor state's completion and hover + * extensions in step with these values: a change from the dialog, the + * control channel or an agent reconfigures every open editor at once. + */ +import type { Extension } from "@codemirror/state"; +import { Compartment, StateEffect, StateField } from "@codemirror/state"; +import { ViewPlugin, type EditorView } from "@codemirror/view"; +import { getActivePinia } from "pinia"; +import { watch } from "vue"; +import { useSettingsStore } from "../../../stores/settings"; + +/** The assist settings with values the editor can use. */ +export interface AssistSettings { + /** Whether typing opens the completion list. */ + autoPopup: boolean; + /** Milliseconds typing pauses before completion is asked for. */ + completionDelay: number; + /** Milliseconds the pointer rests before the hover is asked for. */ + hoverDelay: number; +} + +/** Setting keys of the assist settings. */ +export const ASSIST_SETTING_KEYS = { + autoPopup: "editor.completion.autoPopup", + completionDelay: "editor.completion.delayMs", + hoverDelay: "editor.hover.delayMs", +} as const; + +/** The engine's defaults, used while a value is missing or unusable. */ +export const ASSIST_DEFAULTS: Readonly = { + autoPopup: true, + completionDelay: 0, + hoverDelay: 350, +}; + +/** Where the assist settings come from, and how changes are followed. */ +export interface AssistSettingsSource { + /** The current values. */ + current(): AssistSettings; + /** + * Calls `listener` after the values change. + * + * @returns a function that stops following. + */ + subscribe(listener: () => void): () => void; +} + +/** + * A whole number from untrusted data, clamped to a range. + * + * @param value - the data. + * @param min - smallest value. + * @param max - largest value. + * @param fallback - used when the data is no finite number. + */ +function clampInt(value: unknown, min: number, max: number, fallback: number): number { + if (typeof value !== "number" || !Number.isFinite(value)) { + return fallback; + } + return Math.min(max, Math.max(min, Math.round(value))); +} + +/** + * Reads the assist settings from setting values (unchecked), with the + * defaults for missing or malformed values and numbers clamped to the + * engine's ranges. + * + * @param values - setting values by key. + */ +export function toAssistSettings(values: Readonly>): AssistSettings { + const autoPopup = values[ASSIST_SETTING_KEYS.autoPopup]; + return { + autoPopup: typeof autoPopup === "boolean" ? autoPopup : ASSIST_DEFAULTS.autoPopup, + completionDelay: clampInt(values[ASSIST_SETTING_KEYS.completionDelay], 0, 2000, ASSIST_DEFAULTS.completionDelay), + hoverDelay: clampInt(values[ASSIST_SETTING_KEYS.hoverDelay], 100, 3000, ASSIST_DEFAULTS.hoverDelay), + }; +} + +/** + * Whether two sets of assist settings are equal. + * + * @param a - one set. + * @param b - the other. + */ +export function sameAssistSettings(a: AssistSettings, b: AssistSettings): boolean { + return a.autoPopup === b.autoPopup && a.completionDelay === b.completionDelay && a.hoverDelay === b.hoverDelay; +} + +/** + * The settings store of the active Pinia as a source. Without an active + * Pinia (an editor used outside the app) it gives the defaults and never + * changes. + */ +export const storeAssistSettings: AssistSettingsSource = { + current() { + const pinia = getActivePinia(); + return pinia ? toAssistSettings(useSettingsStore(pinia).values) : { ...ASSIST_DEFAULTS }; + }, + subscribe(listener) { + const pinia = getActivePinia(); + if (!pinia) { + return () => undefined; + } + const store = useSettingsStore(pinia); + return watch( + () => toAssistSettings(store.values), + (next, previous) => { + if (!sameAssistSettings(next, previous)) { + listener(); + } + }, + ); + }, +}; + +/** Records which settings an editor state's assist extensions were built with. */ +const applied = StateEffect.define(); + +/** The settings the state's assist extensions use. */ +const appliedField = StateField.define({ + create: () => ({ ...ASSIST_DEFAULTS }), + update: (value, tr) => { + for (const effect of tr.effects) { + if (effect.is(applied)) { + return effect.value; + } + } + return value; + }, +}); + +/** Builds an extension for the given settings. */ +export type SettingsBuilder = (settings: AssistSettings) => Extension; + +/** + * Extensions that depend on the assist settings and follow them live. + * Each builder sits in its own compartment; when the source reports a + * change (or a view gets a state built with older values), the + * compartments are reconfigured with the new values. The reconfiguration + * is dispatched outside any editor update. + * + * @param source - where the settings come from. + * @param builders - one builder per settings-dependent extension. + * @returns the extensions, built with the current values. + */ +export function liveAssistSettings(source: AssistSettingsSource, builders: readonly SettingsBuilder[]): Extension { + const initial = source.current(); + const slots = builders.map((build) => ({ build, compartment: new Compartment() })); + const sync = (view: EditorView): void => { + const next = source.current(); + if (sameAssistSettings(next, view.state.field(appliedField))) { + return; + } + view.dispatch({ + effects: [ + ...slots.map((slot) => slot.compartment.reconfigure(slot.build(next))), + applied.of(next), + ], + }); + }; + const follower = ViewPlugin.define((view) => { + let live = true; + const stop = source.subscribe(() => { + if (live) { + sync(view); + } + }); + queueMicrotask(() => { + if (live) { + sync(view); + } + }); + return { + destroy() { + live = false; + stop(); + }, + }; + }); + return [ + appliedField.init(() => initial), + ...slots.map((slot) => slot.compartment.of(slot.build(initial))), + follower, + ]; +} diff --git a/ui/src/components/settings/SettingsDialog.vue b/ui/src/components/settings/SettingsDialog.vue index 9ecc46b..4e77826 100644 --- a/ui/src/components/settings/SettingsDialog.vue +++ b/ui/src/components/settings/SettingsDialog.vue @@ -3,27 +3,33 @@ * The settings dialog (`settings.open`, `Mod+,`), built from the engine's * `settings.list`: sections on the left, the settings of the chosen * section on the right, each with its control by type (enum → select, - * int → number field with min/max, bool → switch), label and description - * from the catalog, and "Reset to default" when it differs from the - * default. + * int → number field with min/max, bool → switch, string → text field, + * plus "Browse…" for a path, see `stringSetting.ts`), label and + * description from the catalog, and "Reset to default" when it differs + * from the default. * * - **Search:** the field filters by label, description, key and section * name; while it has text, every match shows, grouped by section. - * - **Changes** apply at once through `settings.set` (a number when the - * field is committed: Enter, the spinner or leaving it). A refused value - * shows its error under the control and keeps the typed text. + * - **Changes** apply at once through `settings.set` (a number or a text + * when the field is committed: Enter, the spinner or leaving it; a path + * when the file picker returns one). A refused value shows its error + * under the control and keeps the typed text. * - **Live:** values follow `settingsChanged` through the settings store, * so a change over the control channel shows while the dialog is open. * - **Keyboard:** Escape closes, Tab and Shift+Tab stay inside the dialog, * and the focus returns to where it was. * - **One modal:** opening the dialog closes the palette or the close * question (see `commands/modals.ts`). + * - **Agents:** `settings.open {section?, query?}` opens on a section or + * with a search, so the dialog can be shown over the control channel + * without clicks. */ import { X } from "@lucide/vue"; import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from "vue"; import { useModalsStore } from "../../commands/modals"; import { useCommandsStore } from "../../commands/store"; import { t } from "../../i18n"; +import { pickFile, type JsonValue } from "../../ipc"; import { descriptionOf, groupSections, @@ -34,6 +40,7 @@ import { type SettingDef, type SettingSection, } from "../../stores/settings"; +import { checkString, isPathSetting, placeholderOf } from "./stringSetting"; const commands = useCommandsStore(); const settings = useSettingsStore(); @@ -45,7 +52,7 @@ const open = ref(false); const query = ref(""); /** Id of the chosen section. */ const current = ref(null); -/** Text typed into number fields, by key; shown while their value is refused. */ +/** Text typed into number and text fields, by key; shown while their value is refused. */ const drafts = reactive>({}); /** The dialog element. */ const dialog = ref(null); @@ -105,6 +112,21 @@ function numberText(def: SettingDef): string { return typeof value === "number" ? String(value) : ""; } +/** + * The text of a text field: the refused draft while there is an error, + * else the value. + * + * @param def - the setting. + */ +function stringText(def: SettingDef): string { + const draft = drafts[def.key]; + if (draft !== undefined && settings.errors[def.key] !== undefined) { + return draft; + } + const value = settings.values[def.key]; + return typeof value === "string" ? value : ""; +} + /** * The value of a select. * @@ -172,6 +194,56 @@ async function onNumber(def: SettingDef, event: Event): Promise { } } +/** + * Sends a text to `settings.set` after the checks of + * {@link checkString}; a refused text stays in the field with its error. + * + * @param def - the setting. + * @param text - the new value. + */ +async function applyString(def: SettingDef, text: string): Promise { + drafts[def.key] = text; + const error = checkString(def, text); + if (error !== null) { + settings.setError(def.key, error); + return; + } + if (await settings.set(def.key, text)) { + Reflect.deleteProperty(drafts, def.key); + } +} + +/** + * Applies a committed text field. + * + * @param def - the setting. + * @param event - the change event. + */ +async function onString(def: SettingDef, event: Event): Promise { + const target = event.target; + if (target instanceof HTMLInputElement) { + await applyString(def, target.value); + } +} + +/** + * "Browse…" of a path setting: shows the native file picker and applies + * the chosen file. Cancelling changes nothing; a picker that cannot open + * shows its error under the control. + * + * @param def - the setting. + */ +async function onBrowse(def: SettingDef): Promise { + const picked = await pickFile(t("settings.dialog.browseTitle", { name: labelOf(def) })); + if (!picked.ok) { + settings.setError(def.key, t("settings.error.browseFailed", { message: picked.error.message })); + return; + } + if (picked.value !== null) { + await applyString(def, picked.value); + } +} + /** * Flips a switch. * @@ -202,8 +274,13 @@ function choose(id: string): void { query.value = ""; } -/** Opens the dialog (or focuses its search field) and reloads the settings. */ -async function show(): Promise { +/** + * Opens the dialog (or focuses its search field) and reloads the settings. + * + * @param params - optional `{section?, query?}` from `settings.open`: + * the section id to show, the search text; anything else is ignored. + */ +async function show(params?: JsonValue): Promise { modals.opened("settings", close); if (!open.value) { const active = document.activeElement; @@ -211,6 +288,14 @@ async function show(): Promise { query.value = ""; open.value = true; } + if (typeof params === "object" && params !== null && !Array.isArray(params)) { + if (typeof params.section === "string") { + choose(params.section); + } + if (typeof params.query === "string") { + query.value = params.query.slice(0, 200); + } + } await nextTick(); search.value?.focus(); await settings.load(); @@ -295,7 +380,7 @@ function onFocusIn(event: FocusEvent): void { } onMounted(() => { - withdraw = commands.provide("settings.open", { run: show }); + withdraw = commands.provide("settings.open", { run: (params) => show(params) }); document.addEventListener("focusin", onFocusIn); }); @@ -419,6 +504,7 @@ defineExpose({ show, close }); v-for="def in section.settings" :key="def.key" class="settings__row" + :class="{ 'settings__row--wide': def.type === 'string' }" :data-key="def.key" data-test="settings-row" > @@ -478,6 +564,32 @@ defineExpose({ show, close }); data-test="settings-control" @change="onNumber(def, $event)" > +