fix(zen-mode): restore input history and watch replay (@byseif21) (#6863)

### Description

fix:
* The result “input history” panel sometimes rendered nothing because
the renderer attempted to split an undefined target word.
added split word ?? "" to handle missing target words in zen.

* The replay view in zen mode could be empty if the last word was just
submitted (so input.current was empty at finish), and the replay words
list never got updated.

---------

Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
Seif Soliman 2025-08-10 15:47:52 +03:00 committed by GitHub
parent 59a6004de7
commit 1048e04884
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -904,6 +904,12 @@ export async function finish(difficultyFailed = false): Promise<void> {
Replay.replayGetWordsList(TestInput.input.getHistory());
}
// in zen mode, ensure the replay words list reflects the typed input history
// even if the current input was empty at finish (e.g., after submitting a word).
if (Config.mode === "zen") {
Replay.replayGetWordsList(TestInput.input.getHistory());
}
TestInput.forceKeyup(now); //this ensures that the last keypress(es) are registered
const endAfkSeconds = (now - TestInput.keypressTimings.spacing.last) / 1000;

View file

@ -1279,7 +1279,8 @@ async function loadWordsHistory(): Promise<boolean> {
throw new Error("empty input word");
}
const errorClass = input !== word ? "error" : "";
const errorClass =
Config.mode === "zen" ? "" : input !== word ? "error" : "";
if (corrected !== undefined && corrected !== "") {
const correctedChar = !containsKorean
@ -1297,7 +1298,7 @@ async function loadWordsHistory(): Promise<boolean> {
}
const inputCharacters = Strings.splitIntoCharacters(input);
const wordCharacters = Strings.splitIntoCharacters(word);
const wordCharacters = Strings.splitIntoCharacters(word ?? "");
const correctedCharacters = Strings.splitIntoCharacters(corrected ?? "");
let loop;