Persist attempts used across sessions#41
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
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, or 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 fix this CI failure" or "@codex address that feedback".
| setStudentName(savedName); | ||
| const storageKey = `ss::${assignment.id}::${savedName}`; | ||
| const savedProgress = loadProgress(storageKey); | ||
| setAttemptsUsed(savedProgress?.attemptsUsed ?? 0); | ||
| if (savedProgress && savedProgress.results.length > 0) { | ||
| setProgress(savedProgress); | ||
| setShowResumePrompt(true); |
There was a problem hiding this comment.
[P1] Preserve attempts when progress has no results
The initialization effect loads savedProgress and restores attemptsUsed, but it immediately calls startNewAttempt() whenever savedProgress.results.length === 0. startNewAttempt overwrites the saved data and resets attemptsUsed back to 0 in both state and localStorage. If a student closes the page after using some attempts on the first sentence (before any results are recorded), reopening the homework resets the remaining attempts instead of enforcing the persisted limit. Consider skipping startNewAttempt when a saved record exists or at least avoiding the reset when attemptsUsed > 0 so the max-attempt limit is still honored across sessions.
Useful? React with 👍 / 👎.
Summary
Testing
npm testnpm run buildhttps://chatgpt.com/codex/tasks/task_e_68c821dac704832cbdd17782430440e7