Skip to content

Keep notes and bookmarks on replayed games - #5

Merged
BAKocska merged 5 commits into
mainfrom
feat/study-notes
Sep 28, 2026
Merged

BAKocska merged 5 commits into
mainfrom
feat/study-notes

Conversation

@BAKocska

@BAKocska BAKocska commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Delivers RM-01.b on top of v0.7.0.

  • New internal/study: one versioned document per saved game id in study/ under the configuration directory, bound to the canonical record digest and the entry index. Writes hold a per-study advisory lock across re-read, revision compare and atomic replacement (Windows through internal/winfs); loading never writes. A different record, a newer or damaged document, an exhausted revision and unfinished games are refused without touching the file. Notes are bounded to 8 KiB of UTF-8 and documents to 1 MiB.
  • Replay viewer: m bookmarks the entry on screen and e edits its one-line note; both are kept per entry, not per ply, shown in the panel and marked */# in the entry list. Stored text is drawn inert.
  • A save overtaken by another window is refused with the typed note kept; it can replace the stored note only once the current layout has shown that stored version whole. Every refusal reaches the status line when there is no panel.

Scope and compatibility

Canonical records and game export are unchanged; deleting a saved game leaves its study file in place. No CLI command, cascade or portable bundle. Study format 1 only.

Verification

  • Local: gofmt, vet (also GOOS=windows), full suite with zero e2e skips, -race on internal/app, internal/cli and internal/study (added to the CI race job).
  • Two-process tests prove the lock covers the read/modify/write; they are required storage tests on native Windows.
  • Compiled e2e TestStudyNoteSurvivesLeavingAndResizing: menu → finished game → jump → note → bookmark → leave → reopen → the note and bookmark are on the same entry, survive resize, and the saved game's bytes are unchanged. Required on native Windows.
  • Two independent review rounds resolved. Twelve finite mutations were killed by named tests (entry vs ply, stale revision compare, lock after read, digest attachment, unfinished writes, size bound, inert rendering, paste measured before cleaning, stale overwrite of an unseen note, clipped stored-note fit, load writing, revision wrap).
  • Actual binary smoke in tmux, including reopen and a 40×12 resize.

A study document per saved game id, bound to the canonical record digest and entry index. Writes compare the loaded revision under a per-study advisory lock and replace the file atomically; loading never writes. A different record, a newer or damaged document and unfinished games are refused without touching the file. Notes are bounded to 8 KiB of UTF-8 and documents to 1 MiB.
m bookmarks the entry on screen and e edits its one-line note; both are kept per entry, not per ply, and marked in the entry list. A save overtaken by another window is refused with both versions kept, and is only replaced once the stored version has been shown whole. Refusals reach the status line when there is no panel.
A study file left at the highest revision loads, but the next save would wrap to a negative revision that Load refuses, losing every note while reporting success. Set now refuses it as damaged before anything is written.
# Conflicts:
#	.github/scripts/test-windows.ps1
#	.github/workflows/ci.yml
#	CHANGELOG.md
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T13:39:57.835635Z a8a31a2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8a31a2e59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/study/study.go
Comment on lines +350 to +353
dec := json.NewDecoder(bytes.NewReader(data))
dec.DisallowUnknownFields()
var s Study
if err := dec.Decode(&s); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject missing or duplicated study fields

When a study file is hand-edited or partially generated with a missing, null, or duplicated entries field, DisallowUnknownFields does not reject it: a missing/null field becomes an empty slice, while a duplicated field silently keeps the last value. Load therefore treats the damaged document as valid, and the next note or bookmark save rewrites it, potentially discarding marks from the omitted or earlier field despite the stated guarantee that damaged study files are preserved. Track required field presence and reject duplicate object keys before accepting the document.

Useful? React with 👍 / 👎.

@BAKocska
BAKocska merged commit 49fb076 into main Sep 28, 2026
16 checks passed
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