Skip to content

Clock times in the PGN of games against Maia, and in the analysis export - #463

Merged
ashtonanderson merged 1 commit into
mainfrom
claude/pgn-clock-times-maia-b4f009
Dec 3, 2026
Merged

ashtonanderson merged 1 commit into
mainfrom
claude/pgn-clock-times-maia-b4f009

Conversation

@ashtonanderson

Copy link
Copy Markdown
Member

From a Discord request: the PGN of a Play vs. Maia game lost all its clock times, which players want for seeing whether they spend too much or too little time on moves.

What changes

  • Play page: the PGN has each move's clock as a %clk comment, as Lichess exports it:
    1. e4 { [%clk 0:03:00] } 1... c5 { [%clk 0:03:00] } 2. Nf3 { [%clk 0:02:59] } ...
    The clocks are rebuilt from the time the server charged each move, with the server's rule (first move of each side free, then charged and given the increment): mainlineClocks in src/lib/pgn.ts. The board now takes the server's move_times when its answers come (syncMoveTimes), in place of the times the page first gave the moves.
  • Analysis page: a stored game keeps the PGN the backend sends (AnalyzedGame.pgn), and the export writes the clocks found in a game's PGN (pgnClocks). Played games get them once CSSLab/maia-platform-backend#388 is deployed; Lichess games get theirs now (their exports used to drop them too).
  • Practice games have no clocks: a takeback keeps the time used, and extra time isn't kept per move, so their clocks can't be rebuilt. The backend PR does the same.

Checks

  • On the local dev server: in a 3+2 game the PGN clocks matched the on-board clocks, stayed the same after reloading and resuming, and were there once the game ended. A live Lichess blitz game's analysis export keeps its clocks. A played game opens on the analysis page as before against the production backend.
  • New tests in src/lib/pgn.test.ts and ExportGame.test.tsx; npx tsc --noEmit, npm run lint, and all 678 tests pass.

Either PR can merge first: until the backend is deployed, played games' analysis exports simply have no clocks.

🤖 Generated with Claude Code

Play vs. Maia (and Hand and Brain): the PGN has each move's clock as a
%clk comment, rebuilt from the time the server charged each move under
its rule (the first move of each side free, then charged and given the
increment). The board now takes the server's move times when its answers
come, in place of the times the page first gave the moves.

Analysis: a stored game keeps the PGN the backend sends, and the export
writes the clocks in a game's PGN (a played game's once the backend has
them, and a Lichess game's).

Practice games have no clocks: a takeback keeps the time used, and extra
time isn't kept move by move, so they can't be rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maia-platform-frontend Ready Ready Preview Dec 3, 2026 11:48pm UTC

Request Review

@ashtonanderson
ashtonanderson merged commit 948d641 into main Dec 3, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 728d7ba8 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant