Skip to content

Conversation

@BhavishyaMaheshwari
Copy link

@BhavishyaMaheshwari BhavishyaMaheshwari commented Oct 19, 2025

Description

Added a "Potential WPM" feature that calculates an alternate typing speed ignoring minor adjacent character swap errors (transpositions). This provides users insight into what their speed would be if they hadn't made simple typos like typing "teh" instead of "the" or "form" instead of "from".

Key Features:

  • Detects adjacent character swaps only (e.g., "teh" → "the", "from" → "form")
  • Calculates potential WPM treating swaps as correct
  • Displays a small button next to the WPM during typing and on results screen
  • Button only appears when swap errors are detected
  • Hover shows potential WPM in a compact tooltip (0.75rem, positioned below button)
  • Click shows detailed popup with swap count and comparison

Implementation Details:

  • Added isMinorSwap() utility function to detect adjacent character transpositions
  • Modified stats tracking to count minor swap errors separately from real errors
  • Updated accuracy calculation to treat swaps as correct
  • Added UI components in live-speed and result screens
  • Custom styling with balloon.css for consistent tooltip appearance
  • Total changes: ~948 lines added across 15 files

Files Modified:

  • frontend/src/ts/typing.ts - Added swap detection
  • frontend/src/ts/stats.ts - NEW: Helper functions and state management
  • frontend/src/ts/utils/swap-detection.ts - NEW: Swap detection utility
  • frontend/src/ts/test/test-stats.ts - Updated WPM calculation
  • frontend/src/ts/controllers/input-controller.ts - Accuracy treats swaps as correct
  • frontend/src/ts/test/live-speed.ts - Live WPM display with potential button
  • frontend/src/ts/test/result.ts - Results screen integration
  • frontend/src/ts/test/test-logic.ts - Reset counters on test start
  • frontend/src/ts/test/test-input.ts - Input processing
  • frontend/src/ts/test/test-timer.ts - Timer integration
  • frontend/src/styles/test.scss - Button styling, popup, tooltips
  • frontend/src/svelte/Results.svelte - Svelte component updates
  • frontend/src/ts/utils/misc.ts - Utility export
  • frontend/src/ts/EXAMPLE_USAGE.ts - NEW: Documentation

Checks

  • Check if any open issues are related to this PR
  • Make sure the PR title follows the Conventional Commits standard
  • Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title

Screenshots

  1. The example swap
    SwapExample
  2. The small button next to WPM during typing
    PotentialButtonView
  3. The hover tooltip showing "Potential: XX.XX"
    PotentialHoverView
  4. Raw vs potential speed (basically showing that they are different)
    RawSpeedvsPotentialSpeed

Future (potential) changes

  • Add more factors to potential wpm calculation such as, accidental spacebars, double key presses etc.

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Oct 19, 2025
@socket-security
Copy link

socket-security bot commented Oct 19, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedexpress@​5.1.09810010084100
Addedexpress-rate-limit@​7.5.110010010085100
Updateddisposable-email-domains-js@​1.16.0 ⏵ 1.18.098 +310093 +790100

View full report

@BhavishyaMaheshwari BhavishyaMaheshwari changed the title Feature/potential wpm feat: add potential WPM calculation ignoring adjacent swap errors (@BhavishyaMaheshwari) Oct 19, 2025
@github-actions
Copy link
Contributor

Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.

@github-actions github-actions bot added waiting for update Pull requests or issues that require changes/comments before continuing and removed waiting for update Pull requests or issues that require changes/comments before continuing labels Oct 19, 2025
@Miodec
Copy link
Member

Miodec commented Oct 27, 2025

AI generated (why would you add a svelte file???) PR for an undiscussed, unwanted feature. Sorry, closing this one.

@Miodec Miodec closed this Oct 27, 2025
@BhavishyaMaheshwari BhavishyaMaheshwari deleted the feature/potential-wpm branch October 27, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants