Skip to content

fix(test): recover pace caret after word generation gaps (@anuragkej)#7560

Open
anuragkej wants to merge 1 commit intomonkeytypegame:masterfrom
anuragkej:fix/7527-pace-caret-plus-three
Open

fix(test): recover pace caret after word generation gaps (@anuragkej)#7560
anuragkej wants to merge 1 commit intomonkeytypegame:masterfrom
anuragkej:fix/7527-pace-caret-plus-three

Conversation

@anuragkej
Copy link

Description

This PR fixes a pace-caret edge case triggered with Plus Three (and similar dynamic word generation scenarios):

  • keeps pace-caret state when it briefly runs past words that are not generated yet,
  • retries safely while additional words may still be generated,
  • stops retries cleanly when word exhaustion is terminal (to avoid an endless hidden-caret timer loop),
  • adds targeted unit coverage for both recovery and terminal-stop paths.

Supersedes #7559 (GitHub would not allow reopening it after the source repo was detached from fork network).

Checks

  • Adding quotes?
    • Make sure to include translations for the quotes in the description (or another comment) so we can verify their content.
  • Adding a language?
    • Make sure to follow the languages documentation
    • Add language to packages/schemas/src/languages.ts
    • Add language to exactly one group in frontend/src/ts/constants/languages.ts
    • Add language json file to frontend/static/languages
  • Adding a theme?
    • Make sure to follow the themes documentation
    • Add theme to packages/schemas/src/themes.ts
    • Add theme to frontend/src/ts/constants/themes.ts
    • (optional) Add theme css file to frontend/static/themes
    • Add some screenshots of the theme, especially with different test settings (colorful, flip colors) to your pull request
  • Adding a layout?
    • Make sure to follow the layouts documentation
    • Add layout to packages/schemas/src/layouts.ts
    • Add layout json file to frontend/static/layouts
  • Adding a font?
    • Make sure to follow the fonts documentation
    • Add font file to frontend/static/webfonts
    • Add font to packages/schemas/src/fonts.ts
    • Add font to frontend/src/ts/constants/fonts.ts
  • Check if any open issues are related to this PR; if so, be sure to tag them below.
  • Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info)
  • Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.

Closes #7527

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Mar 2, 2026
@anuragkej anuragkej marked this pull request as ready for review March 2, 2026 02:26
Copilot AI review requested due to automatic review settings March 2, 2026 02:26
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Mar 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an edge case where the pace caret can disappear when it advances into yet-to-be-generated words (e.g., Plus Three), by adding a safe retry mechanism and a terminal stop condition to avoid endless hidden-caret loops.

Changes:

  • Update pace-caret stepping to retain state on “out of words” and retry updates while more words may still be generated.
  • Stop retrying (and clear pace-caret settings) when word generation is terminal for the current mode/limits.
  • Add Vitest unit coverage for the recovery and terminal-stop behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
frontend/src/ts/test/pace-caret.ts Adds retry scheduling + terminal exhaustion detection; refactors stepping to return success/failure.
frontend/__tests__/test/pace-caret.spec.ts Adds targeted tests around recovery vs terminal-stop behavior.

Comment on lines +209 to +214
function areAllTestWordsGenerated(): boolean {
if (Config.mode === "words") {
return TestWords.words.length >= Config.words && Config.words > 0;
}

if (Config.mode === "quote") {
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

areAllTestWordsGenerated() duplicates TestLogic.areAllTestWordsGenerated() logic (frontend/src/ts/test/test-logic.ts:572-590). This risks drift if generation/limit rules change. Consider extracting this predicate into a small shared module (importable by both) or otherwise centralizing it so pace-caret and test-logic stay consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +65
await PaceCaret.update(0);

Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

This recovery test doesn’t exercise the new timer-based retry path: it manually calls PaceCaret.update(0) again after pushing a word, instead of letting the scheduled retry fire. To validate the fix end-to-end, assert a retry timer was scheduled after the first failure and then advance/run fake timers (and flush pending promises) to confirm the caret state recovers via the scheduled update.

Suggested change
await PaceCaret.update(0);
expect(vi.getTimerCount()).toBeGreaterThan(0);
await vi.runOnlyPendingTimersAsync();
await Promise.resolve();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pace Caret disappears when you advance beyond Plus Three.

3 participants