A2: disk-conflict banner, overwrite question and Local History dialog

- Banner inside the editor pane for a dirty tab whose file changed
  (Reload (discard mine) / Keep mine / Compare) or was deleted (Keep as
  unsaved / Close); state in stores/diskConflicts.ts, the old notice is gone.
- Save and save all ask Overwrite / Cancel when the engine refuses with
  disk_changed.
- Diff tabs against the disk text (file.readDisk) and a Local History
  entry (history.read); "Revert to This" in the caption.
- Show Local History dialog (history.show: tree context menu, palette,
  File menu) with Show Diff and an undoable Revert to This.
- History failures warn once until a snapshot works again.
- Docs: docs/local-history.md, G2 in gaps.md, ui-parity, architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-08 12:23:14 +01:00
parent dfe2f19ca5
commit d2344bf216
29 changed files with 1999 additions and 52 deletions

View file

@ -125,6 +125,9 @@ pub struct History {
next_id: u64,
/// Most bytes the blobs may take: [`MAX_BYTES`], smaller in tests.
max_bytes: u64,
/// A failed snapshot was reported and none has succeeded since, so
/// further failures stay quiet.
warned: bool,
}
/// Milliseconds since the Unix epoch; 0 before it.
@ -171,6 +174,7 @@ impl History {
blobs: BTreeMap::new(),
next_id: 1,
max_bytes: MAX_BYTES,
warned: false,
};
history.load()?;
let dropped = history.prune(now);
@ -449,13 +453,20 @@ fn warn(state: &mut State, message: String) {
/// Takes a snapshot of `text` for the project-relative `path`. Best
/// effort: without a history nothing happens, and a failure is reported as
/// a warning instead of failing the caller, because a save or a reload must
/// not stop for the history.
/// not stop for the history. Only the first failure after a success is
/// reported, so a full disk does not raise one warning per save.
pub fn snapshot(state: &mut State, path: &Path, text: &str, bom: bool, reason: Reason) {
let Some(history) = state.history.as_mut() else {
return;
};
if let Err(message) = history.record(&path_string(path), text, bom, reason, SystemTime::now()) {
warn(state, message);
match history.record(&path_string(path), text, bom, reason, SystemTime::now()) {
Ok(_) => history.warned = false,
Err(message) => {
if !history.warned {
history.warned = true;
warn(state, message);
}
}
}
}