Frontend/backend migration → TS · PixiJS · React · Zustand: remaining work (retire app.js, Postgres, art pass) #44

Open
opened 2026-06-14 21:16:55 -07:00 by tank-operator-host[bot] · 0 comments
tank-operator-host[bot] commented 2026-06-14 21:16:55 -07:00 (Migrated from github.com)

Handoff for the architecture migration. Phases 0–4 + a React main-menu are done and live-validated on draft PR #42 (branch tank/session/930/chess-tactics). This issue tracks what's left, with enough context for a fresh session to drive it.

Architecture (decided — see PR #42 history for the rationale)

  • Core — pure, deterministic, serializable TypeScript rules engine; no DOM/canvas. The part that must outlive any renderer. (frontend/src/core/)
  • Render — PixiJS v8, isometric board. (frontend/src/render/)
  • UI — React 19. (frontend/src/ui/)
  • State — Zustand stores driving the pure core: intents in, new state out. (frontend/src/game, /editor, /campaign)
  • Data — custom typed JSON level/campaign schema (Tiled/LDtk rejected: neither supports isometric + elevation + gameplay zones). (frontend/src/core/level.ts)
  • Persistence — document store; file-backed today, designed to swap to Postgres (relational metadata + JSONB body). (backend/server.js)
  • Native-web (no Godot/Unity export). Strangler-fig: legacy app.js still runs untouched; new surfaces are React islands mounted by app.js's router.

Done (live on PR #42)

Routes: /menu-next (React hub) → /play (skirmish: Pixi board + React HUD on the core), /edit (level editor: paint terrain/elevation/units, undo/redo, Save/Publish/Load), /campaigns-next (campaign editor: CRUD + Save). / = original game, untouched.
Gate: 44 vitest tests, tsc --noEmit clean, Vite build code-splits each surface, Docker image CI-green, zero console errors on every surface.


Remaining

1. Retire app.js (biggest, highest-risk — do incrementally)

  • React app entry + router to replace app.js's string-HTML router.
  • Port remaining screens to React: main menu as the real /, lobbies, settings, the design catalog/glossary/widgets surfaces.
  • Delete the legacy game + old level/campaign editors in app.js (superseded by /play, /edit, /campaigns-next); finally remove app.js.
  • Keep the game playable throughout; delete each old path as its replacement lands.

2. Postgres persistence (currently file-backed under /var/run)

  • Provision Postgres in-cluster; wire a connection secret/env via k8s/ + ArgoCD.
  • Add pg to backend; schema = relational tables (users, level metadata, campaigns, level refs, ratings, lobbies) + a jsonb body column for the level/campaign documents.
  • Swap the store seams in backend/server.js (readLevelStore/writeLevelStore, readCampaignWorkspace/writeCampaignWorkspace) from fs to the DB. Same documents — no API/client change.

3. Persistence hardening

  • Auth + per-user scoping on /api/levels and /api/campaign-workspace writes (currently unauthed; mirror the existing /api/campaigns auth).
  • Level picker (list + load) in the editors (client already has listLevels).
  • Decide: unify the new campaign editor with the existing /api/campaigns (old level format) or migrate that format to the new schema.

4. Game depth toward the concepts

Concepts (docs/art/ui-screen-concepts/, docs/ui-art-direction.md) call for Into-the-Breach-style tactics: HP, action points, economy (CP/funds/income), telegraphed enemy queued attacks shown a turn ahead (the signature mechanic), terrain effects (elevation/water/cliffs on movement), per-objective win conditions. The current core is chess-movement + capture + last-side-standing.

  • Extend the pure deterministic core toward this (queued enemy intents + forecast API, HP/AP, terrain, objectives), unit-tested. (The deterministic core already exists to support exactly this — telegraphs == "forecast the queued action".)

5. Art pass (chess-tactics style)

  • Produce/normalize isometric tile + piece + prop sprite sheets (extend the frontend/scripts/normalize-*.mjs pipeline; nearest-neighbor, integer scaling, texture atlases, devicePixelContentBox for crispness).
  • Render them on the Pixi board (replace the placeholder colored diamonds/tokens in SkirmishBoard/EditorBoard).
  • Tune the --ds-* design tokens to the art.

How to work (operational notes)

  • Git: branch tank/session/930/chess-tactics, draft PR #42. restricted_git — commits auto-publish to the PR; no direct push to main; git merge origin/main when main advances (it recently picked up the BGM feature; resolved in e444ab5).
  • Frontend: npm --prefix frontend run check (node --check + bgm checks + vitest + tsc) and ... run build (Vite). Tests = vitest.
  • Backend: Express backend/server.js; file stores at /var/run/chess-tactics-*.json.
  • Live validation: check out a Glimmung test slot, then connect playwright-core directly to the slot's Playwright server (ws://slot-playwright.<slot>.svc.cluster.local:3000) to click/drive/screenshot — the inspect-only tool can't click. Hot-swap: frontend kubectl cp frontend/dist/. <pod>:/var/run/chess-tactics-static-override; backend kubectl cp backend/server.js <pod>:/var/run/chess-tactics-hot/server.js then kill -HUP 1. Slots churn ~30–40 min; extend the lease.
  • CI: docker-build-check.yaml auto-trigger has been flaky on rapid commits — dispatch it manually (workflow_dispatch, git_ref input) to validate the image build.

Key files

  • Core: frontend/src/core/{types,rng,rules,level,index}.ts (+ *.test.ts)
  • Game/store: frontend/src/game/{setup,store}.ts
  • Render: frontend/src/render/{iso,SkirmishBoard,EditorBoard}.{ts,tsx}
  • Editors: frontend/src/editor/store.ts, frontend/src/campaign/store.ts
  • React UI: frontend/src/ui/* (Skirmish, LevelEditor, CampaignEditor, MainMenu + *Mount.tsx)
  • Net clients: frontend/src/net/{levels,campaignWorkspace}.ts
  • Backend persistence: backend/server.js (/api/levels, /api/campaign-workspace)
  • Legacy router/island wiring (to retire): frontend/src/app.js

Recommended order: 1 (retire app.js) and 2 (Postgres) unblock the cleanest end-state; 4/5 (game depth + art) are the product-facing payoff and are now low-friction on this stack.

Handoff for the architecture migration. **Phases 0–4 + a React main-menu are done and live-validated** on draft **PR #42** (branch `tank/session/930/chess-tactics`). This issue tracks what's left, with enough context for a fresh session to drive it. ## Architecture (decided — see PR #42 history for the rationale) - **Core** — pure, deterministic, serializable TypeScript rules engine; no DOM/canvas. The part that must outlive any renderer. (`frontend/src/core/`) - **Render** — PixiJS v8, isometric board. (`frontend/src/render/`) - **UI** — React 19. (`frontend/src/ui/`) - **State** — Zustand stores driving the pure core: *intents in, new state out*. (`frontend/src/game`, `/editor`, `/campaign`) - **Data** — custom typed JSON level/campaign schema (Tiled/LDtk rejected: neither supports isometric + elevation + gameplay zones). (`frontend/src/core/level.ts`) - **Persistence** — document store; **file-backed today**, designed to swap to **Postgres (relational metadata + JSONB `body`)**. (`backend/server.js`) - Native-web (no Godot/Unity export). **Strangler-fig**: legacy `app.js` still runs untouched; new surfaces are React islands mounted by `app.js`'s router. ## Done (live on PR #42) Routes: **`/menu-next`** (React hub) → **`/play`** (skirmish: Pixi board + React HUD on the core), **`/edit`** (level editor: paint terrain/elevation/units, undo/redo, Save/Publish/Load), **`/campaigns-next`** (campaign editor: CRUD + Save). **`/`** = original game, untouched. Gate: 44 vitest tests, `tsc --noEmit` clean, Vite build code-splits each surface, Docker image CI-green, zero console errors on every surface. --- ## Remaining ### 1. Retire `app.js` (biggest, highest-risk — do incrementally) - [ ] React app entry + router to replace `app.js`'s string-HTML router. - [ ] Port remaining screens to React: main menu as the real `/`, lobbies, settings, the design catalog/glossary/widgets surfaces. - [ ] Delete the legacy game + old level/campaign editors in `app.js` (superseded by `/play`, `/edit`, `/campaigns-next`); finally remove `app.js`. - Keep the game playable throughout; delete each old path as its replacement lands. ### 2. Postgres persistence (currently file-backed under `/var/run`) - [ ] Provision Postgres in-cluster; wire a connection secret/env via `k8s/` + ArgoCD. - [ ] Add `pg` to `backend`; schema = relational tables (users, level metadata, campaigns, level refs, ratings, lobbies) + a `jsonb` `body` column for the level/campaign documents. - [ ] Swap the store seams in `backend/server.js` (`readLevelStore`/`writeLevelStore`, `readCampaignWorkspace`/`writeCampaignWorkspace`) from `fs` to the DB. **Same documents — no API/client change.** ### 3. Persistence hardening - [ ] Auth + per-user scoping on `/api/levels` and `/api/campaign-workspace` writes (currently unauthed; mirror the existing `/api/campaigns` auth). - [ ] Level picker (list + load) in the editors (client already has `listLevels`). - [ ] Decide: unify the new campaign editor with the existing `/api/campaigns` (old level format) or migrate that format to the new schema. ### 4. Game depth toward the concepts Concepts (`docs/art/ui-screen-concepts/`, `docs/ui-art-direction.md`) call for Into-the-Breach-style tactics: HP, action points, economy (CP/funds/income), **telegraphed enemy queued attacks shown a turn ahead** (the signature mechanic), terrain effects (elevation/water/cliffs on movement), per-objective win conditions. The current core is chess-movement + capture + last-side-standing. - [ ] Extend the **pure deterministic core** toward this (queued enemy intents + forecast API, HP/AP, terrain, objectives), unit-tested. (The deterministic core already exists to support exactly this — telegraphs == "forecast the queued action".) ### 5. Art pass (chess-tactics style) - [ ] Produce/normalize isometric **tile + piece + prop sprite sheets** (extend the `frontend/scripts/normalize-*.mjs` pipeline; nearest-neighbor, integer scaling, texture atlases, `devicePixelContentBox` for crispness). - [ ] Render them on the Pixi board (replace the placeholder colored diamonds/tokens in `SkirmishBoard`/`EditorBoard`). - [ ] Tune the `--ds-*` design tokens to the art. --- ## How to work (operational notes) - **Git**: branch `tank/session/930/chess-tactics`, draft **PR #42**. `restricted_git` — commits auto-publish to the PR; **no direct push to `main`**; `git merge origin/main` when main advances (it recently picked up the BGM feature; resolved in `e444ab5`). - **Frontend**: `npm --prefix frontend run check` (node --check + bgm checks + vitest + tsc) and `... run build` (Vite). Tests = vitest. - **Backend**: Express `backend/server.js`; file stores at `/var/run/chess-tactics-*.json`. - **Live validation**: check out a Glimmung test slot, then connect `playwright-core` directly to the slot's Playwright server (`ws://slot-playwright.<slot>.svc.cluster.local:3000`) to click/drive/screenshot — the inspect-only tool can't click. Hot-swap: frontend `kubectl cp frontend/dist/. <pod>:/var/run/chess-tactics-static-override`; backend `kubectl cp backend/server.js <pod>:/var/run/chess-tactics-hot/server.js` then `kill -HUP 1`. Slots churn ~30–40 min; extend the lease. - **CI**: `docker-build-check.yaml` auto-trigger has been flaky on rapid commits — dispatch it manually (workflow_dispatch, `git_ref` input) to validate the image build. ## Key files - Core: `frontend/src/core/{types,rng,rules,level,index}.ts` (+ `*.test.ts`) - Game/store: `frontend/src/game/{setup,store}.ts` - Render: `frontend/src/render/{iso,SkirmishBoard,EditorBoard}.{ts,tsx}` - Editors: `frontend/src/editor/store.ts`, `frontend/src/campaign/store.ts` - React UI: `frontend/src/ui/*` (`Skirmish`, `LevelEditor`, `CampaignEditor`, `MainMenu` + `*Mount.tsx`) - Net clients: `frontend/src/net/{levels,campaignWorkspace}.ts` - Backend persistence: `backend/server.js` (`/api/levels`, `/api/campaign-workspace`) - Legacy router/island wiring (to retire): `frontend/src/app.js` Recommended order: **1 (retire app.js)** and **2 (Postgres)** unblock the cleanest end-state; **4/5** (game depth + art) are the product-facing payoff and are now low-friction on this stack.
Sign in to join this conversation.
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
romaine-life/chess-tactics#44
No description provided.