Skip to content

Commit 1048e04

Browse files
byseif21Miodec
andauthored
fix(zen-mode): restore input history and watch replay (@byseif21) (monkeytypegame#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 <[email protected]>
1 parent 59a6004 commit 1048e04

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

frontend/src/ts/test/test-logic.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ export async function finish(difficultyFailed = false): Promise<void> {
904904
Replay.replayGetWordsList(TestInput.input.getHistory());
905905
}
906906

907+
// in zen mode, ensure the replay words list reflects the typed input history
908+
// even if the current input was empty at finish (e.g., after submitting a word).
909+
if (Config.mode === "zen") {
910+
Replay.replayGetWordsList(TestInput.input.getHistory());
911+
}
912+
907913
TestInput.forceKeyup(now); //this ensures that the last keypress(es) are registered
908914

909915
const endAfkSeconds = (now - TestInput.keypressTimings.spacing.last) / 1000;

frontend/src/ts/test/test-ui.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,8 @@ async function loadWordsHistory(): Promise<boolean> {
12791279
throw new Error("empty input word");
12801280
}
12811281

1282-
const errorClass = input !== word ? "error" : "";
1282+
const errorClass =
1283+
Config.mode === "zen" ? "" : input !== word ? "error" : "";
12831284

12841285
if (corrected !== undefined && corrected !== "") {
12851286
const correctedChar = !containsKorean
@@ -1297,7 +1298,7 @@ async function loadWordsHistory(): Promise<boolean> {
12971298
}
12981299

12991300
const inputCharacters = Strings.splitIntoCharacters(input);
1300-
const wordCharacters = Strings.splitIntoCharacters(word);
1301+
const wordCharacters = Strings.splitIntoCharacters(word ?? "");
13011302
const correctedCharacters = Strings.splitIntoCharacters(corrected ?? "");
13021303

13031304
let loop;

0 commit comments

Comments
 (0)