Repository navigation
Pick a random problem cycles only through overdue attempts while unseen problems remain #210
Description
Description
Observed behavior
When at least two previously attempted problems are due for review, clicking "Pick a random problem" selects only among those problems. With exactly two due problems, the button alternates between them indefinitely, even when unseen problems exist at the selected difficulty. Changing difficulty may still select an overdue problem outside the selected difficulty.
The random number generator is working. The candidate pool is restricted before the random draw.
Expected behavior
An explicit "Pick a random problem" action should allow new problems at the selected difficulty to be chosen. Automatic spaced-review recommendations can still prioritize overdue attempts, but the explicit random button should not silently inherit a queue that permanently excludes unseen problems.
Reproduction
- Have two distinct Easy problems with saved scored attempts at least one day old. For example, give each problem a single HIRE result from two days ago. NO_HIRE attempts can become due too.
- Leave additional Easy problems unattempted and select Easy in the lobby.
- Click "Pick a random problem" repeatedly without completing another interview.
- The two due problems alternate; unseen Easy problems are never selected.
Version & environment
OS: Window 10
Browser: Microsoft Edge Version 154.0.4258.48 (Official build) (64-bit)
CodeTrial: latest with commit 417b2c2
Cause
web/app.js:176: the random button updatesroll, setsavoidedProblemto the current problem, and callsrecommend().web/app.js:880:recommend()calls the samepickProblem()used for review recommendations, with the saved reports.web/problem-picker.js:168:dueis built from the whole problem bank, including difficulties not selected.web/problem-picker.js:171: the picker chooses the first nonempty pool from[due, fresh, eligible], after excluding only the current problem.
With two due problems, the due pool always contains the other problem. The fresh pool is never considered. Clicking does not change the attempt timestamps or due status, so repeated clicks cannot escape the queue.
This test explicitly assert that due reviews take priority over unseen problems and may cross difficulty filters. The behavior is therefore an intentional recommendation policy applied to a button labeled as a random choice, rather than a broken RNG or missing history fetch.
Suggestion Improvement
Give explicit random selection its own policy, either through a separate helper or an explicit picker mode. Keep overdue-review priority for the initial automatic recommendation. For the random button, build the pool from the selected difficulties and exclude the current problem whenever another eligible problem exists. Draw uniformly from that pool so every eligible unseen problem has a chance of selection.
If the intended action is specifically to discover new exercises, offer a clearly labeled "Pick an unattempted problem" action instead. That pool should exclude every previously attempted problem, including NO_HIRE and incomplete attempts; the current fresh pool excludes only HIRE results. Fall back to all eligible problems when no unattempted problem remains and explain that fallback in the recommendation text.
Activity
Krixi0828 commentedon Oct 2, 2026
I observed the same behavior on macOS. I also found that the selected difficulty filter was ignored in my test.
Steps I tried
Results
The selected problems were:
All 10 selections were Easy problems marked as
Review due after 1 day, even though I had selected only Medium difficulty.No Medium problem was selected during these 10 attempts.
This behavior seems consistent with the analysis in this issue that overdue review problems are considered before the difficulty-filtered problem pool.
From a user's perspective, I would expect Pick a random problem to respect the currently selected difficulty. Review recommendations could still prioritize overdue problems separately, but an Easy problem should not be selected when only Medium is checked.
jserv commentedon Oct 4, 2026
@jiawei110 The cause you found holds on
main:pickProblembuildsduefrom the whole bank (web/problem-picker.js:168) and tries it beforefresh, so two due reviews alternate forever and ignore the difficulty filter, which @Krixi0828 also saw. The due-first rule is deliberate for the recommendation shown when the lobby opens (tests/browser/problem-picker.test.js:34), and that stays. "Pick a random problem" should mean what it says: draw uniformly from the problems at the checked difficulties, excluding the one on screen when another exists. A separate "Pick an unattempted problem" button is not needed for this. A pull request that gives the button its own pool, with a test that two due reviews no longer lock it, is welcome.Ericko00o commentedon Oct 6, 2026
I'm working on #210. I've separated explicit random selection from the initial due-first recommendation. The random button now draws uniformly from the checked difficulties, excluding the current problem when alternatives exist.
I'll add unit and browser regression tests covering the two-overdue-review case, difficulty filtering, and page restoration. I'm reviewing the changes before opening a PR.
Apply batched suggestions from code review
Apply batched suggestions from code review
Apply batched suggestions from code review
Separate random draws from review recommendations
Separate random draws from review recommendations
Separate random draws from review recommendations
Separate random draws from review recommendations
jserv commentedon Oct 11, 2026
Reopening: the cause found here still holds on
main(pickProblemtries theduepool, built fromreviewProblems, beforefresh), and open PR #256 fixes it withCloses #210, so its merge will close this. @jiawei110, if you closed it because something else resolved it for you, post the output ofcodetrial --versionand what you saw.