M3.5: go to definition, find references and rename through Phpactor
Engine (`cmd/lsp_nav.rs`, on the pending outcomes of 20d1d28):
- `lsp.definition` (F12) and `lsp.references` (Shift+F12, sorted, with
line previews) return project-relative locations; locations outside
the project, such as PHAR stubs and symlink escapes, are dropped.
- `lsp.prepareRename` uses the word at the cursor when the server has
no prepareProvider.
- `lsp.rename` (F2) applies the workspace edit (`lsp_nav/edit.rs`):
1. Check everything first: inside the project, ranges fit (UTF-16,
CRLF), open buffers unchanged since the request, no file
operations, no incomplete edit.
2. Write closed files atomically through the VFS, restoring earlier
writes when a later one fails.
3. Change open buffers through `buffer.edit` (dirty, undoable).
4. Send each written file to Phpactor as didOpen/didSave/didClose
plus didChangeWatchedFiles; without this its index kept the old
names. Then the summary notification `notification.lsp.renamed`.
UI (`components/editor/nav/`):
- Mod+click goes to the definition, with a pointer cursor while Mod is
held.
- A location picker for several definitions (exclusive modal).
- A References tab in the bottom panel, grouped by file.
- An inline rename field with a use/file count (exclusive modal).
- `BufferSync.beginUndoableRemote` puts the engine's rename edit into
the editor history as one undo step per buffer.
- Catalog strings and tokens only.
Fake LSP server: `--script FILE` with scripted capabilities and
answers (additive next to M3.4's arms).
Tests:
- `crates/engine/tests/lsp_nav.rs` (fake): definition; bad positions;
references; prepareRename; a multi-file rename incl. a closed CRLF
file; refusals for outside the project, a bad range, a stale buffer,
bad names and no server.
- The ignored real-Phpactor test covers definition, references and a
rename and back across 3 files.
- Vitest `ui/tests/nav/`.
Live (Phpactor 2026.06.25.0, Windows, port 7935, tick on):
- definition 93 ms cold / 7-18 ms warm
- references ~140 ms
- prepareRename ~11 ms
- rename 28-59 ms
- index follows written files in 140 ms
- Phpactor 57 MB working set, ~1.6% of a core while ticking idle
Gate: 13 steps, 197 s, Vitest 484 + 1 skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b3fd7c6478
commit
578160a2ba
28 changed files with 3730 additions and 34 deletions
|
|
@ -462,6 +462,46 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
- Unit tests: kinds, lists, snippets, hover parts, signature spans, caps.
|
||||
- Vitest `ui/tests/editor/assist/`: triggers, the query, applying (text edits, typing since the request, imports, CRLF), the Markdown renderer (incl. an XSS set), hover, signature help and the UI commands.
|
||||
|
||||
### Definition, references, rename (M3.5)
|
||||
|
||||
- **Commands** (`crates/engine/src/cmd/lsp_nav.rs`). All take `{id, position: {line, column}}` (buffer id, 0-based, UTF-16 column) and return a pending outcome (see above):
|
||||
- `lsp.definition` (F12) returns `{locations: [{path, range}]}`.
|
||||
- `lsp.references` (Shift+F12, `includeDeclaration?` default true) returns `{locations: [{path, range, preview, previewColumn}]}`, sorted.
|
||||
- `lsp.prepareRename` returns `{range, placeholder}` or null. It uses the word at the cursor when the server has no `prepareProvider`.
|
||||
- `lsp.rename {…, newName}` (F2) returns `{files: [{path, edits, bufferId?, version?}], edits, written}`.
|
||||
- Locations are project-relative, deduplicated and capped at 10,000. Locations outside the project are dropped: Phpactor stubs inside the PHAR, other folders, symlinks that resolve outside.
|
||||
- A position outside the buffer is `invalid_params`; no running server is `failed`.
|
||||
- **Workspace edits** (`cmd/lsp_nav/edit.rs`), all or nothing as far as a file system allows:
|
||||
1. **Check everything first:**
|
||||
- The edit is complete and has no file operations.
|
||||
- Every document is inside the project.
|
||||
- Every range converts (UTF-16 columns, CRLF as one break) and applies to a copy.
|
||||
- Every open buffer is still at the version it had when the request was sent.
|
||||
2. **Write closed files**, each atomically through the VFS, keeping the BOM and line endings. If a write fails, the files written so far get their old text back; a failed restore is named in the error. No buffer is touched then.
|
||||
3. **Change open buffers** through `buffer.edit`, one batch per buffer. They become dirty and get journal, LSP and syntax updates like typing.
|
||||
4. **Follow-up:** each written file is sent to Phpactor as `didOpen` → `didSave` → `didClose` with its new text (files the user opened meanwhile are skipped), plus `workspace/didChangeWatchedFiles` for servers that watch through the client. Phpactor ignored the notification alone and kept the old names until its polling watcher noticed: in the live check a "method does not exist" error stayed, and renaming back found one use instead of four. `didOpen` alone reindexed only class files, not the member references of a function file. With all three, its index followed in 140 ms (`real_phpactor_navigates_and_renames_across_files`). Then the notification `notification.lsp.renamed {name, edits, files, written}`.
|
||||
- **Undo:** the frontend calls `BufferSync.beginUndoableRemote()` on every tab before `lsp.rename` and `endUndoableRemote(version)` after it. The engine's change to an open buffer then enters the CodeMirror history as one step, and Mod+Z reverts it through `buffer.edit`. Files written on disk are not part of any editor history. Without the UI (control channel, MCP) the change is applied the same way but is not undoable in an editor.
|
||||
- **UI** (`ui/src/components/editor/nav/`):
|
||||
- `nav.ts` (store) supplies the context of the three engine commands with `commands.provide` and calls them with `runWaiting` after the sync is idle.
|
||||
- `navExtension.ts`: Mod+click goes to the definition; the cursor becomes a pointer while Mod is held; the extension remembers the view for placing the rename field.
|
||||
- `NavPicker.vue` (exclusive modal `navPicker`), `RenameInput.vue` (exclusive modal `rename`, the preview count from `lsp.references`), `ReferencesToolWindow.vue` (bottom panel tab `references`), all mounted by `NavLayer.vue`.
|
||||
- **Tests:**
|
||||
- `crates/engine/tests/lsp_nav.rs` runs against the fake server's `--script` answers. It covers definition, bad positions, references (sorted, deduplicated, outside dropped), prepareRename with and without the server, a multi-file rename over an open buffer and two closed files (one CRLF), refusals (outside the project, a bad range, a buffer edited meanwhile, bad names) and no server.
|
||||
- The ignored `real_phpactor_navigates_and_renames_across_files` runs with `LUTRA_PHPACTOR=<phar>`.
|
||||
- Vitest: `ui/tests/nav/nav.test.ts`.
|
||||
- **Live** (Phpactor 2026.06.25.0, Windows 11, debug build, tick on, a 3-file temp project), measured:
|
||||
|
||||
| Request | Latency |
|
||||
|---|---|
|
||||
| definition across files | 93 ms cold, 7–18 ms warm |
|
||||
| references (4 uses in 3 files) | 137–150 ms |
|
||||
| prepareRename | 10–11 ms |
|
||||
| rename (4 edits, 2 files written) | 28 ms in the app, 44–59 ms in the real test |
|
||||
| index follows the written files | 140 ms |
|
||||
|
||||
- Phpactor took 57 MB working set (45 MB private) and 4 s of CPU over the session, about 1.6% of one core while ticking idle.
|
||||
- The keys and Mod+click were not pressed in the live app: sending keys would need the window focused, and the owner was using another app. Vitest covers them.
|
||||
|
||||
### Toolchain (M3.1)
|
||||
|
||||
- **Owner decision D15:** Lutra downloads the Phpactor PHAR itself; PHP is the user's (found through `php.executable` or `PATH`). Library code lives in `crates/lsp/src/toolchain/` (L3), the engine side in `crates/engine/src/cmd/toolchain.rs`.
|
||||
|
|
@ -504,6 +544,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 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 |
|
||||
| 2026-10-22 | minor | M3.5 step 1: pending outcomes (`Pending`, `Engine::resolve`, `run_waiting`), `engine_execute_waiting` / `runWaiting` |
|
||||
| 2026-10-20 | minor | M3.10: autosave (blur, tab switch, idle), `flushDirty`, `file.saveAll {skipConflicts}`, disk conflicts and own-write hashes in `Buffers` |
|
||||
|
|
|
|||
|
|
@ -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); G7 under way (`lutra` CLI and single instance, MCP server, integrated terminal); G14 English UI catalog in place · **Last updated:** 2026-10-22
|
||||
> **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); G7 under way (`lutra` CLI and single instance, MCP server, integrated terminal); G14 English UI catalog in place · **Last updated:** 2026-10-22
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ Every known shortfall, ranked. This is the work list: unless the owner gives a t
|
|||
| 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, definition, hover, rename via Phpactor (~~PHP detection and Phpactor download~~, M3.1; ~~engine wiring and diagnostics~~, M3.3; ~~completion, hover, signature help~~, M3.4) | M3 | ~23 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 |
|
||||
| G7 | ~~Terminal~~ (M3.6: PTY sessions, xterm.js sub-tabs in the bottom panel; settings, persistence, links and search still open), ~~`lutra` CLI and single instance~~ (M3.7: open folders and files at a line, `--wait`, forwarding a second start, token-protected rendezvous), ~~MCP server~~ (M3.8: `lutra mcp` with list/execute every command, screenshot, read buffer, recent events, open buffers as resources; still missing: resource and tool change notifications, progress for long commands), files outside the open project (the CLI refuses them; needs out-of-project buffers or a second window), `lutra diff` | M3 | ~16 h |
|
||||
| G8 | Git integration | M4 | ~150 h |
|
||||
| G9 | Debugger, test runner, Composer, run configurations | M5 | ~300 h |
|
||||
|
|
@ -44,12 +44,13 @@ Known smaller items from M0:
|
|||
- `ui.screenshot` captures the screen region of the window, so covering windows appear in the image; a webview-native capture would avoid that.
|
||||
- `cargo xtask fixtures` needs Composer, which the M0 machine does not have.
|
||||
|
||||
G6 progress: M3.2 landed the LSP client library in `crates/lsp`: JSON-RPC framing over stdio (32 MiB cap, malformed messages dropped and logged, fuzzed), `initialize` with UTF-16 positions, typed requests with timeouts and `$/cancelRequest`, answers to server requests, supervision with backoff restarts (give up after 5 crashes in 2 min) and reopening of documents, incremental document sync from `lutra_text` edits, all tested against a fake server. M3.3 wired it into the engine (one Phpactor per project on its own thread, ordered document sync, `lspStatus`) and shows Phpactor's diagnostics as editor underlines and in a Problems tab. It was checked against the real Phpactor on Windows, which needed three workarounds: a keep-alive tick, in-process diagnostics and a polling watcher (see `docs/architecture.md`). M3.4 added completion, hover and signature help in the editor (Phpactor's answers, Lutra's triggers, safe Markdown, measured 61–109 ms per completion while typing on Windows). Still open: navigation and rename (M3.5), slow first indexing on Windows (Phpactor advances one step per stdin message, so a 2,000-class project takes ~65 s before completion is useful), PHP lint syntax errors on Windows, quick-fixes, and killing a Phpactor process left behind when Lutra itself is killed.
|
||||
G6 progress: M3.2 landed the LSP client library in `crates/lsp`: JSON-RPC framing over stdio (32 MiB cap, malformed messages dropped and logged, fuzzed), `initialize` with UTF-16 positions, typed requests with timeouts and `$/cancelRequest`, answers to server requests, supervision with backoff restarts (give up after 5 crashes in 2 min) and reopening of documents, incremental document sync from `lutra_text` edits, all tested against a fake server. M3.3 wired it into the engine (one Phpactor per project on its own thread, ordered document sync, `lspStatus`) and shows Phpactor's diagnostics as editor underlines and in a Problems tab. It was checked against the real Phpactor on Windows, which needed three workarounds: a keep-alive tick, in-process diagnostics and a polling watcher (see `docs/architecture.md`). M3.4 added completion, hover and signature help in the editor (Phpactor's answers, Lutra's triggers, safe Markdown, measured 61–109 ms per completion while typing on Windows). M3.5 added go to definition (F12, Mod+click, a picker for several), find references (a References tab) and rename (F2, an inline field; open buffers dirty and undoable, closed files written atomically, edits outside the project refused), all through Phpactor without blocking the engine; rename has no preview list yet, and the editor's undo does not revert closed files it wrote. Still open: slow first indexing on Windows (Phpactor advances one step per stdin message, so a 2,000-class project takes ~65 s before completion is useful), PHP lint syntax errors on Windows, quick-fixes, and killing a Phpactor process left behind when Lutra itself is killed.
|
||||
|
||||
## Revision history
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-22 | minor | G6 shrunk: definition, references, rename (M3.5) |
|
||||
| 2026-10-22 | minor | G6 shrunk: completion, hover and signature help (M3.4) |
|
||||
| 2026-10-21 | minor | G6 shrunk: engine wiring and diagnostics (M3.3) |
|
||||
| 2026-10-20 | minor | G2 shrunk: autosave and `flushDirty` (M3.10) |
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
- [ ] Highlighting, including heredoc/nowdoc and embedded HTML
|
||||
- [ ] File structure: namespaces, classes, interfaces, traits, enums, functions, constants
|
||||
- [ ] Go to declaration and implementation
|
||||
- [ ] Find usages
|
||||
- [ ] Find usages (partial, M3.5: find references and go to definition through Phpactor; no scopes, no usage kinds)
|
||||
- [ ] Completion: members, functions, classes with auto-import, keywords
|
||||
- M3.4 (2026-10-22): partial, from Phpactor: members after `->`/`::`, variables, classes and keywords with hover documentation and signature help; imports applied when Phpactor sends them. No type inference of Lutra's own.
|
||||
- [ ] Type inference from declarations, PHPDoc, generics in PHPDoc
|
||||
- [ ] Diagnostics: syntax errors, undefined symbols, type mismatches
|
||||
- [ ] Refactorings: rename, extract variable/method, move class, change signature
|
||||
- [ ] Refactorings: rename (partial, M3.5: through Phpactor with an inline field; no preview list), extract variable/method, move class, change signature
|
||||
- [ ] Formatting to PSR-12 / PER coding style
|
||||
- [ ] PHPDoc generation and completion
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Hours are agent wall-clock hours for one agent; M0 and M1 so far are measured, t
|
|||
| M0 | Foundation: workspace, lints, quality gate, command registry, control channel, empty window | done 2026-10-14 (CI workflow written, not yet run: hosted on Forgejo, runners unknown) | ~2 (measured) |
|
||||
| M1 | Editor and project: open folder, tree, tabs, editor, save, recovery, palette, settings, themes | done 2026-10-16 (M1.1 text, M1.2 VFS, M1.5 tree UI, M1.3 engine workspace, M1.4 desktop bridge, M1.6 tabs and editor, M1.11 message catalog, M1.9a settings backend, M1.10 themes, M1.7 recovery journal, M1.12 notifications, M1.13 C1 follow-ups, M1.8 command palette and keymap, M1.14 app icon, M1.9b settings dialog; C2 live checks pending, gaming mode) | ~5.6 (measured: C1 2.5, C2 3.1) |
|
||||
| M2 | Syntax and search: highlighting, structure, find in files, go to file/class/symbol | done 2026-10-17 (C3: M2.1 tree-sitter syntax, M2.2 highlighting + `editor.reveal`, M2.3 search backend, M2.4 Find tool window, M2.5 symbol index + go-to commands, M2.6 go-to popup, M2.7 Structure tool window) | ~6.1 (measured) |
|
||||
| M3 | LSP, terminal, CLI: completion, diagnostics, go to definition, hover, rename; terminal; `lutra` CLI and MCP — **MVP** | in progress (M3.7 CLI and single instance, M3.8 MCP server, M3.10 autosave, M3.6 integrated terminal, M3.3 engine wiring and diagnostics, M3.4 completion, hover and signature help done) | ~12 |
|
||||
| M3 | LSP, terminal, CLI: completion, diagnostics, go to definition, hover, rename; terminal; `lutra` CLI and MCP — **MVP** | in progress (M3.7 CLI and single instance, M3.8 MCP server, M3.10 autosave, M3.6 integrated terminal, M3.3 engine wiring and diagnostics, M3.4 completion, hover and signature help, M3.5 definition, references and rename done) | ~12 |
|
||||
| M4 | Git: status, diff, commit, branches, log, blame, conflicts | not started | ~150 |
|
||||
| M5 | Debugger (Xdebug via DAP), PHPUnit/Pest runner, Composer, run configurations | not started | ~300 |
|
||||
| M6 | Own indexer and inspections; Symfony, Laravel, Shopware, WordPress support | not started | ~1,100 |
|
||||
|
|
@ -34,6 +34,7 @@ By the raw estimates the alpha gate needs M1–M4 plus cross-platform verificati
|
|||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-22 | minor | M3.5 definition, references, rename |
|
||||
| 2026-10-22 | minor | M3.4 completion, hover and signature help |
|
||||
| 2026-10-21 | minor | M3.3 engine wiring and diagnostics |
|
||||
| 2026-10-20 | minor | M3.10 autosave |
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue