M4.4: Git gutter change markers and status colours in tree and tabs
- git.lineChanges {id} -> {ranges: [{kind, startLine, endLine}], version}:
the buffer against its index blob, line diff with similar (Myers +
Replace, no Compact) off the lock, CRLF-safe; index texts cached per
path and dropped on gitChanged (State::emit -> git_lines::observe)
- editor gutter markers for added, modified and deleted lines, queried
150 ms after edits, on show and on gitChanged, mapped through edits
- vcsStatus store (git.status on projectOpened and gitChanged, no
polling) colouring file names in the project tree and editor tabs with
the --lt-vcs-* tokens; contrast also checked on the active tab
- tests: unit and property tests, real-repo engine tests, Vitest
- docs: architecture, parity, gaps, roadmap, ui-parity, ROADMAP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
56dadc91dc
commit
fc8ae6c2e3
24 changed files with 1970 additions and 20 deletions
|
|
@ -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), settings dialog string and path controls and assist settings (H4), the banner-aligned themes and diagnostic/VCS tokens (H5); Git backend (M4.1), Changes tool window (M4.2) · **Last updated:** 2026-10-25
|
||||
> **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), the banner-aligned themes and diagnostic/VCS tokens (H5); Git backend (M4.1), Changes tool window (M4.2); line changes, gutter markers and status colours (M4.4) · **Last updated:** 2026-10-25
|
||||
|
||||
## Overview
|
||||
|
||||
|
|
@ -585,6 +585,19 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
- **States without a repository:** git missing or too old shows git's reason and a hint to Settings › Git executable; a project outside a repository and a clean tree say so; the status line names the branch, or the short hash when detached, or "no commits yet".
|
||||
- **Tests:** `ui/tests/vcs/ChangesToolWindow.test.ts` (19 Vitest tests against a fake engine: parsing and grouping, rename unstaging, refresh triggers and serialisation, staging per file and group, git's error as a toast, commit after `flushDirty` with the short hash, a commit cancelled by a failed save, amend without staged files, the window's status lines, checkboxes, keyboard, `vcs.showDiff` and the `file.open` fallback, the commands' shortcuts and menu paths in the layout).
|
||||
|
||||
### Line changes, gutter markers and status colours (M4.4)
|
||||
|
||||
- **`git.lineChanges {id}`** (`crates/engine/src/cmd/git_lines.rs`, a pending outcome) → `{ranges: [{kind: added|modified|deleted, startLine, endLine}], version}`: the buffer's lines against the file's blob in the index. Lines are 0-based, `endLine` exclusive; a `deleted` range has `startLine = endLine`, the removed lines were before it (at the line count when they were at the end). `version` is the buffer version the ranges are for (an addition to the C5 contract). No ranges, not an error, when the project has no repository, git is unusable or the file is not in the index (untracked, binary, over 32 MiB, conflicted); an unknown buffer is `failed`.
|
||||
- **Off the lock:** under the lock the command clones the buffer's rope (shared chunks, no copy) and takes the cached lookups; a `lutra-git-lines` thread detects git and opens the repository through `lutra-vcs` when needed, reads the blob with `Repo::show(path, Rev::Index)` when it is not cached, and diffs. At most 8 calls run at once. It keeps its own repository lookup instead of reaching into `cmd::git`'s state (no change to M4.1's file).
|
||||
- **Line endings:** both texts are split at `\n`, `\r\n` and a lone `\r`, without an empty line after a final break, so a CRLF buffer equals its LF index blob (autocrlf) and a missing final newline is not a change. The lines match CodeMirror's.
|
||||
- **Diff:** `similar` 2.7.0 (Apache-2.0, no default features, no dependencies), Myers with a 1 s deadline, adjacent deletes and inserts merged into replacements (`Replace` hook), at most 10,000 ranges. Its `Compact` step is not used: in 2.7.0 it moved a delete to a wrong position in the new text (found by the property test, kept as a unit test).
|
||||
- **Cache:** index texts per path (at most 256 files or 64 MiB, cleared when full), dropped on every `gitChanged`: `State::emit` calls `git_lines::observe` for each event (one line in `state.rs`), and a generation counter keeps a thread that started before from storing stale text. A project change drops everything. "No repository" and "no usable git" are kept for 10 s only, because no `gitChanged` arrives without a repository.
|
||||
- **Gutter** (`ui/src/components/editor/gitGutter.ts`, appended to `editorExtensions` for buffers): a 4 px gutter beside the code with a bar on added (`--lt-vcs-added`) and modified (`--lt-vcs-modified`) lines and a 3 px notch at the top of the line after deleted ones (`--lt-vcs-deleted`; at the bottom of the last line for deletions at the end), each with a catalog tooltip. A view plugin asks with `runWaiting` when the view shows the state, 150 ms after the last edit, and on `refreshGitGutters()` (every `gitChanged`); it waits for the buffer sync's `idle()` and drops answers for a document that changed meanwhile. Between answers the markers are mapped through the edits. A failure keeps the markers. Background tabs refresh when shown again.
|
||||
- **Status colours** (`ui/src/stores/vcsStatus.ts`, Pinia `vcsStatus`, started by `App.vue`): `git.status` through `runWaiting` on start, `projectOpened` and every `gitChanged` (never polled), one query at a time plus one more for requests made meanwhile, answers for a closed project dropped. A file's two states fold into one token: conflicted, untracked, ignored, added (unless deleted again in the work tree), deleted, otherwise modified. The project tree and the editor tabs colour file names with `--lt-vcs-*` classes; inside a repository the tree also gives ignored entries `--lt-vcs-ignored` (`git.status` does not list them). Directories are not coloured. The contrast test also checks the status colours on the active tab.
|
||||
- **Not shared yet:** the Changes window (M4.2) queries `git.status` itself, so a `gitChanged` costs two status calls (~100 ms each, off the lock). One shared store is a C6 follow-up.
|
||||
- **Measured** (debug build with the bundled UI, Windows 11, git 2.47.1, control port 7944, a temp repository with the owner's global `core.autocrlf`; each number includes the control round trip and the pending wait): the first `git.lineChanges` 332 ms (git detection, opening the repository, reading the blob), then 0.4–1.4 ms with the index text cached; after `git.stage` (158 ms) the next call reads the blob again and returns no ranges. Screenshots read in both themes: a modified bar, a deleted notch and an added bar where expected, no markers after staging, tabs in the modified and untracked colours, no markers for the untracked file. No keys were sent (owner at the PC).
|
||||
- **Tests:** `cmd::git_lines` unit and property tests (line splitting, kinds, line endings, empty files, cache caps and generation, ranges in order and inside the buffer); `crates/engine/tests/git_lines.rs` (4 tests against real temp repositories: added/modified/deleted, a CRLF buffer against an autocrlf LF blob, staging drops the cache, an untracked file and no repository, bad params); Vitest `ui/tests/editor/gitGutter.test.ts` (12: reading, building, query on show, debounce, stale answers, failures, refresh, mapping), `ui/tests/vcs/vcsStatus.test.ts` (colours, reading, coalescing, events, tabs) and one tree test in `ui/tests/project/ProjectTree.test.ts`.
|
||||
|
||||
## Decisions (M0)
|
||||
|
||||
| Question | Decision | Why |
|
||||
|
|
@ -602,6 +615,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-25 | minor | M4.4: `git.lineChanges` (index cache, `similar` line diff off the lock), gutter change markers, Git status colours in the tree and tabs |
|
||||
| 2026-10-25 | minor | M4.2: Changes tool window (`vcs.openChanges`, `vcs.commit`, `vcs.refresh`, staging, commit after `flushDirty`) |
|
||||
| 2026-10-25 | minor | M4.1: Git backend (`lutra-vcs`, `git.*` commands, `gitChanged`, `git.executable`) |
|
||||
| 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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue