A2: engine half of files changed on disk and Local History v1

- Disk conflicts per buffer (changed / removed), reported in buffer.get
  as diskConflict; diskConflictResolved when settled.
- Every watcher event only means "look again": delete + create (git
  checkout, atomic saves) reloads instead of losing the buffer; a file that
  disappears keeps its buffer as unsaved.
- file.save checks mtime + hash and fails with disk_changed instead of
  overwriting a newer file (overwrite: true after asking); saveAll lists
  such buffers under diskChanged. New file.reload and file.readDisk.
- Local History store in the data dir (content-addressed SHA-256 blobs,
  index.jsonl, 14 days / 200 MB, pruned on open); snapshots on save,
  before reloads, on deletion, before lsp.rename and file-changing git
  commands. Commands history.list / history.read / history.revert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-08 12:09:16 +01:00
parent 7f309dbc4e
commit dfe2f19ca5
17 changed files with 1953 additions and 116 deletions

View file

@ -300,7 +300,9 @@ pub(super) fn start_then(
start(state, command, Op::Custom { mutates, run }, Some(then))
}
/// Runs `op` on a new thread and returns the pending outcome.
/// Runs `op` on a new thread and returns the pending outcome. A command
/// that changes files first snapshots the open buffers into the Local
/// History ([`crate::history::before_git`]).
///
/// # Errors
/// [`EngineError::Disabled`] without a project, [`EngineError::Failed`]
@ -311,6 +313,7 @@ fn start(
op: Op,
then: Option<ThenFn>,
) -> Result<Outcome, EngineError> {
crate::history::before_git(state, command);
let project = state
.project
.as_ref()