Skip to content

Add fair mode (pseudo-random) to picker#22

Merged
K-Cully merged 4 commits intomainfrom
copilot/add-pseudo-random-mode-to-picker
May 7, 2026
Merged

Add fair mode (pseudo-random) to picker#22
K-Cully merged 4 commits intomainfrom
copilot/add-pseudo-random-mode-to-picker

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

  • Add "fair mode" (pseudo-random) toggle to picker UI per topic
  • Implement fair-mode logic: track which users have been picked, exclude them until all users have been picked, then reset
  • Persist fair-mode state (toggle + tracking) in localStorage data structure
  • Update pickRandom to respect fair mode when enabled
  • Add UI toggle in the picker card
  • Update DECISIONS.md with the new feature decision
  • Run parallel validation
  • Address PR review: add fairMode defaults to v1→v2 migration branch
  • Address PR review: make pickRandom() pure (no state mutation)
  • Address PR review: disable fair mode checkbox during spin animation
  • Address code review: improve readability of guard clause

Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 19:22
Copilot AI linked an issue May 7, 2026 that may be closed by this pull request
Adds a per-topic "Fair mode" toggle that ensures each user is picked
before any user is repeated. When enabled, entries attributed to
already-picked users are excluded from the candidate pool until every
user with entries in the topic has been selected, then the round resets.

- New fairMode and fairModePickedUserIds fields in topic data
- pickRandom respects fair mode filtering
- recordPick tracks picked users and resets when round completes
- UI checkbox toggle in picker card
- State persisted in localStorage
- DECISIONS.md updated with rationale

Agent-Logs-Url: https://github.com/K-Cully/random-picker/sessions/f269db2d-b428-46c1-a8a3-2b4f925e4ec9

Co-authored-by: K-Cully <2370032+K-Cully@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 19:27
Copilot AI changed the title [WIP] Add pseudo random mode to picker for fair distribution Add fair mode (pseudo-random) to picker May 7, 2026
Copilot AI requested a review from K-Cully May 7, 2026 19:29
Copilot finished work on behalf of K-Cully May 7, 2026 19:29
@K-Cully K-Cully marked this pull request as ready for review May 7, 2026 19:37
Copilot AI review requested due to automatic review settings May 7, 2026 19:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional per-topic “Fair mode” to reduce repeat picks by excluding users already selected in the current round until all users with entries have been picked, with the state persisted in localStorage.

Changes:

  • Extended topic persistence/migration and topic creation to include fairMode + fairModePickedUserIds.
  • Updated picker logic (pickRandom / recordPick) to enforce fair-mode eligibility and round reset behavior.
  • Added a Fair mode checkbox in the picker UI with accompanying styles, and documented the decision in DECISIONS.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
js/app.js Adds fair-mode topic state, selection logic, and UI wiring for the new toggle.
css/styles.css Styles the fair mode toggle and aligns picker action row contents.
DECISIONS.md Documents the rationale and implementation notes for fair mode.

Comment thread js/app.js
Comment thread js/app.js Outdated
Comment thread js/app.js
@K-Cully
Copy link
Copy Markdown
Owner

K-Cully commented May 7, 2026

@copilot review the comments and address the issues identified

- Add fairMode/fairModePickedUserIds defaults to v1→v2 migration
- Remove side effect from pickRandom(), keep it pure
- Move round reset logic into recordPick() before tracking
- Disable fair mode checkbox during spin animation

Agent-Logs-Url: https://github.com/K-Cully/random-picker/sessions/15435e48-9aea-49b2-90a0-4e373a1e41f9

Co-authored-by: K-Cully <2370032+K-Cully@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 7, 2026

@copilot review the comments and address the issues identified

All three review issues addressed in c8a8edb:

  1. v1→v2 migration – Added fairMode: false and fairModePickedUserIds: [] defaults to the v1 migration branch so all topics have a consistent schema.
  2. Pure pickRandom() – Removed the state mutation (round reset) from pickRandom(). It now falls back to the full entry list without modifying state. The round reset is handled entirely in recordPick() (which calls persist()).
  3. Checkbox disabled during spin – The fair mode checkbox is now disabled alongside the Pick button during the spin animation and re-enabled when the spin completes.

Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 20:06
Copilot finished work on behalf of K-Cully May 7, 2026 20:06
@K-Cully K-Cully merged commit 55a8c49 into main May 7, 2026
@K-Cully K-Cully deleted the copilot/add-pseudo-random-mode-to-picker branch May 7, 2026 20:16
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.

the picker should have a pseudo random mode

3 participants