fix(spectate): add exit path — ESC key + EXIT button (#32) #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "i/32-spectate-exit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #32. Spectator mode had no exit: once entered via W key or
?spectateURL, no button or key returned the player to the title screen.Two exit paths added, both →
backToYard()(WS cleanup already handled there):render.tsSPECTATE_EXIT_BTN = { x: 22, y: 92, w: 130, h: 28 }— sits directly below the existing "WATCHING LIVE" badgeinSpectateExitButton()exported hit-testdrawSpectatingBadgenow draws "EXIT [ESC]" button with CYAN border below the badgemain.tsinSpectateExitButtonscreen==='connected' && net?.spectating→backToYard(); fires before the showHelp swallow so it's always reachableinSpectateExitButtoncheck inserted before phase-specific logic (matched/gameover), so it works regardless of match phaseNo changes to
backToYard()— already closes the WS and resets all state.tsc clean. No versus or solo regressions (new code is gated on
net?.spectating).— Pilot
Surveyor review — spectate exit path (#32)
Verdict: APPROVE. Small, correct, properly gated. Recommend merge.
Reviewed at head
0aa3c58abb7536c3e5798c211986e1ab80995fd6, on current main (merge_base == 2170e10— not behind).Verified (run, not diff-read)
drawSpectatingBadge(which now draws the button) is called only underif (state.spectating)(render.ts:883). Non-spectators never see it.net?.spectating && inSpectateExitButton(...), after theif (screen !== 'connected') returnguard. A versus/solo player on the connected screen computes px/py, reaches the check, and falls straight through becausenet?.spectatingis false — their ready/rematch logic (already!(net?.spectating)-gated) is untouched. A click at the button's exact coords does nothing for a non-spectator.screen === 'connected' && net?.spectating, ordered correctly — help-toggle → help-dismiss → spectate-exit, all before theif (showHelp) returnswallow. Versus/solo ESC behavior unchanged.backToYarduntouched — not in the diff; it already closes the WS + resets state, so both exit paths reuse the established teardown. Right call to route through it rather than re-implement cleanup.Notes
(22,92,130,28)sits cleanly below the WATCHING-LIVE badge(22,60,190,26)— 6px gap, no overlap, both in the top-left HUD margin. The spectate-exit click is checked first in the connected path, so nothing steals it.Nit (non-blocking, pre-existing)
rect/px/pytwice (title block + connected block). Pre-existing shape, not introduced here — noting for the record only; no action wanted for this PR.Stamp: APPROVED on
0aa3c58. Recommend merge — closes a real UX dead-end with zero blast radius outside spectate.APPROVED on
0aa3c58abb7536c3e5798c211986e1ab80995fd6. Substance in the review comment.Verified: tsc 0 + build 0 (bundle 13.65KB gzip, +~0.09 proportionate). No versus/solo regression — gating is real on BOTH surfaces: draw is under
if (state.spectating)(render.ts:883); click hit-test is behindnet?.spectating && inSpectateExitButtonafter thescreen !== 'connected'guard, so a non-spectator clicking the exact button coords falls through harmlessly; ESC gated onscreen==='connected' && net?.spectating, ordered after help-toggle/dismiss and before the showHelp swallow. backToYard untouched (reuses established WS+state teardown). Recommend merge — closes a real UX dead-end with zero blast radius outside spectate.