Tray pieces now render at a usable minimum size instead of shrinking… #4

Merged
cmoriarty merged 4 commits from osf/179-feedback-to-implement-puzzle-game into main 2026-11-06 23:08:41 -05:00
Owner

What was done

  • Tray pieces now render at a usable minimum size instead of shrinking to fit, and when they do not all fit the tray scrolls vertically inside its panel, which keeps exactly its current width and height.
  • A piece dropped back into the tray settles into the nearest empty slot instead of piling on top of another piece, so two pieces never share a spot.
  • A custom scrollbar (a track plus a draggable thumb) is drawn on the tray frame and driven by the mouse wheel, appearing only when the pieces do not all fit.
  • The play field still fits the viewport with no page scrolling — only the tray's contents scroll — and the board and already-placed pieces never move.
  • The completion firework is re-synthesized to sound like a real firework (a rising whistle, a low thump under the burst, and a longer scatter of crackles), still generated entirely in code with no audio files.
  • New unit tests cover the tray layout math and the tray-drop slot logic, and the full test suite passed while a judge opened the running app in a real browser and played a complete session — starting a puzzle, scrolling the tray, solving it, and replaying — to confirm the behavior.
  • Not done: the setup screen overflows a 720p-tall viewport by ~35px (the last image row needs a small page scroll); this is pre-existing, untouched by this change, and the game screen itself never scrolls.
  • Not done: the re-synthesized firework has no automated test — it is verified by listening in a browser, and the spec deliberately covers no audio.

How to review

  1. Check out the branch and diff it against origin/main to see the change — it spans the tray layout math, the drop logic, the game and tray components, the firework audio, and the README.
  2. Run the checks with npm test, npm run typecheck, npm run lint, and npm run build — all four should pass.
  3. Start the app with npm run dev and open the printed URL — you should see the setup screen (an image gallery, difficulty options, and a "Start puzzle" button that is disabled until you pick an image).
  4. Pick an image and a large grid such as 12×12, then start — the board appears on the left and the tray on the right, with pieces at a usable size and a scrollbar on the tray's right edge.
  5. Play with the tray: wheel over it (or drag the scrollbar thumb) to scroll the pieces, then drag a piece out and drop it back — the pieces scroll within the fixed-size panel while the board stays put, and the dropped piece settles into the nearest empty slot rather than on top of another piece.
  6. Read src/lib/layout.ts and src/hooks/usePuzzle.ts first — the minimum-scale and content-vs-panel geometry, and the nearest-empty-slot drop logic, live there.

Code review

Reviewed the tray-scroll/slot-drop/firework change against its proposal, spec delta, design and tasks: geometry floor (TRAY_MIN_SCALE), nearest-free-slot reducer rule, scroll offset + bounding rule, scrollbar UI and re-synthesized firework all match the spec, the commit is clean (no artifacts; dist/ is gitignored), and the new tests assert what they are named for. Fixed two bugs in Game.tsx: the pointer→field conversion keyed the scroll offset on the pointer while the render shift keyed on the piece position, so dragging across the tray's x edges jumped the piece by the full scroll amount (now both key on the piece position, including the grab offset); and a non-snapping drop in the strip below the panel could rest in a slot just outside the visible window, leaving the piece unrendered (the drop now nudges trayScroll so the rest slot is inside the window). Full gate re-run after the fixes: 52/52 tests, typecheck, lint and build all pass.

Fixed before the commit

  • major, src/components/Game.tsx:130: toField added trayScroll when the POINTER was inside the tray column, but the render shift applied when the PIECE's x was inside it. With any non-zero grab offset the two disagree in a window of width |dx| around the tray's left/right x edges, so dragging a tray piece toward the board (or a board piece into the tray) with the tray scrolled made the rendered y jump by the full trayScroll (up to ~444 field units at 12x12) mid-drag — violating task 3.2's 'no jump at the boundary'. Fixed: toField now probes the piece's would-be position (pointer minus grab offset) while dragging, and handlePiecePointerDown keys the grab offset on the piece's side of the column, so conversion, render shift and the reducer's drop rule all agree on one point and the piece follows the pointer continuously.
  • minor, src/components/Game.tsx:175: A non-snapping drop in the tray column rests in the nearest free slot, but a drop in the 40-unit strip below the tray panel (reachable by dragging to the bottom margin) has its nearest slot just below the visible window when scroll is near 0 — the piece then rendered nowhere until the user scrolled, contradicting the design's invariant that a piece never comes to rest invisible. Fixed: after such a drop the pointer-up handler recomputes the same nearestFreeSlot the reducer uses and nudges trayScroll minimally (clamped to [0, maxScroll]) so the rest slot is inside the panel window; drops whose slot is already visible change nothing.

Tests

All 8 scenarios of feedback-to-implement-puzzle-game-1-piec-w47x98 have a tagged test.

The test lint recorded nothing in the run's tests.

Braid run

  • Workflow: Braid's OpenSpec flow, change feedback-to-implement-puzzle-game-1-piec-w47x98 (34 steps, 1 retried)
  • Issue: cmoriarty/brooke#3
  • Model: vLLM · qwen3.8-27b
  • Time: 1 h 28 m from start to this pull request, 1 h 35 m of it in the model
  • Tokens: 22.7M input, 82k output, 271k reasoning, over 362 model calls
  • Pre-flight estimate: fits, p50 136k / p80 207k tokens against a 240k-token step allowance
  • CI: no CI ran on the checked code: the project has no CI (no workflow under .forgejo/workflows, .gitea/workflows or .github/workflows); what only CI tests went unverified
  • Run: run_01M6SY0G75HV6T5Q3JGKW47X98

Opened by Braid.

## What was done - Tray pieces now render at a usable minimum size instead of shrinking to fit, and when they do not all fit the tray scrolls vertically inside its panel, which keeps exactly its current width and height. - A piece dropped back into the tray settles into the nearest empty slot instead of piling on top of another piece, so two pieces never share a spot. - A custom scrollbar (a track plus a draggable thumb) is drawn on the tray frame and driven by the mouse wheel, appearing only when the pieces do not all fit. - The play field still fits the viewport with no page scrolling — only the tray's contents scroll — and the board and already-placed pieces never move. - The completion firework is re-synthesized to sound like a real firework (a rising whistle, a low thump under the burst, and a longer scatter of crackles), still generated entirely in code with no audio files. - New unit tests cover the tray layout math and the tray-drop slot logic, and the full test suite passed while a judge opened the running app in a real browser and played a complete session — starting a puzzle, scrolling the tray, solving it, and replaying — to confirm the behavior. - **Not done:** the setup screen overflows a 720p-tall viewport by ~35px (the last image row needs a small page scroll); this is pre-existing, untouched by this change, and the game screen itself never scrolls. - **Not done:** the re-synthesized firework has no automated test — it is verified by listening in a browser, and the spec deliberately covers no audio. ## How to review 1. Check out the branch and diff it against `origin/main` to see the change — it spans the tray layout math, the drop logic, the game and tray components, the firework audio, and the README. 2. Run the checks with `npm test`, `npm run typecheck`, `npm run lint`, and `npm run build` — all four should pass. 3. Start the app with `npm run dev` and open the printed URL — you should see the setup screen (an image gallery, difficulty options, and a "Start puzzle" button that is disabled until you pick an image). 4. Pick an image and a large grid such as 12×12, then start — the board appears on the left and the tray on the right, with pieces at a usable size and a scrollbar on the tray's right edge. 5. Play with the tray: wheel over it (or drag the scrollbar thumb) to scroll the pieces, then drag a piece out and drop it back — the pieces scroll within the fixed-size panel while the board stays put, and the dropped piece settles into the nearest empty slot rather than on top of another piece. 6. Read `src/lib/layout.ts` and `src/hooks/usePuzzle.ts` first — the minimum-scale and content-vs-panel geometry, and the nearest-empty-slot drop logic, live there. ## Code review Reviewed the tray-scroll/slot-drop/firework change against its proposal, spec delta, design and tasks: geometry floor (TRAY_MIN_SCALE), nearest-free-slot reducer rule, scroll offset + bounding rule, scrollbar UI and re-synthesized firework all match the spec, the commit is clean (no artifacts; dist/ is gitignored), and the new tests assert what they are named for. Fixed two bugs in Game.tsx: the pointer→field conversion keyed the scroll offset on the pointer while the render shift keyed on the piece position, so dragging across the tray's x edges jumped the piece by the full scroll amount (now both key on the piece position, including the grab offset); and a non-snapping drop in the strip below the panel could rest in a slot just outside the visible window, leaving the piece unrendered (the drop now nudges trayScroll so the rest slot is inside the window). Full gate re-run after the fixes: 52/52 tests, typecheck, lint and build all pass. **Fixed before the commit** - major, `src/components/Game.tsx:130`: toField added trayScroll when the POINTER was inside the tray column, but the render shift applied when the PIECE's x was inside it. With any non-zero grab offset the two disagree in a window of width |dx| around the tray's left/right x edges, so dragging a tray piece toward the board (or a board piece into the tray) with the tray scrolled made the rendered y jump by the full trayScroll (up to ~444 field units at 12x12) mid-drag — violating task 3.2's 'no jump at the boundary'. Fixed: toField now probes the piece's would-be position (pointer minus grab offset) while dragging, and handlePiecePointerDown keys the grab offset on the piece's side of the column, so conversion, render shift and the reducer's drop rule all agree on one point and the piece follows the pointer continuously. - minor, `src/components/Game.tsx:175`: A non-snapping drop in the tray column rests in the nearest free slot, but a drop in the 40-unit strip below the tray panel (reachable by dragging to the bottom margin) has its nearest slot just below the visible window when scroll is near 0 — the piece then rendered nowhere until the user scrolled, contradicting the design's invariant that a piece never comes to rest invisible. Fixed: after such a drop the pointer-up handler recomputes the same nearestFreeSlot the reducer uses and nudges trayScroll minimally (clamped to [0, maxScroll]) so the rest slot is inside the panel window; drops whose slot is already visible change nothing. ## Tests All 8 scenarios of `feedback-to-implement-puzzle-game-1-piec-w47x98` have a tagged test. The test lint recorded nothing in the run's tests. ## Braid run - **Workflow:** Braid's OpenSpec flow, change `feedback-to-implement-puzzle-game-1-piec-w47x98` (34 steps, 1 retried) - **Issue:** cmoriarty/brooke#3 - **Model:** vLLM · qwen3.8-27b - **Time:** 1 h 28 m from start to this pull request, 1 h 35 m of it in the model - **Tokens:** 22.7M input, 82k output, 271k reasoning, over 362 model calls - **Pre-flight estimate:** fits, p50 136k / p80 207k tokens against a 240k-token step allowance - **CI:** no CI ran on the checked code: the project has no CI (no workflow under `.forgejo/workflows`, `.gitea/workflows` or `.github/workflows`); what only CI tests went unverified - **Run:** [run_01M6SY0G75HV6T5Q3JGKW47X98](http://openspecflow.internal.underthere.xyz/run/run_01M6SY0G75HV6T5Q3JGKW47X98) _Opened by Braid._
cmoriarty deleted branch osf/179-feedback-to-implement-puzzle-game 2026-11-06 23:08:41 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/brooke!4
No description provided.