diff --git a/src/components/admin/tech-tree/AGENTS.md b/src/components/admin/tech-tree/AGENTS.md index 1c478f4f..b6fa6c18 100644 --- a/src/components/admin/tech-tree/AGENTS.md +++ b/src/components/admin/tech-tree/AGENTS.md @@ -6,7 +6,7 @@ `/admin/tech-tree` — visual tech tree editor over `technologies`, built on `@xyflow/react` v12 following the narrative-flow patterns. Custom admin view (root view) + a "Tech Tree" nav entry injected under the Intelligence group; the Technologies list/edit views are untouched. - **Schema**: `tech-categories` collection (`src/collections/intelligence/TechCategories.ts`: `name` unique, `position` number = timeline order, optional hex `color`) + `Technologies.category` relationship (FK `ON DELETE set null`, so deleting a category just unfiles its techs) + `Technologies.treePosition` group (`x`/`y` numbers; manual canvas position from dragging, empty = automatic). Permissions mirror technologies (`tech-categories:*` + `admin:tech-categories:manage`, registered in `src/permissions/index.ts`); `tech-categories` is in `DIVISION_ADMIN_QUALIFICATIONS`, so Intelligence division members get admin-panel access exactly like `technologies`. Migrations: `20260930_230747_add_tech_categories`, `20261001_000320_add_tech_tree_position`. -- **Note nodes**: `tech-tree-notes` (`src/collections/intelligence/TechTreeNotes.ts`, `admin.hidden`, no sidebar page) are amber annotation cards on the canvas, deliberately NOT technologies: no prerequisites, cost rows, approval workflow or research state, so `computeLayout`, edge building and the research rules never see them. Fields: `title` (required), `body` (textarea, line breaks preserved), `showOnFrontend` (checkbox, **false by default**), `treePosition` group. Access reuses the `technologies` permissions (`read`/`create`/`update`/`delete`), so no permission group or admin-page gate was added; notes are created, edited and deleted only from the canvas (`NoteDialog`, "+ New Note" toolbar button) and the delete button is hidden without `technologies:delete`. A new note lands at the viewport centre; untouched notes park in an automatic column one step right of the tree (`notes.ts` `computeNoteLayout`). Note React Flow ids are namespaced `note-` (`noteNodeId`/`parseNoteNodeId`) so they can never collide with technology ids, and note cards have no handles, so they can never become prerequisite endpoints. Note drags, Save positions and Auto-arrange reuse the bulk `/api/tech-tree/positions` write by sending `collection: "tech-tree-notes"` (the route swaps the target table and the token source); never add a PATCH-per-note path. Ticking `showOnFrontend` publishes the note to the member tech tree, which queries `showOnFrontend: { equals: true }` and renders the same amber card read-only; unpublished notes never reach members. Notes are edge-routing obstacles in both canvases. +- **Note nodes**: `tech-tree-notes` (`src/collections/intelligence/TechTreeNotes.ts`, `admin.hidden`, no sidebar page) are annotation cards on the canvas, deliberately NOT technologies: no prerequisites, cost rows, approval workflow or research state, so `computeLayout`, edge building and the research rules never see them. **Visual contract**: a note must not look like a technology card. It uses a deliberately different silhouette (`NoteNode.tsx`): warm paper-tinted fill (`#1b1409`), chunky dashed amber border, a vertical `NOTE` rail instead of the tech classification strip, a folded top-right corner, no corner brackets, no readout footer (the status line sits at the bottom of the body) and no connection handles. Keep it that way; do not "harmonise" it back to the tech card chrome. Fields: `title` (required), `body` (textarea, line breaks preserved), `showOnFrontend` (checkbox, **false by default**), `treePosition` group. Access reuses the `technologies` permissions (`read`/`create`/`update`/`delete`), so no permission group or admin-page gate was added; notes are created, edited and deleted only from the canvas (`NoteDialog`, "+ New Note" toolbar button) and the delete button is hidden without `technologies:delete`. A new note lands at the viewport centre; untouched notes park in an automatic column one step right of the tree (`notes.ts` `computeNoteLayout`). Note React Flow ids are namespaced `note-` (`noteNodeId`/`parseNoteNodeId`) so they can never collide with technology ids, and note cards have no handles, so they can never become prerequisite endpoints. Note drags, Save positions and Auto-arrange reuse the bulk `/api/tech-tree/positions` write by sending `collection: "tech-tree-notes"` (the route swaps the target table and the token source); never add a PATCH-per-note path. Ticking `showOnFrontend` publishes the note to the member tech tree, which queries `showOnFrontend: { equals: true }` and renders the same amber card read-only; unpublished notes never reach members. Notes are edge-routing obstacles in both canvases. - **View wiring**: `payload.config.ts` `admin.components.views.techTree` (path `/tech-tree`, component `src/components/admin/tech-tree/TechTreeView.tsx`) and `admin.components.Nav` → `TechTreeNav.tsx`. Custom root views are public by default, so the view gates itself (logged-in + `technologies:read` OR Intelligence qualification). The nav replica injects the entry into the group containing `technologies` and reuses public exports (`NavWrapper`/`NavHamburger`/`DefaultNavClient` from `@payloadcms/next/client`, `groupNavItems` from `@payloadcms/ui/shared`); registered admin components must be **default exports** (importMap convention in this repo). - **Layout** (`layout.ts`, pure): a **propagating left-to-right tree**. A technology WITH prerequisites is placed one column to the right of its parents, at their average row, so linking A -> B drops B immediately beside A and B's dependents continue further right; nothing is teleported to a distant column when its depth changes. Technologies in a category stay pinned to that category's column (the category contract); uncategorized roots fill a catalog grid whose slots come from each tech's rank among ALL uncategorized technologies (`MAX_ROWS_PER_COLUMN` = 10 rows, spilling into more columns) so promoting a tech into the tree leaves an empty slot rather than re-shuffling the grid; uncategorized dependents follow their parents inside the uncategorized zone. Collisions search rows outward from the desired row (dependents may also grow upward, and their columns are not height-capped, so a link from a full column still lands beside its parent rather than far right). Category bands are the bounding box of their members' final positions. Prerequisites placed to the RIGHT of their dependent surface as amber warnings (toolbar chip + node icon + preview panel section). - **Edges**: AND prerequisites solid slate, OR prerequisites dashed cyan with an OR label. Connections are editable on the canvas: drag from a node's right handle onto another node (the target card OR its handle) to add it as an AND prerequisite; the drop-on-card case is resolved by an `onConnectEnd` fallback because React Flow only resolves drops onto a handle. Select an edge and press Backspace to remove the prerequisite. Duplicates, self-references, and cycles (direct or transitive) are rejected by the pure `prereqEdits.ts` helpers with an inline error in the toolbar. Lines are also manually routable: selecting an edge reveals a "+" handle at each segment's midpoint (click to add a bend), bends drag to move, and double-clicking a bend removes it (`RoutedEdge.tsx` + `edgeRoutes.ts`). Routes are stored per browser in `localStorage`; making them shared would need a persisted field on the target technology. Edges also route around technologies they are not connected to: `edgeRouting.ts` detours each segment around the node rectangles it would cross (inflated by a clearance margin) and `buildRoutePath` rounds every corner. An unrouted edge keeps its automatic out/across/in shape unless that path would cut through a node, in which case it falls back to a direct line the router can bend around. diff --git a/src/components/admin/tech-tree/NoteNode.tsx b/src/components/admin/tech-tree/NoteNode.tsx index a7c6d2cf..5c32f4a5 100644 --- a/src/components/admin/tech-tree/NoteNode.tsx +++ b/src/components/admin/tech-tree/NoteNode.tsx @@ -14,67 +14,79 @@ export type NoteNodeData = { export type NoteNodeModel = Node; /** - * Amber annotation card. Fixed chrome on purpose: a note must never be - * mistaken for a technology (cyan) or a category band (category accent), in the - * admin editor or on the member-facing tree. It has no handles, so it can never - * become a prerequisite endpoint. + * Memo card for canvas annotations. + * + * Deliberately a different silhouette from a technology card, not just a + * different accent colour: no classification strip, no readout footer, no + * corner brackets, a dashed amber border, a warm paper-tinted fill and a + * vertical rail label. At fit-view zoom (where the text is illegible) the warm + * tint and dashed edge are what separate it from the near-black tech cards; up + * close the vertical NOTE rail and folded corner do. It has no handles either, + * so it can never become a prerequisite endpoint. */ export function NoteNodeCard({ data, selected }: NodeProps) { const { note } = data; return ( -
+
- {/* Classification strip */} -
- - NOTE // ANNOTATION + {/* Folded corner: the page-coloured triangle reads as a peeled note, + which no technology card has. */} + + + {/* Vertical rail label instead of a horizontal classification strip */} +
+ + Note - {note.showOnFrontend ? "PUBLISHED" : "INTERNAL"} - + />
{/* Body: the title keeps a fixed two-line slot and the detail text takes whatever height is left, so a long title can never clip the body to nothing (the card height is fixed by the canvas). */} -
+
{note.title}
{note.body.trim() ? ( -

+

{note.body}

) : ( -

+

No details

)} -
- - {/* Footer readout */} -
- - Annotation - - - NOT RESEARCHABLE - +
+ + {note.showOnFrontend ? "Published" : "Internal"} + + + // Annotation + +