M1.15: one modal at a time, restore dialog follows outside restores
- Modal rule (ui/src/commands/modals.ts): palette, settings dialog and the
close question are exclusive; opening one closes the other. Running any
command but palette.open (keyboard, palette, uiCommand) closes the
palette. The restore dialog is queued: hidden while another modal is
open, back with its list intact afterwards.
- recovery.restore / recovery.discard emit recoveryResolved {paths}; the
restore dialog drops the settled paths and closes when none are left.
Rust was needed: discard gave the UI no signal, and a restored entry
stays in the journal as the buffer's own entry.
- Dimmed restored text (C2 screenshot 09) was the dialog overlay, not an
editor style; no editor change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d12a517009
commit
1a38e68480
13 changed files with 442 additions and 12 deletions
|
|
@ -47,6 +47,15 @@ pub fn infos(state: &mut State) -> Vec<EntryInfo> {
|
|||
entries.iter().map(|e| journal::info(state, e)).collect()
|
||||
}
|
||||
|
||||
/// Emits [`Event::RecoveryResolved`] for `paths`, unless there are none.
|
||||
fn emit_resolved(state: &mut State, mut paths: Vec<String>) {
|
||||
if paths.is_empty() {
|
||||
return;
|
||||
}
|
||||
paths.sort();
|
||||
state.emit(Event::RecoveryResolved { paths });
|
||||
}
|
||||
|
||||
/// `recovery.list`: the unsaved texts the journal holds.
|
||||
pub struct List;
|
||||
|
||||
|
|
@ -123,7 +132,7 @@ impl Command for Restore {
|
|||
label: "Restore Unsaved Changes",
|
||||
menu_path: None,
|
||||
default_shortcut: None,
|
||||
params: "{ paths?: [string] (all entries if missing) }; opens each file as a dirty buffer with the journal text, line ending and BOM; returns { restored: [{ path, id }], failed: [{ path, message }] }",
|
||||
params: "{ paths?: [string] (all entries if missing) }; opens each file as a dirty buffer with the journal text, line ending and BOM; returns { restored: [{ path, id }], failed: [{ path, message }] }; emits recoveryResolved with the restored paths",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,13 +148,18 @@ impl Command for Restore {
|
|||
.into_iter()
|
||||
.map(|path| json!({ "path": path, "message": "no recovery entry" }))
|
||||
.collect();
|
||||
let mut resolved = Vec::new();
|
||||
for entry in entries {
|
||||
let path = entry.path.clone();
|
||||
match restore(state, entry) {
|
||||
Ok(id) => restored.push(json!({ "path": path, "id": id })),
|
||||
Ok(id) => {
|
||||
restored.push(json!({ "path": path, "id": id }));
|
||||
resolved.push(path);
|
||||
}
|
||||
Err(e) => failed.push(json!({ "path": path, "message": e.to_string() })),
|
||||
}
|
||||
}
|
||||
emit_resolved(state, resolved);
|
||||
Ok(Outcome::value(
|
||||
json!({ "restored": restored, "failed": failed }),
|
||||
))
|
||||
|
|
@ -162,7 +176,7 @@ impl Command for Discard {
|
|||
label: "Discard Unsaved Changes",
|
||||
menu_path: None,
|
||||
default_shortcut: None,
|
||||
params: "{ paths?: [string] (all entries if missing) }; deletes the journal entries; an open buffer with unsaved changes is journaled again; returns { discarded: [path] }",
|
||||
params: "{ paths?: [string] (all entries if missing) }; deletes the journal entries; an open buffer with unsaved changes is journaled again; returns { discarded: [path] }; emits recoveryResolved with the discarded paths",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +200,7 @@ impl Command for Discard {
|
|||
discarded.push(entry.path);
|
||||
}
|
||||
}
|
||||
emit_resolved(state, discarded.clone());
|
||||
Ok(Outcome::value(json!({ "discarded": discarded })))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue