feat(gui): a tab owns its threads; kept state belongs to its books; one dock layout
An independent review of the tab work found that closing a tab did not end what the tab started, that what the viewer keeps was filed under the book id alone, and a few smaller things. All of it is the viewer's own state: nothing here writes the books. Threads: every thread a tab starts (loader, receipts' workers, export, owner job, the dock's start and its agent's reaper) is counted in one per-view registry (jobs.rs). Dropping the view tells them to stop and the registry says, on a condition, when the last has ended. An owner job that changes something (restore, format upgrade, new books, connect, close the books, check for updates, update) is never abandoned: its tab's close control is off with a hover text saying what runs, App::close refuses, and the window's close request is cancelled with a dialog that offers only to wait. Read-only jobs (an export, a backup, the restore's check) stop with the tab: an export checks at its phase boundaries and saves nothing (the save is one atomic write of a new file; one the stop reaches too late is removed). The dock's agent is hung up on and, if it ignores that for two seconds, killed and reaped; the window's drop waits for that. Release on close: the loader checks "gone" before every retry and between the phases of a load, its retry wait is woken by the drop, and the viewer presence is let go in the drop itself, not when a refresh in flight ends. A thumbnail for a closed tab is not written. Kept state: filed under a hash of the data root's canonical path and the id (books outside any root: under their folder), with the books' identity, the SHA-256 of the journal's first line, taken once they load. A stored state whose identity differs from the loaded books' is discarded with the remembered name. Old unkeyed keys are read without error and not used. A start that names a company never writes the list of open companies. The dock's height is the app's one layout in every tab (said in the spec block and tested); the sidebar, rail and top bar panels now take ids made from their view's, since egui keys a panel's size by the id as given. Every new test was seen to fail with its fix switched off. The four sidenav tests keep their BAR_H: at the owner's 519 they fail by 15 points (sidebar) and 11 (rail) without it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5cd0eded36
commit
ec436cfc02
16 files changed
+2388
-154
No files matched your search
@@ -554,3 +554,42 @@ fn the_menus_worksheet_says_which_payees_lack_a_tin() {
|
||||
"{note}"
|
||||
);
|
||||
}
|
||||
|
||||
/// menu.rs INVARIANT 4: an export whose tab has closed is told to stop and
|
||||
/// saves nothing, at any of its phase boundaries: told before it starts,
|
||||
/// after the books are read, after the file is built, or too late to stop
|
||||
/// the write (the file it just made is removed). Told at none, it saves.
|
||||
#[test]
|
||||
fn a_stopped_export_leaves_no_file_whenever_it_is_told() {
|
||||
use ledger_gui::jobs::Stop;
|
||||
downloads();
|
||||
let f = root_book();
|
||||
let b = load(&f.book);
|
||||
// A year of its own (the other tests save 2026's): no other test's file has its name.
|
||||
let mine = || -> Vec<String> {
|
||||
saved_files()
|
||||
.into_iter()
|
||||
.filter(|n| n.contains("2025"))
|
||||
.collect()
|
||||
};
|
||||
let mut told = 0;
|
||||
for looks in 0..20 {
|
||||
match Job::Worksheet(2025).run_until(&b, &Stop::given_after(looks)) {
|
||||
Err(why) => {
|
||||
assert!(why.starts_with("stopped"), "{why}");
|
||||
assert_eq!(
|
||||
mine(),
|
||||
Vec::<String>::new(),
|
||||
"told after {looks} looks, the export left a file"
|
||||
);
|
||||
told += 1;
|
||||
}
|
||||
Ok((path, _)) => {
|
||||
assert_eq!(mine().len(), 1, "told too late: it saves");
|
||||
std::fs::remove_file(path).unwrap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(told >= 4, "its boundaries: only {told} told it to stop");
|
||||
}
|
||||
Reference in new issue
Block a user