2026-10-19 09:33:37 +03:00
//! Getting an engine when there is none (decision 14, `docs/design/engine-download.md`):
//! an offer to download the official Stockfish, its progress (hidden into a small
//! indicator if the user wants), the errors with what to do next, and the action the
//! user came for (live analysis or game analysis) started once the engine is there.
use std ::path ::PathBuf ;
use egui ::{ RichText , Ui , vec2 } ;
use crate ::engine_download ::{ self , Download , Failure , Stage } ;
use crate ::i18n ::{ tr , trf } ;
use crate ::settings ::Settings ;
2026-10-22 19:57:53 +03:00
/// The id of the download indicator in the corner (it is never in the way of Escape).
pub const DOWNLOAD_INDICATOR : & str = " download_indicator " ;
2026-10-19 09:33:37 +03:00
/// What the user wanted to do when the engine turned out to be missing.
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum Pending {
LiveAnalysis ,
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
/// The analysis of the game on the screen whose `serial` is `game` (no other game's);
/// `full`: anew, over evaluations read from the PGN.
GameAnalysis {
game : u64 ,
full : bool ,
} ,
/// The search for opening errors of the preparation whose `serial` is `prep`.
OpeningErrors {
prep : u64 ,
} ,
}
/// A number of its own for a screen an action waits on (a game, a preparation), so
/// that an engine arriving later starts it there and nowhere else.
pub fn next_serial ( ) -> u64 {
static NEXT : std ::sync ::atomic ::AtomicU64 = std ::sync ::atomic ::AtomicU64 ::new ( 1 ) ;
NEXT . fetch_add ( 1 , std ::sync ::atomic ::Ordering ::Relaxed )
2026-10-19 09:33:37 +03:00
}
/// What the owner should do.
pub enum OfferEvent {
/// The downloaded Stockfish is ready: make it the active engine, then run `Pending`.
Installed ( Option < Pending > ) ,
/// Use the Stockfish found on this computer, then run `Pending`.
UseSystem ( PathBuf , Option < Pending > ) ,
/// Open the file dialog to choose an engine.
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
#[ cfg(not(web)) ]
2026-10-19 09:33:37 +03:00
ChooseFile ,
Toast ( String ) ,
}
#[ derive(Clone, PartialEq) ]
enum Mode {
Offer ,
/// A `stockfish` is installed on the computer.
System ( PathBuf ) ,
/// The downloaded engine was deleted from the disk.
Missing ,
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
/// The game analysis or the opening errors, which need ChessPenguin's Stockfish 19
/// itself (their search is the same on every computer): only its download helps.
Own ,
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
/// The same, when the user's engine does not do (`review_engine`): it is named.
OwnInstead ( crate ::review_engine ::Unfit ) ,
2026-10-19 09:33:37 +03:00
}
pub struct EngineOffer {
open : bool ,
mode : Mode ,
pending : Option < Pending > ,
download : Option < Download > ,
failure : Option < Failure > ,
/// Bytes per second, smoothed, for "about 20 s left".
speed : f64 ,
last : Option < ( f64 , u64 ) > ,
}
impl EngineOffer {
pub fn new ( ) -> EngineOffer {
EngineOffer {
open : false ,
mode : Mode ::Offer ,
pending : None ,
download : None ,
failure : None ,
speed : 0.0 ,
last : None ,
}
}
/// Whether the active engine can be started.
pub fn engine_ready ( settings : & Settings ) -> bool {
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>
2026-10-30 16:35:16 +03:00
settings . active_engine ( ) . is_some_and ( | e | e . present ( ) )
2026-10-19 09:33:37 +03:00
}
/// Opens the offer for an action that needs an engine.
pub fn ask ( & mut self , pending : Pending , settings : & Settings ) {
self . pending = Some ( pending ) ;
self . failure = None ;
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
self . mode = if pending ! = Pending ::LiveAnalysis {
Mode ::Own
} else if settings . active_engine ( ) . is_some_and ( | e | e . builtin ) {
2026-10-19 09:33:37 +03:00
Mode ::Missing
} else if settings . engines . is_empty ( )
& & let Some ( p ) = crate ::engines ::system_stockfish ( )
{
Mode ::System ( p )
} else {
Mode ::Offer
} ;
self . open = true ;
}
2026-10-31 13:16:15 +03:00
/// Opens the offer of ChessPenguin's Stockfish 19 for the game analysis or the
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
/// opening errors, saying why the user's engine does not do.
pub fn ask_instead_of ( & mut self , pending : Pending , unfit : crate ::review_engine ::Unfit ) {
2026-10-31 13:16:15 +03:00
self . pending = Some ( pending ) ;
self . failure = None ;
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
self . mode = Mode ::OwnInstead ( unfit ) ;
2026-10-31 13:16:15 +03:00
self . open = true ;
}
2026-10-19 09:33:37 +03:00
/// Starts the download (from the offer or from the settings).
pub fn start ( & mut self , ctx : & egui ::Context ) {
if self . download . as_ref ( ) . is_some_and ( Download ::running ) {
return ;
}
self . failure = None ;
self . speed = 0.0 ;
self . last = None ;
self . download = Some ( Download ::start ( ctx ) ) ;
}
/// The download's stage, for the settings window.
pub fn stage ( & self ) -> Option < Stage > {
self . download . as_ref ( ) . map ( Download ::stage )
}
pub fn cancel ( & mut self ) {
if let Some ( d ) = & self . download {
d . cancel ( ) ;
}
}
/// The offer window, the indicator of a hidden download, and what follows a
/// finished one.
pub fn show ( & mut self , ctx : & egui ::Context ) -> Vec < OfferEvent > {
let mut events = Vec ::new ( ) ;
let now = ctx . input ( | i | i . time ) ;
if let Some ( d ) = & self . download {
match d . stage ( ) {
Stage ::Done ( _ ) = > {
let pending = self . pending . take ( ) ;
events . push ( OfferEvent ::Installed ( pending ) ) ;
events . push ( OfferEvent ::Toast (
match pending {
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Some ( Pending ::GameAnalysis { .. } ) = > {
2026-10-19 09:33:37 +03:00
tr ( " Stockfish installed — game analysis started " )
}
Some ( Pending ::LiveAnalysis ) = > {
tr ( " Stockfish installed — analysis is on " )
}
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Some ( Pending ::OpeningErrors { .. } ) = > {
Opponent prep: the desktop screen (dialog, report, engine run)
The «Prepare against…» entry points in the library (the filter panel's button
when a player is set, the game row's context menu, Ctrl+Shift+P), the dialog
(database, the player's spellings with the similar names apart, colour, book)
and the report screen in the stack between the library and the game: the
repertoire tree with transpositions, opening names, scores and the book
column, the openings table by family and variation, the errors tab (repeated
errors and by opening), the board of the chosen position with the line under
it, and the games of the selection, which open in the game screen at that move
with «⬅ Back to preparation».
The engine run reuses the game analysis job over the distinct opening
positions of the chosen colour: the launch dialog shares the engine picker and
the quality/threads/memory grid with review.rs (quality «Fast» by default, its
own setting), marks appear as positions are evaluated, «Stop» keeps what was
done, the evaluations and the report are cached under <cache>/prep. One engine
job per program: game analysis and the live engine are blocked meanwhile.
Core: targets and counts by colour (`targets_for`, `missing_for`), the book
step keeps its per-position counts (`book_counts`) for the tree column.
Narrow windows: the board stacks over the lists under 804 px and folds into a
button under 720 px of height; the right column is split explicitly (a nested
bottom panel is not reserved from the content above it in egui).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 15:43:15 +03:00
tr ( " Stockfish installed — the search for opening errors started " )
}
2026-10-19 09:33:37 +03:00
None = > tr ( " Stockfish installed " ) ,
}
. to_string ( ) ,
) ) ;
self . download = None ;
self . open = false ;
}
Stage ::Failed ( f ) = > {
if ! self . open {
events . push ( OfferEvent ::Toast (
tr ( " ⚠ Stockfish wasn't downloaded " ) . into ( ) ,
) ) ;
}
self . failure = Some ( f ) ;
self . download = None ;
}
Stage ::Cancelled = > {
self . download = None ;
self . pending = None ;
self . open = false ;
}
Stage ::Downloading { done , .. } = > {
if let Some ( ( t , b ) ) = self . last
& & now - t > = 0.5
{
let rate = ( done . saturating_sub ( b ) ) as f64 / ( now - t ) ;
self . speed = if self . speed = = 0.0 {
rate
} else {
0.7 * self . speed + 0.3 * rate
} ;
self . last = Some ( ( now , done ) ) ;
} else if self . last . is_none ( ) {
self . last = Some ( ( now , done ) ) ;
}
ctx . request_repaint_after ( std ::time ::Duration ::from_millis ( 200 ) ) ;
}
Stage ::Unpacking = > {
ctx . request_repaint_after ( std ::time ::Duration ::from_millis ( 200 ) ) ;
}
}
}
if self . open {
self . window ( ctx , & mut events ) ;
} else if self . download . is_some ( ) | | self . failure . is_some ( ) {
self . indicator ( ctx ) ;
}
events
}
fn window ( & mut self , ctx : & egui ::Context , events : & mut Vec < OfferEvent > ) {
let modal = egui ::Modal ::new ( egui ::Id ::new ( " engine_offer " ) ) . show ( ctx , | ui | {
ui . set_width ( 440.0 ) ;
if let Some ( d ) = & self . download {
self . progress_body ( ui , & d . stage ( ) ) ;
} else if let Some ( f ) = self . failure . clone ( ) {
self . failure_body ( ui , & f , events ) ;
} else {
self . offer_body ( ui , events ) ;
}
} ) ;
if modal . should_close ( ) {
// Escape or a click outside: "Later", or "Hide" while downloading.
self . open = false ;
if self . download . is_none ( ) {
self . pending = None ;
self . failure = None ;
}
}
}
fn offer_body ( & mut self , ui : & mut Ui , events : & mut Vec < OfferEvent > ) {
let size = engine_download ::size_mb ( ) ;
2026-10-31 13:16:15 +03:00
let ( title , text ) : ( & str , String ) = match & self . mode {
2026-10-19 09:33:37 +03:00
Mode ::Offer = > (
tr ( " Analysis needs a chess engine " ) ,
tr (
" Download Stockfish, the strongest free chess engine? Analysis will start as soon as the download finishes. " ,
2026-10-31 13:16:15 +03:00
)
. into ( ) ,
2026-10-19 09:33:37 +03:00
) ,
Mode ::System ( _ ) = > (
tr ( " Analysis needs a chess engine " ) ,
2026-10-31 13:16:15 +03:00
tr ( " Stockfish is already installed on this computer. " ) . into ( ) ,
2026-10-19 09:33:37 +03:00
) ,
Mode ::Missing = > (
tr ( " Stockfish not found " ) ,
2026-10-31 13:16:15 +03:00
tr ( " The Stockfish file is missing from the disk. Download it again? " ) . into ( ) ,
2026-10-19 09:33:37 +03:00
) ,
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
Mode ::Own = > (
tr ( " Analysis needs Stockfish 19 " ) ,
tr (
" Game analysis and the search for opening errors always use ChessPenguin's Stockfish 19, so that their marks are the same on every computer. Download it? The analysis will start as soon as the download finishes. " ,
2026-10-31 13:16:15 +03:00
)
. into ( ) ,
) ,
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Mode ::OwnInstead ( unfit ) = > (
2026-10-31 13:16:15 +03:00
tr ( " Analysis needs Stockfish 19 " ) ,
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
instead_text ( unfit , self . pending ) ,
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
) ,
2026-10-19 09:33:37 +03:00
} ;
ui . heading ( title ) ;
ui . add_space ( 6.0 ) ;
ui . label ( text ) ;
ui . add_space ( 4.0 ) ;
if matches! ( self . mode , Mode ::System ( _ ) ) {
ui . label (
RichText ::new ( trf (
" Or download the official Stockfish 19 build ({mb} MB). " ,
& [ ( " mb " , & size ) ] ,
) )
. weak ( ) ,
) ;
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>
2026-10-30 16:35:16 +03:00
} else if cfg! ( web ) {
// The browser's engine: from our site, into this browser (design §1.4).
ui . label ( tr (
" It evaluates the position, shows the best moves and reviews the game. It is downloaded once and kept in this browser. " ,
) ) ;
let free = crate ::platform ::storage_free ( ) . map ( | f | {
trf (
" free for the site: {free} " ,
& [ ( " free " , & crate ::platform ::size_text ( f ) ) ] ,
)
} ) ;
let size = trf ( " Size: {size} " , & [ ( " size " , & format! ( " {size} MB " ) ) ] ) ;
ui . label ( RichText ::new ( free . map_or ( size . clone ( ) , | f | format! ( " {size} · {f} " ) ) ) . weak ( ) ) ;
2026-10-19 09:33:37 +03:00
} else {
ui . label (
RichText ::new ( trf (
" {mb} MB · from the official Stockfish page " ,
& [ ( " mb " , & size ) ] ,
) )
. weak ( ) ,
)
. on_hover_text ( " https://github.com/official-stockfish/Stockfish/releases/tag/sf_19 " ) ;
ui . label ( RichText ::new ( tr ( " Installed for your account only " ) ) . weak ( ) ) ;
}
ui . add_space ( 10.0 ) ;
let enter = ui . input ( | i | i . key_pressed ( egui ::Key ::Enter ) ) ;
ui . horizontal ( | ui | {
ui . with_layout ( egui ::Layout ::right_to_left ( egui ::Align ::Center ) , | ui | {
match self . mode . clone ( ) {
Mode ::System ( p ) = > {
let main = ui . add ( egui ::Button ::new ( RichText ::new ( tr ( " Use it " ) ) . strong ( ) ) ) ;
main . request_focus ( ) ;
if main . clicked ( ) | | enter {
events . push ( OfferEvent ::UseSystem ( p , self . pending . take ( ) ) ) ;
self . open = false ;
}
if ui . button ( tr ( " Later " ) ) . clicked ( ) {
self . open = false ;
self . pending = None ;
}
if ui . button ( tr ( " Download " ) ) . clicked ( ) {
self . start ( ui . ctx ( ) ) ;
}
}
mode = > {
let label = if mode = = Mode ::Missing {
tr ( " Download again " )
} else {
tr ( " Download Stockfish " )
} ;
let main = ui . add ( egui ::Button ::new ( RichText ::new ( label ) . strong ( ) ) ) ;
main . request_focus ( ) ;
if main . clicked ( ) | | enter {
self . start ( ui . ctx ( ) ) ;
}
if ui . button ( tr ( " Later " ) ) . clicked ( ) {
self . open = false ;
self . pending = None ;
}
}
}
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>
2026-10-30 16:35:16 +03:00
// Another engine does not do for the game analysis (and a browser has
// no engine programs).
#[ cfg(not(web)) ]
2026-10-31 13:16:15 +03:00
if ! matches! ( self . mode , Mode ::Own | Mode ::OwnInstead ( _ ) ) {
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
ui . with_layout ( egui ::Layout ::left_to_right ( egui ::Align ::Center ) , | ui | {
if ui . button ( tr ( " Choose engine file… " ) ) . clicked ( ) {
events . push ( OfferEvent ::ChooseFile ) ;
self . open = false ;
self . pending = None ;
}
} ) ;
}
2026-10-19 09:33:37 +03:00
} ) ;
} ) ;
}
fn progress_body ( & mut self , ui : & mut Ui , stage : & Stage ) {
ui . heading ( tr ( " Downloading Stockfish " ) ) ;
ui . add_space ( 8.0 ) ;
match * stage {
Stage ::Downloading { done , total } = > {
let frac = if total > 0 {
done as f32 / total as f32
} else {
0.0
} ;
ui . add (
egui ::ProgressBar ::new ( frac )
. show_percentage ( )
. desired_width ( ui . available_width ( ) ) ,
) ;
let mb = | b : u64 | b / 1_000_000 ;
let mut line = trf (
" {done} of {total} MB " ,
& [ ( " done " , & mb ( done ) ) , ( " total " , & mb ( total ) ) ] ,
) ;
if self . speed > 0.0 {
let left = ( total . saturating_sub ( done ) ) as f64 / self . speed ;
line . push_str ( " · " ) ;
line . push_str ( & trf ( " about {s} s left " , & [ ( " s " , & ( left . ceil ( ) as u64 ) ) ] ) ) ;
}
ui . label ( line ) ;
}
_ = > {
ui . horizontal ( | ui | {
ui . spinner ( ) ;
ui . label ( tr ( " Checking and installing… " ) ) ;
} ) ;
}
}
ui . add_space ( 4.0 ) ;
let after = match self . pending {
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Some ( Pending ::GameAnalysis { .. } ) = > {
2026-10-19 09:33:37 +03:00
tr ( " Game analysis will start by itself when the download finishes. " )
}
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Some ( Pending ::OpeningErrors { .. } ) = > {
Opponent prep: the desktop screen (dialog, report, engine run)
The «Prepare against…» entry points in the library (the filter panel's button
when a player is set, the game row's context menu, Ctrl+Shift+P), the dialog
(database, the player's spellings with the similar names apart, colour, book)
and the report screen in the stack between the library and the game: the
repertoire tree with transpositions, opening names, scores and the book
column, the openings table by family and variation, the errors tab (repeated
errors and by opening), the board of the chosen position with the line under
it, and the games of the selection, which open in the game screen at that move
with «⬅ Back to preparation».
The engine run reuses the game analysis job over the distinct opening
positions of the chosen colour: the launch dialog shares the engine picker and
the quality/threads/memory grid with review.rs (quality «Fast» by default, its
own setting), marks appear as positions are evaluated, «Stop» keeps what was
done, the evaluations and the report are cached under <cache>/prep. One engine
job per program: game analysis and the live engine are blocked meanwhile.
Core: targets and counts by colour (`targets_for`, `missing_for`), the book
step keeps its per-position counts (`book_counts`) for the tree column.
Narrow windows: the board stacks over the lists under 804 px and folds into a
button under 720 px of height; the right column is split explicitly (a nested
bottom panel is not reserved from the content above it in egui).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 15:43:15 +03:00
tr ( " The search for opening errors will start by itself when the download finishes. " )
}
2026-10-19 09:33:37 +03:00
_ = > tr ( " Analysis will start by itself when the download finishes. " ) ,
} ;
ui . label ( RichText ::new ( after ) . weak ( ) ) ;
ui . add_space ( 10.0 ) ;
ui . horizontal ( | ui | {
ui . with_layout ( egui ::Layout ::right_to_left ( egui ::Align ::Center ) , | ui | {
let hide = ui . add ( egui ::Button ::new ( RichText ::new ( tr ( " Hide " ) ) . strong ( ) ) ) ;
hide . request_focus ( ) ;
if hide . clicked ( ) {
self . open = false ;
}
if ui . button ( tr ( " Cancel download " ) ) . clicked ( ) {
self . cancel ( ) ;
}
} ) ;
} ) ;
}
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
// In a browser nothing is pushed: there are no engine files to choose.
#[ cfg_attr(web, allow(clippy::ptr_arg)) ]
2026-10-19 09:33:37 +03:00
fn failure_body ( & mut self , ui : & mut Ui , f : & Failure , events : & mut Vec < OfferEvent > ) {
ui . heading ( tr ( " ⚠ Stockfish wasn't downloaded " ) ) ;
ui . add_space ( 6.0 ) ;
let ( text , details ) = failure_text ( f ) ;
ui . label ( text ) ;
if let Some ( d ) = details {
egui ::CollapsingHeader ::new ( tr ( " Details " ) )
. id_salt ( " download_details " )
. show ( ui , | ui | {
ui . label ( RichText ::new ( d ) . small ( ) . weak ( ) ) ;
} ) ;
}
2026-10-31 13:16:15 +03:00
if matches! ( f , Failure ::Network ( _ ) )
& & cfg! ( target_os = " linux " )
& & ! matches! ( self . mode , Mode ::Own | Mode ::OwnInstead ( _ ) )
{
2026-10-19 09:33:37 +03:00
ui . label (
RichText ::new ( tr (
" A stockfish package of your distribution is found by ChessPenguin too. " ,
) )
. weak ( ) ,
) ;
}
ui . add_space ( 10.0 ) ;
let enter = ui . input ( | i | i . key_pressed ( egui ::Key ::Enter ) ) ;
ui . horizontal ( | ui | {
ui . with_layout ( egui ::Layout ::right_to_left ( egui ::Align ::Center ) , | ui | {
let retry = ui . add ( egui ::Button ::new ( RichText ::new ( tr ( " Retry " ) ) . strong ( ) ) ) ;
retry . request_focus ( ) ;
if retry . clicked ( ) | | enter {
self . start ( ui . ctx ( ) ) ;
}
if ui . button ( tr ( " Close " ) ) . clicked ( ) {
self . open = false ;
self . failure = None ;
self . pending = None ;
}
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>
2026-10-30 16:35:16 +03:00
#[ cfg(not(web)) ]
2026-10-31 13:16:15 +03:00
if ! matches! ( self . mode , Mode ::Own | Mode ::OwnInstead ( _ ) ) {
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
ui . with_layout ( egui ::Layout ::left_to_right ( egui ::Align ::Center ) , | ui | {
if ui . button ( tr ( " Choose engine file… " ) ) . clicked ( ) {
events . push ( OfferEvent ::ChooseFile ) ;
self . open = false ;
self . failure = None ;
self . pending = None ;
}
} ) ;
}
2026-10-19 09:33:37 +03:00
} ) ;
} ) ;
}
/// "⬇ Stockfish 42 %" in the top right corner while a download runs hidden (or
/// "⚠ Stockfish wasn't downloaded" after it failed); a click opens the window.
fn indicator ( & mut self , ctx : & egui ::Context ) {
let text = match self . download . as_ref ( ) . map ( Download ::stage ) {
Some ( Stage ::Downloading { done , total } ) if total > 0 = > {
format! ( " ⬇ Stockfish {} % " , done * 100 / total )
}
Some ( _ ) = > " ⬇ Stockfish… " . to_string ( ) ,
None = > tr ( " ⚠ Stockfish wasn't downloaded " ) . to_string ( ) ,
} ;
2026-10-22 19:57:53 +03:00
egui ::Area ::new ( egui ::Id ::new ( DOWNLOAD_INDICATOR ) )
2026-10-19 09:33:37 +03:00
. anchor ( egui ::Align2 ::RIGHT_BOTTOM , vec2 ( - 12.0 , - 12.0 ) )
. order ( egui ::Order ::Foreground )
. show ( ctx , | ui | {
egui ::Frame ::popup ( ui . style ( ) ) . show ( ui , | ui | {
ui . horizontal ( | ui | {
if ui
. add ( egui ::Label ::new ( text ) . sense ( egui ::Sense ::click ( ) ) )
. on_hover_text ( tr ( " Show the download " ) )
. clicked ( )
{
self . open = true ;
}
let close = crate ::widgets ::small_close_button ( ui ) ;
let close = if self . download . is_some ( ) {
close . on_hover_text ( tr ( " Cancel download " ) )
} else {
close . on_hover_text ( tr ( " Close " ) )
} ;
if close . clicked ( ) {
if self . download . is_some ( ) {
self . cancel ( ) ;
} else {
self . failure = None ;
self . pending = None ;
}
}
} ) ;
} ) ;
} ) ;
}
}
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
/// Why the user's engine does not do for the game analysis (or the opening errors),
/// what is offered instead, and that the analysis follows the download by itself.
fn instead_text ( unfit : & crate ::review_engine ::Unfit , pending : Option < Pending > ) -> String {
use crate ::review_engine ::Why ;
let errors = matches! ( pending , Some ( Pending ::OpeningErrors { .. } ) ) ;
let engine = crate ::widgets ::shorten ( & unfit . name , 48 ) ;
let mut parts = vec! [ match unfit . why {
Why ::Differs = > tr (
" Your Stockfish 19 calculates differently from ChessPenguin's build (another build or network). " ,
)
. to_owned ( ) ,
Why ::NotStarted = > trf ( " {engine} could not be started. " , & [ ( " engine " , & engine ) ] ) ,
2026-10-31 13:51:29 +03:00
Why ::TimedOut = > trf (
" {engine} did not finish the check in time; it will be checked again next time. " ,
& [ ( " engine " , & engine ) ] ,
) ,
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
Why ::Other if unfit . from_settings = > {
trf ( " The settings name {engine}. " , & [ ( " engine " , & engine ) ] )
}
Why ::Other = > trf ( " The system has {engine}. " , & [ ( " engine " , & engine ) ] ) ,
} ] ;
2026-10-31 13:51:29 +03:00
let official = matches! ( unfit . why , Why ::Differs | Why ::TimedOut ) ;
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
parts . push (
2026-10-31 13:51:29 +03:00
match ( official , errors ) {
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
( true , false ) = > tr (
" So that the marks are the same on every computer, game analysis runs on the official build. " ,
) ,
( true , true ) = > tr (
" So that the marks are the same on every computer, the search for opening errors runs on the official build. " ,
) ,
( false , false ) = > tr (
" Game analysis needs Stockfish 19 itself, so that the marks are the same on every computer. " ,
) ,
( false , true ) = > tr (
" The search for opening errors needs Stockfish 19 itself, so that the marks are the same on every computer. " ,
) ,
}
. to_owned ( ) ,
) ;
parts . push (
2026-10-31 13:51:29 +03:00
if official {
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
tr ( " Download it? " )
} else {
tr ( " Download Stockfish 19? " )
}
. to_owned ( ) ,
) ;
if unfit . why ! = Why ::NotStarted {
parts . push ( tr ( " Your engine stays for position analysis. " ) . to_owned ( ) ) ;
}
parts . push (
if errors {
tr ( " The search for opening errors will start by itself when the download finishes. " )
} else {
tr ( " Game analysis will start by itself when the download finishes. " )
}
. to_owned ( ) ,
) ;
parts . join ( " " )
}
2026-10-19 09:33:37 +03:00
/// What to tell the user about a failure, and the technical details (collapsed).
fn failure_text ( f : & Failure ) -> ( String , Option < String > ) {
match f {
Failure ::Network ( e ) = > (
tr ( " Couldn't connect. Check your internet connection and try again. " ) . into ( ) ,
Some ( e . clone ( ) ) ,
) ,
Failure ::Server ( code ) = > (
trf (
" The server didn't provide the file (error {code}). Please try again later. " ,
& [ ( " code " , code ) ] ,
) ,
None ,
) ,
Failure ::Checksum = > (
tr ( " The downloaded file failed the integrity check and was deleted. It was most likely damaged during the download. " ) . into ( ) ,
Some ( " SHA-256 mismatch " . into ( ) ) ,
) ,
Failure ::Disk ( e ) = > (
tr ( " Couldn't save the engine on the disk (not enough space or no permission). " ) . into ( ) ,
Some ( e . clone ( ) ) ,
) ,
Failure ::Broken = > (
tr ( " Stockfish was downloaded but doesn't run on this computer. " ) . into ( ) ,
None ,
) ,
Failure ::Unsupported = > (
tr ( " There is no Stockfish download for this computer. Choose an engine file instead. " )
. into ( ) ,
None ,
) ,
}
}
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
#[ cfg(test) ]
mod tests {
use super ::{ Pending , instead_text } ;
use crate ::review_engine ::{ Unfit , Why } ;
fn text ( why : Why , from_settings : bool , pending : Pending ) -> String {
let unfit = Unfit {
name : " Rodent V 1.2 " . into ( ) ,
from_settings ,
why ,
} ;
instead_text ( & unfit , Some ( pending ) )
}
/// The offer says why the user's engine does not do and where it is from; the
/// user's engine stays for the live analysis, the analysis follows the download.
#[ test ]
fn the_offer_says_why_the_users_engine_does_not_do ( ) {
let game = Pending ::GameAnalysis {
game : 1 ,
full : false ,
} ;
let errors = Pending ::OpeningErrors { prep : 1 } ;
let t = text ( Why ::Other , true , game ) ;
assert! ( t . starts_with ( " The settings name Rodent V 1.2. " ) , " {t} " ) ;
assert! ( t . contains ( " Your engine stays for position analysis. " ) ) ;
assert! ( t . ends_with ( " Game analysis will start by itself when the download finishes. " ) ) ;
let t = text ( Why ::Other , false , errors ) ;
assert! ( t . starts_with ( " The system has Rodent V 1.2. " ) , " {t} " ) ;
assert! ( t . contains ( " The search for opening errors needs Stockfish 19 itself " ) ) ;
let t = text ( Why ::Differs , true , game ) ;
assert! (
t . starts_with ( " Your Stockfish 19 calculates differently " ) ,
" {t} "
) ;
assert! ( t . contains ( " Download it? " ) ) ;
2026-10-31 13:51:29 +03:00
let t = text ( Why ::TimedOut , true , game ) ;
assert! (
t . starts_with ( " Rodent V 1.2 did not finish the check in time " ) ,
" {t} "
) ;
assert! ( t . contains ( " runs on the official build " ) & & t . contains ( " Download it? " ) ) ;
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
let t = text ( Why ::NotStarted , true , game ) ;
assert! ( t . starts_with ( " Rodent V 1.2 could not be started. " ) , " {t} " ) ;
assert! ( ! t . contains ( " stays for position analysis " ) ) ;
}
}