1
0
Fork 0
polaris-task-force/src/components/frontend/AGENTS.md
Z8MB1E b28708c590 docs(agents): split domain guidance into nested AGENTS.md files
Move 19 domain sections out of the root guide into per-directory
AGENTS.md files that OpenCode v2 injects lazily when an agent reads
each subtree. The always-loaded root drops from 121KB to ~30KB and
gains a domain index table with never-miss invariants. Original root
and pre-merge sub-guides are preserved under
docs/backups/pre-agents-split-20261009/ for restoration.

Note: also carries the pre-existing uncommitted wiki-section edits to
the root AGENTS.md, preserved verbatim in src/lib/wiki/AGENTS.md.
2026-10-09 15:46:36 -04:00

9.5 KiB

AGENTS.md — Frontend Components

Parent: ../../AGENTS.md — commands, auth flow, Next.js 16 rules, deployment.

Overview

100+ client components organized by domain. The (frontend) layout renders guests LandingPage (no app shell); authed users get AppSidebar + SiteHeader + CommandPalette.

Structure

components/frontend/
  auth/           2 files    LoginForm, LoginLink (returnTo via usePathname)
  account/       16 files    Profile, password, preferences, Discord link
  awards/         4 files    Medal/ribbon display, award dialogs
  banking/        9 files    Account cards, ledger, deposit/withdraw/transfer dialogs
  baseManagement/ 4 files    StaffRoster, HireStaffDialog, EmploymentCard, UpgradeCard (structure page)
  blocks/         7 files    AppSidebar (data in sidebarData.ts), NavCore, NavUser, XPDisplay
  dashboard/      6 files    ProfileSummary, QuickStats, MissionBriefing, RecentEvents
  eod/            4 files    Minefield Clearance minigame
  evaluations/    0 files    EMPTY directory (placeholder — no components yet)
  flappy/         4 files    Flight Simulator canvas game, leaderboard, sounds
  helpdesk/       8 files    Ticket list/detail, create dialog, timeline
  impersonation/  2 files    Admin impersonation banner/controls
  intelligence/  17 files    Mission cards/attendance/comms, campaign/faction cards
  locker/        13 files    Grid, equipment editor, loadouts, wardrobe
  logistics/      8 files    Shipment cards/actions, toast notifications
  market/        10 files    Listing cards, negotiation flow, NPC chat, patience meter
  notifications/  2 files    Bell (polling), inbox page
  personnel/      3 files    NpcDirectory, NpcCard, NpcProfile (/personnel/contacts)
  profile/        3 files    Profile page components (incl. rating dialog)
  projects/      12 files    Jira-like boards, releases, sprints
  qualification/  6 files    Aim trainer arena/game/canvas/leaderboard, sounds
  radio/          5 files    Radio Traffic game, message generator, leaderboard
  realtime/       1 file     GameTickRealtime (SSE -> router.refresh)
  roster/         1 file     Org chart view
  session/        1 file     Session expiry UI (pairs with useSessionExpired hook)
  shims/          1 file     Frontend shim renderer
  storage/       14 files    Structure grid, storage dialogs, event ledger
  transfers/      7 files    Assignment transfer request/decision UI
  wiki/          11 files    Index, editor + toolbar, content renderer, revisions, standards dialog
  + root files: LandingPage.tsx, SiteHeader.tsx, ClientDate.tsx, PayloadButtons.tsx

Conventions

Server → Client data flow

Pages are server components that fetch via getPayload(), then pass data as props to client components. Client components receive typed props and never call Payload directly.

Item compound component

storage/ uses a compound <Item> component for grid cells with slots: <Item.Slot name="icon">, <Item.Slot name="stats">, <Item.Menu>. Attachments render as stacked badges on the grid cell; popover shows full detail on hover.

SSE consumers

  • GameTickRealtime mounts in (frontend)/layout.tsx for all authed users.
  • ShipmentToasts mounts only for logistics-qualified users.
  • Both use useGameTick() hook (custom ptf:game-tick event dispatch).

Nested dialogs

Market negotiation uses MakeOfferDialog nested inside ListingCard dialog. Loadout editor uses EquipmentEditorDialog nested inside locker grid. When a parent dialog unmounts (e.g., sold listing), the child stays visible for 3.5s minimum via useNow() hook for readability before refresh.

Route anomalies

logistics/vehicles/VehiclesList.tsx is a client component placed directly in the route directory (not under components/frontend/). This is the only route with an inline component file.

Personnel (NPC directory)

  • /personnel/contacts — NPC directory over game-npcs (src/components/frontend/personnel/: NpcDirectory, NpcCard); /personnel/contacts/[id] — NPC profile (faction, in-game vs generated badges, vendor listings, NpcProfile).
  • /personnel/statistics — theater-wide NPC stats: faction distribution, in-game vs generated counts, vendor stall count, top 5 vendors by active auto listings.
  • Sidebar entries live in src/components/frontend/blocks/sidebarData.ts (nav data extracted from AppSidebar).

Tactical dossier style (Battlefield-style UI)

An approved militaristic/intel-interface style for feature surfaces. The user (Jason) likes it a lot. Reference implementation: the official campaign cards (v0.2.27):

  • Component: src/components/frontend/intelligence/CampaignCard.tsx (official variant, size="lg"; community cards keep the conventional style for contrast)
  • Effects CSS: src/app/(frontend)/styles.css (.glitch-hover, .glitch-ghost, .glitch-shard-a/b/c, .glitch-soft, .glitch-soft-late, .glitch-ghost-img-a/b + their keyframes; trust the file for current values, the list here describes intent)

The recipe (each piece is separable; use subsets, do not feel obliged to use all):

  1. Classification strip: full-width top bar (bg-black/50 backdrop-blur-sm border-b border-white/15), 9px font-mono uppercase tracking-widest text-white/60 labels at both ends (e.g. OFFICIAL // UNIT COMMAND left, a deterministic REF ### derived from the record id right).
  2. Corner brackets: four 1px white/25 L-marks inset from the edges (inset-2, size-3, per-corner border sides), brightening to white/60 on hover. pointer-events-none + aria-hidden.
  3. Squared corners: rounded-none on the tactical surface only; sibling/secondary surfaces keep rounded-lg. The contrast is deliberate.
  4. Military status language: squared pill (rounded-sm) or plain colored text, uppercase relabels (e.g. Concept → Planning, In Progress → Active Deployment, Completed → Concluded). The status color renders as text (text-blue-400 / text-emerald-400 / text-muted-foreground); do not duplicate status in two places on one card.
  5. Readout footer: a permanent (not hover-only) single-line bar (border-t border-white/15 bg-black/60 py-1.5 backdrop-blur-sm), cells flex-1 separated by hairline border-r border-white/15, each cell a font-mono text-xs tabular-nums text-white/80 value plus a 9px uppercase text-white/50 label (e.g. 3 MSNS, 4h 0m DURATION). No owner/DIR cell unless the user wants it.
  6. Darkened cover imagery: image at opacity-15 (hover 25) under a heavy gradient (from-black/85 via-black/60 to-black/25) so text stays readable.
  7. Faint grid texture: 1px white grid lines, 28px cells, opacity-[0.04]. Constant opacity: it does NOT brighten on hover (only borders/brackets/imagery highlight).
  8. One-shot glitch hover (only with explicit user opt-in; it is extra motion): every layer fires instantly at 0% then decays; steps-based chaos only in the first ~15-20% of the animation; title/soft text restore to readable within ~25-35%; chromatic aberration via paired cyan/rose text-shadow; title shards are duplicated absolutely-positioned aria-hidden spans clipped by slanted clip-path polygons (cyan #22d3ee, rose #f43f5e, white); image tears use two ghost <img> copies clipped to horizontal bands so pieces shift but nothing ever disappears (never animate opacity: inherit on an image, it flashes to full brightness). Image band decay may run longer (2s) than text (1s). Everything is one-shot (no infinite) and fully disabled under prefers-reduced-motion.

Where it fits: large feature/hero cards, section headers, showcase surfaces. Where it does not: dense data UI, tables, forms, dialogs, buttons, or anything shadcn-styled (the root guide's shadcn rule still governs those). Consistency rule: within one page, secondary surfaces stay conventional so the tactical surface stands out.

Protocol: offer, demo, or default (MANDATORY)

Whenever creating a new component or refactoring an existing component's styling, ask the user whether they want to try applying the tactical dossier style to it. Concretely:

  • Yes: demo similar styling on that component first (same approach as the campaign cards: build it, let the user eyeball it, iterate on tuning).
  • No, or no answer: stick with the existing styling conventions (shadcn + the site's dark theme conventions). Do not apply tactical styling unasked, and do not nag: ask once, then proceed either way.

Where to look

Task Path
Add a new page src/app/(frontend)/<domain>/page.tsx + create client component here
Add nav entry src/components/frontend/blocks/sidebarData.ts (nav data extracted from AppSidebar)
Modify auth gate src/app/(frontend)/layout.tsx (conditional renders LandingPage or shell)
Add SSE consumer src/hooks/useGameTick.ts + mount in layout
NPC dialogue/chatter src/lib/market/npcDialogue.ts (pure, client-safe import)
Minigame game rules src/lib/aim-trainer.ts etc. — pure libs, components consume them
Keyboard shortcuts src/components/command-palette/
Admin custom fields src/components/admin/ (awards designers, CollapsibleGroupField, narrative-flow, shims)

Anti-patterns

  • NEVER call getPayload() in client components — fetch in server page, pass as props
  • NEVER add useRouter().refresh() in SSE consumers without a guard — use the useGameTick() hook
  • NEVER use shadcn defaults for dark theme — the admin panel's theme handles styling
  • NEVER place server-side logic (hooks, Payload calls) in "use client" files