Skip to content

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

Open
anuragkej wants to merge 46 commits 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 46 commits 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.
Copy link
Member

@Miodec Miodec left a comment

Choose a reason for hiding this comment

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

It recovers yes, but it seems like its no longer accurate. If you Enable plus one and set it to 60wpm, start the test and pause, then catch up to the pace caret and try to finish near it, the result will not be close to 60wpm. (i got 36 and i finished right with the pace caret).

Image

@Miodec Miodec added waiting for update Pull requests or issues that require changes/comments before continuing and removed waiting for review Pull requests that require a review before continuing labels Mar 9, 2026
Miodec and others added 20 commits March 9, 2026 17:19
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
…typegame#7558)

Co-authored-by: Jack <jack@monkeytype.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
also adds tests to existing anime components

!nuf
Co-authored-by: Christian Fehmer <cfe@sexy-developer.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Miodec and others added 19 commits March 9, 2026 17:19
…ter-events

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Brr

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jack <jack@monkeytype.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
…onkeytypegame#7589)

### Description

This PR prevents interaction with UI elements while the **"Downloading
user data..."** loading state is active.

During the initial authentication loading phase ("Downloading user
data..."), the UI remains interactive even though the application is
still initializing user data.

This allows users to hover and interact with elements such as the
navbar, footer, and test configuration before the loading process
finishes.

### Reproduction

1. Log into an account
2. Refresh the page
3. Move the cursor over navbar icons or other UI elements while the
loading bar is visible
4. Notice hover effects and interactions are still possible

### After Fix

While the loading process is active, UI interaction is disabled for key
interactive sections:
- Navbar
- Footer
- Test configuration panel

Users can no longer trigger hover effects or interact with these
elements until loading finishes.

### Technical Notes

A temporary `loading` class is applied to the `body` element during the
loading phase.

While active, the following UI sections have interactions disabled:
- `header nav`
- `footer`
- `#testConfig`

This is achieved using:

```
pointer-events: none;
user-select: none;
```

The class is removed once navigation loading completes.

### 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](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LANGUAGES.md)
  - [ ] 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](https://github.com/monkeytypegame/monkeytype/blob/master/docs/THEMES.md)
  - [ ] 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](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LAYOUTS.md)
  - [ ] 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](https://github.com/monkeytypegame/monkeytype/blob/master/docs/FONTS.md)
  - [ ] Add font file to `frontend/static/webfonts`
  - [ ] Add font to `packages/schemas/src/fonts.ts`
  - [ ] Add font to `frontend/src/ts/constants/fonts.ts`
- [x] Check if any open issues are related to this PR; if so, be sure to
tag them below.
- [x] Make sure the PR title follows the Conventional Commits standard.
(https://www.conventionalcommits.org for more info)
- [x] Make sure to include your GitHub username prefixed with @ inside
parentheses at the end of the PR title.

Closes monkeytypegame#7587

---------

Co-authored-by: Miodec <jack@monkeytype.com>
Co-authored-by: Miodec <jack@monkeytype.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- wrong text on public profile test activity "months" instead "last 12
months"
- newlines not displayed in profile bio and keyboard
@monkeytypegeorge monkeytypegeorge added backend Server stuff docs Related to Markdown files and documentation assets Languages, themes, layouts, etc. packages Changes in local packages labels Mar 9, 2026
@github-actions github-actions bot removed the waiting for update Pull requests or issues that require changes/comments before continuing label Mar 9, 2026
@monkeytypegeorge monkeytypegeorge removed backend Server stuff docs Related to Markdown files and documentation assets Languages, themes, layouts, etc. packages Changes in local packages labels Mar 9, 2026
@Miodec Miodec added the waiting for update Pull requests or issues that require changes/comments before continuing label Mar 9, 2026
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 update Pull requests or issues that require changes/comments before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pace Caret disappears when you advance beyond Plus Three.

6 participants