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:
danny 2026-10-16 21:49:38 +02:00
parent d12a517009
commit 1a38e68480
13 changed files with 442 additions and 12 deletions

View file

@ -2,7 +2,8 @@
* Tests for the restore dialog and its store: the list from
* `recoveryAvailable` and from `recovery.list` after `projectOpened`, the
* "changed on disk" hint, Restore all / Restore selected / Discard with
* explicit paths, failures, errors, Escape, and checking untrusted entries.
* explicit paths, failures, errors, Escape, entries settled elsewhere
* (`recoveryResolved`), and checking untrusted entries.
* The engine is a fake behind the mocked Tauri `invoke`.
*/
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
@ -217,6 +218,26 @@ describe("RecoveryDialog", () => {
expect(wrapper.find("[data-test=recovery-dialog]").exists()).toBe(false);
expect(calls).toEqual([]);
});
it("drops entries restored or discarded elsewhere and closes when none are left", async () => {
const wrapper = mountDialog();
await offer();
await wrapper.get("[data-test='recovery-select-c.php']").setValue(true);
const store = useRecoveryStore();
store.handleEvent({ kind: "recoveryResolved", paths: ["src/a.php", "c.php", 7, "gone.php"] });
await flushPromises();
expect(wrapper.findAll("[data-test=recovery-entry]").map((r) => r.find(".recovery__path").text())).toEqual([
"src/b.php",
]);
expect([...store.selected]).toEqual([]);
store.handleEvent({ kind: "recoveryResolved", paths: "nope" });
await flushPromises();
expect(wrapper.findAll("[data-test=recovery-entry]")).toHaveLength(1);
store.handleEvent({ kind: "recoveryResolved", paths: ["src/b.php"] });
await flushPromises();
expect(wrapper.find("[data-test=recovery-dialog]").exists()).toBe(false);
expect(calls).toEqual([]);
});
});
describe("toRecoveryEntries", () => {