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

@ -981,15 +981,19 @@ impl GameView {
} else {
0.0
}
+ button(ui, "⏷")
+ button(
ui,
if compact {
"🔍"
} else {
tr("🔍 Find in database")
},
)
+ if crate::platform::CAPS.reference {
button(ui, "⏷")
+ button(
ui,
if compact {
"🔍"
} else {
tr("🔍 Find in database")
},
)
} else {
0.0
}
+ notes.as_ref().map_or(0.0, |n| button(ui, n.text()))
};
// The result, or during a game against the computer its time control («5+3», «∞»)
@ -1129,7 +1133,7 @@ impl GameView {
let why = tr("After a null move (--) this is a teaching scheme, not a position of a game: it is not searched");
// Not during a game against Maia: it would leave the game.
let playing = self.play.is_some() || self.train.is_some();
if !playing { ui.add_enabled_ui(searchable && !databases.is_empty(), |ui| {
if !playing && crate::platform::CAPS.reference { ui.add_enabled_ui(searchable && !databases.is_empty(), |ui| {
ui.menu_button("⏷", |ui| {
for db in databases {
let name = db
@ -1445,8 +1449,10 @@ impl GameView {
egui::CentralPanel::default().show(ui, |ui| {
ui.horizontal(|ui| {
ui.selectable_value(&mut self.side_tab, SideTab::Notation, tr("Notation"));
ui.selectable_value(&mut self.side_tab, SideTab::Reference, tr("Reference"))
.on_hover_text(tr("What was played in this position in a database"));
if crate::platform::CAPS.reference {
ui.selectable_value(&mut self.side_tab, SideTab::Reference, tr("Reference"))
.on_hover_text(tr("What was played in this position in a database"));
}
if report {
ui.selectable_value(&mut self.side_tab, SideTab::Report, tr("Report"));
}
@ -1501,7 +1507,12 @@ impl GameView {
}
return;
}
match self.translation.strip(ui, settings, hub) {
let strip = if crate::platform::CAPS.translation {
self.translation.strip(ui, settings, hub)
} else {
None
};
match strip {
Some(crate::translate_ui::StripAction::OpenSettings) => {
actions.push(GameAction::OpenTranslationSettings)
}
@ -2154,7 +2165,9 @@ impl GameView {
}
pub fn show_reference_tab(&mut self) {
self.side_tab = SideTab::Reference;
if crate::platform::CAPS.reference {
self.side_tab = SideTab::Reference;
}
}
pub fn search_line(&self) -> Option<(Chess, Vec<shakmaty::Move>, bool)> {
@ -4760,6 +4773,16 @@ impl GameView {
if i.consume_shortcut(&ctrl(Key::W)) {
cmds.push("back");
}
// A browser keeps Ctrl+W, Ctrl+1…6 and Ctrl+Shift+C for itself
// (docs/design/web-version.md §4): Alt+←, plain 1…6 and Ctrl+C there.
if cfg!(web) {
if i.consume_shortcut(&KeyboardShortcut::new(Modifiers::ALT, Key::ArrowLeft)) {
cmds.push("back");
}
if i.consume_shortcut(&ctrl(Key::C)) {
cmds.push("copy");
}
}
if i.consume_shortcut(&ctrl(Key::G)) {
cmds.push("play_from");
}
@ -4783,7 +4806,9 @@ impl GameView {
(Key::Num5, "nag5"),
(Key::Num6, "nag6"),
] {
if i.consume_shortcut(&ctrl(key)) {
if i.consume_shortcut(&ctrl(key))
|| (cfg!(web) && i.consume_key(Modifiers::NONE, key))
{
cmds.push(cmd);
}
}
@ -4845,7 +4870,7 @@ impl GameView {
}
"game_data" => actions.push(GameAction::EditGameData),
"back" => actions.push(GameAction::BackKey),
"find" if self.search_line().is_some() => {
"find" if crate::platform::CAPS.reference && self.search_line().is_some() => {
actions.push(GameAction::FindPosition(None))
}
"back1" => self.step_back(),