Skip to content

feat: continuous timed mode — stream words until the clock stops (#6) - #26

Open
hindriix wants to merge 1 commit into
jrnxf:mainfrom
hindriix:feat/continuous-timed-mode
Open

feat: continuous timed mode — stream words until the clock stops (#6)#26
hindriix wants to merge 1 commit into
jrnxf:mainfrom
hindriix:feat/continuous-timed-mode

Conversation

@hindriix

@hindriix hindriix commented Jul 22, 2026

Copy link
Copy Markdown

What

Makes timed tests (-s) a true Monkeytype-style time attack: instead of ending the moment you reach the end of a fixed prompt, fresh words stream in as you type and the test ends only when the clock hits zero.

Closes #6.

Why

Today, thokr -s 60 over the default 15 words is over in a couple of seconds — the timer is really just a cap, not a duration. A timed test people actually want runs for the full time and keeps feeding you words. #6 has asked for this ("continually load new words to meet time limit / scroll lines") since early 2023.

How

  • thok: a refill_words pool; when it's non-empty, refill_if_needed() tops the prompt up whenever the runway ahead of the cursor runs low, and has_finished() ends the test on the timer only — never by reaching the end of the words.
  • main: seeds the pool from the active language, but only in the default word mode with -s. A custom prompt (-p) or sentences (-f) are finite text, so they still end at their own length.
  • ui: because the prompt is now unbounded, the running view scrolls a fixed 3-line window (anchored to the cursor line) instead of expanding to fit — the layout stays centered and stable. The hardware-cursor math tracks the same window so it can't drift from the rendered text.

Verification

  • cargo build, cargo test, cargo clippy, cargo fmt --check all clean; new unit tests cover refill-keeps-runway, timer-only finish, and that non-continuous mode still finishes by length.
  • Manually driven through a PTY: the timer counts down, the prompt streams well past the initial buffer, and the test ends on the clock with a normal results screen.

Backwards compatible: non--s runs and -p/-f are unchanged.

Timed tests (`-s`) previously ended the moment you reached the end of a
fixed prompt, so a 60s run over 15 words was over in a couple seconds.
This makes `-s` a true Monkeytype-style time attack: words stream in as
you type and the test ends only when the timer expires. Closes the
long-standing request in issue jrnxf#6.

- thok: add a `refill_words` pool; `refill_if_needed()` tops the prompt
  up whenever the runway ahead of the cursor runs low, and continuous
  tests finish on the timer only (never by length).
- main: seed the refill pool from the active language in the default word
  mode with `-s`; a custom prompt (`-p`) or sentences (`-f`) stay finite.
- ui: render a scrolled 3-line viewport for the (now unbounded) prompt so
  the layout stays centered and stable; cursor math tracks the window.
- docs + `--help`: describe continuous mode; refresh examples.
- tests: cover refill, timer-only finish, and non-continuous length finish.
@hindriix
hindriix force-pushed the feat/continuous-timed-mode branch from f4dd032 to 6c24147 Compare July 25, 2026 06:07
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.

continually load new words to meet time limit / scroll lines

1 participant