2026-10-18 01:54:06 +03:00
|
|
|
//! Persistent user settings (JSON in the XDG config dir), written atomically.
|
|
|
|
|
|
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
use crate::assets::{BoardThemeId, PieceSet, SoundSet};
|
|
|
|
|
use crate::i18n::Lang;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
|
|
|
|
pub struct EngineConfig {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub path: PathBuf,
|
|
|
|
|
#[serde(default = "default_threads")]
|
|
|
|
|
pub threads: u32,
|
|
|
|
|
#[serde(default = "default_hash")]
|
|
|
|
|
pub hash_mb: u32,
|
|
|
|
|
#[serde(default = "default_multipv")]
|
|
|
|
|
pub multipv: u32,
|
|
|
|
|
/// Search time per position in seconds; `None` = infinite.
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub search_secs: Option<u32>,
|
2026-10-19 09:33:37 +03:00
|
|
|
/// ChessPenguin's Stockfish (bundled in the Flatpak, otherwise downloaded on
|
|
|
|
|
/// request); `path` is unused and resolved at start.
|
2026-10-18 11:53:30 +03:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub builtin: bool,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn default_threads() -> u32 {
|
|
|
|
|
std::thread::available_parallelism()
|
|
|
|
|
.map(|n| (n.get() as u32 / 2).max(1))
|
|
|
|
|
.unwrap_or(1)
|
|
|
|
|
}
|
|
|
|
|
fn default_hash() -> u32 {
|
|
|
|
|
256
|
|
|
|
|
}
|
|
|
|
|
fn default_multipv() -> u32 {
|
|
|
|
|
3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EngineConfig {
|
|
|
|
|
pub fn new(name: String, path: PathBuf) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
name,
|
|
|
|
|
path,
|
|
|
|
|
threads: default_threads(),
|
|
|
|
|
hash_mb: default_hash(),
|
|
|
|
|
multipv: default_multipv(),
|
|
|
|
|
search_secs: None,
|
2026-10-18 11:53:30 +03:00
|
|
|
builtin: false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 09:33:37 +03:00
|
|
|
/// Executable to start; `None` if ChessPenguin's Stockfish is neither bundled nor
|
|
|
|
|
/// downloaded yet (it is offered for download then).
|
2026-10-18 11:53:30 +03:00
|
|
|
pub fn executable(&self) -> Option<PathBuf> {
|
|
|
|
|
if self.builtin {
|
2026-10-19 09:33:37 +03:00
|
|
|
crate::engines::own_stockfish()
|
2026-10-18 11:53:30 +03:00
|
|
|
} else {
|
|
|
|
|
Some(self.path.clone())
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-21 19:57:54 +03:00
|
|
|
/// Piece animation, with Lichess's durations.
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
|
|
|
|
|
pub enum Animation {
|
|
|
|
|
Off,
|
|
|
|
|
Fast,
|
|
|
|
|
#[default]
|
|
|
|
|
Normal,
|
|
|
|
|
Slow,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Animation {
|
|
|
|
|
pub const ALL: [Animation; 4] = [Self::Off, Self::Fast, Self::Normal, Self::Slow];
|
|
|
|
|
|
|
|
|
|
pub fn seconds(self) -> f32 {
|
|
|
|
|
match self {
|
|
|
|
|
Self::Off => 0.0,
|
|
|
|
|
Self::Fast => 0.12,
|
|
|
|
|
Self::Normal => 0.25,
|
|
|
|
|
Self::Slow => 0.5,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn label(self) -> &'static str {
|
|
|
|
|
crate::i18n::tr(match self {
|
|
|
|
|
Self::Off => "Off",
|
|
|
|
|
Self::Fast => "Fast",
|
|
|
|
|
Self::Normal => "Normal",
|
|
|
|
|
Self::Slow => "Slow",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub struct Settings {
|
|
|
|
|
pub piece_set: PieceSet,
|
|
|
|
|
pub board_theme: BoardThemeId,
|
|
|
|
|
pub show_coords: bool,
|
2026-10-21 19:57:54 +03:00
|
|
|
/// How fast moves slide on the board.
|
|
|
|
|
pub animation: Animation,
|
Premoves, the auto-queen setting, the play dialog redone
Premoves in the game against Maia, as on Lichess: while she thinks, a move of
the user's piece by its pattern on an empty board (a pawn forward and both
diagonals, sliders through pieces, the king at home to castle with an own rook,
by the king's square or the rook's) is set and shown in dark blue; after her
move it is played at once when legal (a promotion as a queen), else dropped.
A right click or a click beside the own pieces cancels it; a take-back, the
leave question and the end drop it. A piece in hand stays there when Maia
moves, unless she took it.
Settings › Board: «Always promote to a queen», off by default — then the
piece is chosen, as before.
The dialog «Play against the computer» redone after the owner's review: You,
Opponent (the strength in the title, the slider edge to edge with 600/2600,
Weaker · As me · Stronger lit when they match, or a line asking for the
rating), Colour, Time; every choice a framed tile of one height, the tiles of a
row sharing its width; time 3+0…30+20 without category captions, Custom with
aligned sliders, Unlimited (no clocks) as a double tile; a solid scroll bar
in a low window, where the introduction is left out. Dev hook CP_PREMOVE.
Adjourning a game recorded as a task.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 12:12:35 +03:00
|
|
|
/// A pawn reaching the last rank becomes a queen without the choice of a piece.
|
|
|
|
|
pub auto_queen: bool,
|
Move notation: Latin letters, figurines or the interface language's letters
Settings › Board & pieces: Nf3, ♘f3 as on Lichess, or Кр Ф Л С К (German
K D T L S, French R D T F C, Spanish and Italian R D T A C; in English the
Latin letters), with a sample per option and a line of a game. Only the shown
label changes (san::show): the game, PGN, copied games, the analysis written
into a game, the reference cache and every comparison stay Latin SAN. Applied
in the move list, engine lines, the reference tab, board search and the
analysis report. The figurines are egui's chess glyphs cut out to a 4.7 KB
font, a little smaller and on the baseline. Latin remains the default.
Reviewed by the designer and the tester agents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:18:53 +03:00
|
|
|
/// How moves are shown: Latin letters, figurines or the interface language's letters.
|
|
|
|
|
pub move_notation: crate::san::MoveNotation,
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
/// Translating game comments (docs/design/translation.md).
|
|
|
|
|
pub translation: crate::translate::TranslationSettings,
|
2026-10-18 01:54:06 +03:00
|
|
|
pub sound_enabled: bool,
|
|
|
|
|
pub sound_set: SoundSet,
|
|
|
|
|
pub volume: f32,
|
|
|
|
|
pub dark_mode: bool,
|
|
|
|
|
pub language: Lang,
|
|
|
|
|
pub engines: Vec<EngineConfig>,
|
|
|
|
|
pub active_engine: Option<usize>,
|
|
|
|
|
pub show_best_arrow: bool,
|
|
|
|
|
/// Recently opened PGN files, most recent first.
|
|
|
|
|
pub databases: Vec<PathBuf>,
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
/// Whole-game analysis options.
|
|
|
|
|
pub review: ReviewSettings,
|
2026-10-18 11:53:30 +03:00
|
|
|
/// The first-start engine discovery has run (see `engines::first_run_setup`).
|
|
|
|
|
pub engines_discovered: bool,
|
2026-10-19 12:21:09 +03:00
|
|
|
/// The sample databases were put on the shelf (see `examples::first_run_setup`).
|
|
|
|
|
pub examples_added: bool,
|
2026-10-20 07:55:59 +03:00
|
|
|
/// Ask GitHub for a newer release at start (Settings → About).
|
|
|
|
|
pub check_updates: bool,
|
|
|
|
|
/// A version the user chose to skip (its button is not shown).
|
|
|
|
|
pub skipped_version: Option<String>,
|
|
|
|
|
/// The version that ran last (to say "updated to …" once).
|
|
|
|
|
pub last_version: Option<String>,
|
2026-10-24 13:45:15 +03:00
|
|
|
/// A random id of this installation, sent with the update check (the site counts
|
|
|
|
|
/// installations that run; nothing else identifies the user).
|
|
|
|
|
pub install_id: String,
|
2026-10-19 23:20:37 +03:00
|
|
|
/// The database of the reference tab (`None`: the largest one on the shelf).
|
|
|
|
|
pub reference_db: Option<PathBuf>,
|
Own databases: create PGN bases, add, save, delete games; library logging
Desktop: «✚ New database» on the shelf (Ctrl+Shift+N), «Add to database…»
(Ctrl+Shift+S, 💾, ☰) for any game — new, pasted, from a ChessBase, online or
legacy-encoded database — into a PGN of the user's choice; Ctrl+S saves the
changes back into the game's own PGN (its record is replaced) or adds the game
when the source is read-only; the game data editor (F2, the title, ☰) asked once
when a new game is first added; duplicate check (same players, date, moves →
replace / add as new, no Enter); delete from the table with a question and Undo
(Ctrl+Z, 6 s, waits under the mouse); UTF-8 copy for legacy-encoded files with
the restored letters; online and ChessBase stay read-only. Writes are explicit:
append, or an atomic rewrite through a temporary file and a rename (through a
symlink, keeping the mode, syncing the folder), refused when the file changed on
the disk. chess_core::pgn::store: append/replace/remove/restore/write_utf8_copy,
find_same_game, pgn_date; Game::remove_tag and order_roster. Settings: your
name (annotator), the folder for new databases, the last target. Nine languages.
Also: library warnings (wgpu, winit) go to chesspenguin.log, CP_LOG_FRAMES=1
traces egui_wgpu frames (the GNOME hang hunt); dev hooks CP_OWN, CP_PASTE,
CP_COMMENT, CP_KEYS with Ctrl+, CP_SETTINGS=interface.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 00:46:47 +03:00
|
|
|
/// The user's name: the annotator of games they add (own-databases.md §7).
|
|
|
|
|
pub your_name: String,
|
|
|
|
|
/// Where new databases are made (`None`: Documents/ChessPenguin).
|
|
|
|
|
pub new_database_dir: Option<PathBuf>,
|
|
|
|
|
/// The database a game was last added to (preselected in the chooser).
|
|
|
|
|
pub last_target: Option<PathBuf>,
|
Play against Maia: dialog, clocks, game screen, result strip
«⚔ Play» (Ctrl+G) opens «Play against the computer»: name and rating
(optional), strength 600–2600 (or weaker/as me/stronger), colour, Lichess time
controls, custom, no clock. The game screen in play mode: clock cards above
and below the notation (read-only), take back, resign (abort before the first
moves); no engine, analysis or editing. Maia answers in a background thread
with a human-like pause bounded so she never loses on time; stale answers are
dropped. Endings: mate, stalemate, no material, threefold, fifty moves, time
(draw when the other side cannot mate), resignation; then the result strip
(Analyse, Rematch, New game, Save to a database) and an ordinary game with the
tags of a played game and [%clk]. Leaving during a game asks (resign and add /
resign and leave / keep playing), the clocks wait meanwhile. maia reads the
published PyTorch checkpoint directly (zip + a small pickle reader that refuses
everything but tensors); maia_download fetches it on request (pinned revision,
SHA-256). Dev hooks CP_PLAY, CP_PLAY_AUTO, CP_MAIA. Russian texts; the other
languages follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 04:10:02 +03:00
|
|
|
/// The user's rating (optional): the strength of Maia is chosen relative to it.
|
|
|
|
|
pub rating: Option<u32>,
|
|
|
|
|
/// The last choices of the play dialog.
|
|
|
|
|
pub play: crate::play::PlayPrefs,
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Options of the whole-game analysis (the engine is the active one).
|
2026-10-25 22:47:39 +03:00
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub struct ReviewSettings {
|
|
|
|
|
/// Index into [`REVIEW_QUALITY`].
|
|
|
|
|
pub quality: usize,
|
|
|
|
|
pub threads: u32,
|
|
|
|
|
pub hash_mb: u32,
|
2026-10-25 22:47:39 +03:00
|
|
|
/// An analysis was started from the dialog once: «Analyse» starts the next one with
|
|
|
|
|
/// these options at once (the dialog stays for «Analyse again…»).
|
|
|
|
|
pub chosen: bool,
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for ReviewSettings {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
quality: 1,
|
|
|
|
|
threads: default_threads(),
|
|
|
|
|
hash_mb: default_hash(),
|
2026-10-25 22:47:39 +03:00
|
|
|
chosen: false,
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Search effort per position: (label, nodes).
|
|
|
|
|
pub const REVIEW_QUALITY: [(&str, u64); 3] = [
|
|
|
|
|
("Fast", 250_000),
|
|
|
|
|
("Normal", 1_000_000),
|
|
|
|
|
("Deep", 3_000_000),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
impl ReviewSettings {
|
2026-10-25 23:03:16 +03:00
|
|
|
/// Options other than the defaults were chosen in the dialog (before `chosen` was
|
|
|
|
|
/// kept, 1.5): they count as chosen.
|
|
|
|
|
pub fn note_earlier_choice(&mut self) {
|
|
|
|
|
let default = ReviewSettings::default();
|
|
|
|
|
if (self.quality, self.threads, self.hash_mb)
|
|
|
|
|
!= (default.quality, default.threads, default.hash_mb)
|
|
|
|
|
{
|
|
|
|
|
self.chosen = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
pub fn nodes(&self) -> u64 {
|
|
|
|
|
REVIEW_QUALITY[self.quality.min(REVIEW_QUALITY.len() - 1)].1
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Settings {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
piece_set: PieceSet::default(),
|
|
|
|
|
board_theme: BoardThemeId::default(),
|
|
|
|
|
show_coords: true,
|
2026-10-21 19:57:54 +03:00
|
|
|
animation: Animation::default(),
|
Premoves, the auto-queen setting, the play dialog redone
Premoves in the game against Maia, as on Lichess: while she thinks, a move of
the user's piece by its pattern on an empty board (a pawn forward and both
diagonals, sliders through pieces, the king at home to castle with an own rook,
by the king's square or the rook's) is set and shown in dark blue; after her
move it is played at once when legal (a promotion as a queen), else dropped.
A right click or a click beside the own pieces cancels it; a take-back, the
leave question and the end drop it. A piece in hand stays there when Maia
moves, unless she took it.
Settings › Board: «Always promote to a queen», off by default — then the
piece is chosen, as before.
The dialog «Play against the computer» redone after the owner's review: You,
Opponent (the strength in the title, the slider edge to edge with 600/2600,
Weaker · As me · Stronger lit when they match, or a line asking for the
rating), Colour, Time; every choice a framed tile of one height, the tiles of a
row sharing its width; time 3+0…30+20 without category captions, Custom with
aligned sliders, Unlimited (no clocks) as a double tile; a solid scroll bar
in a low window, where the introduction is left out. Dev hook CP_PREMOVE.
Adjourning a game recorded as a task.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 12:12:35 +03:00
|
|
|
auto_queen: false,
|
Move notation: Latin letters, figurines or the interface language's letters
Settings › Board & pieces: Nf3, ♘f3 as on Lichess, or Кр Ф Л С К (German
K D T L S, French R D T F C, Spanish and Italian R D T A C; in English the
Latin letters), with a sample per option and a line of a game. Only the shown
label changes (san::show): the game, PGN, copied games, the analysis written
into a game, the reference cache and every comparison stay Latin SAN. Applied
in the move list, engine lines, the reference tab, board search and the
analysis report. The figurines are egui's chess glyphs cut out to a 4.7 KB
font, a little smaller and on the baseline. Latin remains the default.
Reviewed by the designer and the tester agents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:18:53 +03:00
|
|
|
move_notation: Default::default(),
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
translation: Default::default(),
|
2026-10-18 01:54:06 +03:00
|
|
|
sound_enabled: true,
|
|
|
|
|
sound_set: SoundSet::default(),
|
|
|
|
|
volume: 0.7,
|
|
|
|
|
dark_mode: true,
|
|
|
|
|
language: Lang::default(),
|
|
|
|
|
engines: Vec::new(),
|
|
|
|
|
active_engine: None,
|
|
|
|
|
show_best_arrow: true,
|
|
|
|
|
databases: Vec::new(),
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
review: ReviewSettings::default(),
|
2026-10-18 11:53:30 +03:00
|
|
|
engines_discovered: false,
|
2026-10-19 12:21:09 +03:00
|
|
|
examples_added: false,
|
2026-10-20 07:55:59 +03:00
|
|
|
check_updates: true,
|
|
|
|
|
skipped_version: None,
|
|
|
|
|
last_version: None,
|
2026-10-24 13:45:15 +03:00
|
|
|
install_id: String::new(),
|
2026-10-19 23:20:37 +03:00
|
|
|
reference_db: None,
|
Own databases: create PGN bases, add, save, delete games; library logging
Desktop: «✚ New database» on the shelf (Ctrl+Shift+N), «Add to database…»
(Ctrl+Shift+S, 💾, ☰) for any game — new, pasted, from a ChessBase, online or
legacy-encoded database — into a PGN of the user's choice; Ctrl+S saves the
changes back into the game's own PGN (its record is replaced) or adds the game
when the source is read-only; the game data editor (F2, the title, ☰) asked once
when a new game is first added; duplicate check (same players, date, moves →
replace / add as new, no Enter); delete from the table with a question and Undo
(Ctrl+Z, 6 s, waits under the mouse); UTF-8 copy for legacy-encoded files with
the restored letters; online and ChessBase stay read-only. Writes are explicit:
append, or an atomic rewrite through a temporary file and a rename (through a
symlink, keeping the mode, syncing the folder), refused when the file changed on
the disk. chess_core::pgn::store: append/replace/remove/restore/write_utf8_copy,
find_same_game, pgn_date; Game::remove_tag and order_roster. Settings: your
name (annotator), the folder for new databases, the last target. Nine languages.
Also: library warnings (wgpu, winit) go to chesspenguin.log, CP_LOG_FRAMES=1
traces egui_wgpu frames (the GNOME hang hunt); dev hooks CP_OWN, CP_PASTE,
CP_COMMENT, CP_KEYS with Ctrl+, CP_SETTINGS=interface.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 00:46:47 +03:00
|
|
|
your_name: String::new(),
|
|
|
|
|
new_database_dir: None,
|
|
|
|
|
last_target: None,
|
Play against Maia: dialog, clocks, game screen, result strip
«⚔ Play» (Ctrl+G) opens «Play against the computer»: name and rating
(optional), strength 600–2600 (or weaker/as me/stronger), colour, Lichess time
controls, custom, no clock. The game screen in play mode: clock cards above
and below the notation (read-only), take back, resign (abort before the first
moves); no engine, analysis or editing. Maia answers in a background thread
with a human-like pause bounded so she never loses on time; stale answers are
dropped. Endings: mate, stalemate, no material, threefold, fifty moves, time
(draw when the other side cannot mate), resignation; then the result strip
(Analyse, Rematch, New game, Save to a database) and an ordinary game with the
tags of a played game and [%clk]. Leaving during a game asks (resign and add /
resign and leave / keep playing), the clocks wait meanwhile. maia reads the
published PyTorch checkpoint directly (zip + a small pickle reader that refuses
everything but tensors); maia_download fetches it on request (pinned revision,
SHA-256). Dev hooks CP_PLAY, CP_PLAY_AUTO, CP_MAIA. Russian texts; the other
languages follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 04:10:02 +03:00
|
|
|
rating: None,
|
|
|
|
|
play: Default::default(),
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Settings {
|
|
|
|
|
pub fn config_dir() -> Option<PathBuf> {
|
|
|
|
|
directories::ProjectDirs::from("io.github", "vrubelroman", "ChessPenguin")
|
|
|
|
|
.map(|d| d.config_dir().to_path_buf())
|
|
|
|
|
}
|
|
|
|
|
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
/// `~/.cache/chesspenguin` (derived data that can be deleted at any time).
|
|
|
|
|
pub fn cache_dir() -> Option<PathBuf> {
|
|
|
|
|
directories::ProjectDirs::from("io.github", "vrubelroman", "ChessPenguin")
|
|
|
|
|
.map(|d| d.cache_dir().to_path_buf())
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
fn file() -> Option<PathBuf> {
|
|
|
|
|
Self::config_dir().map(|d| d.join("settings.json"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn load() -> Self {
|
|
|
|
|
let Some(path) = Self::file() else {
|
2026-10-19 12:24:40 +03:00
|
|
|
return Self::first_start();
|
2026-10-18 01:54:06 +03:00
|
|
|
};
|
|
|
|
|
migrate_legacy_config(&path);
|
|
|
|
|
match std::fs::read(&path) {
|
2026-10-25 23:03:16 +03:00
|
|
|
Ok(bytes) => {
|
|
|
|
|
let mut s: Settings = serde_json::from_slice(&bytes).unwrap_or_else(|e| {
|
|
|
|
|
eprintln!(
|
|
|
|
|
"settings: cannot parse {}: {e}; using defaults",
|
|
|
|
|
path.display()
|
|
|
|
|
);
|
|
|
|
|
Self::default()
|
|
|
|
|
});
|
|
|
|
|
s.review.note_earlier_choice();
|
|
|
|
|
s
|
|
|
|
|
}
|
2026-10-19 12:24:40 +03:00
|
|
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Self::first_start(),
|
2026-10-18 01:54:06 +03:00
|
|
|
Err(_) => Self::default(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 12:24:40 +03:00
|
|
|
/// Settings of the very first start: the defaults in the system's language (if it
|
|
|
|
|
/// is one of ours, otherwise English).
|
|
|
|
|
fn first_start() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
language: Lang::system(),
|
|
|
|
|
..Self::default()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
pub fn save(&self) -> std::io::Result<()> {
|
|
|
|
|
let Some(path) = Self::file() else {
|
|
|
|
|
return Ok(());
|
|
|
|
|
};
|
|
|
|
|
let json = serde_json::to_vec_pretty(self).map_err(std::io::Error::other)?;
|
|
|
|
|
write_atomic(&path, &json)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn active_engine(&self) -> Option<&EngineConfig> {
|
|
|
|
|
self.active_engine.and_then(|i| self.engines.get(i))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn touch_database(&mut self, path: &Path) {
|
|
|
|
|
self.databases.retain(|p| p != path);
|
|
|
|
|
self.databases.insert(0, path.to_path_buf());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Copies settings of the pre-rename build (`chessbase-linux`) once, if the new file is absent.
|
|
|
|
|
fn migrate_legacy_config(new_file: &Path) {
|
|
|
|
|
if new_file.exists() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let legacy = directories::ProjectDirs::from("org", "chessbase-linux", "chessbase-linux")
|
|
|
|
|
.map(|d| d.config_dir().join("settings.json"));
|
|
|
|
|
if let Some(old) = legacy.filter(|p| p.is_file())
|
|
|
|
|
&& let Ok(bytes) = std::fs::read(&old)
|
|
|
|
|
{
|
|
|
|
|
let _ = write_atomic(new_file, &bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Writes via a temp file in the same directory and renames over the target.
|
|
|
|
|
pub fn write_atomic(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
|
|
|
|
|
if let Some(dir) = path.parent() {
|
|
|
|
|
std::fs::create_dir_all(dir)?;
|
|
|
|
|
}
|
|
|
|
|
let tmp = path.with_extension(format!("tmp{}", std::process::id()));
|
|
|
|
|
std::fs::write(&tmp, bytes)?;
|
|
|
|
|
std::fs::rename(&tmp, path).inspect_err(|_| {
|
|
|
|
|
let _ = std::fs::remove_file(&tmp);
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-10-25 23:03:16 +03:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn options_chosen_before_count_as_chosen() {
|
|
|
|
|
let mut r = ReviewSettings::default();
|
|
|
|
|
r.note_earlier_choice();
|
|
|
|
|
assert!(!r.chosen, "the defaults: never chosen");
|
|
|
|
|
r.quality = 2;
|
|
|
|
|
r.note_earlier_choice();
|
|
|
|
|
assert!(r.chosen);
|
|
|
|
|
}
|
|
|
|
|
}
|