PM: merge F1 vcs fixes, git.lastMessage, shared git status store
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
89df12f408
14 changed files with 649 additions and 314 deletions
|
|
@ -565,7 +565,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
- Caps: status 64 MiB, one file 32 MiB, other reads 16 MiB, stderr 16 KiB (the error text, also a failing hook's output; stdout is used when stderr is empty).
|
||||
- Output is read only from machine formats: `status --porcelain=v2 -z --branch`, `cat-file --batch-check`, `for-each-ref` with NUL-separated fields, `show -s --format=%H%x00%s`. The parsers are property-tested with random bytes. Paths git prints that are not UTF-8 (Unix only) become U+FFFD instead of failing the status.
|
||||
- `Git::detect(setting)` runs `git --version`; `Git::open(dir)` runs `rev-parse --show-toplevel --absolute-git-dir --git-common-dir --show-prefix` and gives `None` outside a work tree (the repository containing the project root; a nested repository wins). Paths in and out of `Repo` are project-relative with `/`; the prefix maps them to the repository root, and files outside the project are left out of the status. Input paths are refused when empty, absolute, with `..`, NUL or line breaks; they go to git through `--pathspec-from-file=- --pathspec-file-nul`, so any count and any name works.
|
||||
- Operations: `status` (untracked files one by one, ignored files not listed), `head` (branch information only, `--untracked-files=no`), `stage` (`add -A`), `unstage` (`reset -q HEAD`, or `rm --cached` before the first commit), `commit` (`-F -` from stdin, `--cleanup=whitespace` so lines starting with `#` stay), `show` (the blob as stored: no smudge filters, no line-ending conversion, so LFS stays a pointer and nothing reaches the network; binary when a NUL is in the first 8000 bytes, the text is not UTF-8, or the entry is a submodule; a UTF-8 BOM is dropped), `branches`, `checkout` (local branch: `switch`; remote branch `origin/x`: `switch --track`, a local tracking branch), `create_branch` (name checked with `check-ref-format --branch`, which must echo the name unchanged, so `@{-1}` is refused; `switch -c` or `branch --end-of-options`). Names and revisions starting with `-` are refused. Changes hold a per-repository mutex.
|
||||
- Operations: `status` (untracked files one by one, ignored files not listed), `head` (branch information only, `--untracked-files=no`), `stage` (`add -A`), `unstage` (`reset -q HEAD`, or `rm --cached` before the first commit), `commit` (`-F -` from stdin, `--cleanup=whitespace` so lines starting with `#` stay), `show` (the blob as stored: no smudge filters, no line-ending conversion, so LFS stays a pointer and nothing reaches the network; binary when a NUL is in the first 8000 bytes, the text is not UTF-8, or the entry is a submodule; a UTF-8 BOM is dropped), `branches`, `checkout` (local branch: `switch`; remote branch `origin/x`: `switch -c x --track` when a configured `remote.<name>.fetch` refspec maps a branch to it, the local name taken from that refspec as git does; otherwise, such as a removed remote or a hand-made ref, `switch -c x --no-track`, because git would update the work tree before failing on the tracking setup and leave it dirty; C6 F1), `last_message` (`show -s --format=%B HEAD`, none before the first commit; C6 F1), `create_branch` (name checked with `check-ref-format --branch`, which must echo the name unchanged, so `@{-1}` is refused; `switch -c` or `branch --end-of-options`). Names and revisions starting with `-` are refused. Changes hold a per-repository mutex.
|
||||
- `RepoWatch` polls `HEAD`, `index`, `MERGE_HEAD`, `ORIG_HEAD`, `packed-refs` and the files under `refs/heads` and `refs/remotes` (at most 4,096) every 250 ms on its own thread, comparing size and modification time. The project watcher never sees `.git`, and OS notifications on a directory whose object store churns on every commit would be noisier than a few `stat` calls. `rebase()` takes the current state as the baseline after Lutra's own change.
|
||||
- **Engine (`crates/engine/src/cmd/git.rs`):** every `git.*` command returns a pending outcome (M3.5). Under the lock it parses its params and takes the setting, the cached git and the cached repository; a `lutra-git` thread detects git and opens the repository when they are not cached, runs the call and fills a reply slot (the `Pending` channel only signals). The finish caches git (per setting value) and the repository (per project root), starts the watch, and emits `gitChanged` after a change. At most 32 calls run at once. Hosts and the UI call these commands with `run_waiting` / `runWaiting`.
|
||||
- **Commands** (all need a project):
|
||||
|
|
@ -574,7 +574,8 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
- `git.commit {message, amend?}` → `{commit, summary}`; a blank message is `invalid_params`.
|
||||
- `git.show {path, ref: "HEAD"|"index"}` → `{text|null, binary, tooLarge}`.
|
||||
- `git.branches` → `{current|null, local: [{name, head, upstream?}], remote: [{name, head}]}` sorted by name, without `origin/HEAD`.
|
||||
- `git.checkout {branch}` → `{}`; git's refusal is the error text. Open buffers follow through the file watcher.
|
||||
- `git.lastMessage` → `{message|null}`: the full message of HEAD without trailing line breaks, null before the first commit (C6 F1, for the Amend prefill). Read-only, no `gitChanged`.
|
||||
- `git.checkout {branch}` → `{}`; git's refusal is the error text. A remote branch without a configured remote becomes an untracked local branch (C6 F1). Open buffers follow through the file watcher.
|
||||
- `git.createBranch {name, from?, checkout}` → `{}`.
|
||||
- Bad paths, names or messages are `invalid_params`; everything git refuses is `failed` with git's message; no project is `disabled`.
|
||||
- **Event `gitChanged {available, repo, filesChanged: true}`:** after every successful change (in the same outcome), and 300 ms after the last change the `.git` watch or the project watcher reported (at most 2 s after the first), from a `head()` query on its own thread. The UI re-queries `git.status`.
|
||||
|
|
@ -588,7 +589,8 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
|
||||
- **Where:** a Changes tab in the bottom panel (`ui/src/components/vcs/changes/`): `changes.ts` is the Pinia store, `ChangesToolWindow.vue` the window. The main layout starts the store when it mounts, so the status is current before the tab opens, and supplies the UI commands.
|
||||
- **Commands** (UI commands, menu group Git): `vcs.openChanges` `Mod+Alt+Shift+G` shows the tab; `vcs.commit` `Mod+Alt+Shift+M` shows it and focuses the message box; `vcs.refresh` re-reads the status (enabled while `git.status` is). The shortcuts are Lutra's own: checked against the public default keymaps (Windows and macOS) so they copy no default there, and against Lutra's registered shortcuts and CodeMirror's `basicSetup` keys (`Mod+Alt+G` is its go to line, which the global listener would swallow).
|
||||
- **Status:** `git.status` through `runWaiting` on start, on `projectOpened`, on `gitChanged` and on `vcs.refresh`; calls are serialised and requests made during a round cause exactly one more round. `projectClosed` clears it. The result is untrusted: unknown states and malformed entries are dropped, at most 50,000 files. The event type `gitChanged` is now part of `EngineEventPayload` in `ui/src/ipc.ts`.
|
||||
- **Status:** read from the shared status store (`ui/src/stores/vcsStatus.ts`, since C6 F1), which runs `git.status` on start, on `projectOpened`, on `gitChanged` and on `vcs.refresh`; `projectClosed` clears it and with it the rows and the selection. The result is untrusted: unknown states and malformed entries are dropped, at most 50,000 files.
|
||||
- **Amend prefill (C6 F1):** checking Amend with an empty message box fills it from `git.lastMessage`; clearing Amend empties a box that still holds exactly that text. A message already typed is never replaced. The event type `gitChanged` is now part of `EngineEventPayload` in `ui/src/ipc.ts`.
|
||||
- **Groups:** Staged (the index side changed), Changes (the work tree side changed, or conflicted), Untracked. A partly staged file is in Staged and Changes. Names are coloured with `--lt-vcs-*` (renamed and modified use `modified`, copied uses `added`); a deleted file is struck through. A staged rename shows "from <old path>".
|
||||
- **Staging:** a checkbox per file and per group header: checked in Staged (clearing it unstages), clear elsewhere (checking it stages). `git.stage {paths}` / `git.unstage {paths}`, both through `runWaiting`; unstaging a staged rename passes both paths, as M4.1 requires. Keyboard: Up/Down, Page Up/Down, Home, End move; Space stages or unstages; Enter opens. Failures toast git's message (`notification.command.failed`).
|
||||
- **Opening:** Enter or a double-click runs the UI command `vcs.showDiff {path, staged}` when something provides it (the diff viewer, M4.3, registers and provides it); until then the file opens with `file.open`, and a deleted file does nothing.
|
||||
|
|
@ -605,7 +607,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
- **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.
|
||||
- **Shared status store (C6 F1):** `vcsStatus` is the only caller of `git.status` in the UI. It keeps the snapshot (`snapshot`, read by `toStatus`: files, `repo` with branch, head, upstream, ahead and behind), `loading`, `loadError` (a failure keeps the last snapshot; `disabled` drops it) and the colours. The Changes window, the tree and tab colours and the branch status-bar item (M4.5) all read it, so each `gitChanged` costs one `git.status`; one round at a time, requests during a round share one more. `start` / `stop` are counted (`App.vue` and the main layout both hold it). Later features read `snapshot` and call `refresh()`, never `git.status`.
|
||||
- **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`.
|
||||
|
||||
|
|
@ -649,6 +651,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
|||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-27 | minor | C6 F1: remote branch checkout without a configured remote (`--no-track`), `git.lastMessage` and the Amend prefill, one shared git status store |
|
||||
| 2026-10-27 | minor | F2: `ui.screenshot` through WebView2 `CapturePreview` without focus; region fallback elsewhere; `--control` windows open unfocused |
|
||||
| 2026-10-26 | minor | M4.5: branches (status-bar item, popup, `vcs.branches`, `vcs.newBranch`, `vcs.checkout`) |
|
||||
| 2026-10-26 | minor | M4.3: diff viewer (`vcs.showDiff`, `vcs.nextChange`, `vcs.previousChange`, `@codemirror/merge` loaded lazily, the project tree's context menu) |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue