Skip to content
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8a6fcdb
yeet wpm history, raw history, burst history, old burst calculation
Miodec May 30, 2026
ee43b07
burst improve perf
Miodec May 30, 2026
4f6f87c
yeet keypress timings
Miodec May 30, 2026
99a7953
yeet keypresscounthistory
Miodec May 30, 2026
c2bb661
yeet afk history
Miodec May 30, 2026
1dae6e4
missing after last yeet
Miodec May 30, 2026
1e01096
yeet error history
Miodec May 30, 2026
5d3bd07
fix word highlight
Miodec May 30, 2026
709e2ba
fix
Miodec May 30, 2026
1c61693
yeet comparison
Miodec May 30, 2026
2a45341
fix
Miodec May 30, 2026
fd39854
yeet last second not round
Miodec May 30, 2026
e61c110
yeet stats
Miodec May 30, 2026
7fd6d17
yeet acc
Miodec May 30, 2026
48a17b4
yeet test seconds
Miodec May 30, 2026
66bdfe3
fully yeet stats file
Miodec May 30, 2026
fa4e20b
yeet acc
Miodec May 30, 2026
2cf2bf8
yeet
Miodec May 30, 2026
297775f
fixes
Miodec May 30, 2026
c9fa677
yeet missed words
Miodec May 30, 2026
442ddb4
yeet correcred
Miodec May 30, 2026
36b5251
input history
Miodec May 30, 2026
9883c9b
yeet input history
Miodec May 30, 2026
e1a3540
yeet
Miodec May 30, 2026
358e88c
move korean state
Miodec May 30, 2026
b3f3df0
early return
Miodec Jun 1, 2026
e85e149
boom
Miodec Jun 1, 2026
4cbde49
yeet replay
Miodec Jun 1, 2026
b08aeb8
pass now from input to timer start
Miodec Jun 1, 2026
bb555f3
bring command back
Miodec Jun 1, 2026
999fb3b
just use active word index
Miodec Jun 1, 2026
eede7ee
always require param
Miodec Jun 1, 2026
ba8b8ac
accept now from input event
Miodec Jun 1, 2026
580724b
move korean state to test state
Miodec Jun 1, 2026
47f076e
simpler
Miodec Jun 1, 2026
4478f51
simpler
Miodec Jun 1, 2026
0ca7482
accept dom value
Miodec Jun 1, 2026
61d880e
pass now through, log earlier
Miodec Jun 1, 2026
04bb380
Merge branch 'test-events-phase-1.5' into test-events-phase2
Miodec Jun 1, 2026
21e4146
start time
Miodec Jun 1, 2026
92383be
delete events
Miodec Jun 1, 2026
e44ff3b
early
Miodec Jun 1, 2026
94b893d
Merge branch 'test-events-phase-1.5' into test-events-phase2
Miodec Jun 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/__tests__/test/events/data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function timerData(
if (event === "step") {
return { event, timer, drift: 0 };
}
return { event, timer };
return { event, timer, date: 0 };
}

describe("data.ts", () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/test/events/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function timer(
if (event === "step") {
return { event, timer: timerVal, drift: 0 };
}
return { event, timer: timerVal };
return { event, timer: timerVal, date: 0 };
}

// Helper: sets up a basic test with timer start, steps at 1s intervals,
Expand Down
35 changes: 17 additions & 18 deletions frontend/src/ts/commandline/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import { randomizeTheme } from "../controllers/theme-controller";
import { showModal } from "../states/modals";
import {
showErrorNotification,
showSuccessNotification,
clearAllNotifications,
} from "../states/notifications";
import * as VideoAdPopup from "../popups/video-ad-popup";
import * as TestStats from "../test/test-stats";
import { Command, CommandsSubgroup } from "./types";
import { buildCommandForConfigKey } from "./util";
import { CommandlineConfigMetadataObject } from "./commandline-metadata";
Expand Down Expand Up @@ -288,22 +286,23 @@ export const commands: CommandsSubgroup = {
alert(await caches.keys());
},
},
{
id: "copyResultStats",
display: "Copy result stats",
icon: "fa-cog",
visible: false,
exec: async (): Promise<void> => {
navigator.clipboard
.writeText(JSON.stringify(TestStats.getStats()))
.then(() => {
showSuccessNotification("Copied to clipboard");
})
.catch((e: unknown) => {
showErrorNotification("Failed to copy to clipboard", { error: e });
});
},
},
// todo: bring back?
// {
// id: "copyResultStats",
// display: "Copy result stats",
// icon: "fa-cog",
// visible: false,
// exec: async (): Promise<void> => {
// navigator.clipboard
// .writeText(JSON.stringify(TestStats.getStats()))
// .then(() => {
// showSuccessNotification("Copied to clipboard");
// })
// .catch((e: unknown) => {
// showErrorNotification("Failed to copy to clipboard", { error: e });
// });
// },
// },
{
id: "fpsCounter",
display: "FPS counter...",
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/ts/controllers/chart-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ Chart.defaults.elements.line.fill = "origin";
import "chartjs-adapter-date-fns";
import { Config } from "../config/store";
import { configEvent } from "../events/config";
import * as TestInput from "../test/test-input";
import * as Arrays from "../utils/arrays";
import { blendTwoHexColors } from "../utils/colors";
import { typedKeys } from "../utils/misc";
import { getTheme } from "../states/theme";
import { Theme } from "../constants/themes";
import { createDebouncedEffectOn } from "../hooks/effects";
import { getWordIndexesForSecond } from "../test/events/stats";

export class ChartWithUpdateColors<
TType extends ChartType = ChartType,
Expand Down Expand Up @@ -274,8 +274,7 @@ export const result = new ChartWithUpdateColors<
prevTi = ti;
try {
const keypressIndex = Math.round(parseFloat(ti.label)) - 1;
const wordsToHighlight =
TestInput.errorHistory[keypressIndex]?.words;
const wordsToHighlight = getWordIndexesForSecond(keypressIndex);

const unique = [...new Set(wordsToHighlight)];
const firstHighlightWordIndex = unique[0];
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import * as DB from "./db";
import "./ui";
import "./controllers/ad-controller";
import { Config } from "./config/store";
import * as TestStats from "./test/test-stats";
import * as Replay from "./test/replay";
import * as TestTimer from "./test/test-timer";
import * as Result from "./test/result";
Expand Down Expand Up @@ -88,7 +87,6 @@ addToGlobal({
snapshot: DB.getSnapshot,
config: Config,
glarsesMode: enable,
stats: TestStats.getStats,
replay: Replay.getReplayExport,
enableTimerDebug: TestTimer.enableTimerDebug,
getTimerStats: TestTimer.getTimerStats,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/ts/input/handlers/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function onDelete(inputType: DeleteInputType, now: number): void {
TestInput.input.syncWithInputElement();

Replay.addReplayEvent("setLetterIndex", TestInput.input.current.length);
TestInput.setCurrentNotAfk();

const beforeDeleteOnlyTabs = /^\t*$/.test(inputBeforeDelete);
const allTabsCorrect = TestWords.words
Expand Down
12 changes: 1 addition & 11 deletions frontend/src/ts/input/handlers/insert-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,11 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
}

// general per keypress updates
TestInput.setCurrentNotAfk();
Replay.addReplayEvent(correct ? "correctLetter" : "incorrectLetter", data);
TestInput.incrementAccuracy(correct);
WeakSpot.updateScore(data, correct);
TestInput.incrementKeypressCount();
TestInput.pushKeypressWord(wordIndex);
if (!correct) {
TestInput.incrementKeypressErrors();
TestInput.pushMissedWord(TestWords.words.getCurrentText());
}
if (Config.keymapMode === "react") {
flash(data, correct);
}
if (testInput.length === 0 && !isCompositionEnding) {
TestInput.setBurstStart(now);
}
if (!shouldGoToNextWord) {
TestInput.corrected.update(data, correct);
}
Expand Down Expand Up @@ -221,6 +210,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
correctInsert: correct,
isCompositionEnding: isCompositionEnding === true,
zenNewline: charIsNewline && Config.mode === "zen",
now,
});
lastBurst = result.lastBurst;
increasedWordIndex = result.increasedWordIndex;
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/ts/input/handlers/keydown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Config } from "../../config/store";
import * as TestInput from "../../test/test-input";
import * as TestLogic from "../../test/test-logic";
import { getCharFromEvent } from "../../test/layout-emulator";
import * as Monkey from "../../test/monkey";
Expand Down Expand Up @@ -133,9 +132,6 @@ export async function onKeydown(event: KeyboardEvent): Promise<void> {
}

const now = performance.now();
if (!TestState.resultCalculating) {
TestInput.recordKeydownTime(now, event);
}

logTestEvent("keydown", now, {
code: getTestEventCode(event),
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/ts/input/handlers/keyup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Config } from "../../config/store";
import * as TestInput from "../../test/test-input";
import * as Monkey from "../../test/monkey";
import { logTestEvent } from "../../test/events/data";
import { getTestEventCode } from "../../test/events/helpers";

export async function onKeyup(event: KeyboardEvent): Promise<void> {
const now = performance.now();
TestInput.recordKeyupTime(now, event);
logTestEvent("keyup", now, {
code: getTestEventCode(event),
ctrl: event.ctrlKey,
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/ts/input/helpers/word-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ import {
getActiveFunboxesWithFunction,
isFunboxActiveWithProperty,
} from "../../test/funbox/list";
import * as TestStats from "../../test/test-stats";
import * as Replay from "../../test/replay";
import * as Funbox from "../../test/funbox/funbox";
import { showLoaderBar, hideLoaderBar } from "../../states/loader-bar";
import { setInputElementValue } from "../input-element";
import { setAwaitingNextWord } from "../state";
import { DeleteInputType } from "./input-type";
import { getWordBurst } from "../../test/events/stats";

type GoToNextWordParams = {
correctInsert: boolean;
// this is used to tell test ui to update the word before moving to the next word (in case of a composition that ends with a space)
isCompositionEnding: boolean;
zenNewline?: boolean;
now: number;
};

type GoToNextWordReturn = {
Expand All @@ -33,6 +34,7 @@ export async function goToNextWord({
correctInsert,
isCompositionEnding,
zenNewline,
now,
}: GoToNextWordParams): Promise<GoToNextWordReturn> {
const ret = {
increasedWordIndex: false,
Expand All @@ -56,8 +58,7 @@ export async function goToNextWord({
}

//burst calculation and fail
const burst: number = TestStats.calculateBurst();
TestInput.pushBurstToHistory(burst);
const burst = getWordBurst(TestState.activeWordIndex, now);
ret.lastBurst = burst;

PaceCaret.handleSpace(correctInsert, TestWords.words.getCurrentText());
Expand Down Expand Up @@ -88,7 +89,7 @@ export async function goToNextWord({

setInputElementValue("");
TestInput.input.syncWithInputElement();
void TestUI.afterTestWordChange("forward");
void TestUI.afterTestWordChange("forward", burst);

return ret;
}
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/ts/input/listeners/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { getInputElement } from "../input-element";
import * as CompositionState from "../../legacy-states/composition";
import * as TestState from "../../test/test-state";
import * as TestLogic from "../../test/test-logic";
import * as TestInput from "../../test/test-input";
import { setLastInsertCompositionTextData } from "../state";
import * as CompositionDisplay from "../../elements/composition-display";
import { onInsertText } from "../handlers/insert-text";
Expand All @@ -25,9 +24,6 @@ inputEl.addEventListener("compositionstart", (event) => {
if (!TestState.isActive) {
TestLogic.startTest(now);
}
if (TestInput.input.current.length === 0) {
TestInput.setBurstStart(now);
}

logTestEvent("composition", now, {
event: "start",
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/ts/test/events/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
TimerEventData,
} from "./types";
import { keysToTrack } from "./helpers";
import { start } from "../test-stats";
import { Keycode } from "../../constants/keys";
import { roundTo2 } from "@monkeytype/util/numbers";
import { resultCalculating } from "../test-state";
Expand Down Expand Up @@ -222,6 +221,9 @@ export function cleanupData(): void {
export function getAllTestEvents(): TestEvent[] {
if (cachedAllEvents !== undefined) return cachedAllEvents;

const startEventMs =
timerEvents.find((e) => e.data.event === "start")?.ms ?? 0;

// cachedAllEvents = testData300;
// return cachedAllEvents;
cachedAllEvents = [
Expand All @@ -237,7 +239,7 @@ export function getAllTestEvents(): TestEvent[] {
(a.type === "timer" ? 1 : 0) - (b.type === "timer" ? 1 : 0),
)
.map((event) => {
event.testMs = roundTo2(event.ms - start);
event.testMs = roundTo2(event.ms - startEventMs);
return event;
});

Expand Down
Loading
Loading