Repository navigation
Chess cli v2 - #12
Merged
Merged
Chess cli v2#12
Conversation
- New BoardView primitive replaces the fixed-size cv.Table board. Squares scale to the available space and redraw on terminal resize; pieces render as half-block pixel art at larger sizes, glyphs when small. - Mouse click-to-move kept (click doesn't steal focus from the move input); keyboard cursor via Tab + arrows/hjkl + Enter. Legal targets, selection, captures and last move are highlighted. Promotions by mouse now work (auto-queen) - previously impossible. - Online: only your own pieces are selectable, on your turn. - Fix: local post-game screen drew onto the online post-game board. - Lichess: 'Logged in as' shows username only; stop requesting email:read. - Tests for geometry, square mapping and click-to-move.
Replaces auto-queen. A Lichess-style column of the four pieces opens over the promotion square (the rest of the board dims); click one or press q/r/b/n, Esc or a click elsewhere cancels. Works with the board flipped. Selection/picker are dropped when the position changes underneath them.
Stability
- One HTTP helper for every API call: timeouts, bodies always closed,
Lichess error messages surfaced ("Not your turn") instead of raw codes.
No more log.Fatal/os.Exit on network errors.
- Account event stream reconnects with backoff; game stream reconnects
(Lichess resends full state) and is cancelled when you leave a game.
- All online game state is now changed only on the UI goroutine; network
calls (moves, accept, resign...) no longer block the UI. Tests pass
under -race.
- Removed a busy loop on the loading screen that pinned a CPU core.
- Single reader for account events (two goroutines raced for them).
Login and storage
- Login runs in the background: UI stays responsive, the login URL is
shown in case the browser doesn't open, "Cancel" on Lichess and closing
the tab (5 min timeout) are handled, OAuth state is checked, and a
revoked token triggers a fresh login. Expiry comes from Lichess.
- Token and saved games move to ~/.config/chess-cli (0600) instead of
the working directory; old files are migrated (the world-readable
legacy token file is removed after migration).
Bugs fixed
- Random-opponent seeks with a clock sent challenge params (clock.limit)
instead of the seek's time (minutes)/increment.
- Challenges were sent with keepAliveStream but the app read the whole
response, so it only learned its challenge id once the game started.
It now reads the id immediately and keeps the challenge alive.
- Draw/takeback offers never showed for usernames with capitals (name vs
lower-case id); offer popups no longer stack on repeated updates.
- Challenges list kept stale ids between visits (empty list, wrong game).
- Accepting a challenge opened the game even when the accept failed.
- Post-game board is shown from your side.
Features
- Loading screen: Esc cancels the challenge/seek on Lichess.
- In-game chat panel (history loaded on join), Tab cycles move input,
board and chat.
- Claim victory/draw when the opponent leaves (with countdown).
- Rematch from the post-game screen (same settings, colours swapped;
same level vs the AI).
- Challenges screen: decline incoming (d), cancel outgoing (Enter).
- Typed promotions without a piece get a hint (e7e8 -> e7e8q).
- Abort is only offered while Lichess allows it.
Tests: API layer against a fake Lichess (errors, challenge keep-alive and
cancel, seek params, game stream events, OAuth success/cancel/forged
state, legacy config migration) and an end-to-end online game driving
the real UI on tcell's mock terminal (mouse moves, opponent reply, draw
offer, chat, opponent leaving, resignation, rematch).
- GoReleaser config: Linux/macOS/Windows x amd64/arm64 archives with checksums, built when a v* tag is pushed (release workflow). Verified with a local snapshot build. - CI workflow: vet + tests (race detector on Linux/macOS) on all three OSes. - Import cview from codeberg.org directly (same v1.6.3) and drop the replace directives, which made `go install ...@latest` impossible. - Drop the leftover tcell v1 encoding import; use tcell v3's. - `--version` (set at release time) and `--help` (shows the config dir). - README: install/run instructions, controls, Lichess features and the Board API time-control limits, where files live, development/release notes, updated todo list.
- Pieces are drawn with kitty's text sizing protocol: the terminal renders the Unicode glyphs scaled to fill each square (squares are 2s x s cells, s = 1..7). The board's cells are locked in tcell (tcell won't draw over them) and the multicell pieces are sent after each frame, only when the board changed; they're erased when the board leaves the screen. - Support is detected at startup with the spec's cursor-position probe, so any terminal that implements the protocol gets big pieces; tmux and others fall back to normal glyphs. CHESS_CLI_BIG_PIECES=0/1 overrides. - Removed the half-block pixel-art pieces. - Move input accepts standard algebraic (Nf3, exd5, e8=Q, O-O / 0-0), long algebraic, and UCI with a promotion marker (e7e8=N) as well as plain UCI; promotions typed without a piece get a hint. - Fix: typed-move errors in online games went to the local game's status. - Welcome quote gets padding and word wrap. - README: which terminals get big pieces, notation, todo.
kitty measures text by its width in the main monospace font, which has no chess symbols, so a centred piece had its left edge at the square's centre. Sending each piece with a trailing space gives kitty a width close to the glyph's, centring it (verified in kitty 0.45 at scales 3 and 6). Move dots use ⬤ instead of ●: kitty draws ● with its built-in shape renderer and tiled it across the square.
…er frame; CI: no fail-fast, newer actions
Owner
|
lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since f108262 (a76dae4, 5f86be9, c218e47, 517bb9d)
New
graphics protocol (kitty, Ghostty, WezTerm). Pieces are scaled to the exact
square size, so they stay sharp at any terminal size.
celtic, kiwen-suwi, totoy, papercut, rhosgfx, shapes) and 6 board colours
(brown, blue, green, purple, ic, grey). Only sets whose licences allow them
in a GPLv3 program; each keeps its SVG source and licence in
pkg/assets/pieces/.
Image rendering - Lichess boards and pieces as pictures
Advanced rendering - Unicode chess symbols, drawn big in kitty
Basic rendering - plain symbols in 8 standard colours, any terminal
(like the original chess-cli)
rendering mode, previews each one live. This can be changed in Options.
casual like Lichess. Hint, view solution, themes. Rated needs a Lichess
login; casual works without.
classical, Chess960, bots, computer), a player's current game, or any game
by link/ID. Live clocks and move list; TV fills in the moves from before
you joined. Only shown when logged in to Lichess.
coming up, recently finished, with leader/winner) and the latest Lichess
blog posts. Only fetched when logged in. The last news is saved, so it
shows instantly at startup while fresh news loads; the panel only changes
if the news did. Refreshes every 15 minutes after that.
start/now). Click to come back.
right-drag for an arrow; Shift red, Alt blue, Shift+Alt yellow; left-click
clears.
move box always shown instead.
and exits (so two copies can't fight over the Lichess stream or config).
offline. If Stockfish isn't installed: download the official release from
GitHub (checksum-verified, kept in chess-cli's folder, no admin rights),
point chess-cli at your own Stockfish, or see the install command for your
system.
time, a braille-dot bar (gold for time left, grey as it's used; brighter
gold for the running clock) and the time control at the other end
("10+5", "∞ Unlimited", "Correspondence · 3 days"). In watched, online and
local games. Option to turn the bar off (clocks go back to the sidebar).
10+0, 10+5, 15+10, 30+0, 30+20, 45+15, 60+30, 90+30, 120+30, and FIDE
classical (90 min for 40 moves, +30 min after move 40, 30 s per move from
move 1). Clock in the Local / Stockfish menus. Running out loses on time.
during games and while watching.
red # on a checkmated king, red flag for resignation/time, grey = for a
draw. The result ("0-1 · Black wins by checkmate") shows beside the board.
In local, Stockfish, online and watched games.
too, or any study by link. Chapters listed in the sidebar; the moves with
variations (indented, in brackets), comments and symbols (!?, ⩲ ...). The
study's arrows and circles are drawn on the board, and its orientation is
used. Left/right arrows (or the wheel, [ ]) step along the line, up/down
jump to the start/end; click any move, in a variation too, to go there.
f flips the board. Read-only for now. Uses the study:read permission the
login already asks for, so no new login needed.
Moves and chapters each sit in a thin grey box; chapters are numbered.
The move showing has a dark grey background; its comment gets a faint
green one and the side lines that branch off at it are underlined, so
you can see what the text is talking about. Lines nested inside them get
heavier underlines the deeper they go: solid, dashed, dotted, double,
curly (the terminal's underline styles; kitty, Ghostty, WezTerm and
others draw them, other terminals show a plain underline). The
underline is a dim grey so it doesn't crowd the moves. [Not sure about this underline UI - may remove.]
Move symbols show on the board like Lichess: a coloured badge on the
destination square (! green, !! dark green, ? orange, ?? red, !? pink,
?! blue), and in the same colours in the move list. Position and idea
symbols too (=, ∞, ±, ⩲, +−, N, ↑↑, ↑, →, ⇆, ⊕ time trouble, =∞, ∆, □,
⨀), as on Lichess.
round, time control, opening, annotator). Each player beside the board,
above and below it as on Lichess: title in orange, name, rating, and
their result at the other end. The game's result ends the move list:
"1–0" and e.g. "Checkmate • White is victorious" (checkmate and stalemate
read from the final position, time forfeit etc. from the Termination tag).
board is showing is highlighted (follows the mouse wheel and [ ] too). In
local, Stockfish, online, watched and puzzle games and on game-over
screens.
licences): Retro (chiptune blips, the default) or Wood (a soft
piece-on-board click), or off. Moves, captures, checks, castling, game
start, win/loss/draw, low time (under 10 s, once per side), illegal or
wrong moves, puzzle right/solved, and stepping through studies. Played
with the system's player (pw-play, paplay or aplay on Linux, afplay on
macOS, built-in PlaySound on Windows), so builds stay static. Options:
Sound: Retro / Wood / Off (plays a sample). The first-run screen asks
about sound after the rendering choice, previewing each; people
upgrading are asked once.
gradient behind the piece with image rendering, a red-tinted square with
advanced rendering, a red square with basic rendering. Also while
stepping back through a game and in studies.
Changed
board, big, on the right with its result marks and final clocks; players,
result, move list and menu in the sidebar. Step back through the finished
game as during play.
right edge; players, clocks, moves, chat and menu in a sidebar on the left.
Fixed
stripped of control characters before display, so it can't inject terminal
escape sequences; Unicode direction-override characters removed too.
go into a Lichess request URL.
changed in the UI (data race).
account event stream (incoming challenges and game starts went unnoticed).
(they showed 15 s while sending your previous choice), and default to 10+0
instead of a bullet control Lichess rejects.
their screen isn't showing.
fewer than 256 colours, the UI sticks to the standard colours: current
move in silver (the dark grey would be black on black), silver box
borders, no dark tints, plain underlines only (old terminals can misread
styled ones), player titles and clock labels in standard colours. Move
symbols on the board use the 8 standard colours. With kitty's big
pieces the symbol shows in the move list only (the piece fills the
square). Tested in each mode.
many lines; it's now measured properly and refits when the window is
resized.
the mouse had been, hiding the current item.
a stray "[]" when the line wrapped inside them.
has none), and the terminal's colour count is read once per frame from
the app's own screen, not on every board draw (in tests, standalone
boards triggered redraws of the test app, which leaked into another
test's output). Big pieces (kitty text sizing) now keep track of what's
on each screen separately, so a board drawn on one screen can't make
another erase and redraw its pieces.
results show); updated to actions/checkout@v5 and actions/setup-go@v6
(the old ones ran on Node 20, which GitHub is retiring).
Big Unicode pieces in kitty (f82c27a, f108262)
protocol), centred in their squares. Detected at startup;
CHESS_CLI_BIG_PIECES=0/1 overrides.
UCI e2e4).
Releases and CI (c013c59)
and arm64 (Apple Silicon, Raspberry Pi, ARM laptops): six downloads per
release, so people can play without installing Go. Pushing a version tag
(e.g. v0.2.0) starts the release workflow (.github/workflows/release.yml),
which runs GoReleaser (.goreleaser.yaml): it builds all six with
CGO_ENABLED=0 (static, no system libraries needed), stamps the version
into the binary (chess-cli --version), packs each as a .tar.gz (.zip for
Windows) with README and licence, writes checksums.txt (SHA-256) and
publishes them as a GitHub Release with notes made from the commit
messages since the last tag. Try it locally first with
goreleaser release --snapshot --clean (builds into dist/, publishes
nothing).
Lichess rework (7fb52a9)
link is shown if the browser doesn't open. Token saved in
~/.config/chess-cli with private permissions.
challenge/seek.
still opened the game; CPU busy-loop while waiting; saved games now in the
config folder.
Promotion picker (00df152)
or press q/r/b/n; Esc cancels.
Scalable board (64f55c2)
Earlier
tcellto v3 and patchingcviewvanity URLs #11 (e4rthb0y): tcell v3 dependency fix.