1
0
Fork 0

Compare commits

..

No commits in common. "4e9b2d494f7c91df0fcb851e22e96957ad0ea78e" and "8ad7c412e4f3dc674e198f730667316484c6c443" have entirely different histories.

5 changed files with 92 additions and 146 deletions

View file

@ -188,9 +188,7 @@ In development, `postgresAdapter` uses `push: false` — run `bun run payload mi
shadcn/ui components live in `src/components/ui/`. Use `bunx shadcn@latest add <component>` to add new ones. Frontend components in `src/components/frontend/`. Payload admin custom components referenced in `payload.config.ts` under `admin.components`. shadcn/ui components live in `src/components/ui/`. Use `bunx shadcn@latest add <component>` to add new ones. Frontend components in `src/components/frontend/`. Payload admin custom components referenced in `payload.config.ts` under `admin.components`.
**Rule**: always prefer shadcn/ui components (Dialog, Button, Input, Textarea, Select, etc.) over raw HTML elements or custom-built alternatives. Only build new components when no existing shadcn component fits the need. Do not override shadcn's default dark theme classes with custom `bg-*` `border-*` overrides on the **frontend**; the site theme handles styling. **Rule**: always prefer shadcn/ui components (Dialog, Button, Input, Textarea, Select, etc.) over raw HTML elements or custom-built alternatives. Only build new components when no existing shadcn component fits the need. Do not override shadcn's default dark theme classes with custom `bg-*` `border-*` overrides — the admin panel's theme handles styling.
**Exception, custom admin field components**: the admin bundle never loads `src/app/(frontend)/styles.css`, so `--background`, `--popover`, `--border-input` and friends do not exist there. Inside the admin panel, style every surface explicitly in zinc (`bg-zinc-800`/`bg-zinc-900`, `border-white/20`, `text-white`) as `src/components/admin/npc-dialogue/NodeEditDialog.tsx` does. A portaled Radix `Select` is worse than unstyled there: it renders transparent and swallows pointer events, so it can only be driven with the keyboard. Use a native `<select>` in admin field components.
### Tactical "dossier" style (Battlefield-style UI) ### Tactical "dossier" style (Battlefield-style UI)

View file

@ -1,13 +1,5 @@
# Changelog # Changelog
# v0.16.7
### Fixes
- Various bug fixes and improvements.
---
# v0.16.6 # v0.16.6
The site holds up when the whole unit is on at once, which it previously did not. The site holds up when the whole unit is on at once, which it previously did not.

View file

@ -1,6 +1,6 @@
{ {
"name": "polaris-task-force", "name": "polaris-task-force",
"version": "0.16.7", "version": "0.16.6",
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.", "description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",

View file

@ -14,6 +14,13 @@ import {
} from "@/components/ui/dialog"; } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { import {
@ -65,24 +72,11 @@ const INITIAL_BRIEF: DialogueBrief = {
mustInclude: "", mustInclude: "",
}; };
/**
* Admin-panel surface: the Payload admin bundle does not load the frontend's
* shadcn theme variables, so every surface here is styled explicitly in zinc,
* the same way `NodeEditDialog` does it. Native selects are deliberate too: a
* portaled Radix Select inherits nothing inside the admin panel's theme scope,
* which leaves it transparent and unable to take pointer events.
*/
const FIELD_LABEL = "text-[10px] uppercase tracking-wider text-white/50";
const SELECT_CLASS =
"w-full rounded border border-white/20 bg-zinc-800 px-2 py-1.5 text-sm text-white outline-none focus:border-white/40";
const TEXT_INPUT_CLASS =
"bg-zinc-800 border-white/20 text-white placeholder:text-white/30 focus-visible:ring-0 focus-visible:border-white/40";
/** /**
* The brief that seeds a generated conversation. * The brief that seeds a generated conversation.
* *
* The fields are deliberately narrow: a model asked for "a conversation" with no * The fields are deliberately narrow: a 9B model asked for "a conversation" with
* shape produces something generic, while a brief that names the purpose, the * no shape produces something generic, while a brief that names the purpose, the
* takeaway and the outcome produces something an author can edit rather than * takeaway and the outcome produces something an author can edit rather than
* rewrite. Nothing here reaches the database. Cancelling leaves the canvas as it * rewrite. Nothing here reaches the database. Cancelling leaves the canvas as it
* was, and generating only touches unsaved field state. * was, and generating only touches unsaved field state.
@ -161,65 +155,60 @@ export function GenerateDraftDialog({
return ( return (
<Dialog open={open} onOpenChange={(next) => (busy ? undefined : onOpenChange(next))}> <Dialog open={open} onOpenChange={(next) => (busy ? undefined : onOpenChange(next))}>
<DialogContent className="sm:max-w-lg bg-zinc-900 border-white/15 text-white"> <DialogContent className="sm:max-w-lg">
<DialogHeader> <DialogHeader>
<DialogTitle className="flex items-center gap-2 text-base text-white"> <DialogTitle className="flex items-center gap-2">
<Sparkles className="size-4 shrink-0 text-fuchsia-300" /> <Sparkles className="size-4" />
Draft a conversation Draft a conversation
</DialogTitle> </DialogTitle>
<DialogDescription className="text-xs text-white/60"> <DialogDescription>
Describe the beat you want. The model writes a flowchart into the canvas as an unsaved Describe the beat you want. The model writes a flowchart into the canvas as an unsaved
draft, so nothing reaches players until you review it and save. draft, so nothing reaches players until you review it and save.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
{/* Scrolls instead of growing past the viewport on a short screen. */} <div className="flex flex-col gap-3">
<div className="flex max-h-[62vh] flex-col gap-3 overflow-y-auto pr-1">
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-3">
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-purpose"> <Label htmlFor="draft-purpose">Purpose</Label>
Purpose <Select
</Label>
<select
id="draft-purpose"
className={SELECT_CLASS}
value={brief.purpose} value={brief.purpose}
onChange={(e) => set("purpose", e.target.value as BriefPurpose)} onValueChange={(value) => set("purpose", value as BriefPurpose)}
> >
<SelectTrigger id="draft-purpose">
<SelectValue />
</SelectTrigger>
<SelectContent>
{BRIEF_PURPOSES.map((purpose) => ( {BRIEF_PURPOSES.map((purpose) => (
<option key={purpose} value={purpose}> <SelectItem key={purpose} value={purpose}>
{PURPOSE_LABELS[purpose]} {PURPOSE_LABELS[purpose]}
</option> </SelectItem>
))} ))}
</select> </SelectContent>
</Select>
</div> </div>
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-tone"> <Label htmlFor="draft-tone">Tone</Label>
Tone <Select value={brief.tone} onValueChange={(value) => set("tone", value as BriefTone)}>
</Label> <SelectTrigger id="draft-tone">
<select <SelectValue />
id="draft-tone" </SelectTrigger>
className={SELECT_CLASS} <SelectContent>
value={brief.tone}
onChange={(e) => set("tone", e.target.value as BriefTone)}
>
{BRIEF_TONES.map((tone) => ( {BRIEF_TONES.map((tone) => (
<option key={tone} value={tone}> <SelectItem key={tone} value={tone}>
{TONE_LABELS[tone]} {TONE_LABELS[tone]}
</option> </SelectItem>
))} ))}
</select> </SelectContent>
</Select>
</div> </div>
</div> </div>
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-goal"> <Label htmlFor="draft-goal">What should the player learn or do?</Label>
What should the player learn or do?
</Label>
<Textarea <Textarea
id="draft-goal" id="draft-goal"
className={TEXT_INPUT_CLASS}
value={brief.goal} value={brief.goal}
onChange={(e) => set("goal", e.target.value)} onChange={(e) => set("goal", e.target.value)}
placeholder="Learn that the quartermaster is short on rifle magazines, and that the next resupply is delayed." placeholder="Learn that the quartermaster is short on rifle magazines, and that the next resupply is delayed."
@ -229,61 +218,60 @@ export function GenerateDraftDialog({
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-3">
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-outcome"> <Label htmlFor="draft-outcome">Outcome</Label>
Outcome <Select
</Label>
<select
id="draft-outcome"
className={SELECT_CLASS}
value={brief.outcome} value={brief.outcome}
onChange={(e) => set("outcome", e.target.value as BriefOutcome)} onValueChange={(value) => set("outcome", value as BriefOutcome)}
> >
<SelectTrigger id="draft-outcome">
<SelectValue />
</SelectTrigger>
<SelectContent>
{BRIEF_OUTCOMES.map((outcome) => ( {BRIEF_OUTCOMES.map((outcome) => (
<option key={outcome} value={outcome}> <SelectItem key={outcome} value={outcome}>
{OUTCOME_LABELS[outcome]} {OUTCOME_LABELS[outcome]}
</option> </SelectItem>
))} ))}
</select> </SelectContent>
</Select>
</div> </div>
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-size"> <Label htmlFor="draft-size">Length</Label>
Length <Select
</Label>
<select
id="draft-size"
className={SELECT_CLASS}
value={String(brief.size)} value={String(brief.size)}
onChange={(e) => set("size", Number(e.target.value) as DraftSize)} onValueChange={(value) => set("size", Number(value) as DraftSize)}
> >
<SelectTrigger id="draft-size">
<SelectValue />
</SelectTrigger>
<SelectContent>
{DRAFT_SIZES.map((size) => ( {DRAFT_SIZES.map((size) => (
<option key={size} value={String(size)}> <SelectItem key={size} value={String(size)}>
About {size} nodes About {size} nodes
</option> </SelectItem>
))} ))}
</select> </SelectContent>
</Select>
</div> </div>
</div> </div>
{brief.outcome === "set-flag" && ( {brief.outcome === "set-flag" && (
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-flag"> <Label htmlFor="draft-flag">Flag to set</Label>
Flag to set <Select value={brief.flagKey} onValueChange={(value) => set("flagKey", value)}>
</Label> <SelectTrigger id="draft-flag">
<select <SelectValue placeholder="Choose a flag" />
id="draft-flag" </SelectTrigger>
className={SELECT_CLASS} <SelectContent>
value={brief.flagKey}
onChange={(e) => set("flagKey", e.target.value)}
>
<option value="">Choose a flag</option>
{flags.map((flag) => ( {flags.map((flag) => (
<option key={flag.key} value={flag.key}> <SelectItem key={flag.key} value={flag.key}>
{flag.key} ({flag.flagType}) {flag.key} ({flag.flagType})
</option> </SelectItem>
))} ))}
</select> </SelectContent>
<p className="text-[10px] text-white/40"> </Select>
<p className="text-xs text-muted-foreground">
{flagsError ?? {flagsError ??
(flags.length === 0 (flags.length === 0
? "No player flags exist yet, so nothing can be set." ? "No player flags exist yet, so nothing can be set."
@ -293,12 +281,9 @@ export function GenerateDraftDialog({
)} )}
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<Label className={FIELD_LABEL} htmlFor="draft-must-include"> <Label htmlFor="draft-must-include">Must include (optional)</Label>
Must include (optional)
</Label>
<Input <Input
id="draft-must-include" id="draft-must-include"
className={`h-9 ${TEXT_INPUT_CLASS}`}
value={brief.mustInclude} value={brief.mustInclude}
onChange={(e) => set("mustInclude", e.target.value)} onChange={(e) => set("mustInclude", e.target.value)}
placeholder="A place, a name, or a number the line has to mention" placeholder="A place, a name, or a number the line has to mention"
@ -306,35 +291,20 @@ export function GenerateDraftDialog({
</div> </div>
{nodeCount > 0 && ( {nodeCount > 0 && (
<p className="rounded border border-amber-900/50 bg-amber-950/40 px-2 py-1.5 text-[11px] leading-snug text-amber-200"> <p className="rounded-md border border-amber-900/50 bg-amber-950/40 px-3 py-2 text-xs text-amber-200">
Generating replaces the {nodeCount} node{nodeCount === 1 ? "" : "s"} on the canvas. The Generating replaces the {nodeCount} node{nodeCount === 1 ? "" : "s"} on the canvas. The
document is not saved until you save it, so closing without saving undoes this. document is not saved until you save it, so closing without saving undoes this.
</p> </p>
)} )}
{error && ( {error && <p className="text-sm text-red-400">{error}</p>}
<p className="rounded border border-red-900/50 bg-red-950/40 px-2 py-1.5 text-[11px] leading-snug text-red-300">
{error}
</p>
)}
</div> </div>
<DialogFooter className="gap-2 sm:gap-2"> <DialogFooter>
<Button <Button variant="outline" onClick={() => onOpenChange(false)} disabled={busy}>
type="button"
variant="outline"
className="border-white/20 text-white hover:bg-zinc-800"
onClick={() => onOpenChange(false)}
disabled={busy}
>
Cancel Cancel
</Button> </Button>
<Button <Button onClick={() => void handleGenerate()} disabled={busy}>
type="button"
className="inline-flex items-center gap-1.5 border border-fuchsia-700 bg-fuchsia-950 text-fuchsia-200 hover:bg-fuchsia-900"
onClick={() => void handleGenerate()}
disabled={busy}
>
{busy ? ( {busy ? (
<> <>
<Loader2 className="size-4 animate-spin" /> <Loader2 className="size-4 animate-spin" />

View file

@ -87,20 +87,6 @@ pass server-side, so a flag value can never smuggle in another token.
- The model is reachable only through `src/lib/ai/generate.ts`. Do not call - The model is reachable only through `src/lib/ai/generate.ts`. Do not call
`fetch` against Unsloth anywhere else. `fetch` against Unsloth anywhere else.
## Admin panel styling
The admin bundle does not load the frontend's shadcn theme variables, so
`bg-background`, `bg-popover`, `border-input`, `text-muted-foreground` and the
rest resolve to nothing inside a custom admin field. A surface styled only with
those tokens comes out transparent, and a portaled Radix `Select` becomes
transparent *and* unable to take pointer events, so it can only be driven with
the arrow keys.
So: style every admin-panel element explicitly in zinc (`bg-zinc-800` /
`bg-zinc-900`, `border-white/20`, `text-white`), as `NodeEditDialog` does, and
prefer a native `<select>` over the shadcn one. `GenerateDraftDialog` follows
both rules.
## Tests ## Tests
`tests/int/npc-dialogue-*.int.spec.ts`: interpolate, attachments, condition `tests/int/npc-dialogue-*.int.spec.ts`: interpolate, attachments, condition