Skip to content

Manual buckets on partykit - #637

Draft
noahm wants to merge 3 commits into
partykitfrom
claude/weighted-buckets-on-partykit
Draft

Manual buckets on partykit#637
noahm wants to merge 3 commits into
partykitfrom
claude/weighted-buckets-on-partykit

Conversation

@noahm

@noahm noahm commented Aug 25, 2026

Copy link
Copy Markdown
Owner

No description provided.

claude added 3 commits August 25, 2026 02:54
Exploratory: the same feature as claude/weighted-buckets-manual-mode,
rebuilt against partykit's architecture. Squashed rather than replayed
commit by commit, since each of the eight would have hit the same
structural divergence.

What had to change, and what didn't:

- draw-buckets.ts came over untouched. It only needs the ConfigState
  type, getAvailableLevels and a couple of utils, all of which partykit
  still exposes at the same paths.
- ConfigState moved into state/config.slice.ts under a Redux entity
  adapter, so `bucketMode` and `manualBuckets` go in there and in
  `defaultConfig` rather than in a zustand store.
- Sets became arrays on partykit, so the filter checks in card-draw use
  `includes` instead of `has`.
- Components swap `useDrawState((s) => s.gameData)` for `useGameData()`
  and take their setter from `useUpdateConfig()`, which accepts the same
  patch-or-updater shape zustand did, so the call sites are unchanged.

The one real design question was partykit's starting-point draws, which
seed a set from charts already in it. That has to reach the allocation:
a seeded chart fills part of its bucket's share and must not be drawn
again. `drawFromPools` now takes the seeded counts, opens each bucket's
tally at them, discounts them from the minimums, and draws only the
shortfall — which is what the old rejection loop was doing by hand with
`preSeededDifficulties` and splicing out of `requiredDrawIndexes`.
Partykit shows settings as a ~380px column rather than a 500px drawer,
which is narrower than a bucket row's steppers, weight and summary can
sit in — the pool size truncated to "1-…", losing the readout that makes
an empty or over-subscribed bucket visible.

Rows now drop the shared grid below 430px of container width and wrap on
their own, with the summary as a caption underneath. Driven by a
container query on the section rather than a viewport media query, since
what matters is the space the section was given, not the window.

Two details worth keeping: spanning a grid cell mid-row was the first
attempt and it shunted every later cell out of alignment, hence dropping
the grid rather than stretching it; and blueprint doesn't forward a
className onto NumericInput, so the weight field is pinned structurally
as the row's only numeric input. Left filling, it takes the whole line
and pushes everything else onto rows of its own.
Replacing `useWeights` with `bucketMode` changed a shape that persists,
and nothing brought old configs forward. A saved config has no
`bucketMode` at all, which is neither "none", "auto" nor "manual", so
getDrawBuckets falls out of its switch returning undefined and planDraw
throws on it — a hard "Cannot read properties of undefined (reading
'reduce')" on the first draw, for anyone with existing state.

`migrateConfigToBuckets` maps `useWeights` onto the matching mode and
defaults `manualBuckets`, following the migrateToSubdraws pattern in the
drawings slice. It runs from two places, because configs arrive by two
routes: applyMigrations, which covers localStorage rehydration and both
partykit paths, and the config file import, which dispatches setMany
straight from a parsed file.

Verified against state rewritten into the old shape: useWeights false
lands on Off and draws, useWeights true lands on By lvl range, and with
weights present it draws to them. No actions or reducers were touched
here or by the port — only the ConfigState shape and defaultConfig.
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ddr-tools Ready Ready Preview Aug 25, 2026 4:51am

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.

2 participants