Skip to content

Fix/answer dropped before run init - #170

Merged
bitbacchus merged 3 commits into
mainfrom
fix/answer-dropped-before-run-init
Aug 20, 2026
Merged

Fix/answer dropped before run init#170
bitbacchus merged 3 commits into
mainfrom
fix/answer-dropped-before-run-init

Conversation

@bitbacchus

Copy link
Copy Markdown
Member

Fixes a race where an answer selected during the quiz run's (re)initialisation window was silently discarded — e.g. a startup WebSocket reconnect clears run and the async GetRun re-fetch stalls on the ts-actors 5 s ask-timeout, leaving the answer UI clickable while LogAnswer no-ops.

Changes

  • LogAnswer buffers the pending {questionId, answer} in state.pendingAnswer instead of no-oping when run is undefined; flushPendingAnswer() replays it once run + questions are ready (GetRun / StartQuiz / SetQuiz-same / QuestionUpdate). Buffer cleared on Reset / SetQuiz-different / QuizRunDeleted.
  • Student answer UI (RunningQuizTab) gated on run present + hasInitialQuestions, scoped so teacher tabs still render without a run.
  • Added CurrentQuizActor unit test for buffer + replay.
  • Version bump frontend 1.7.0 → 1.7.1; NEWS.md entry.

Verified on the test server. Backend and models unchanged.

An answer selected while CurrentQuizActor.state.run was undefined was
silently discarded: LogAnswer's body is wrapped in `if (this.state.run)`
with no else, and the student answer UI was clickable during the run
(re)initialisation window (e.g. the startup WS reconnect clears `run` and
the async GetRun re-fetch stalls on the ts-actors 5s ask-timeout).

- LogAnswer: buffer the pending {questionId, answer} in state.pendingAnswer
  instead of no-oping when run is undefined; new flushPendingAnswer() replays
  it once run + questions are ready (from GetRun, StartQuiz, SetQuiz-same,
  QuestionUpdate). Buffer cleared on Reset/SetQuiz-different/QuizRunDeleted.
- QuizPage: gate the student answer UI (RunningQuizTab) on run present +
  hasInitialQuestions so a question isn't answerable before the run exists.
  Scoped to that branch (not page-wide) so teacher tabs still render without
  a run while editing; keyed on `run` rather than the unreliable runReady flag.
- Add CurrentQuizActor unit test covering buffer + replay.
@bitbacchus
bitbacchus merged commit 721c866 into main Aug 20, 2026
5 checks passed
@bitbacchus
bitbacchus deleted the fix/answer-dropped-before-run-init branch August 20, 2026 13:47
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.28205% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/frontend/src/pages/QuizPage.tsx 0.00% 10 Missing ⚠️
packages/frontend/src/actors/CurrentQuizActor.ts 68.96% 8 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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