feat: encounter UX, tracked effects, and character state improvements #10

Open
keen wants to merge 14 commits from fix/encounter-ux into main
pull from: fix/encounter-ux
Collaborator

Summary

Broad encounter-management upgrade covering roster workflow, initiative, 5e death state, tracked effects, and tablet-friendly controls.

Encounter UX

  • Group encounters into In Progress / Ready / Completed sections
  • Inline encounter rename
  • Configurable encounter popout and completed-section collapse
  • Campaign settings editor
  • Icon-only stateful caffeine controls
  • Bee-targeted Docker restart wrapper

Initiative and roster state

  • Persist initiative modifiers; reroll per participant or entire encounter
  • Carry roster Current HP, Max HP, AC, and stable state into new encounters
  • Add one-time character-sync choice to End Encounter modal
  • Add independent Hide Disabled / Hide Dead encounter controls
  • Add confirmed Kill, Heal Full, and existing Revive paths

5e death saves and recovery

  • Show death-save state on player display
  • Roll and persist 1d4 stable recovery hours
  • Carry stable state through undo/redo, roster writeback, and future encounters
  • Correct end-combat reset messaging

Tracked effects

  • Generic round-based effects engine with logs and undo/redo
  • Turned and Spiritual Weapon 5e presets inside Conditions panel
  • Custom participant/encounter effects with owner, notes, duration, and player visibility
  • Round countdown and automatic damage expiry
  • Compact/prominent/hidden player display modes
  • Owner-linked effects shown directly on owner card
  • Editable owner and turns remaining

Tooling/docs

  • Encounter-builder spec vetting and PC hard rules
  • Updated TODO backlog

Verification

  • App: 169 tests passed
  • Shared: 244 tests passed
  • Server: 40 tests passed
  • Total: 453 tests passed
  • Production build compiled successfully
## Summary Broad encounter-management upgrade covering roster workflow, initiative, 5e death state, tracked effects, and tablet-friendly controls. ### Encounter UX - Group encounters into In Progress / Ready / Completed sections - Inline encounter rename - Configurable encounter popout and completed-section collapse - Campaign settings editor - Icon-only stateful caffeine controls - Bee-targeted Docker restart wrapper ### Initiative and roster state - Persist initiative modifiers; reroll per participant or entire encounter - Carry roster Current HP, Max HP, AC, and stable state into new encounters - Add one-time character-sync choice to End Encounter modal - Add independent Hide Disabled / Hide Dead encounter controls - Add confirmed Kill, Heal Full, and existing Revive paths ### 5e death saves and recovery - Show death-save state on player display - Roll and persist 1d4 stable recovery hours - Carry stable state through undo/redo, roster writeback, and future encounters - Correct end-combat reset messaging ### Tracked effects - Generic round-based effects engine with logs and undo/redo - Turned and Spiritual Weapon 5e presets inside Conditions panel - Custom participant/encounter effects with owner, notes, duration, and player visibility - Round countdown and automatic damage expiry - Compact/prominent/hidden player display modes - Owner-linked effects shown directly on owner card - Editable owner and turns remaining ### Tooling/docs - Encounter-builder spec vetting and PC hard rules - Updated TODO backlog ## Verification - App: 169 tests passed - Shared: 244 tests passed - Server: 40 tests passed - Total: 453 tests passed - Production build compiled successfully
keen added 14 commits 2026-11-18 11:16:07 -05:00
Completed encounters collapse behind a toggle so reusable ended
encounters stay reachable without cluttering the active list. Group
headers show counts. Cards keep drag-reorder, player-display toggle,
live badge, and delete controls.
Pencil button on each encounter card opens an inline input prefilled
with the current name. Enter or the save button commits via updateDoc;
Escape or the cancel button discards. Empty/whitespace names are
ignored. Covers save, cancel, and empty-name cases in tests.
Open selected encounters in a focused full-page panel by default, with a Back control and scroll lock. Add per-device switches in the Encounters header to disable open-on-top or completed-group collapsing. Cover selection, return-to-list, display updates, and preference persistence.
Add an Edit action to campaign cards with a prefilled form for name, player-display background URL, and default ruleset. Update only those campaign fields, preserving roster and existing encounter rulesets. Cover save, clearing values, cancel, and invalid name.
Replace moon/coffee action-label toggle with coffee icon plus slash overlay. ON shows amber; OFF shows a slash with no color. Accessible name (Caffeine ON/OFF) and aria-pressed carry state. Applied to admin header, encounter header, and both player display states.
Add a dice button beside the Initiative field in the participant edit modal that rolls d20 + Init Mod; Cancel/Save guard accidental changes. Persist initMod on participant creation (quick-add monster, roster character/NPC, Add All) and expose it as an editable field in the modal. Roster NPCs added via the character dropdown now enter as npc type, and the duplicate guard keys on originalCharacterId regardless of type.
- Player display: death-save pips for dying participants (3 successes / 3 failures), stable shows note without pips
- stableRegainHours: 1d4 hours rolled on natural stabilization (3rd save success, manual stabilize, revive-to-stable); cleared on heal, damage-while-stable, inline HP edit, and death; undo/redo round-trips through all paths
- Roster writeback: end-of-encounter sync writes stable hours to characters (stable -> hours, conscious -> null); character card badge shows hours; stable state carried into new encounters via buildCharacterParticipant; editor Cur HP > 0 clears
- End-combat message corrected: states turn position and round reset while initiative values are kept
- Reroll All Initiative: d20 + initMod for every participant in a single write, undoable, pre-combat or paused only; confirmation modal in UI, hidden during active combat
- Add All (Roll Init) hoisted to Add Participants header row so it stays visible when the section is collapsed; header title remains the collapse toggle
- use shared character participant builder for single-add and Add All so saved current HP, Max HP, AC, and stable state carry forward
- add End Encounter checkbox to override character writeback for one action
- default transient checkbox from campaign preference without persisting changes
- support explicit writeback override in shared endEncounter logic
- cover both add paths and modal enable/disable/reset behavior
- add generic encounter effects with round countdown, damage expiry, logs, and undo/redo
- add 5e Turned and Spiritual Weapon presets inside existing Conditions panel
- support custom participant or encounter effects with owner, notes, duration, and player visibility
- convert 5e minute durations to rounds while keeping generic rules round-only
- show prominent or compact effects on player and DM participant cards
- attach owner-linked encounter effects to owner card with global fallback for ownerless effects
- add direct turns-left editing plus step controls
Default effect ownership to active participant, allow inline reassignment or clearing, move owner-linked effects between participant cards, and add direct turns-left editing coverage.
- persist independent Hide Disabled and Hide Dead encounter controls
- keep dead PCs exempt from Hide Dead while allowing Hide Disabled to hide any inactive participant
- add confirmed Kill action that sets zero HP, dead, and inactive without deleting
- add undoable Heal Full action above Revive
- fix random initiative reroll test flake
Spec files are ephemeral (/tmp fine); the server DB is the durable
record — encounter docs carry hpFormula/ac/init, so past builds can be
reconstructed by querying live data, not from kept files.

Vetting before any write (vetSpec):
- monster/npc with neither maxHp nor hpFormula = hard reject (exit 3);
  silent 10 HP defaults caused real damage. --allow-defaults escape
  hatch warns loudly.
- character type in build spec = hard reject. PCs are added only from
  campaign roster verbatim; tooling never invents or edits PC stats.
- missing ac or initMod/initiative = warning, build continues.
- duplicate participant names in one encounter = warning.

Flag parsing: --flags split from args, usage updated.
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/encounter-ux:fix/encounter-ux
git checkout fix/encounter-ux
Sign in to join this conversation.