Web version, stage 2: Stockfish 19 in workers, live analysis, game review on N workers, My games, files, keys

game-review: what the job does for one target (the full search, the second
best without the move played, the shallow ones) becomes a machine without I/O
(job/work.rs), driven by the engine processes on a computer (job/engines.rs,
the same searches as before) and by Web Workers in a browser
(job/workers.rs: a dispatcher polled from the frames, never blocking). The
analysis cache goes through a CacheStore (a folder, or the program's files of
the platform).

The browser's engine: Stockfish.js 19.0.1 (npm stockfish, GPL-3.0), its
single-threaded build served beside /app/ (engine/, build.sh checks the
package's sha512), its 99 MB wasm downloaded only through the engine offer,
checked against its SHA-256 and kept in Cache Storage; workers get it as a
blob: address. Live analysis (lines, arrows, the bar) and the review run on it;
the review uses one worker per logical CPU, at most 8.

My games (the web version): a PGN in the browser's storage, always on the
shelf; Ctrl+S puts a game there (its own record, or a new one); deleting with
undo. chess-core's store gives the bytes of append/replace/remove/restore, so
the platform writes them into the browser's files; on a computer the files
are written as before. Settings: Browser data (used and free space, keeping
the data for good, Download all as PGN, deleting the engine).

Files: a file of the last visit offers Choose the file again; Keep a copy in
the browser (refused with the room it needs when the browser gives too
little); files over 1 GB are not opened, with a word on why. No reference tab
and no search by position in the web version. Keys: Alt+Left, plain 1-6,
Ctrl+C, N in the library (the browser keeps Ctrl+W/N/1-6/Shift+C).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-30 16:35:16 +03:00
parent 4ccf8099a5
commit 61ccd763bc
34 changed files with 2063 additions and 253 deletions

View file

@ -57,6 +57,11 @@ pub enum LibraryAction {
#[cfg(not(web))]
OpenUpdate,
RemoveDatabase(PathBuf),
/// A file the browser held for the last visit only: choose it again, the new one
/// taking its place on the shelf.
ChooseAgain(PathBuf),
/// Keep a copy of a file in the browser (it opens then without choosing it).
KeepCopy(PathBuf),
OpenSettings,
/// A new, empty PGN database (own-databases.md §2).
NewDatabase,
@ -341,6 +346,10 @@ impl Library {
if crate::examples::is_example(path) {
return Some(Block::Example);
}
// In a browser the user's files are only read.
if cfg!(web) && crate::platform::fs::meta(path).is_ok_and(|m| m.readonly) {
return Some(Block::ReadOnly);
}
if !self.files.exists(path) {
return Some(Block::Missing);
}
@ -1091,6 +1100,11 @@ impl Library {
});
trf("loading… {n}", &[("n", &p.games)])
}
Some(Slot::Failed(_)) | None
if crate::platform::files::session_only(path) && !self.files.exists(path) =>
{
tr("↻ Choose the file again").into()
}
Some(Slot::Failed(_)) => tr("error").into(),
None if !self.files.exists(path) => tr("file not found").into(),
// Not opened: its games once counted, nothing till then.
@ -1261,6 +1275,25 @@ impl Library {
});
return;
}
Some(Slot::Failed(_))
if crate::platform::files::session_only(&path) && !self.files.exists(&path) =>
{
// A browser keeps no way back to a file the user chose (Firefox, Safari).
ui.vertical_centered(|ui| {
ui.add_space(40.0);
ui.label(tr("This browser doesn't remember files: after a reload, choose the file again or keep a copy in the browser."));
ui.add_space(8.0);
ui.horizontal(|ui| {
if ui.button(tr("↻ Choose the file again")).clicked() {
actions.push(LibraryAction::ChooseAgain(path.clone()));
}
if ui.button(tr("Remove from list")).clicked() {
actions.push(LibraryAction::RemoveDatabase(path.clone()));
}
});
});
return;
}
Some(Slot::Failed(e)) => {
let e = e.clone();
ui.vertical_centered(|ui| {
@ -1349,6 +1382,7 @@ impl Library {
format,
format_hint,
online,
keep_copy: crate::platform::files::session_only(path),
}
}
}