Skip to content

Order the difficulty filter from Easy to Hard - #287

Merged
jserv merged 1 commit into
sysprog21:mainfrom
Pandamachi:order-difficulty-filter
Oct 13, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
Pandamachi:order-difficulty-filter

Conversation

@Pandamachi

@Pandamachi Pandamachi commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

The Difficulty select in the lobby's progress panel listed its options as All, Easy, Hard, Medium and now reads All, Easy, Medium, Hard, with the rest of the detail in #281.

The comparator orders by position in LEVELS, which web/problem-picker.js exports and which this module already imports to decide which difficulties it will admit at all. Reusing that array keeps the scale defined once; an order written out in the comparator would be a second copy to keep in step with the picker. The duration menu on the next line already passes a comparator, so this is the shape the helper was written for rather than a parameter added for it.

The existing test "filter options are deduplicated, ordered, and free of unreadable values" used only Easy and Medium, whose alphabetical and scale orders agree, so it passed either way and left the comparator unpinned. The case added beside it passes buildProgressModel three records whose difficulties are Hard, Easy and Medium and asserts options.difficulty is ["Easy", "Medium", "Hard"]. Run against the parent commit it fails with ["Easy", "Hard", "Medium"], which is the reported symptom.

./scripts/test.sh exits 0 on this branch, no lane failed, and the node browser suite reports 1042 tests with 858 passing and 0 failing. make indent is clean and leaves the two changed files as they are.

That run left several lanes unchecked, so they are CI's to confirm rather than mine: 184 node browser tests skipped for want of Playwright Chromium, a built server binary and javac, plus the cargo-audit, actionlint, ruff and shellcheck lanes, and the formatter chain skipped ruff and shfmt. The menu was not watched in a running lobby either; the list is computed in web/progress.js before the page renders it, which is the function the new test calls directly.

Closes #281


Summary by cubic

Orders the difficulty filter in the lobby's progress panel by the game's level scale instead of alphabetically, so the menu now shows All, Easy, Medium, Hard rather than All, Easy, Hard, Medium.

The comparator reuses the LEVELS array from web/problem-picker.js, which web/progress.js already imports to decide which difficulties to allow, so the scale stays defined once. A new test covers all three levels because Easy and Medium sort the same either way, so the existing test could not catch the bug.

Closes #281.

Written for commit 1f5a993. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread tests/browser/progress.test.js Outdated
@Pandamachi
Pandamachi force-pushed the order-difficulty-filter branch from 2f884ad to a053405 Compare October 12, 2026 04:04
@jserv
jserv requested review from ColtenOuO and alanhc October 12, 2026 04:20

@ColtenOuO ColtenOuO left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, the behavior looks good to me, but I have a few thoughts on the newly added comment.

Comment thread web/progress.js Outdated
Comment thread web/progress.js
The progress panel's Difficulty menu is built from the distinct
difficulties in the saved history, and the helper that collects them
sorted with no comparator, so the strings decided the order and Hard
came out between Easy and Medium, leaving the menu reading differently
from the difficulty checkboxes beside it. Ordering by position in
LEVELS keeps the scale defined once, in web/problem-picker.js, which
this module already imports to decide which difficulties it will admit
at all; a literal order written here would be a second copy to keep in
step. The existing options test used only Easy and Medium, whose
alphabetical and scale orders agree, so it passed either way, and the
case added beside it carries all three levels.

Closes sysprog21#281
@Pandamachi
Pandamachi force-pushed the order-difficulty-filter branch from a053405 to 1f5a993 Compare October 13, 2026 03:07

@ColtenOuO ColtenOuO left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, LGTM.

@jserv
jserv merged commit 6d1a77c into sysprog21:main Oct 13, 2026
6 checks passed
@jserv

jserv commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Thank @Pandamachi for contributing!

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.

Progress difficulty filter lists Hard before Medium

3 participants