towerdef/docs/review-2026-10-09/findings.md
Claude 72c49eee1f Wrap up: review findings, balance baseline, bot tool and next-session notes
- docs/NEXT.md: where to pick up, prioritised, with the known wall-selling bug
  and its two-line fix
- docs/review-2026-10-09/: 85 reviewer findings (touch, co-op, client code,
  visual, reverse proxy) with verification status, repro scripts archive and
  the review workflow script; nothing fixed yet by design
- docs/BALANCE.md + tools/bot.js: headless balance bot and the untuned baseline
  (IDS Sniper dominates, maze is a near-guaranteed win, credits snowball)
- test/sim.test.js derives tunable numbers from the tables, plus a shape test
- README status note

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
2026-10-09 21:38:59 +00:00

133 KiB

Review findings, 2026-10-09

Five independent reviewers probed the running game in real browsers (Chromium via Playwright, CDP touch events) and against the real server; a second set of agents then tried to refute each finding. The pipeline was stopped before the fix stage, so nothing below has been fixed yet (except where noted). Status per finding:

  • CONFIRMED: an independent verifier reproduced it.
  • REFUTED: a verifier could not reproduce it / judged it intended.
  • UNVERIFIED: reported by a reviewer with a repro, verification had not run yet (treat as likely, re-check before fixing).

Reviewer repro scripts (throwaway Playwright/ws scripts, with the hard-coded scratch paths they were written for) are in repro-scripts.tgz next to this file: tar xzf repro-scripts.tgz gives one folder per reviewer.

Summary

Area Confirmed Refuted Unverified
Touch UX on phones/tablets 18 0 0
Co-op chaos / protocol races 0 0 8
Client code review 0 0 28
Visual / UX QA 7 1 14
Reverse proxy (nginx / NPM) 0 0 9

Touch UX on phones/tablets (18 findings)

Coverage: Tested with real Chromium 156 (Playwright, --no-sandbox), real server on port 8210 (killed afterwards), CDP Input.dispatchTouchEvent touch plus isMobile/hasTouch emulation, pointer:coarse matched. Viewports: 375x667, 390x844, 412x915, 360x640, 320x568, 667x375, 844x390, 915x412, 768x1024, 1024x768, plus width/height sweeps 560-920 wide for the landscape top bar. Covered and OK: tap-preview then confirm bar, tap-same-cell-again and Cancel for all 6 types on 390x844 and 667x375 (all pass); wall drag painting (fast single-jump line, diagonal, dense stroke leaving the board and re-entering: only crossed cells get walls, gold exhaustion, route-seal rejection, pointercancel mid-paint and mid-pinch then fresh tap, pointercancel cancels long-press timer); cellToScreen/screenToCell round trips (0 wrong of 2080 per variant for zoom 1/2.3/3/4 with extreme pan, rotated and unrotated) and 30 real tap [...]

touch-1 [HIGH] Firewall armed: any two-finger pinch/pan drops a wall under the first finger (5 credits)

Status: CONFIRMED (verifier severity: medium)

  • Repro: R=/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/touch-ux ; start server on 8210 (PORT=8210 HOST=127.0.0.1 node server/index.js); source pwenv.sh; node $R/gestures.js i14 (first test). Manual: iPhone 14 390x844, Play solo, tap Firewall in palette, touchStart finger 1 on cell (8,6), 30 ms later add finger 2 on (12,6), spread both outward, lift.
  • Observed: walls 0 -> 1 and gold 140 -> 135 although the gesture was a pinch (zoom ended 1.47). Cause: canvas pointerdown (main.js ~L545) calls placeAt() for the first touch immediately when selType==='wall'; the ptrs.size===2 branch only sets painting=false afterwards, it cannot undo the placement. Every zoom/pan gesture with the main maze tool armed builds a stray wall (can lengthen/alter the route, and in co-op the partner sees it).
  • Expected: A two-finger gesture never builds. Walls should be committed on first move/pointerup (or after a ~60-80 ms delay that is cancelled when a 2nd pointer lands), like the long-press timer already is.
  • Suggested fix: For pointerType touch/pen with a wall armed: defer the first placeAt() to pointerup (if not moved and ptrs.size stayed 1) or to the first pointermove beyond slop; start painting only then. Cancel the deferral in the ptrs.size===2 branch.
  • Verifier: Reproduced with my own scripts (reviews/verify-touch/v1.js, v2.js, v3.js; server on 8210). Code: main.js pointerdown (L545-546) calls placeAt(cell) synchronously for the first touch when selType==='wall'. The ptrs.size===2 branch (L516-520) only does cancelLong(); painting=false; tapSelectOnUp=false and returns, so it cannot undo the placement.

Steps and results (iPhone 14 390x844 dpr3, Play solo, tap Firewall, CDP touch events):

  • Finger 1 down on cell (8,6), 30 ms later finger 2 on (12,6), spread 10 steps, lift. Before: walls [], gold 140, zoom 1. After: walls ["8,6"], gold 135, zoom 1.47. [...]
  • Verifier's better fix: The suggested direction is right, but two details need care:
  1. paintLine() deliberately skips its from cell. If the first placement is deferred to the first move past the slop, the origin cell must be placed explicitly at that moment, then paintLine(origin, current) run, or the first cell of every drag stroke is lost.
  2. A timer-only deferral (~60-80 ms, cancelled when a 2nd pointer lands) is NOT enough. My 80 ms test shows two-finger landings can be that far apart, and a quick tap with a ~40 ms hold would need flushing on pointerup anyway.

Simplest robust version, touch/pen with wall arme [...]

touch-2 [MEDIUM] Turret armed: pinch/pan relocates the pending build to the cell under finger 1

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/gestures.js i14 (tests 2 and 3); also $R/rotate.js and $R/offscreen.js. Manual: arm Packet Filter, tap cell (10,8) (preview + Build bar), then pinch with finger 1 landing on (6,5).
  • Observed: pending {x:10,y:8} -> {x:6,y:5} at pinch start (gestures.js FAIL line 2); rotate.js: pending (15,4) became (15,6) after a pinch, and after three two-finger pans it ended at (8,6). Same root cause as the wall bug: pointerdown for the first finger runs the 'app.pending = cell' branch before the second finger lands. The Build bar (and hint/route preview) now refer to a cell the user never chose, and the bar's .top class is not recomputed (see stale confirm bar finding). Also after lifting one finger of a pinch the remaining finger drags the pending cell around (pointermove single-finger branch).
  • Expected: Pending stays on the chosen cell while the camera is panned/zoomed; only a deliberate one-finger tap or drag moves it.
  • Suggested fix: Defer the pending update to pointermove-beyond-slop or pointerup for touch; ignore single-finger moves for a pointer that was part of a multi-touch gesture (track a 'gestureUsed' flag until all pointers are up).
  • Verifier: Reproduced from scratch with my own scripts (verify-touch/v4.js, v5.js, v6.js, v7.js) against the real server (port 8211), headless Chromium, isMobile + hasTouch, CDP Input.dispatchTouchEvent, iPhone-14 portrait (390x844) and Pixel-7 landscape. Code cause: public/js/main.js pointerdown touch branch (line ~547) runs app.pending = cell for finger 1 before finger 2 exists. The ptrs.size===2 branch only cancels long-press/paint and starts the pinch, so it never undoes that. The single-finger pointermove branch (~594) also keeps moving pending. Nothing handles this elsewhere.

Observed: (1) Filte [...]

  • Verifier's better fix: Deferring the pending update to pointerup, as suggested, would break the drag-to-aim ghost and the tap-again-to-build logic, which relies on prevPending and pending at pointerup. A smaller fix is to keep immediate feedback and undo it when the second finger arrives.
  1. Add a multi flag. Inside the ptrs.size === 2 branch of pointerdown, set multi = true. If app.selType && app.selType !== 'wall', restore app.pending = prevPending ? {...prevPending} : null, set app.previewDirty = true and call updateConfirm(). prevPending was already snapshotted at finger 1's pointerdown, before pe [...]

touch-3 [MEDIUM] After tapping a tower, Upgrade/Sell/Target are below the fold on most phones (portrait and landscape)

Status: CONFIRMED (verifier severity: medium)

  • Repro: node $R/layout.js and node $R/sidescroll.js (screens in $R/shots/layout-*.png, sidescroll-se-bottom.png). Manual: Play solo, build any turret, tap it.
  • Observed: Sell button bottom edge vs viewport height: 375x667 y=826 (vh 667), 390x844 y=929 (vh 844), 360x640 y=810 (vh 640), 320x568 y=754 (vh 568), landscape 667x375 y=569, 844x390 y=548, 915x412 y=548. Only 412x915 (Upgrade/Sell row just fits) and iPad fit. #side scrolls (touch swipe works: scrollTop 0->81) but the portrait palette is sticky and 101 px tall, so the scroll window left is 59 px (360x640), 71 px (375x667), 145 px (390x844). Nothing scrolls #info into view on selection (scrollTop stayed 0). In landscape the info panel starts below the 156-160 px palette grid.
  • Expected: Tower actions reachable without hunting: visible after selection (auto-scroll, compact action bar in the stage, or collapse the palette while a tower is selected).
  • Suggested fix: On selectTower() call info.scrollIntoView({block:'nearest'}) / side.scrollTop reset, collapse the palette to one row (or un-stick it) while a tower is selected, and fix the root cause in the next finding.
  • Verifier: Reproduced from scratch with my own scripts (repro.js, scroll.js, window.js, fix.js in .../scratchpad/reviews/verify-touch/, server on 8210, mobile+touch contexts, real CDP touch swipes). Steps: Play solo, select Packet Filter, tap cell (10,8), tap the check button to build, tap the tower, then read the geometry. Nothing in the repo is edited.
  1. The claim's numbers reproduce exactly. Sell bottom edge against viewport height after selecting the tower, with scrollTop 0 in every case:
    • Portrait: 375x667 gives 826 (vh 667). 390x844 gives 929. 360x640 gives 810. 320x568 gives 754.
    • Landsc [...]
  • Verifier's better fix: The suggested fix is flawed. I simulated each variant in the page with injected JS and CSS (no repo edits), checking the Upgrade and Sell buttons.

  • scrollIntoView on #info with block:'nearest' leaves Sell 0/42 px visible on 375x667, 360x640 and 320x568. #info is 251 px tall against a window of about 59 to 70 px, and the sticky palette covers the top of the scroll port.

  • scrollIntoView on .actions leaves Sell visible but Upgrade and Target cut off (22/42, 11/42 and 0/42 px on the three small phones).

  • Hiding the palette while a tower is selected (a [data-sel] attribute or class on #app) giv [...]

touch-4 [MEDIUM] Small portrait phones: stage wastes ~140-160 px of dead bands, board drawn at 12-14 px cells, side panel starved

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/offboard2.js (second half) and node $R/roundtrip.js se,i14,seL; screen $R/shots/layout-se.png
  • Observed: stage vs drawn board: 320x568 stage 320x329, board 312x192, dead 137 px vertical, cell 12.0 px, side 145 px; 360x640 stage 360x371, board 352x217, dead 155 px, cell 13.5 px, side 161 px; 375x667 stage 375x387, board 367x226, dead 161 px (about 80 px black above and below), cell 14.1 px, side 172 px. 390x844: cell 18.5, 412x915: 20.1. Cause: #stage aspect-ratio uses the rotated ratio (--aspect-p 16/26) but is clamped by max-height:58dvh; the stage then measures ~1.03 tall:wide, the rotation test (height > width*1.05) fails so the board is drawn UNrotated inside a tall box. The dead band is almost exactly the height missing from the side panel. Hit-testing itself is exact (0 wrong of 2080 roun [...]
  • Expected: Stage sized to the board's drawn aspect when unrotated (or rotation chosen when it gives larger cells), giving the freed 140-160 px to the palette/info panel; cells >= ~18 px at 360-375 px width if possible.
  • Suggested fix: When the board will be drawn unrotated, set the stage height to fit the board (aspect-ratio var(--aspect)) instead of the 58dvh box; or raise the cap for narrow phones. Consider an offset/magnifier for the preview.
  • Verifier: REPRODUCED the layout numbers from scratch (own script /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/m1.js, real server on 8212, Playwright mobile emulation, solo game started). Stage WxH / board drawn / cell / dead band / #side height: 320x568 -> 320x329.4, 312x192, 12.0px, 137, 145. 360x640 -> 360x371, 352x217, 13.5, 155, 161. 375x667 -> 375x386.9, 367x226, 14.1, 161, 172 (screenshot shows ~80px black above and below the board). 390x844 -> cell 18.5 (rotated, dead 8), 412x915 -> 20.1. Cause confirmed: computed #stage aspect-r [...]
  • Verifier's better fix: Do not simply fit the stage to the board, because the hint pill and the confirm bar then cover about 45% of it at 375x667. Either (a) move the confirm bar and the route hint out of the stage (for example a sticky action row at the top of #side, or into the freed band), then size the stage to the board aspect; or (b) keep a fixed overlay allowance, e.g. stage height = board height + about 75px for the bar at the bottom, which still frees about 85px of the 161px for #side. For the CSS condition, the unrotated regime is exactly when 58dvh < 1.05*W, i.e. viewport W/H > ~0.55. A media query like @m [...]

touch-5 [MEDIUM] prefers-reduced-motion hides every toast

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/reduced.js (Playwright reducedMotion 'reduce'; screens shots/toast-*.png). Manual: OS 'Reduce motion' on, arm a tower with too few credits and tap twice.
  • Observed: no-preference: toast opacity 0.976, animationDuration 2.6s. reduce: opacity 0, animationDuration 1e-05s, fill 'forwards'. The global reduced-motion rule sets animation-duration .01ms with iteration-count 1, and the toast keyframes end at opacity:0 with fill-mode forwards, so the toast is invisible immediately. That removes reject reasons ('Not enough credits', 'That would seal the route'), 'Wave N cleared +credits', co-op join/leave/lost-connection notices and the 'Room XXXX. Send the invite link' toast. iOS 'Reduce Motion' is common.
  • Expected: Reduced motion shortens/removes the movement, not the information; toasts stay visible for their lifetime.
  • Suggested fix: In the reduced-motion block give .toast animation:none and remove it via the existing setTimeout (or a non-forwards opacity-only animation). Also gate renderer screen shake / core flash on matchMedia('(prefers-reduced-motion: reduce)') (render.js L289/L321 ignore it).
  • Verifier: Reproduced from scratch with my own Playwright script (/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/v2.js, server on port 8210). The script uses the real UI with no sim tampering. In solo play it picks Packet Filter, places filters until credits run out, then taps again to get the "Not enough credits" toast. I ran it on desktop (1280x800, mouse) and a phone (390x844, isMobile, touch), each with reducedMotion 'no-preference' and 'reduce'.

Results, measured 120ms after the toast appears:

  • no-preference, desktop and phone: opac [...]
  • Verifier's better fix: Add one rule after the global reduced-motion rule in public/css/style.css: @media (prefers-reduced-motion: reduce) { .toast { animation: none; } }. I verified it. The toast stays at full opacity until the existing 2700ms setTimeout in main.js removes it, and no JS change is needed. For the shake, gate it in render.js with a single const reduceMotion = root.matchMedia && root.matchMedia('(prefers-reduced-motion: reduce)').matches check around this.shake and this.flashCore. Keep a brief non-movement indicator, such as the core ring or flash, so the leak is still signalled. The global rul [...]

touch-6 [MEDIUM] Landscape phone main menu: Play solo / Co-op buttons cut by the bottom edge

Status: CONFIRMED (verifier severity: medium)

  • Repro: node $R/menu.js (screens shots/menu-seL.png, menu-i14L.png). Manual: open on 667x375 or 844x390, nothing tapped.
  • Observed: 667x375: #btnSolo/#btnCoop top 357, bottom 401 (viewport 375) so only 18 px of the 44 px primary button is visible; 844x390: 357-403 (vh 390). Map picker (137-305) plus description push the buttons off; the card is overflow-y:auto but there is no scroll cue. overlays.js also shows the menu and help cards are scrollable in all landscape sizes.
  • Expected: The primary action visible on first paint (smaller map cards or two-column layout in short landscape).
  • Suggested fix: In (orientation:landscape) and (max-height:520px) lay the menu out as two columns (maps left, buttons right) or shrink .mapcard canvas height.
  • Verifier: Reproduced with my own scripts (menu_v.js, menu_scroll.js, menu_fix.js under scratchpad/reviews/verify-touch/). I used a fresh real server on port 8216, because 8210 was already in use by another agent. The menu was untouched and the viewport was mobile with touch.

Measured with getBoundingClientRect and elementFromPoint:

  • 667x375: #btnSolo/#btnCoop span 357-401, the card spans 14-361, and the card's scrollHeight is 444 against a clientHeight of 345. The reviewer's "18 px visible" is generous. The card's own overflow clip at y=361 leaves only about 4 px of the button hit-testable (elementFro [...]
  • Verifier's better fix: Add a compact variant of the menu card inside the existing short-landscape query, with no markup changes:

@media (orientation: landscape) and (max-height: 520px) { #menu .card { padding: 8px 14px; } #menu .logo-mark { width: 30px; height: 30px; } #menu .card h1 { font-size: 26px; } #menu .tag { margin: 2px 0 6px; } #menu .mapcard { flex-direction: row; align-items: center; padding: 6px; } #menu .mapcard canvas { width: 44%; flex: none; } #menu .mapcard .nm { min-height: 0; font-size: 12.5px; } #menu .mapcard .df { display: none; } #menu .mapdesc { min-height: 0; margin: 4px [...]

touch-7 [MEDIUM] Co-op landscape top bar breaks at 701-760 px wide: Sound button off-screen, Wave button wraps to 3 lines

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/topbar2.js (AUTO=0 node $R/topbar2.js for no countdown); node $R/topbar.js (shots/topbar-l740.png, 740x360). Manual: 740x360 (Galaxy S9 class), join/create a co-op room, optionally enable AUTO.
  • Observed: With the co-op chip visible at height 360 (same at 320/393/412): widths 710/720/730 -> #btnSound right edge beyond the viewport (unreachable); widths 710-760 with AUTO countdown -> #btnWave height 63 px (text 'Wave 29 · 59s' wraps to 3 lines), topbar grows to 70 px. Without AUTO the Sound overflow remains at 710-730. Solo is fine at every width tested. Cause: the compact landscape rule hides #netChip/.lbl only up to max-width:700px, while the nowrap top bar has no shrink strategy in 701-760.
  • Expected: No clipped controls at any width.
  • Suggested fix: Extend the compact rules to max-width:760px or give #topbar flex-wrap/overflow handling and white-space:nowrap + flex:none on #btnWave.
  • Verifier: Reproduced from scratch with my own scripts (verify-touch/tb_real.js, fixtest.js, scan1.js, tapsound.js). I used a real co-op flow instead of the reviewer's DOM injection: host on a 700-860 x 360 mobile/touch context created a room through the real server on 8210, a desktop guest joined, and I enabled AUTO with a real tap. repo public/css/style.css was not touched (md5 unchanged).

CONFIRMED, with measurements:

  • At 701-737 px wide and 360 px high with AUTO on, #btnWave wraps to 3 lines (height 63, width 103) and the topbar grows 45 to 70 px. The text is "Wave 1 · 28s". The screenshot at 720x3 [...]
  • Verifier's better fix: The suggested max-width:760px extension is incomplete. I tested it as a CSS injection ("Fix A"): it clears 701-760 plain viewports but leaves the 63 px wave button on notched iPhones (812/44, 844/47, 852/59, 874/62 insets, effective 724-750 px), and it leaves the 2-line wrap at 761-840. A viewport width media query cannot see the safe-area padding.

A container query on the topbar fixes all of it. Tested at heights 320, 360 and 414, AUTO on and off, widths 690-1000, and the four notched iPhone insets. It gave zero overflow, wave button 40 px, topbar <=47 px: #topbar { container-type: inline- [...]

touch-8 [MEDIUM] Portrait co-op on <=420 px phones: room code and Invite button are below the fold

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/coop.js (real server, two touch contexts; screens shots/coop-se.png, coop-i14.png). Manual: iPhone SE/14 portrait, Co-op online, Create room.
  • Observed: 375x667: #players top 669 / invite button 746-788, viewport 667; 390x844: invite 849-891, viewport 844. The top-bar room chip is display:none at max-width 420px ('moves into players panel'), so the only places to read the 4-letter code or tap Invite are off-screen; the host sees just a 2.6 s toast.
  • Expected: Room code/Invite reachable on first view of the game screen (e.g. a compact chip that opens the share sheet).
  • Suggested fix: Keep a small tap-to-share room chip in the top bar (icon + code) or show the Invite button in the stage; toast stays until dismissed on first create.
  • Verifier: I reproduced this with my own Playwright script against the real server (scratch under reviews/verify-touch/, ports 8210), using isMobile and hasTouch contexts. The claim's geometry matches exactly, but its wording is overstated and the severity is lower than "medium".

What matches the claim

  • 375x667: #players top 669, Invite button 746-788, viewport 667, #side 495-667.
  • 390x844: Invite button 849-891, viewport 844.
  • The Invite button is below the fold at first view on every portrait phone I tried at 420 px wide or less: 320x568, 360x740, 375x667, 390x844, 412x915 and 414x896. It is al [...]
  • Verifier's better fix: The suggested fix to keep the top-bar chip is sound, and the layout cost it implies does not exist. I injected @media (max-width:420px){#netChip{display:flex!important}} at 320x568, 360x740, 375x667 and 390x844. The chip landed in row 1 (about 70 px wide, left 246-314, top 4-5) and the top bar height was unchanged (94 to 89 at 320, 108 to 108 elsewhere). So the "keep it to two rows" justification for hiding it at 420 px or less does not hold.

Simplest change: delete #netChip { display: none; } from the @media (max-width: 420px) block in public/css/style.css. Then add `$('netChip').addEv [...]

touch-9 [MEDIUM] Co-op: partner's touch cursor never clears (and a plain tap never shows one)

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/coop2.js (Alice and Bob on i14, real server). Bob arms Packet Filter, drags the preview (6,5)->(12,7), lifts, then taps Cancel.
  • Observed: Alice's view.cursors = 1,12.5,7.5 during the drag, and still 1,12.5,7.5 3.5 s after Bob lifted and after Bob pressed Cancel: a labelled box stays on her board indefinitely. coop.js: a single tap-preview (no movement) produced 0 cursors on Alice. Cause: main.js only calls sendCursor(null) for mouse pointerleave; touch pointerup/pointercancel/cancel/confirm never clear it, tap does not send one, and RemoteController.sendCursor's 70 ms throttle can drop the final position.
  • Expected: Cursor shows while the preview is pending and disappears when the finger-driven preview ends or is built/cancelled.
  • Suggested fix: Send the cursor on touch pointerdown, send a trailing update, and sendCursor(null) on pointerup/cancel when no pending exists, on build, cancel and selectType(null).
  • Verifier: Reproduced with my own script (scratch dir .../reviews/verify-touch/cur2.js; real server on 127.0.0.1:8211, two i14-sized touch contexts, Alice hosts, Bob joins, CDP touch events, fresh room per scenario).

Code: public/js/main.js calls app.ctrl.sendCursor only at lines 564, 585, 596 (mouse hover/move and the touch pointermove branch with selType) and 627 (null, mouse pointerleave only). endPointer, btnCancelBuild (-> selectType(null)), btnConfirmBuild, updateConfirm and tap-to-build never send null. server/room.js handleCursor only clears p.cursor on x:null, disconnect, removal or rejoin, and [...]

  • Verifier's better fix: The suggested fix is a bit broad and has a throttle flaw. Simpler version, all in public/js/main.js and controllers.js:
  1. Make RemoteController.sendCursor(null, null) bypass the 70 ms throttle (and reset lastCursor). Otherwise a clear sent within 70 ms of the last move is silently dropped.
  2. Track the last pointer type that moved the cursor (or a touchCursorActive flag set in the touch pointermove branch and on touch pointerdown with a type selected). When pending goes from set to null (build, Cancel/selectType(null), tap-to-build, Escape) and that flag is set, send sendCursor(null, null) an [...]

touch-10 [MEDIUM] Long-press ping does nothing while a build type is armed; with Firewall armed it builds a wall instead

Status: CONFIRMED (verifier severity: medium)

  • Repro: node $R/longpress.js (i14).
  • Observed: Nothing armed: ping works (also with 5 px jitter; 12 px drift correctly cancels). With Packet Filter armed: marks=0, pending set, Build bar shown. With Firewall armed: marks=0 and walls +1 from the long-press. The long-press timer is only started in the 'no selType' branch, yet the armed type stays selected after every build, so in normal play (and especially co-op, where pings matter) the documented 'long-press pings your partner' only works after deselecting the tool.
  • Expected: Long-press (about 520 ms without moving) pings regardless of the armed tool and does not place/preview.
  • Suggested fix: Start the long-press timer for all touch pointerdowns; if it fires, markAt() and suppress the pending placement/wall (needs the deferral from finding 1).
  • Verifier: Reproduced with my own script (/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/lp.js) against a real server on port 8211. It uses isMobile/hasTouch Chromium and CDP Input.dispatchTouchEvent, so the game sees real pointerType=touch events. I wrapped ctrl.sendMark to count real ping calls instead of relying on renderer.marks. I ran three viewports: iPhone14 390x844, iPhone14 landscape 844x390 and SE 375x667. The results were identical on all three.

Code cause: in public/js/main.js (pointerdown, touch branch, about lines 540-552), [...]

  • Verifier's better fix: The reviewer's suggestion is right in direction but incomplete, with two points to add.
  1. Add && !longFired to the "tap previewed cell again builds" branch in endPointer. Without it, a long-press on the previewed cell still builds the tower, because after the timer fires pending still equals prevPending. This is the build-on-hold behaviour in the second observation above.

  2. For a tower type armed, handle the ping at pointerdown time. Start the 520 ms timer in every touch branch. When it fires, restore app.pending = prevPending (or null) and call updateConfirm(), set longFired=true, then [...]

touch-11 [LOW] Second tap on the preview with a few px of finger drift moves the preview instead of building

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/jitter.js. Arm Packet Filter, tap (10,8), tap it again with the finger 0.35 cell from centre drifting 4 px (below the 8 px tap slop).
  • Observed: 375x667 (14.1 px cells): towers 0 -> 0, pending moves to (11,8). 390x844 (18.5 px): pending moves to (10,7). pointermove updates app.pending for any movement, before the 8 px 'moved' slop is exceeded, so prevPending no longer equals pending on pointerup.
  • Expected: Movement under the tap slop is a tap on the originally touched cell and builds.
  • Suggested fix: Only update pending in pointermove once p.moved is true, or compare against the pointerdown cell on pointerup. Slop of 8 px is more than half a 12-14 px cell: scale slop with cell size.
  • Verifier: REPRODUCED with my own script (scratch dir .../reviews/verify-touch/jit1.js, jit2.js, jit3.js; real server on port 8214, unmodified repo; CDP Input.dispatchTouchEvent, isMobile+hasTouch).

Code cause confirmed in public/js/main.js: the touch pointermove handler (~line 594-596) sets app.pending = cell for ANY movement when selType is non-wall, before/independent of the 8 px p.moved slop. endPointer (~line 620) only builds if !p.moved AND prevPending === app.pending, so a sub-slop drift that crosses a cell boundary leaves pending on the neighbour and nothing is built.

Exact claim scenario: Pack [...]

  • Verifier's better fix: The first half of the reviewer's fix is right and simple; the second half is wrong. In the touch/pen branch of pointermove, only move the preview once the gesture is a real drag: if (p.moved) { app.pending = { x: cell.x, y: cell.y }; setHover(cell); updateConfirm(); } and keep app.ctrl.sendCursor(cell.fx, cell.fy) outside the guard. pointerdown already sets pending to the touchdown cell, so endPointer's existing prevPending === pending check then compares the touchdown cell, which is what a tap means. I verified this on a patched copy (verify-touch/repo2, port 8217, repo untouched): the ex [...]

touch-12 [LOW] Third finger (palm) freezes pinch and the next move after it lifts jumps zoom to max

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/third.js (CDP touchEnd releases the listed points: it releases only the palm).
  • Observed: Pinch to zoom 2.20; palm lands: fingers spread 130 -> 260 px apart, zoom stays 2.20 (py shifts -11.1 -> 12.9 because each finger is treated as a single-finger pan); palm lifted and fingers moved 2 px: zoom 2.20 -> 4.00 in one step. Cause: pointerdown returns early at ptrs.size>2, pointermove only pinches when size===2, endPointer clears pinch only when size<2, so pinch.d is stale.
  • Expected: Extra touches are ignored; pinch continues smoothly.
  • Suggested fix: Track only the first two pointer ids for pinch (ignore others), and re-seed pinch.d/mx/my whenever the pair changes.
  • Verifier: REPRODUCED with my own script (390x844 touch, CDP Input.dispatchTouchEvent, real server on 8214; scripts in /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/pm/third.js and variants.js). Page-level pointer log shows the third finger is a genuine pointerdown id=6 and later pointerup id=6 (not a test artefact). Numbers match the claim exactly: pinch gives zoom 2.200 (py -11.1); palm down, fingers spread 130->260 px: zoom stays 2.200, py moves -11.1 -> 12.9; palm up with no move: still 2.200; fingers move 2 px: zoom 2.200 -> 4.000 in [...]
  • Verifier's better fix: The suggestion is correct and sufficient for the claim. A minimal version, tested on a scratch copy: add seedPinch(), which stores ids=[...ptrs.keys()].slice(0,2) plus d/mx/my. In pointerdown at ptrs.size===2 call seedPinch(). In pointermove replace if (ptrs.size===2 && pinch) with if (pinch) { if (!pinch.ids.includes(e.pointerId)) return; const a=ptrs.get(pinch.ids[0]), b=ptrs.get(pinch.ids[1]); ... }, so extra fingers are fully ignored and cannot pan or move app.pending. In endPointer, `if (pinch && pinch.ids.includes(e.pointerId)) { ptrs.size>=2 ? seedPinch() : (pinch=null); } else if ( [...]

touch-13 [LOW] Touch targets below 44 px on coarse pointers

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/layout.js (small-buttons lists) and node $R/overlays.js.
  • Observed: Portrait info-panel Upgrade/Target/Sell: 42 px high (portrait rule .actions button min-height 42). Landscape phones: Menu 36x38, Auto 45x38, Speed/Pause/Sound 36x38 (4 px gaps) at 667x375, 40 px at 844x390/915x412; Wave 38-40 px. 320x568: all icon buttons 38 px. Menu 'How to play' and 'Fullscreen' link buttons 36 px. Adjacent 36x38 Speed/Pause/Sound makes mis-taps on Pause easy. (The 46 px default for pointer:coarse is overridden by the later landscape/340px rules.)
  • Expected: At least 44x44 css px with spacing on coarse pointers.
  • Suggested fix: Keep --btn at 44+ under (pointer:coarse) even in compact layouts, drop labels/stats instead; give link buttons min-height 44.
  • Verifier: Reproduced from scratch with my own script on port 8215 (own scripts in .../reviews/verify-touch/t44/: meas.js, info.js, fix44.js, chip.js). Context: Chromium isMobile+hasTouch, so (pointer: coarse) and (hover: none) both matched. I did not edit repo files.

MEASURED (getBoundingClientRect of visible buttons, game screen):

  • 375x667, 390x844, 412x915, 360x640, 768x1024, 1024x768: every topbar button is 46 px (Auto 49x46). No topbar button is below 44 on those sizes.
  • Landscape 667x375 and 568x320: Menu 36x38, Wave 118.5x38, Auto 45.2x38, Speed/Pause/Sound 36x38, with 4 px gaps (Speed 545-581, [...]
  • Verifier's better fix: Do not hand-edit each rule. In the landscape (line 62), max-width:700 (line 263) and max-width:340 (line 274) blocks, change --btn to 44px (or add a final @media (pointer: coarse){ :root{--btn:44px} button.icon{min-width:44px} .actions button, button.link{min-height:44px} } after them). Also set button.icon{min-width:var(--btn)} in those blocks instead of the 36/38 px literals.

Caveat the suggestion misses: the landscape co-op chip in the 701-756 px width range. In chip.js I forced the co-op chip visible with the text 'ABCD' and '123ms'. The topbar already overflows in the base layout a [...]

touch-14 [LOW] Confirm bar position goes stale after rotation and can cover the pending cell

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/staleconfirm.js (390x844 -> 844x390 via setViewportSize with a pending turret).
  • Observed: updateConfirm() only runs from pointer/selection handlers, never from resize/pan/zoom/Fit, so .top is stale. Pending (16,2) in portrait (bar at top) -> landscape: cell centre (377,103) inside bar rect [195,99,413,159] (covered); pending (14,3): centre (335,124) covered. At fit zoom without rotation the bar never covered the pending cell centre over all 404 free cells on 375x667, 390x844, 667x375, 844x390 (overlap.js).
  • Expected: Bar re-evaluated whenever the cell's screen position changes.
  • Suggested fix: Call updateConfirm() from resizeCanvas() and after any camera change (or from the frame loop when pending exists).
  • Verifier: Reproduced with my own scripts (scratch under reviews/verify-touch/: sc1.js, sc_rot.js, sc_fit.js, sc_rec.js), real CDP touch taps against the real server on port 8215.

Code: updateConfirm() (public/js/main.js ~457) is called only from selectType, selectTower, pointerdown/pointermove, build/cancel and Esc. It is not called from resizeCanvas(), updateFit(), the btnFit handler, the wheel handler or frame(). The 'top' class is only chosen from cellToScreen() at call time. The in-code comment says the bar should be kept clear of the cell being placed, so the stale case contradicts the stated inte [...]

  • Verifier's better fix: Add a one-line updateConfirm() at the end of resizeCanvas() (after renderer.resize), and one at the end of updateFit() (it already runs after every pinch/pan/wheel/Fit click). No per-frame call is needed. It is a no-op when app.pending is null.

touch-15 [LOW] Bottom safe-area inset applied twice in portrait

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/safe2.js (CDP Emulation.setSafeAreaInsetsOverride, bottom 34, i14 portrait, tower selected, side scrolled to the end).
  • Observed: gap between last panel and viewport bottom 8 px with inset 0 but 76 px with inset 34 (expected 42); #side clientHeight 198 -> 164 px. #app has padding var(--safe-b) and the portrait #side rule adds calc(8px + var(--safe-b)) again. Top/left/right insets behave (safe.js: topbar at y=47, landscape content at x=47).
  • Expected: Inset counted once.
  • Suggested fix: Remove + var(--safe-b) from the portrait #side padding.
  • Verifier: Reproduced with my own script (/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/sa/v.js and v2.js, server on port 8210, Chromium 156, mobile and touch emulation, CDP Emulation.setSafeAreaInsetsOverride, solo game, #side scrolled to the end). CSS cause confirmed in public/css/style.css: line 43 gives #app padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l), and the portrait rule on line 58 gives #side padding: 8px 10px calc(8px + var(--safe-b)). The bottom inset is therefore applied twice.

Measured gap from the la [...]

  • Verifier's better fix: The suggested fix is correct and minimal. In public/css/style.css line 58, change the portrait #side padding from 8px 10px calc(8px + var(--safe-b)) to 8px 10px 8px, because #app already pads by --safe-b. I tested exactly this override: the gap went from 76 to 42 px with no other layout change.

touch-16 [LOW] Error sound plays once per cell during a wall stroke

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/errsfx.js (12 credits, 19-cell drag).
  • Observed: sfx calls: click 1, wall 2, error 18 (onReject plays 'error' for every rejected cell; toast is de-duplicated but the sound has no MIN_GAP). Painting while broke or along a sealing line produces a buzzer burst.
  • Expected: One error sound per stroke/second.
  • Suggested fix: Add error to MIN_GAP (e.g. 0.4 s) or throttle in onReject.
  • Verifier: Reproduced from scratch with my own scripts (server on 127.0.0.1:8210, now killed). Scripts are in /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/ (verify.js, fast.js).

Code: public/js/audio.js line 99 has MIN_GAP = {shot_filter, kill, arc, boom, shot_mortar, shot_ids, wall} with no 'error' entry. sfx() therefore never throttles 'error'. public/js/main.js onReject() (line 166) calls toast(), which is de-duplicated for 900 ms (line 59), and then calls Audio.sfx('error') unconditionally. paintLine() calls placeAt() for every cell [...]

  • Verifier's better fix: The reviewer's one-line fix is sound: add error: 0.4 to MIN_GAP in public/js/audio.js. The error sound is about 0.21 s long, so the gap must be at least that, and 0.35-0.5 s is fine. This also covers the co-op remote-reject path, and the only caller is onReject. Caveat: during a long continuous stroke it still gives a slow buzz every 0.4 s rather than a single one. A stricter alternative is a per-stroke flag in main.js: set strokeErrored = true on the first reject while painting is true, skip Audio.sfx('error') while it is set, and clear it on pointerdown/pointerup/pointercancel. That gi [...]

touch-17 [LOW] Wall stroke that starts on a turret selects the turret and silently drops the Firewall tool

Status: CONFIRMED (verifier severity: low)

  • Repro: node $R/paint.js i14 (case 3).
  • Observed: Firewall armed, drag from a turret cell downward: walls=0, selType=null, selTower=1; the tool is deselected and the rest of the drag does nothing. (Fast single-jump strokes, diagonal strokes, gold exhaustion, sealing rejection and pointercancel mid-paint all behaved correctly; the 16/18 result was the two dead nodes in row 3.)
  • Expected: At most the starting cell is skipped; stroke continues and tool stays armed.
  • Suggested fix: Do not call selectTower from a wall-armed pointerdown that becomes a drag; select only on a stationary tap.
  • Verifier: Reproduced from scratch with my own script (/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/verify-touch/v2/mine.js, server on 8217, gold set to 9999). It fails on both input paths.

Steps: build a Filter turret at (10,5), arm the Firewall (wall) tool, then drag from the turret cell (10,5) down to (10,9) in four moves.

Observed:

  • Touch (390x844 isMobile, CDP touchStart/Move/End, portrait rot=pi/2): walls=0, selType=null, selTower=1. Gold was unchanged (9974) and the board had no new walls.
  • Mouse (1280x800, mouse down/move/up): identical r [...]
  • Verifier's better fix: The suggested direction (select only on a stationary tap) is right, but "do not call selectTower from a wall-armed pointerdown" is incomplete on its own, because a plain tap on a turret must still select it. I tested a minimal patch on a copy of the repo (scratchpad .../verify-touch/v2/repo, served on 8218; the real repo is untouched). In both the mouse and touch pointerdown branches, add a case before the existing selectTower branch: if (app.selType==='wall' && ex && ex.type!=='wall') { setHover(cell); painting=true; paintCell=cell; tapTowerId=ex.id; }. In endPointer, if `tapTowerId && !p.m [...]

touch-18 [LOW] Cosmetic touch UI leftovers

Status: CONFIRMED (verifier severity: low)

  • Repro: $R/fit.js, $R/hint.js, $R/overlap.js, shots/crop-bleed.png, $R/tapbuild.js
  • Observed: (a) 'Reset zoom' (#btnFit) stays visible at zoom 1 after rotation reset or new game (zoom 2.92 -> 1, fitHidden=false): updateFit() is not called. (b) Hint pill: longest reject text 'That would seal the route. Leave a path!' overflows the pill at 320 (scrollW 340 > clientW 298) and 360 (340 vs 338); hint also sits over cells near the top-centre edge (pending cell centre under hint: 8 cells on 390x844 e.g. (0,6)-(1,9), 6 on 667x375, 8 on 844x390). (c) Scrolled-under text ('Upgrade 60', 'Target: First') shows through the 8 px strip above the sticky palette (palette bg is rgba .97, sticky top:-8px). (d) The red X on the Build bar also drops the armed tower type (selectType(null)), so 'wrong cell [...]
  • Expected: Tidy states.
  • Suggested fix: Call updateFit() after camera resets; add overflow:hidden/ellipsis or wrap to .hint; make sticky palette bg opaque; make X clear only pending.
  • Verifier: The claim is a bundle of five cosmetic items. I reproduced (a), (b), (c) and (e) with my own scripts on port 8210, and (d) is intended behaviour rather than a defect. Scripts and shots are in .../reviews/verify-touch/ (a.js, b.js, c.js, d.js, e.js, f.js, shots/). No repo files were edited.

(a) CONFIRMED. At 390x844 I pinch-zoomed to 3.88, then resized to 844x390. The camera reset to zoom 1 and rot 0, but #btnFit stayed visible (hidden=false, 40x40 at [560,342]) and app.zoomed stayed true; shots/a-rotated.png shows the button. After zooming again and calling ctrl.newGame(), the state was the s [...]

  • Verifier's better fix: (a) Call updateFit() at the end of resizeCanvas() and adoptBoard() in public/js/main.js, or sync the button once per frame from renderer.zoom. Both are one-liners, and updateFit is a hoisted function declaration. (b) Shorten REASONS.blocks (for example "That would seal the route") or add overflow:hidden; text-overflow:ellipsis to .hint. Wrapping is unnecessary because the toast already carries the full text. (c) Make the sticky palette background opaque, using a solid colour that matches the blended #side background; no margin or top changes are needed. (d) Leave as is. (e) Skip the shake and [...]

Co-op chaos / protocol races (8 findings)

Coverage: All scripts, screenshots and raw outputs are in /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/coop-chaos/ (lib.js holds the shared helpers: in-process server, order-preserving TCP proxy with freeze/refuse/jitter, raw ws client). No repo files were edited. All servers were stopped (ports 8220-8229 free at the end).

TESTED, and behaved correctly:

  • Races (s1_races.js raw ws, s12_ui_races.js two browsers): same-cell place at the same instant gave exactly 1 tower, one 'occupied' reject, gold charged once (3 of 3 valid UI trials; two trials were my own toggle mistake). Turret vs turret on the same cell: 1 tower. Double sell: refund once (17), second gets 'no_tower'. A sell and B's place on the same cell resolve to either result without corruption. A hostile 150-message burst closes the socket 4429 as designed. A non-host newgame gets 'not [...]

coop-1 [HIGH] A client that stalls rendering for about 1 s permanently loses the partner's tower changes (ghost or missing towers, wrong route preview) until the next tower change

Status: UNVERIFIED

  • Repro: Scripts are in /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/coop-chaos/. Run source <scratchpad>/pwenv.sh; node s2_buf.js. In-process server with two desktop browsers. Variant 1 swaps window.requestAnimationFrame on B for a holder for 1.5 s, which is what a hidden tab does. While B is stalled, A places 2 walls. Variant 2 runs a 1 s busy loop on B's main thread while A places 1 wall. Variant 3 uses a 450 ms busy loop. Variants 1 and 2 are the failing ones. Spontaneous repro with no deliberate stall: node dbg2.js creates 10 fresh host+guest sessions, places 4 towers, and starts a wave. It failed in 1 of 10 runs (1 of 8 earlier). The sa [...]
  • Observed: Variant 1: server towers=2, but B ctrl.towers=0, ctrl.rev=0, view.rev=2, recvRev=2, gold 130 (the spend IS shown). This stayed unchanged for the full 5 s sampling window and indefinitely after that. Variant 2: server 4, B 3, same signature. Variant 3 (450 ms stall): fine, B 5 of 5. B's mirrored board.routeLen stays at the old value, so the route preview is wrong. B's click on a cell the server holds a tower on is rejected with 'Something is already there' while the cell looks empty. A sold tower would stay visible as a ghost the same way. The next tower change by anyone resynced B at once (3 of 3 towers), so the desync only lasts until the next build or sell. Cause: _push caps buf at 10 entr [...]
  • Expected: Client towers, board mirror and rev always equal the server's after any pause in rendering, and a desync is self-healing. Backgrounded tabs and slow phones are normal in co-op.
  • Suggested fix: Apply tw (and set this.rev and the board) when the snapshot ARRIVES, or keep the newest undisplayed tw outside the ring buffer so shift() cannot discard it. Additionally, in update() compare this.rev with the latest recvRev and call requestSync() if they differ for more than about 1 s. Do not drop entries that carry ev or tw when trimming. requestSync() already repairs the state (forced in s5b setup). Add a unit test that feeds 15 snaps with a tw on the 2nd and then calls update().

coop-2 [HIGH] Half-open connection (wifi/cell switch, NAT or proxy drop): the UI looks alive but frozen for 47-65 s with no 'Reconnecting' overlay. The watchdog's ws.close() never reconnects.

Status: UNVERIFIED

  • Repro: node s5a_freeze.js: B loads the game through a TCP proxy on 8225 that swallows all bytes on the existing connection while still accepting new ones. HOLD=1 node s5a_freeze.js also stops FIN/RST from the server reaching the browser, which is a true dead path. node s13_offline.js section 2 uses Playwright context.setOffline(true) for 8 s. Each script polls ctrl.status, ws.readyState and the visibility of #reconnect.
  • Observed: Freeze without HOLD: status stays 'joined' with no overlay. At about 5-6 s readyState becomes 2 (CLOSING, the 5 s watchdog fired ws.close()), and nothing else changes. The overlay appears only at 47.3 s, when the server's own ping/pong termination closes the TCP socket and the proxy relays it. Rejoin at 48.0 s. With HOLD=1 (no close ever delivered): CLOSING from 5.3 s, overlay only at 65.1 s (Chrome's closing-handshake timeout), rejoin at 65.7 s. setOffline for 8 s: status 'joined' with overlay hidden for the whole 8 s, then 0.1 s 'reconnecting' and 0.3 s 'joined' once the network came back. Server side: the partner sees B as offline only after the server's own ping timeout, about 45 s. B's [...]
  • Expected: Within about 5-6 s of silence the client shows the Reconnecting overlay and opens a NEW socket (the server replaces the old connection by pid, close code 4001), without waiting for onclose. Also react to the offline event and to a stale lastMsg.
  • Suggested fix: In the watchdog and in _wake(), after ws.close(), detach the old socket's handlers (set onclose=null, this.ws=null), call this._failed()/connect() straight away and show the overlay. The server already handles the pid takeover. Optionally listen for window 'offline' and show the overlay at once.

coop-3 [MEDIUM] Host leaves (or times out) while the end overlay is open: the promoted guest is stuck on 'Waiting for the host to start a new game...' with no Play again button

Status: UNVERIFIED

  • Repro: node s3_end_menu.js, Test 3. Host A (desktop) and guest B (phone). Set sim.lives=1 and speed=3, start a wave, and let a real leak end the game ('lost'). Both see 'Breach!'. A presses Menu on the end overlay, which leaves the room. Screenshot: scratchpad/reviews/coop-chaos/t3_guest_end_after_host_left.png.
  • Observed: Before: A {again:true, wait:false}, B {again:false, wait:true}. After A leaves: server room shows slot 1 host=true and B's ctrl.you.host=true, but B's #btnAgain is still hidden and #endWait ('Waiting for the host...') is still shown. The only choice is Menu. endScreen() sets btnAgain/endWait once and nothing recomputes them on a 'players' update. The server does accept B's newgame (B's newGame API call moved the room back to 'playing'). The same happens if the host just closes the tab, after the 60 s grace.
  • Expected: When the promotion arrives, B's end overlay switches to the host variant (Play again visible, wait text hidden).
  • Suggested fix: In onPlayers() (or the 'players' handler), if the end overlay is visible, recompute btnAgain/endWait from ctrl.you.host.

coop-4 [MEDIUM] Opening Menu > Co-op online during a live co-op game and failing to join (bad code, full room) silently kills the current game: the player is left on a dead, frozen game screen

Status: UNVERIFIED

  • Repro: node s3_end_menu.js, Test 4. A hosts with B joined. A: #btnMenu, #btnCoop, type ZZZZ, #btnJoin. Then #btnLobbyBack. Screenshot: t4_after_back.png.
  • Observed: connectRemote() calls app.ctrl.close() first, which sends 'leave' and closes the live room, before the new connect has succeeded. The 'fatal' (no_room) handler then takes the else lobbyMsg(...) branch because app.ctrl is still the closed old controller. After 'Back': A's ctrl.status='closed', app.inGame=true, #reconnect hidden. The HUD and player panel still look normal (it still lists 'Alice (you) host', 'Bob'), but nothing is interactive: a place command leaves gold at 140 and the server at 0 towers. The partner B sees players ['Bob'] only, so A has left B's game without knowing it. (A successful join to a different room works: T4b.)
  • Expected: Keep the current session until the new join succeeds, or on failure return the player to the still-connected game or to a proper menu with a message.
  • Suggested fix: Create the new RemoteController first and close the old one only inside its first 'joined'. Alternatively, hide Co-op online/Join in the in-game menu, or route the failure through leaveToMenu().

coop-5 [MEDIUM] Simultaneous Upgrade (and Next Wave) from both players are applied twice: the partner pays for a second upgrade they did not intend, and two waves start

Status: UNVERIFIED

  • Repro: node s1_races.js (raw ws clients, in-process server): sections 3 and 4. A and B both send {t:'cmd',c:'upgrade',id} for the same level-1 filter in the same tick. Sections 4 and 5 do the same for 'wave' and for conflicting pause/speed.
  • Observed: Double upgrade: tower ends at level 3, gold 1000 -> 915 (85 credits charged), neither client receives a reject. Simultaneous 'wave': wave counter 0 -> 2, spawnQ 19, so two waves launched. Conflicting pause (A true, B false) resolves last-writer-wins (paused=false); conflicting speed (3 vs 2) ends at 2. These are consistent but silent. (Same-cell place, double sell, sell-vs-place all resolve correctly, see coverage.)
  • Expected: The second of two simultaneous identical intents should be a no-op or rejected, for example 'stale', so that no one is charged twice or gets a surprise second wave.
  • Suggested fix: Let 'upgrade' carry the level the sender saw (lv) and reject if t.level != lv. For 'wave' send the wave counter the sender saw (w) and reject on mismatch (or debounce).

coop-6 [LOW] After a server restart both players are dumped to the lobby with 'That room does not exist (any more).' (no mention of the restart). A reload with a stale saved room lands on a bare main menu with no message. After a 53 s outage Resume is wiped.

Status: UNVERIFIED

  • Repro: node s6_restart.js (child-process server on 8229, SIGTERM, restart after 3 s) and node s8_lobby.js section 1b (sessionStorage nw.room=ZZZZ plus a localStorage nw.session) and node s5c_long.js (proxy refuses for the full retry schedule).
  • Observed: SIGTERM with 2 clients connected: server exits in 142 ms with code 0, and both clients show the Reconnecting overlay (good). Restart after 3.5 s: both clients get the 'no_room' error within 1 s and go to the lobby with 'That room does not exist (any more).'. They can recover (A creates a new room, B joins by code; verified), but have to coordinate by hand and the message does not say the server restarted. Server stays down: both give up after 52.5 s (retries at 0.4, 1.0, 2.1, 3.9, 6.9, 11.9 ... 52.4 s) with 'Lost connection to the server.'. That is 7.5 s BEFORE the 60 s grace expires, and the fatal handler deletes nw.room and nw.session (Resume button gone) even though the seat is still held [...]
  • Expected: A clear 'The server restarted; your game was lost. Create a new room' message, visible in every path. Keep Resume until the grace period is really over.
  • Suggested fix: On boot-path failures call openLobby() before lobbyMsg. Map no_room after a reconnect attempt to a 'game was lost (server restarted?)' message. Do not delete nw.session on a 'connect'/'lost' fatal, only on explicit leave or no_room.

coop-7 [LOW] Pending touch placement stays armed after the partner builds on that cell, with no warning until Build is pressed

Status: UNVERIFIED

  • Repro: node s12_ui_races.js section 3. B previews an IDS Sniper at (18,4) with a tap, A then builds a wall there. Screenshot: pending_cell_taken.png.
  • Observed: Pending stays {18,4}, the confirm bar stays visible, and #hint is null (ui.noGhost suppresses the hint for any cell holding a tower). Pressing Build gives the toast 'Something is already there' and clears pending (towers 2 -> 2, gold unchanged, so nothing is lost).
  • Expected: Clear the pending cell (or show the invalid hint) as soon as the partner's tower appears.
  • Suggested fix: In frame(), if app.pending and a tower now sits at that cell, set app.pending=null and updateConfirm().

coop-8 [LOW] After a board swap (new game on a different map) the 'Reset zoom' button stays visible although the camera was reset (not reachable from the normal UI)

Status: UNVERIFIED

  • Repro: node s10_newgame.js section e. B zoomed (wheel), then A calls NW.app.ctrl.newGame('twin') and then 'hub' through the API. (The UI's Play again always reuses the current map.)
  • Observed: Renderer board swapped correctly (rendMap, aspect, spawns 2 and 3, routeLen A/B/server equal: 56.21 / 34.24). But the zoom went 2.3 -> 1 while #btnFit stayed visible (updateFit is not called from adoptBoard). A same-map new game does not reset the camera or the particles at all (zoom stays 2.53).
  • Expected: Button state follows the actual zoom after setBoard.
  • Suggested fix: Call updateFit() at the end of adoptBoard().

Client code review (28 findings)

Coverage: COLD-START PREAMBLE (everything was killed at the end; I did not edit any repo file, scratch scripts live only in the scratchpad). RC=/tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/reviews/client-code . Steps: (1) source /tmp/claude-1000/-home-jav-git-towerdefence/417476cf-3c23-4caf-be25-6f9a83ee50b9/scratchpad/pwenv.sh ; (2) cd /home/jav/git/towerdefence && PORT=8230 HOST=127.0.0.1 node server/index.js & ; (3) only for the service-worker/audio-failure scripts s1_sw.js, s2_update.js, t16*_midfail.js: node $RC/proxy.js (port 8231, forwards to 8230; mode is switched at runtime via /__mode?m=ok|502|down|v2|trunc|slowcut); (4) only for t24_coop_win.js: node $RC/srv_win.js (port 8232, test-only wrapper that makes every room win at wave 1). Then node $RC/