Repository navigation
feat: avg click distance metric (% of canvas diagonal) - #18
Merged
Merged
Conversation
startUp() registered the listener, then startSession() registered it again without an intervening unregister, double-counting clicks during a session. Registration is now managed solely by start/stopSession.
This was referenced Jun 22, 2026
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.
Avg Click Distance metric
Adds a third live metric alongside Consistency and Avg Click Interval: Average Click Distance — the mean mouse jump between consecutive clicks, expressed as a percentage of the game canvas diagonal (0–100%). Lets you compare how much mouse movement an activity demands, independent of resolution or display mode.
How it works
(x, y)in parallel with its timestamp.computeAverageDistanceaverages the Euclidean distance between consecutive clicks (in click order, no sorting);toDistancePercentnormalizes that against the canvas diagonal (sqrt(w² + h²)). Both are pure and unit-tested;getAverageClickDistanceis the live wrapper usingclient.getCanvasWidth()/getCanvasHeight().Session.avgDistancePercent) and shown in the panel via a stat card + a linear 0–100DistanceIndicator, plus the history line and copy-to-clipboard text. Format%.1f%%everywhere.0.0.Backward compatibility
Sessions saved before this change have no distance field; Gson deserializes it to
0.0, so they render0.0%(visible in the history row of the screenshot). No migration needed.Drive-by fix
Removed a double-registration of the mouse listener:
startUp()registered it andstartSession()registered it again with no intervening unregister, which double-counted clicks during a session. Registration is now managed solely bystart/stopSession.Tests
14 unit tests covering the two pure helpers (empty/single point, known distances, zero/half/full-diagonal normalization) plus the updated Session constructor. Full build green.
Caveat
If the canvas is resized mid-session, stored pixel distances are normalized by the canvas diagonal at stop time, a small accepted skew for an AFK stat.