feat(viewer): wire 5 OpenWorlds screens to live engine data + GM-Advisory (playable app) - #161
Conversation
…GM-Advisory (the playable app) OpenWorlds had 4 screens on live engine data (table/combat/atlas/launcher) and 5 rendering hardcoded prototype data. Wires those 5 to the engine snapshot the app already carries — turning it from 4-live+5-mockups into a fully-PLAYABLE session. All in the viewer lane (zero collision with the macOS Swift shell). New viewer/server.py surfaces (projection fn + do_GET branch via a shared _serve_simple_surface helper mirroring the atlas dispatch; resolve-latest-snapshot like the wired surfaces; graceful empty): - /journal-surface: quests (status/objectives/entries) + quest_hooks (rumors) + the Campaign Director top-3 debts (real scene_debt.detect/director.compute off the snapshot; snapshot-only heuristic fallback). Wired screen-journal.jsx. - /character-surface: full 5e sheets (classes, AC, saves, skills w/ expertise, spells, class_resources, conditions, death_saves). Wired screen-character.jsx. - /inventory-surface: per-PC inventory + equipped + currency. Wired screen-inventory.jsx. - /relations-surface: factions (reputation bar) + companion dossiers (approval/banter/ relationships) + companion_arcs + met NPCs. Wired screen-relations.jsx. - /parley-surface: lead-PC parley slots (skill+modifier+suggested_dc, alignment, free_form) mirroring generate_parley_options' math snapshot-only. Wired screen-dialogue.jsx (closes #141's UI). Old tree kept as a demo fallback. - GM-Advisory widget on screen-table.jsx surfaces the top Director debt in play (#72). Additive: data.js + the 4 wired screens untouched; each screen falls back to demo until its first live fetch. 51 viewer tests pass (41 + 10 new; a CON-save ability-name bug was caught + fixed by a test).
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
Cache: Disabled due to Reviews > Disable Cache setting 📝 WalkthroughWalkthroughThis PR introduces five server-side read-model "surface" endpoints that project snapshot campaign state into browser-safe JSON shapes for OpenWorlds screens. Client screens now poll these surfaces every 5 seconds with visibility-aware pausing. The parley screen renders a new interactive menu with skill/free-form moves; journal and table screens display a director advisory panel surfacing structural campaign debts; relations screen renders dynamic faction/NPC lists with companion dossiers. ChangesOpenWorlds live read-model surfaces
Sequence Diagram(s)sequenceDiagram
participant User
participant Screen as Screen Component
participant Surface as /X-surface endpoint
participant Snapshot as Campaign Snapshot
rect rgba(100, 150, 200, 0.5)
Note over Screen,Snapshot: Initial load & visibility-aware poll
Screen->>Surface: GET /X-surface?campaign=...
Surface->>Snapshot: Read campaign state
Snapshot-->>Surface: Projection
Surface-->>Screen: {surface, advisory, ...}
Screen->>Screen: Update local state
end
rect rgba(150, 100, 200, 0.5)
Note over User,Screen: 5-second polling with visibility
rect rgba(200, 200, 100, 0.5)
Note over Screen: Tab hidden: stop polling
end
rect rgba(200, 200, 100, 0.5)
Note over Screen: Tab visible: resume polling
Screen->>Surface: Poll request
Surface-->>Screen: Updated surface
end
end
rect rgba(200, 100, 150, 0.5)
Note over User,Screen: User interaction (parley example)
User->>Screen: Choose skill / free-form move
Screen->>Surface: POST /move {check, campaign}
Surface-->>Screen: {outcome}
Screen->>Screen: Update history, show toast
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Complexity drivers: Multiple new server-side projection functions with dense logic (character sheets, inventory stash inference, parley DC computation), five similar but distinct client polling patterns requiring careful review of visibility handling and error swallowing, new interactive parley menu with move submission, and comprehensive test suite validating all surfaces and advisory paths. Substantial cross-file coordination (server projections ↔ client polling ↔ UI rendering) with no significant refactoring of existing code, making each change independently verifiable but collectively heterogeneous. Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
Turns OpenWorlds from 4-live-screens + 5-mockups into a fully-playable session — wiring journal, character, inventory, relations, and parley to live engine read-models (mirroring the 4 already-wired surfaces). Entirely the viewer lane; zero collision with the macOS Swift shell.
New viewer/server.py surfaces (+ wired screens)
Tests / safety
Closes the journal/character/inventory/relations/parley wiring; surfaces the Director (#72) in-play; closes #141's UI.
Summary by CodeRabbit
New Features
Tests