Manual buckets on partykit - #637
Draft
noahm wants to merge 3 commits into
Draft
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.