1
0
Fork 0
Commit graph

42 commits

Author SHA1 Message Date
538b7d4c4c feat(npc-dialogue): reorder choices in the dialogue editor
Choice rows in the dialogue node editor now have up/down buttons so a
choice can be moved up or down into the desired order, which is the
order shown to the player. The swap lives in a pure reorderChoice
helper (no-op at the edges, input not mutated) with a focused test.
2026-10-07 14:01:00 -04:00
9f0f7db612 feat(npc-dialogue): auto-grow the dialogue line box to fit its content
The Line textarea in the dialogue node editor grows to fit its content
up to a 200px default max, so long lines no longer scroll in a
fixed-height box. It stays drag-resizable (resize-y) and the user can
still expand it past the max.

The auto-grow hooks run above the early-return guard so their call
order never changes, fixing a Rules of Hooks violation the change would
otherwise introduce.
2026-10-07 14:00:15 -04:00
f643028638 feat(npc-dialogue): let event flag effects target self, global, or a specific user
Event node flag effects previously always wrote the active participant's
flag. A flag's identity is (owner, key), so the same key can hold
independent values for different owners, but there was no way to target
them from the editor.

- Add flagTarget ("self" | "global" | "user") + flagTargetUserId to
  NpcDialogueEffect. "self" (default) keeps current behavior.
- Add resolveFlagOwner (flags.ts) to map a scope onto the player-flags
  user column; "user" with no id falls back to the participant so a
  misconfigured effect never nudges the global flag.
- Move applyFlagEffect into flags.ts, parameterized by resolved owner;
  the runtime action resolves the owner and delegates.
- Add a Target control (+ user picker) to the event node editor and
  validateGraph enforcement for the "user" scope.
- Integration tests cover owner resolution and self/global/user writes.
2026-10-07 13:33:52 -04:00
f595828c99 feat(npc-dialogue): stacked markup, link popups, new badges, locked choices, timed flags
- DialogueText rewritten as a recursive parser so markup accumulates
  ({green}**bold green**{/} and friends nest freely, colors close inner-first)
- [label](url) dialogue links open in an iframe popup dialog so
  conversation progress survives; only http(s)/relative urls render
- NEW badges: Converse button + choice buttons badge unread paths via a
  per-browser seen map (ptf:npc-dialogue-seen) keyed by flow hash, so GM
  edits re-flag the conversation
- choices gain lockedHint: failing conditions can show the choice disabled
  with a rich tooltip instead of hiding it (evaluateNpcDialogueChoices now
  returns ChoiceGate pass/showLocked pairs)
- player flags gain activatesAt/expiresAt time windows honored by readFlag,
  flag effects gain flagDelayMinutes for slow-burn writes, and
  {{countdown:key}} tokens tick live toward activation (done/missing states)
- migration 20261006_add_flag_time_windows; spec extended to 33 tests
2026-10-06 17:06:27 -04:00
59fe616024 feat(npc-dialogue): rich hover tooltips on player choices 2026-10-06 16:21:53 -04:00
f20f57de66 feat(npc-dialogue): interpolate flag values into conversation text 2026-10-06 16:09:10 -04:00
efab41ba29 refactor(flow): share the edge shape builder between both flow canvases
Extract the dialogue canvas's routing upgrades into routeEdge() in the
shared lib: perpendicular handle stubs, candidate scoring (Z-step vs
straight for forward edges, top/bottom bus corridors for back edges),
per-edge detour lane spreading, and multi-pass obstacle clearing. The
NPC dialogue RoutedFlowEdge becomes a thin renderer over it, and the
tech tree RoutedEdge now inherits the same logic while keeping its own
features intact: manual waypoints route verbatim (and define the
add-a-bend base), per-source stepPosition lanes feed the Z-step, and
its fixed right/left handles map to the new direction params.

New pure spec covers the Z-step shape, blocked-forward detouring,
back-edge bus routing, per-id lane spread, and waypoint pass-through.
2026-10-06 14:47:14 -04:00
28bb08f43e fix(npc-dialogue): bus-route return edges and spread detour lanes
Two routing defects on the dialogue canvas:

- Return edges entering the same handle detoured through identical
  corners, stacking into one thick bundle on the left of the target.
  Each edge now derives a stable lane offset from its id, so parallel
  detours run in visibly separate lanes.
- Long leftward runs relied on greedy corner-hopping alone, which could
  still leave a segment cutting under a card. Back edges now try
  structured bus routes (corridor above or below every card, then swing
  in to the entry handle) and score candidates by residual crossings,
  picking the first clean shape. The router also re-runs until clean
  (bounded to three passes) instead of trusting one greedy pass.

Verified on doc #2: all seven edges route with zero card crossings and
no stacked lanes; tech-tree edge-routing specs still pass.
2026-10-06 14:38:42 -04:00
3c70fa70d8 fix(npc-dialogue): persist node drags into the flow field value
Dragging a card updated the canvas but never wrote to the Payload
field, so document Save persisted stale positions. Wrap onNodesChange
and serialize once a drag settles (the final position change with
dragging === false), keeping the write off the mousemove hot path.
Selection and in-progress-drag flags are stripped before serializing
so clicking a card never marks the document dirty.
2026-10-06 14:28:18 -04:00
46f1abd4da feat(npc-dialogue): selection ring, draft-cancel removal, snap-to-grid toggle
- Selected node cards gain a gentle cyan ring so selection state is
  obvious without fighting the per-type border colors.
- A node created via double-click/toolbar/pane menu opens straight into
  its dialog; closing that dialog with Cancel (or Escape/backdrop/X)
  now discards the empty draft instead of persisting it. Saving clears
  the draft marker, so cancelling a later edit never deletes anything.
- New Snap toggle in the editor toolbar enables React Flow grid
  snapping (20px, matching the background dots); the preference is
  remembered per browser like the tech tree's.
2026-10-06 14:20:21 -04:00
5a9bd0052b feat(npc-dialogue): route flow edges around node cards
Crossing Bezier connectors made return edges (a choice looping back to
an earlier line) impossible to trace on the dialogue canvas. Extract
the tech tree's obstacle-avoidance router into a shared pure lib
(src/lib/flow-edge-routing.ts, plus rounded path building and a new
polylineMidpoint for label placement), leave re-export shims where the
tech tree imported it, and render dialogue edges through a new
RoutedFlowEdge type: perpendicular stubs at each handle, an orthogonal
base for forward edges, full-card detouring for back edges, arrowheads,
and condition labels as chips at the path midpoint.
2026-10-06 14:13:13 -04:00
1f7729c509 feat(npc-dialogue): select nodes on click, edit on double-click
- Single click now only selects a node; the edit dialog opens on
  double-click so the Del-to-delete flow is never interrupted by a modal
- Guard the canvas double-click handler so double-clicking a node can
  never also spawn a new dialogue node behind the dialog
- Update the editor hint text to describe the new click model
2026-10-06 13:56:46 -04:00
089246def8 feat(npc-dialogue): flow editor UX pass for authoring dialogue flows
- Delete selected nodes with Del/Backspace (guarded against open dialogs,
  menus, and focused form fields)
- Double-click the canvas to drop a dialogue node at the cursor; right-click
  empty canvas for a New node menu with all six types; toolbar buttons now
  place nodes at the viewport center instead of blind grid coordinates
- Choices support optional flag conditions evaluated server-side per player
  (player flag first, global fallback); gated choices stay hidden until the
  server confirms them, so forbidden options never flash on screen
- Litegraph-style per-output handles: one source handle per choice row plus
  dedicated true/false handles on condition nodes, wired through derived
  edges and handle-aware connections
- Brighten passive edge lines and edge labels on the dark canvas
- New dialogue nodes default to an empty speaker, rendering the NPC's name
2026-10-06 13:44:01 -04:00
0cadd1e062 feat(npc-dialogue): taller flow canvas plus expand-to-screen toggle
Raise the default editor height from h-96 to 60vh (min 28rem) and add an
Expand/Shrink toolbar toggle that floats the whole editor over the document
form, filling the viewport right of the admin sidebar via the shell's
--nav-width/--app-header-height vars. Esc collapses it unless the node
dialog or context menu is open.
2026-10-06 12:43:02 -04:00
035dd49149 feat(npc-dialogue): add global flag support (nullable user on player-flags) 2026-10-06 11:58:54 -04:00
ac6415d034 feat(npc): complete dialogue feature and fix migration snapshot base
Finish the NPC dialogue flowchart work carried over from the base commit:
- Coloured NPC dialogue text via friendly names ({red}) or hex ({#ff00ff});
  invalid names/hex render as literal text. Shared client-safe renderer
  (DialogueText.tsx) used by both the admin canvas preview and the runtime.
- Player-flags feature: condition nodes branch on flags (evaluated
  server-side), flag effects set/clear/adjust flags, PlayerFlags collection
  + migration, and event nodes can set flags.
- One-time ("once") choices: a choice flagged "Hide after picked" is hidden
  for the rest of the current conversation only (per-session, resets on
  begin()); GMs can persist across conversations with a condition flag.
- Admin editor: colour hint, once checkbox on choices, amber "once" badge.

Migration repair: the player_flags migration (20261005_185014) was sorting
before 20261006_000000, whose stale snapshot omitted player_flags, so any
future `migrate:create` re-emitted player_flags DDL. Restored 20261006_000000's
snapshot to the full current schema so it is the correct diff base.

Verified: `bun run payload migrate` clean, `migrate:create` reports no
schema changes, `tsc --noEmit` clean.
2026-10-05 16:02:53 -04:00
2a3ad57bce feat(npc): add weighted activity, level, and dialogue conversations
- GameNpcs: Narrative Activity group (weighted options, forced flag,
  configurable reshuffle interval), level + richText levelDescription,
  canMessage toggle
- New npc-dialogues collection with a purpose-built React Flow dialogue
  editor (dialogue/choice/event/end nodes) in the admin panel
- Frontend: Currently-activity line and level description on the contact
  profile page; NpcConversation messaging surface with a documented
  (disabled) LLM extension seam
- Permissions: npc-dialogues CRUD + admin manage in a new NPC Dialogue
  group; event types for dialogue triggers
- Migration 20261006_000000 (applied to dev DB) with full schema
  snapshot sidecar
2026-10-05 12:51:59 -04:00
80ad24580a fix(tech-tree): save canvas positions in one request so auto-arrange cannot overload the server
Every canvas position write (Auto-arrange, Save positions, drags, freeze pins)
used to send one PATCH per technology, all at once. On a large tree that was
dozens of concurrent full document updates, which exhausted the database pool
and could crash the server.

- Add POST /api/tech-tree/positions: validates `{ positions: [{ id, x, y }] }`
  (null x/y clears a pin, capped at 2000) and applies every position in a
  single UPDATE on the tree position columns. Access mirrors the technologies
  update rule (technologies:update or Intelligence membership).
- Route all canvas position writes through it; failures now surface in the
  toolbar instead of being swallowed.
- Auto-arrange is optimistic: the canvas re-lays out on click and the pins
  are restored if the save fails. A spinner status chip shows while a layout
  save runs, and layout controls and dragging are locked until it finishes.
- Integration tests for validation and the bulk write; the e2e checks the busy
  indicator and that no per-node PATCHes are sent.
2026-10-03 04:08:29 -04:00
d43b2ef658 feat(tech-tree): drag groups, snap to grid, and route edges around nodes
Round out the canvas editing experience.

- Dragging one card of a multi-selection now moves and persists the whole
  selection (React Flow hands the full dragged set to onNodeDragStop).
- A category band is draggable by its header, which moves every technology in
  that band; the band body stays click-through.
- A "Snap: On/Off" toolbar toggle (default on, remembered per browser) snaps
  dragged cards to a 46px grid that divides the column and row steps, so
  snapped cards line up with the automatic layout.
- Connection lines are adjustable: select an edge to reveal "+" handles at each
  segment's midpoint (click to add a bend), drag bends to reroute, and
  double-click a bend to remove it. Routes persist per browser.
- Edges route around technologies they are not connected to, and corners are
  rounded, so lines no longer cut through unrelated cards.
- Ctrl/Cmd-clicking to multi-select no longer pops the side panel over the
  canvas.
2026-10-03 03:28:27 -04:00
89482798f4 feat(tech-tree): add admin tech tree editor view
Add a custom admin view over the technologies collection so staff can model
prerequisites as a left-to-right tree instead of a flat list.

- React Flow v12 canvas with category bands, OR-prerequisite edges, a
  lite side-panel editor, and a quick-create dialog.
- Propagating layout: a technology with prerequisites lands one column right
  of its parents at their average row; uncategorized roots fill a catalog
  grid keyed by each tech's rank among all uncategorized technologies, so
  promoting one into the tree leaves an empty slot instead of re-shuffling
  the grid.
- Stability contract: connecting or removing edges never moves a card (the
  connected node is pinned to its current spot), and a "Save positions"
  control commits every on-screen node so the arrangement survives reload;
  "Auto-arrange" clears manual positions and restores the ordered layout.
- Progression-path edge colors and per-source lanes keep overlapping edges
  readable. Wire the view and its nav entry into payload.config.ts and add
  dark React Flow / scrollbar styling.
2026-10-01 10:03:58 -04:00
6169bf6ce6 feat(awards): add ribbon design studio, review queue and submission UI
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-11 03:25:59 -04:00
1b552b3a6d feat(voiceover): add admin audio preview for voice submissions 2026-09-09 18:54:58 -04:00
06dbf5b796 feat(admin): add collapsible group field
Wraps Payload's group field in a Collapsible so long groups (e.g. profile minigames) can start collapsed in the admin panel; refreshes the import map.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-06 01:24:11 -04:00
66181ff51c feat(assignments): add AssignmentMembersField component for managing assignment members 2026-08-29 23:53:13 -04:00
ab86be05ae feat(awards): add commendation color field and update award sorting 2026-08-28 00:54:25 -04:00
83f203d736 feat(shims): add targeted client-side injections 2026-08-26 00:53:31 -04:00
b060b967c0 feat(awards): add AwardCard and RibbonRack components for award display 2026-08-21 12:46:44 -04:00
5058d9ce6c style(admin): format admin narrative-flow and award components 2026-08-16 23:27:51 -04:00
f9c33c3fb9 feat: add award ribbon and medal designers
- Add RibbonDesigner admin component for visual ribbon design
- Add MedalDesigner admin component for visual medal design
- Add ribbonDesign and medalDesign JSON fields to Awards collection
- Conditionally show design fields based on award type
2026-07-31 20:03:19 -04:00
2ffd5e2a84 refactor: LiteGraph-style node layout with NodeShell wrapper
- NodeShell component wraps all nodes with handle rendering + px-8 content padding
- Handles positioned at node edges with labels outside (no overlap with content)
- Labels: 9px mono font, full opacity, color-matched to socket type
- Removed old TypedHandle + NodeHandles (replaced by NodeShell internals)
- All 18 node components updated to use NodeShell
- Format node dynamically generates handles from template {0}, {1}, etc.
2026-07-28 18:26:13 -04:00
707562faaa fix: restore small handle labels and make Format node dynamic
- TypedHandle now shows tiny 8px labels next to handles (color-matched)
- Labels positioned outside the handle, no overlap with node content
- Format node dynamically generates input handles from template {0}, {1}, etc.
- NodeHandles accepts dynamicInputs/dynamicOutputs overrides
- isValidConnection treats dynamic handles (arg-*, option-*) as any-type
2026-07-28 18:22:25 -04:00
8ec0c194ff fix: reduce handle size and remove overlapping labels
- Flow handles: 12px → 8px (rounded square)
- Data handles: 10px → 6px (circle)
- Border: 2px → 1.5px with softer opacity
- Removed label text from handles (color indicates type)
- Removed wrapper div — handles render directly via React Flow
2026-07-28 18:19:06 -04:00
06fb1ede75 feat: new blueprint node types for data flow and logic
New node types:
- GameData: reads runtime state (structure health, deliveries, resources, etc.)
- Flag: read/write persistent flags by name
- Compare: A [op] B → boolean (>, <, ==, !=, >=, <=)
- Math: A [op] B → number (+, -, *, /)
- Format: template string with {0}, {1} placeholders → string
- Logic: A [op] B → boolean (AND, OR, XOR)
- NOT: boolean → inverted boolean
- Branch: flow in + boolean condition → true/false flow out
- Sequence: flow in → 3 flow outs (executes in order)

Toolbar updated with categorized buttons (Story, Data, Logic).
MiniMap color-coded for all 18 node types.
NodeEditDialog handles all new types with operator/field selectors.
2026-07-28 18:16:20 -04:00
9a7462e5f7 feat: typed socket foundation for LiteGraph-style blueprint editor
Phase 1 — Typed Socket Foundation:
- SocketType enum: flow, number, string, boolean, any
- Socket definitions for all 9 existing node types (inputs + outputs)
- TypedHandle component: color-coded circles (flow=white square, number=purple, string=teal, boolean=green, any=indigo)
- NodeHandles helper: auto-renders handles from socket config with proportional spacing
- isValidConnection: rejects type mismatches, any-type sockets accept all connections
- All existing nodes refactored to use NodeHandles instead of manual Handle components
2026-07-28 18:11:52 -04:00
cfba38ca24 refactor: switch all node types to left/right handles for L-to-R layout
- Updated handle positions:
  - Target: Position.Left (incoming edges from left)
  - Source: Position.Right (outgoing edges to right)
- Updated MiniMap nodeColor to color-code all 9 node types
- Maintains consistency across narrative, primitive, and control nodes
2026-07-28 17:49:48 -04:00
4a573f7cfc feat: add Wait and primitive node types to NarrativeFlowEditor
- New node types:
  - Wait: delays execution for N ticks, supports optional input
  - Number: stores a numeric value
  - String: stores a string value
  - Random: generates random numbers in range [min, max]
  - Boolean: stores true/false flag
  - Date: stores a date value
- Color-coded nodes matching React Flow palette:
  - Wait: yellow
  - Number: purple
  - String: teal
  - Random: pink
  - Boolean: emerald
  - Date: cyan
- NodeEditDialog now handles all new types with appropriate fields
- Toolbar updated with color-matched buttons
2026-07-28 17:44:46 -04:00
9651ad83ae fix: use span for close button to ensure true transparency
- Browser button elements have default background/border
- Span with onClick provides the same functionality with no defaults
- Maintains keyboard focus states and accessibility
2026-07-28 17:33:20 -04:00
fbaad2e4bb fix: close button is now transparent with solid X icon
- No padding, no border, no background on button
- X icon itself has text-zinc-500 color
- Only hover background tint on the button
2026-07-28 17:30:40 -04:00
8ddca4d647 refactor: simplify close button to transparent X icon only 2026-07-28 17:29:38 -04:00
56980eebd3 fix: add dark mode utility classes to NodeEditDialog inputs and buttons
- Add dark:bg-zinc-800 dark:border-zinc-700 dark:text-zinc-100 to all Inputs/Textareas
- Add dark:bg-blue-600 dark:hover:bg-blue-700 dark:text-white to Save button
- Add dark:border-zinc-700 dark:text-zinc-300 to Cancel, Add buttons
- Add dark:bg-red-900/60 dark:hover:bg-red-800/80 to destructive icon buttons
- Ensures dialog renders correctly inside Payload admin portal context
2026-07-28 17:23:10 -04:00
fe863845bb refactor: use shadcn components in NodeEditDialog, add Textarea component
- Replace raw <textarea> with shadcn Textarea component
- Replace raw <button> with shadcn Button (variant='destructive' + icon)
- Remove custom className overrides fighting admin dark theme
- Add shadcn preference rule to AGENTS.md
2026-07-28 16:28:14 -04:00
103340271b feat: narrative events flowchart editor with React Flow
- NarrativeEvents collection redesigned with flowData JSON (React Flow format)
- Custom admin field component: NarrativeFlowEditor with @xyflow/react
- Three node types: NarrativeBeat (blue), Choice (amber), Outcome (emerald)
- NodeEditDialog with type-specific forms replacing prompt() editing
- Right-click context menu (Delete node/edge with Radix primitives)
- Dynamic handles on Choice nodes (one per option)
- Dark-themed canvas with MiniMap, Controls, and animated edges
- All changes sync bidirectionally with Payload form state
- AGENTS.md updated with architecture docs
2026-07-28 16:26:57 -04:00