Skip to content

Players page: remember each player's filters and explored line too - #289

Open
jozef2svrcek wants to merge 2 commits into
mainfrom
feat/players-view-remembers-filters
Open

jozef2svrcek wants to merge 2 commits into
mainfrom
feat/players-view-remembers-filters

Conversation

@jozef2svrcek

Copy link
Copy Markdown
Contributor

The problem

On the Players page, set up a view and then Open in Analysis. Coming back loses the setup: the game list returns unfiltered and the explored line is gone. In the reported case, the setup was Player B, Opponent W, the explored line 1. c4 e62. g3, and a selected game.

#288 (in v0.17.0) remembers only the selected game and move per player. The filters and the explored line were left out on purpose, so a forgotten filter couldn't silently hide games. That was the wrong trade-off:

  • the filters are shown in the Filters panel, so a remembered one is never hidden;
  • they are exactly the setup you come back for.

Changes

Where What
lib/playerViewState.ts Keeps the whole view per player: the colour for Player and Opponent, the opponent, event, dates, the explored line and its position, and the selected game and move. Each field is checked on load. Views saved by 0.17.0 (selection only) still load, and the missing fields fall back to EMPTY_PLAYER_VIEW.
GamesPage.tsx, first render The Players view starts from the player's saved view (restored ?? savedView feeds every remembered field's initial state). This matters: the effect that clears the explored line when the colour is "Any" also runs on mount. Had the saved view been applied only in the player effect, that clear would have queued after it in the same commit and wiped the restored line.
GamesPage.tsx, player switch Restores that player's view, or EMPTY_PLAYER_VIEW for a player seen for the first time. Until now a new player inherited the previous player's filters.
GamesPage.tsx, save Saves every remembered field, still keyed by viewOwner (whose view is on screen), so a switch can't file one player's view under another.

Not remembered per player: the Collection filter, which is shared across pages and already survives navigation, and whether the Filters panel is folded, which stays one app-wide setting.

Verification

  • npx tsc --noEmit: clean. npm run build: succeeds.
  • lib/playerViewState.ts under Node with an in-memory localStorage: 9/9 passed.
    • The full view round-trips.
    • A 0.17.0 selection-only view keeps its selection and gets defaults for the rest.
    • Invalid fields fall back one by one (unknown colour, opponent without an id, non-string event or date, non-string moves), and the position is capped at the length of the explored line.
    • Keeps the 20 most recent players; corrupt JSON is handled and a full storage doesn't throw.
  • Not exercised in the app (no desktop app against a server here). To check:
    1. Players → pick a player → set Player B / Opponent W, explore a few moves, select a game → Open in Analysis → back to Players. Everything should be as you left it.
    2. Switch to another player and back: each player keeps their own view. A player you open for the first time starts clean.
    3. Restart the app: the views are still there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P4Dx2ACk3LrQbspzrQaZVN

jozef2svrcek and others added 2 commits September 14, 2026 16:25
#288 remembered only the selected game and move per player; the colour
filters, opponent, event, dates and the move line explored under them were
left out on purpose, and coming back from Analysis lost them. They're
visible in the Filters panel, so remembering them can't hide games, and
they are exactly the setup you come back for.

- lib/playerViewState keeps the whole view per player (validated field by
  field; views saved by 0.17.0 still load, the rest falls back to defaults).
- The view starts from the player's saved state on mount (restored ??
  savedView), so the effect that clears the line under "Any", which runs on
  mount too, can't wipe a restored line.
- A player switch restores that player's view, or EMPTY_PLAYER_VIEW for a
  new player instead of inheriting the previous player's filters.
- Save every remembered field, still keyed by viewOwner.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4Dx2ACk3LrQbspzrQaZVN
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4Dx2ACk3LrQbspzrQaZVN
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