Repository navigation
feat: continuous timed mode — stream words until the clock stops (#6) - #26
Merged
Merged
Conversation
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
force-pushed
the
feat/continuous-timed-mode
branch
from
July 25, 2026 06:07
f4dd032 to
6c24147
Compare
Adds a `-d` / `--death-mode` flag. With it on, the test finishes the instant an incorrect character is typed, checked ahead of the usual length/timer rules so it beats even a running timer. Practicing with zero tolerance for errors is a well-known way to build accuracy (and, in turn, speed). This revives the idea from the long-open PR jrnxf#18 with a focused implementation and tests. - thok: `death_mode` flag on `Thok`; `has_finished` returns early on any incorrect input when it's set. - main: `-d` flag wired through `App::new`/`reset`. - docs: README example + `--help` entry. - tests: mistake ends it, off tolerates mistakes, and it overrides a running timer.
A run that dies after a fraction of a second would otherwise be logged as an absurdly high wpm. Thok::died() is the one place that says a test ended on a mistake; has_finished uses it, and save_if_finished skips the history append for a died run. Clean runs in death mode still log.
…the new ui - lang.rs: word_pool() replaces the old lang/mod.rs one - the 3-line prompt window is applied to the wrapped lines before the layout, and char_cell on that slice gives the cursor row - the prompt is topped up once when the pool is set, so -w 0 -s 5 no longer panics on the first key and the prompt stays its full height from the first frame; an empty prompt does not start with a space - the death-mode check stays above the continuous timer-only rule in has_finished, so a mistake still ends a -d -s run - regenerate the snapshots that the window now affects - README: no em dashes, table realigned
Instead of the wpm results, a run that died shows a YOU DIED heading, the expected character against the key pressed, the prompt around the mistake with the word it was in underlined, and how far the run got in words, characters and time. A clean death-mode run and a mistake outside death mode keep the normal results screen. Retry and new-test keys are unchanged.
The refill was sized in characters, so on a wide screen the prompt started under three lines and a later refill grew it mid-test, jumping the centred block up a row. The refill now works in wrapped lines: the screen reports its line width on every draw, and the prompt is topped up until a full window of lines follows the cursor's line, at the start, after each key and after a resize.
The block (heading, what went wrong, the prompt around it, how far the run got) is centred on the screen, every line on one axis, with the key hints bottom left where the results screen has them. The website's snapshot check skips the death screen, which the page has no death mode to draw.
Main now holds death mode (squash-merged from its own PR), whose tree matches what this branch already merged from the death-mode branch, so the result keeps everything from main plus this PR's changes.
Owner
|
Thanks @hindriix, continuous timed mode is a great addition and fixes #6. I merged the current main into your branch (plus the death mode branch, so
Merged, thanks again! |
Merged
Owner
|
Shipped in v0.7.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 60over 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
refill_wordspool; when it's non-empty,refill_if_needed()tops the prompt up whenever the runway ahead of the cursor runs low, andhas_finished()ends the test on the timer only — never by reaching the end of the words.-s. A custom prompt (-p) or sentences (-f) are finite text, so they still end at their own length.Verification
cargo build,cargo test,cargo clippy,cargo fmt --checkall clean; new unit tests cover refill-keeps-runway, timer-only finish, and that non-continuous mode still finishes by length.Backwards compatible: non-
-sruns and-p/-fare unchanged.