feat(answer-game): auto-persist config draft on every keystroke

Open Beginner friendly
#272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in InstructionsOverlay and trace the existing onPersistLastSession callback and draftApi.draft.config flow introduced by PR #270. Add debounced persistence for draft changes while preserving the explicit Play-branch writes. Done means edits from both forms survive a refresh, the debounce is at least 300 ms, and playing still persists correctly.

Written by the indexing model from the issue text.

Description

enhancement

Problem

Before PR #270, usePersistLastGameConfig debounced config writes to saved_game_configs on every keystroke. This meant the panel state survived browser refreshes — the user's last-edited config was restored on next visit.

PR #270 removed the debounce and replaced it with explicit writes only on Play. As a result, edits made in the simple form (or advanced modal) are lost if the user refreshes before playing.

Proposed solution

Re-add lightweight auto-persistence so that saved_game_configs is kept in sync with the current draft as the user edits. Options (in order of preference):

  1. Debounced write inside InstructionsOverlay — call onPersistLastSession(draftApi.draft.config) in a useEffect that watches draftApi.draft.config, with a ~500 ms debounce. The onPersistLastSession callback already exists on the overlay; this is purely additive.
  2. Restore a lightweight hook — reintroduce a slim usePersistLastGameConfig (or rename it useAutoSaveDraft) that wraps the debounce, and wire it back into the route alongside the explicit Play-branch calls.

Option 1 keeps the logic close to the overlay and avoids re-adding a route-level hook.

Acceptance criteria

  • Making a change in the simple form or advanced modal and refreshing the page restores the edited config (not the last-played config).
  • Debounce is at least 300 ms to avoid hammering RxDB on every keystroke.
  • The explicit Play-branch writes from PR #270 are preserved (no regression).

Context

  • PR #270 (config state sync) introduced useConfigDraft and onPersistLastSession
  • Issue #254 (parent of #270)
  • Issue #271 (confirm on discard — related UX improvement)
Dominant language
TypeScript
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leocaseiro/base-skill

All issues in leocaseiro/base-skill

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.