Skip to content

Add SRS review due mode and tests#5

Open
Neio wants to merge 15 commits intomainfrom
feature/srs-review-due
Open

Add SRS review due mode and tests#5
Neio wants to merge 15 commits intomainfrom
feature/srs-review-due

Conversation

@Neio
Copy link
Owner

@Neio Neio commented Mar 14, 2026

Summary

  • Add SM-2 SRS scheduling with a new Review Due mode (client-only)
  • Seed existing mastered words into SRS with conservative defaults
  • Add scheduler module, unit tests, and Playwright SRS UI coverage
  • Document algorithm and data model in docs/srs-design.md

Testing

  • node tests/test-srs.js
  • node tests/test-automated.js

Notes

  • Cache-busting version bumped to 202603130001
  • Incorrect review flow unchanged

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a spaced repetition system (SRS) to the WordMaster application, enabling users to review vocabulary at spaced intervals. It includes the core scheduling logic, data persistence, UI elements, and automated tests. The SRS feature is designed to improve long-term retention of learned words.

Highlights

  • SRS Scheduling: Implemented a spaced repetition system (SRS) with Review Due mode, using a simplified SM-2 algorithm for scheduling.
  • Local Storage Persistence: Enabled local storage persistence for SRS data, allowing users to retain their review progress.
  • UI Integration: Added a 'Review Due' button to the UI, displaying the count of due words and initiating SRS reviews.
  • Automated Testing: Included Playwright tests to ensure the SRS feature functions correctly and the UI is responsive.
  • Documentation: Documented the SRS algorithm and data model in docs/srs-design.md.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/srs-design.md
    • Created documentation for the SRS algorithm and data model.
  • index.html
    • Added 'Review Due' button to the main UI.
    • Updated stylesheet and script versions.
  • src/app.js
    • Implemented SRS scheduling logic using a simplified SM-2 algorithm.
    • Added local storage persistence for SRS data.
    • Integrated 'Review Due' functionality into the UI.
    • Seeded existing mastered words into SRS with conservative defaults.
    • Added methods to compute next SRS, make SRS key, seed mastered words, load and save SRS data, ensure SRS entry, update SRS on answer, and get SRS due words.
    • Modified start quiz functions to set quiz source.
    • Updated review buttons to include SRS review.
  • src/styles/index.css
    • Added styles for the new 'Review Due' button and setup actions layout.
  • src/utils/SrsScheduler.js
    • Created a new module for SRS scheduling functions, including computeNextSrs, makeSrsKey, and seedMastered.
  • tests/test-automated.js
    • Added Playwright tests for SRS functionality, including button visibility and review flow.
  • tests/test-srs.js
    • Created unit tests for the SRS scheduler module.
Activity
  • Neio added SRS scheduling (SM-2) with Review Due mode and localStorage persistence
  • Neio seeded existing mastered words into SRS with conservative defaults
  • Neio added pure-function SRS scheduler module and unit tests
  • Neio added SRS UI coverage in Playwright test suite
  • Neio documented algorithm and data model in docs/srs-design.md
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature: a Spaced Repetition System (SRS) for reviewing words. The implementation includes the core scheduling logic based on the SM-2 algorithm, persistence in localStorage, and integration into the UI with a new 'Review Due' mode. The changes are well-structured, with new logic encapsulated in a dedicated SrsScheduler.js module. Unit tests for the new scheduler and Playwright E2E tests for the UI flow have been added, which is great for ensuring correctness and preventing regressions.

My review focuses on improving maintainability by reducing code duplication in styles, optimizing a function for better performance, and enhancing the user experience by suggesting modern alternatives to alert(). I've also noted a potential for flakiness in the E2E tests due to fixed timeouts.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a well-designed Spaced Repetition System (SRS) feature, which is a significant enhancement. The changes are comprehensive, including a clear design document, the core scheduling logic, UI integration for a new "Review Due" mode, and robust unit and end-to-end tests. The code is well-structured and demonstrates good practices. I have a few minor suggestions to further improve code clarity and maintainability, but overall, this is an excellent contribution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Spaced Repetition System (SRS) feature to the WordMaster application, documented in docs/srs-design.md and implemented in a new SrsScheduler.js module using a simplified SM-2 algorithm. The app.js file was extensively modified to integrate SRS data management, including seeding mastered words, updating SRS stats based on quiz answers, and displaying a new 'Review Due' button. UI changes in index.html and index.css support the new SRS review mode. Automated tests were added and updated to cover the new functionality. Review comments suggest improving the clarity of the SRS algorithm documentation and optimizing the getSrsDueForBook function in app.js for better efficiency by restructuring its filtering and sorting logic.

@Neio Neio force-pushed the feature/srs-review-due branch from 049f8ca to 42fd1c3 Compare March 14, 2026 06:30
@Neio Neio force-pushed the feature/srs-review-due branch from 42fd1c3 to 9f16360 Compare March 14, 2026 06:38
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature: a Spaced Repetition System (SRS) for reviewing words, based on the SM-2 algorithm. The changes include the core scheduling logic, integration into the main application, UI updates for the new review flow, and comprehensive unit and end-to-end tests. The implementation is solid, but I've identified a few inconsistencies between the implementation and the design specification, particularly regarding the visibility and dynamic text of the 'Review Due' button. I've also noted a couple of minor areas for improvement in UI code and test naming for better clarity and maintainability. Overall, this is a great addition to the application.

@Neio Neio self-assigned this Mar 14, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-implemented Spaced Repetition System (SRS) feature. The changes include the core SM-2 scheduling logic, UI updates for a new review flow, automatic seeding of mastered words, and comprehensive unit and automated tests. The code is well-structured, and the separation of concerns with the new SrsScheduler.js module is excellent. I've identified a few areas for improvement, mainly concerning a potential performance optimization, a discrepancy in a unit test, and some inconsistencies across the documentation that should be addressed to ensure everything is aligned.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-implemented Spaced Repetition System (SRS) feature. The code is well-structured, with the core scheduling logic cleanly separated into its own module and supported by both unit and end-to-end tests. The documentation is also clear and thorough. My review focuses on a few key areas: I've identified a bug that incorrectly hides the SRS review button, which contradicts the feature's specification. I've also suggested some improvements for performance and maintainability in the data retrieval logic, a security enhancement to prevent potential XSS vulnerabilities, and a correction to the test plan to align it with the documented behavior. Overall, this is a strong contribution.

@Neio
Copy link
Owner Author

Neio commented Mar 14, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature: a Spaced Repetition System (SRS) based on the SM-2 algorithm. The implementation is well-structured, with a dedicated scheduler, new UI components, and comprehensive automated tests. My review found a couple of issues: a critical error in a unit test that incorrectly asserts an SRS interval, and a resulting documentation error in the changelog. Correcting the test will ensure the scheduling logic is verified correctly and prevent future confusion.

@Neio
Copy link
Owner Author

Neio commented Mar 14, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant feature enhancement by adding a Spaced Repetition System (SRS) with a "Review Due" mode. The implementation includes the SM-2 scheduling algorithm, automatic seeding of mastered words from previous sessions, and a new UI flow for SRS reviews. The changes are well-structured, with new logic encapsulated in a dedicated SrsScheduler.js module, and is well-tested with both new unit tests and expanded end-to-end Playwright tests. The documentation has also been thoughtfully updated. The overall code quality is high, with notable improvements such as replacing alert() with a more user-friendly notice UI and refactoring for better maintainability. I have a couple of minor suggestions to further improve code consistency and style.

@Neio
Copy link
Owner Author

Neio commented Mar 14, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Spaced Repetition System (SRS) review mode, implementing a simplified SM-2 algorithm for scheduling word reviews, along with new UI elements for the review flow, automatic seeding of mastered words, and updated documentation and tests. The review comments suggest several improvements and fixes: addressing a duplicate property in an object literal, removing a redundant check in the SRS seeding logic, enhancing user experience by replacing alert() calls with a consistent showSetupNotice method, optimizing the startReviewQuiz function for better performance using a Set, improving maintainability and preventing UI bugs by consistently using the showView method for view transitions, and making automated tests more robust by replacing fixed timeouts with specific element condition waits.

I am having trouble creating individual review comments. Click here to see my feedback.

src/app.js (83)

medium

There is a duplicate next property in this object literal. While modern JavaScript engines may handle this gracefully by taking the last definition, it's redundant and can cause confusion. Please remove the duplicate line.

src/app.js (308)

medium

This condition checks if this.masteredWords.size is 0 and returns. However, the seeding logic relies on masteredWords to find words to seed. If masteredWords is empty, the entries array on line 310 will also be empty, and the function will correctly return on line 321. This check is therefore redundant and can be removed to simplify the code.

        if (alreadySeeded || hasSrs) return;

src/app.js (318-319)

medium

Using alert() for user notifications is inconsistent with the application's UI and provides a poor, blocking user experience. It's better to use the newly introduced showSetupNotice method for a more integrated and non-blocking notification.

        if (wrongWords.length === 0) {
            this.showSetupNotice("Great job! No incorrect words for this lesson.", false);

src/app.js (324-326)

medium

The current implementation uses filter and some to find matching words, which has a time complexity of O(n*m). For large lists, this can be inefficient. Using a Set for the wrongWords lookup improves performance by reducing the complexity to O(n+m).

        const wrongWordSet = new Set(wrongWords.map(item => item.word));
        const fullWords = wordlyLibrary[book][chapter].filter(w => wrongWordSet.has(w.word));

src/app.js (371)

medium

Using alert() for user notifications is inconsistent with the application's UI and provides a poor, blocking user experience. Please use the new showSetupNotice method for a more integrated and non-blocking notification.

            this.showSetupNotice("Please select or enter some words first!");

src/app.js (394-396)

medium

Directly manipulating classList for view switching is less maintainable than using the centralized showView method. The showView method ensures that only one view is visible at a time, preventing potential UI bugs where multiple views could be displayed simultaneously. It's good practice to use this helper for all view transitions.

        this.showView('quiz');

tests/test-automated.js (184)

medium

Using a fixed timeout (waitForTimeout) can lead to flaky tests, as the time it takes for an operation to complete can vary. It's more reliable to wait for a specific state or element condition. In this case, waiting for the next button to be visible, the input to be re-enabled, or the results view to appear would make the test more robust.

        await page.waitForSelector('#next-btn:not(.hidden), #spelling-input:enabled, #results-view:not(.hidden)');

@Neio
Copy link
Owner Author

Neio commented Mar 15, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature: a Spaced Repetition System (SRS) for reviewing words. The implementation includes a new "Review" mode powered by a simplified SM-2 scheduling algorithm, automatic seeding of mastered words into the SRS, and a new UI flow for previewing review lists. The changes are well-structured and supported by comprehensive unit tests, automated Playwright tests, and design documentation. My review identified a couple of opportunities to improve performance in the JavaScript application logic, specifically around list processing and DOM manipulation. Overall, this is a solid and well-executed feature addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant