Commit Graph
11 Commits
Author SHA1 Message Date
SirStone 52ab50d765 fix(client): tile loading: centre-out, one request per tile, 404 recovery (#86)
The GM survey view asked row-major, at most 8 at a time, rebuilt the whole
wanted window on every settle, and paid two requests for every failed tile
(image error, then a fetch to learn the status). A 404/5xx was stored as
permanent `denied`, so a tile imported after page load stayed black until a
page reload, and `viewport.setScene` swallowed a same-id art_version change
so the old textures were never dropped.

- TILE_CONCURRENCY 8 -> 32, the measured knee on a Full HD scene (min-of-3
  headless: GM fit + player 0.5, tile 32/64; 64 is inside the noise).
- orderTilesCentreOut: nearest the viewport centre first.
- Settle path is incremental (one settle = one tile sprite/flag update);
  the window is rebuilt only on camera/scene changes.
- fetch + createImageBitmap: status from the same response, decode off the
  main thread, so a failure costs one request.
- 403 stays permanent (retried only on fog.fresh); 404/5xx/network retry
  with 250/500 ms backoff up to 3 loads, and `hello`/reconnect or a
  scene/art_version change resets the budget. A failure that lands after a
  reconnect is a fresh first attempt; a failure that leaves the window does
  not spend the budget.
- setScene emits for a same-id scene; a new art_version drops the texture
  cache and reschedules. Tiles are `Cache-Control: private, max-age=1y,
  immutable` (still gated), so a reload reuses them; DESIGN 3.3/11.1 and
  client/README updated.

Tests: vitest for ordering, incremental invariants, retry budget/backoff,
reconnect epoch and art_version invalidation; e2e for a GM survey fill (one
request per succeeded tile) and a 404 tile recovering after the file appears
and a real reconnect. Before -> after (min-of-3, saturated host, Full HD):
GM fit 32px 910->843 ms, player 0.5 32px 972->862 ms, GM fit 64px
320->249 ms, player 0.5 64px 332->368 ms (noise).

Part of #63. Blocks #77.
2026-11-21 22:28:18 +01:00
SirStone 297718efdb test(e2e): count distinct tile URLs, tolerate transient image errors
The mobile map gate compared the cumulative request counter to the wanted
window, but the #70 rule re-asks a tile whose 403 became allowed when the
explored frame lands after the first window, so a correct load can be 481
attempts for a 480-tile window (seen once on a loaded host). Expose
data-tile-distinct and assert that no tile URL is fetched twice; the no-retry
proof stays the 403 test's per-URL count. The console collector now ignores the
browser's network-level resource line, like the fog suites: a transient tile
error is explicitly tolerated by the tile contract, and the page wait already
reflects it.
2026-11-21 22:09:42 +01:00
SirStone 9c05bb1f46 fix(client): make data-tiles ready when the pass completes
A transient tile load error is terminal for the current window (retried only on
a new window or a reconnect), but data-tiles treated it as never settled, so one
host hiccup left it at 'loading' forever and every e2e readiness wait hung
(audit.test.mjs timed out under a parallel lane). TileScheduler.isPending() now
reports loading only for queued/in-flight tiles; ready means the pass is done.
Proven by aborting one tile request: the wait timed out before, passes after.
Unit-tested at the scheduler seam.
2026-11-21 18:19:47 +01:00
SirStone 9c7f9de910 feat(m4): playtest friction: perf overlay, fresh import, token seed (#82)
Opt-in ?perf=1 overlay (fps, frame p50/p95, JS p50/p95, tokens, zoom; no node or ticker work when off). fff-vtt import creates and migrates a fresh/empty state dir through the shared server startup path; devbox run serve gains --image. devbox run seed creates deterministic labelled NPC tokens over the real WS (idempotent rerun, --replace), and the GM token form defaults X/Y to the viewport centre.
2026-11-21 17:20:05 +01:00
SirStone 91a51c706d feat(client): GM wall editor, round-1 fields (#73)
Draw, select, edit and delete walls through the GM panel: the four 5.8
presets, raw switches (preset XOR raw, open excluded from wall.update), a
private label, the one-way arrow + flip (sight_dir names the blind side),
the player-marker switch, door open/close through door.set, secret/locked
with the locked hint and one-click unlock, delete and single-step undo.
No thickness, height or position-flip control (ADR-0012).

The pure rules and payload builders live in src/wallEditor.ts; the GM wall
slice (src/slices/walls.ts) owns the server records, selection and undo;
the render module draws on the gm layer and defines the input precedence:
token drag (#72) > armed wall draw > camera pan (#69), with a click (no
movement) selecting the nearest wall.

Shared core edits: client/src/reducer.ts gains the wall-select and
wall-record-undo events (the only new core events); style.css and the
client README document the panel and rules. Unit tests cover the slice,
presets, derived kind, arrow side, snapping, payload XOR, door intent and
undo builders; the e2e draws every preset, edits the fields, flips the
one-way wall, opens/closes a door, deletes and undoes, proves a token drag
still wins over draw mode, and probes the player's fog pixels, with the
player WS leaking no wall data.

Ref #73
2026-11-21 11:26:45 +01:00
SirStone 2d9548c941 feat(client): fog explored bitmap, vision cut-out and player markers (#70)
The fog layer (DESIGN 7.1 layer 4, spec #63 decision 9) keeps the explored
grid in one cell-resolution RGBA canvas: never-seen cells opaque black,
explored cells black at 0.6 alpha. A second canvas is the sprite texture:
the explored canvas is copied into it and the union of the server's vision
polygons is cut out with `destination-out`. A full explored snapshot
repaints; a cell diff mutates only the new bytes and uploads the dirty
rectangle. Player markers from the marker set/del frames are sprites above
the fog; the GM layer hides the fog.

The cut-out is baked instead of using a Graphics stencil mask: on the e2e's
software renderer the stencil state cost ~350 ms of the phone-class viewport
fill budget (412x869 dpr 2.625), while baking keeps the fill at the pre-fog
baseline. The cut-out is rasterized at cell resolution, the same grid the
server sends.

Integration fix in the tile layer: a tile denied with 403 because it was
unexplored is asked once more when the fog says its cells became explored;
unexplored denials still never retry (the map 403 test is unchanged).

Proven at the reducer seam (fog slice) and by screenshot pixel probes in the
browser e2e: black/dim/visible, window see-through, one-way blind side,
secret door, marker anchor and retraction, a drag that moves the fog with no
reload, and a reconnect resync. Fog update cost recorded under the 412x869
dpr 2.625 / 4x CPU emulation.
2026-11-21 10:44:32 +01:00
SirStone d225e956ca test(client): drag through the camera transform after #69
Rebase #72 onto the map/pan-zoom lane. Drag e2e now converts world points to
page points with the camera transform, drags at zoom 0.5 and 4, and proves a
token drag leaves the camera alone while an empty-canvas gesture still pans.
The camera publishes its x/y in `data-camera` for that (UI fact, like zoom).
Also folds #69's duplicate viewport import in tiles.ts into one.
2026-11-21 09:51:44 +01:00
SirStone c7d5e2cc69 feat(client): drag with prediction and rollback (#72)
Drag a controlled token (GM: any token) at <=20 Hz plus a final send on release;
the sprite follows the pointer while authoritative frames are ignored for drawing.
Uniform move nacks roll back with a short tween (on release if still dragging),
rate-limited acks drop quietly, and pending reqIds die with the connection.

- slices/move.ts: pure drag/pending/ack state machine at the reducer seam
- render/modules/drag.ts: canvas pointer input, capture-phase so token drag wins
  over pan/pinch (#69); sends via the new intents bridge
- tokens renderer draws the optimistic/confirmed position and tweens the rollback
- intents.ts + ws.send onReqId: one reqId-keyed sender for render modules
- e2e: drag persists after reload, wall refusal tween, GM move mid-drag,
  reconnect mid-drag dropping the pending map
2026-11-21 09:41:03 +01:00
SirStone 4534ed6426 feat(client): map tiles, grid and pan/zoom (#69)
T6 of spec #63. Tiles are requested only for the viewport plus one tile of
margin, in viewport order, at most 8 at a time (TileScheduler); decoded
textures are cached by URL so a reconnect refetches nothing; a 403/404 is
remembered as denied and never retried. The browser image loader is the hot
path, with one status fetch only to classify an error.

Camera: drag to pan, wheel/pinch to zoom around the pointer/midpoint; players
clamp at 0.5 (ADR-0013) and the GM has no player floor; both stop at 4.0.
Grid is one TilingSprite toggled by #grid-toggle. Camera is local UI state,
not a reducer slice, so hello/reconnect does not move the view.

Tests: viewport/tile unit tests (clamps, margin window, 8-wide queue, denial,
cache) and client/e2e/map.test.mjs (mobile viewport fill gate (a), grid,
pinch, cache across reconnect, GM zoom, 403 no-retry) against the real
server through TLS/h2. Tile-size gate (a) documented in client/README.md.
2026-11-21 01:11:12 +01:00
SirStone 429f023c62 feat(client): tokens, BitmapText labels, statuses and lists (#71)
- slices/tokens.ts: token upsert, token_gone, hello reset; status names only.
- slices/characters.ts + slices/encountered.ts: own characters, encountered
  list with grey entries; the GM's per-player copies are ignored.
- render/tokenBoard.ts (pure): event -> entered/updated/left patches, so one
  changed token costs one container; seeds from the reducer on mount.
- render/modules/tokens.ts: pooled world-coordinate nodes on the tokens layer,
  one shared unit-circle context per kind, BitmapText from one pre-installed
  BitmapFont assigned only on a name change, stuck/squeezed badges, canvas
  dataset instrumentation for the "only changed entities" criterion.
- panels/lists.ts + render/modules/lists.ts: #lists under #panels, textContent
  only, greyed encountered rows; mounted by a render module so no shared
  bootstrap file changed.
2026-11-21 00:51:16 +01:00
SirStone 3c0258ea31 feat: client shell, sign-in and protocol client (#67)
New `client/` package (Vite + TypeScript + PixiJS v8, plain DOM overlay):
the pure reducer seam (no Pixi import), an append-only slice registry
build-time glob, the `proto` 2 WS client with envelope/ack/closing mapping,
the sign-in door (`POST /join`, one "Key not recognised." for wrong and
unknown), the DOM shell/HUD and a minimal Pixi stage created only after a
live `hello`. `hello` resets every slice so a reconnect cannot show stale
state; `proto-mismatch` shows reload; `revoked` returns to the sign-in page
and stops.

The browser e2e moves into the client package (`client/e2e/`, owning
playwright-core) and runs the real Vite build through the TLS/HTTP2 test
nginx: join -> canvas -> hello/roster for GM and player, no data before
join, identical wrong/unknown key refusal, proto mismatch, revoked.
`devbox run client-test` adds the Vitest seam; `devbox run e2e` builds the
client first. The #66 stub dist stays local to `tools/vhost.test.mjs`, so
`devbox run test` still needs no npm install.

Refs #67
2026-11-20 23:57:16 +01:00