1
0
Fork 0

Compare commits

...

5 commits

Author SHA1 Message Date
70378b23e8 v0.12.9 - period-first minigame boards, configurable Compose model 2026-10-19 12:19:47 -04:00
3655e61247 docs: add v0.12.9 changelog entry 2026-10-19 12:18:16 -04:00
5e4ecd455b docs(minigames): note period-primary game pages with collapsed all-time boards 2026-10-19 12:14:58 -04:00
923831ba82 feat(minigames): make period standings the primary board on game pages
The six period-scored game pages (flappy, eod, opord, radio,
qualification, call-for-fire) now render their current-period
PeriodStandingsCard directly under the game board, in the slot the
lifetime board used to occupy. Each game's all-time leaderboard moves
below it into a collapsed AllTimeLeaderboard disclosure (shadcn
Collapsible) that expands on click, so period standings are centered and
primary and the lifetime board is opt-in.

PeriodStandingsCard drops its period/all-time toggle and keeps the
current period only, now with the presence line the pages previously
omitted. The old "Anchored period standings" heading and card block are
removed from the six page.tsx files. The e2e spec covers the collapsed
all-time section on /minigames/flappy.
2026-10-19 12:14:57 -04:00
15e434998a feat(ai): configure Compose model and label via env
UNSLOTH_MODEL selects the model the Compose plugin calls, and the optional UNSLOTH_MODEL_NAME labels it in the admin (derived from the model id when omitted). The model-id select keeps its stable internal key, a Postgres enum, so switching models needs no schema change.

The seeded per-prompt model value is cleared so the env var applies; an admin can still pin a model on a single prompt row. Migration 20261019_121500_use_env_ai_model drops the column default and clears the seeded value.
2026-10-19 12:13:22 -04:00
23 changed files with 238 additions and 112 deletions

View file

@ -30,6 +30,10 @@ GAME_TICK_NOTIFY_SECRET=YOUR_GAME_TICK_NOTIFY_SECRET
UNSLOTH_URL=http://192.168.1.7:8888/v1
# sk-unsloth-... API key generated in Unsloth Studio (Settings -> API).
UNSLOTH_API_KEY=YOUR_UNSLOTH_API_KEY
# Model id served by the Unsloth connection (the GGUF name its API reports).
UNSLOTH_MODEL=unsloth/Ornith-1.0-9B-GGUF
# Optional label for the model in the Compose UI; derived from UNSLOTH_MODEL when omitted.
# UNSLOTH_MODEL_NAME=Ornith 1.0 9B
# --- Bin script file logging ---
# Optional. Payload bin scripts (game-tick, market-tick, mission-tick,

View file

@ -1,5 +1,17 @@
# Changelog
# v0.12.9
### Improvements
- Game pages now lead with the current period's standings, sitting right beside the game, with the all-time leaderboard tucked into a collapsible section below that you open on demand.
### Fixes
- Various bug fixes and improvements.
---
# v0.12.8
### Fixes

View file

@ -1,6 +1,6 @@
{
"name": "polaris-task-force",
"version": "0.12.8",
"version": "0.12.9",
"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",
"type": "module",

View file

@ -5,7 +5,6 @@ import { headers as nextHeaders } from "next/headers";
import { redirect } from "next/navigation";
import { Target } from "lucide-react";
import { CallForFireArena } from "@/components/frontend/minigames/call-for-fire/CallForFireArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
@ -68,15 +67,6 @@ export default async function CallForFirePage() {
</div>
<CallForFireArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard
gameKey="callForFire"
icon="Target"
currentUserId={user.id as number}
/>
</div>
</div>
);
}

View file

@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
import { Bomb } from "lucide-react";
import { EodArena } from "@/components/frontend/minigames/eod/EodArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "Minefield Clearance (Polaris Task Force)",
@ -72,11 +71,6 @@ export default async function EodPage() {
</div>
<EodArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="eod" icon="Bomb" currentUserId={user.id as number} />
</div>
</div>
);
}

View file

@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
import { Bird } from "lucide-react";
import { FlappyArena } from "@/components/frontend/minigames/flappy/FlappyArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "Flight Simulator: Polaris Task Force",
@ -70,11 +69,6 @@ export default async function FlappyPage() {
</div>
<FlappyArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="flappy" icon="Bird" currentUserId={user.id as number} />
</div>
</div>
);
}

View file

@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
import { ScrollText } from "lucide-react";
import { OpordArena } from "@/components/frontend/minigames/opord/OpordArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "OPORD Recall (Polaris Task Force)",
@ -73,11 +72,6 @@ export default async function OpordPage() {
</div>
<OpordArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="opord" icon="FileTextIcon" currentUserId={user.id as number} />
</div>
</div>
);
}

View file

@ -10,7 +10,6 @@ import { Crosshair } from "lucide-react";
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
import { AimTrainerArena } from "@/components/frontend/minigames/qualification/AimTrainerArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "Qualification Course: Polaris Task Force",
@ -77,11 +76,6 @@ export default async function QualificationPage() {
</div>
<AimTrainerArena initialStats={stats} currentUserId={user.id} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="qualification" icon="Crosshair" currentUserId={user.id as number} />
</div>
</div>
);
}

View file

@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
import { Radio } from "lucide-react";
import { RadioArena } from "@/components/frontend/minigames/radio/RadioArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "Radio Traffic (Polaris Task Force)",
@ -81,11 +80,6 @@ export default async function RadioPage() {
</div>
<RadioArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="radio" icon="Radio" currentUserId={user.id as number} />
</div>
</div>
);
}

View file

@ -0,0 +1,40 @@
"use client";
import { ChevronDown, History } from "lucide-react";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import { cn } from "@/lib/utils";
export interface AllTimeLeaderboardProps {
children: React.ReactNode;
className?: string;
}
/**
* Collapsed container for a game's lifetime board. The period standings stay
* the primary surface on the game page; the all-time board is opt-in.
*/
export function AllTimeLeaderboard({ children, className }: AllTimeLeaderboardProps) {
return (
<Collapsible className={cn("w-full max-w-[520px]", className)}>
<CollapsibleTrigger asChild>
<button
type="button"
className="group flex w-full items-center gap-2 rounded-xl border border-border bg-card px-4 py-3 text-left text-sm font-semibold text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground"
>
<History className="size-4" aria-hidden="true" />
<span>All-time leaderboard</span>
<span className="ml-auto text-xs font-normal group-data-[state=open]:hidden">Expand</span>
<span className="ml-auto hidden text-xs font-normal group-data-[state=open]:inline">
Collapse
</span>
<ChevronDown
className="size-4 transition-transform group-data-[state=open]:rotate-180"
aria-hidden="true"
/>
</button>
</CollapsibleTrigger>
<CollapsibleContent className="pt-2">{children}</CollapsibleContent>
</Collapsible>
);
}

View file

@ -1,6 +1,5 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { Trophy } from "lucide-react";
@ -22,9 +21,9 @@ export interface PeriodStandingsCardProps {
}
/**
* Period-scoped standings for a single game, embedded on the game page. Defaults
* to the current period and offers an All-Time toggle; the full multi-board view
* lives at /minigames/leaderboards.
* Current-period standings for a single game, embedded on the game page. The
* game's lifetime board sits below it in a collapsed all-time section; the full
* multi-board view lives at /minigames/leaderboards.
*/
export function PeriodStandingsCard({
gameKey,
@ -34,12 +33,13 @@ export function PeriodStandingsCard({
presence,
className,
}: PeriodStandingsCardProps) {
const [view, setView] = useState<"period" | "all-time">("period");
const { data, failed, loading } = useLeaderboards(view === "all-time" ? "all-time" : "current", refreshKey);
const { data, failed, loading } = useLeaderboards("current", refreshKey);
const board = data?.boards.find((entry) => entry.key === gameKey) ?? null;
const Icon = minigameIcon(icon ?? board?.icon);
const isAllTime = view === "all-time";
const presenceNoun = presence?.noun ?? "operator";
const presenceLabel =
presence && presence.participants.length === 1 ? presenceNoun : `${presenceNoun}s`;
return (
<div className={cn("w-full max-w-[420px] rounded-xl border border-border bg-card", className)}>
@ -48,43 +48,27 @@ export function PeriodStandingsCard({
<Icon className="size-4 text-muted-foreground" />
<h2 className="truncate text-sm font-semibold">{board?.label ?? "Standings"}</h2>
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
{isAllTime ? "All-Time" : (data?.period?.label ?? "No active period")}
{data?.period?.label ?? "No active period"}
</span>
</div>
<div className="flex items-center gap-1 border-b border-border px-2 py-1.5">
<button
type="button"
onClick={() => setView("period")}
className={cn(
"rounded-md px-2.5 py-1 text-xs font-medium",
!isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
)}
>
This period
</button>
<button
type="button"
onClick={() => setView("all-time")}
className={cn(
"rounded-md px-2.5 py-1 text-xs font-medium",
isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
)}
>
All-Time
</button>
<div className="flex items-center gap-2 border-b border-border px-4 py-2 text-xs text-muted-foreground">
<span>Best run this period · placement points</span>
<Link
href={`/minigames/leaderboards?game=${gameKey}`}
className="ml-auto py-1 pr-1 text-xs text-muted-foreground hover:text-foreground"
className="ml-auto shrink-0 py-1 text-xs text-muted-foreground hover:text-foreground"
>
All boards
</Link>
</div>
{presence && !isAllTime && (
<div className="border-b border-border px-4 py-2 text-xs text-muted-foreground" aria-live="polite">
{presence && (
<div
className="border-b border-border px-4 py-2 text-xs text-muted-foreground"
aria-live="polite"
>
<span className="font-medium text-emerald-400">{presence.participants.length}</span>{" "}
{presence.participants.length === 1 ? `${presence.noun ?? "operator"} is` : `${presence.noun ?? "operators"} are`} active now
{presenceLabel} {presence.participants.length === 1 ? "is" : "are"} active now
{presence.participants.length > 0 && (
<span className="ml-1 text-foreground">
({presence.participants.map((participant) => participant.name).join(", ")})
@ -106,8 +90,8 @@ export function PeriodStandingsCard({
rows={board?.rows ?? []}
scoreLabel={board?.scoreLabel ?? "Score"}
currentUserId={currentUserId}
showPoints={!isAllTime}
emptyLabel={isAllTime ? "No all-time runs yet." : "No runs this period yet. Be the first!"}
showPoints
emptyLabel="No runs this period yet. Be the first!"
/>
)}
</div>

View file

@ -7,6 +7,8 @@ import type {
} from "@/app/(frontend)/minigames/call-for-fire/actions";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { useSidebar } from "@/components/ui/sidebar";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { CallForFireLeaderboard } from "./CallForFireLeaderboard";
import { FireMissionBoard } from "./FireMissionBoard";
@ -38,13 +40,23 @@ export function CallForFireArena({
onPhaseChange={onPhaseChange}
onDifficultyChange={setSelectedDifficulty}
/>
<CallForFireLeaderboard
<PeriodStandingsCard
gameKey="callForFire"
icon="Target"
refreshKey={refreshKey}
currentUserId={currentUserId}
activeTeams={activeTeams}
difficulty={selectedDifficulty}
onDifficultyChange={setSelectedDifficulty}
presence={{ participants: activeTeams, noun: "team" }}
className="max-w-[520px]"
/>
<AllTimeLeaderboard>
<CallForFireLeaderboard
refreshKey={refreshKey}
currentUserId={currentUserId}
activeTeams={activeTeams}
difficulty={selectedDifficulty}
onDifficultyChange={setSelectedDifficulty}
/>
</AllTimeLeaderboard>
</div>
);
}

View file

@ -5,6 +5,8 @@ import type { EodDifficulty, EodStats } from "@/app/(frontend)/minigames/eod/act
import { isEodUnlocked } from "@/lib/minigames/custom/eod";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { useSidebar } from "@/components/ui/sidebar";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
import { EodLeaderboard } from "./EodLeaderboard";
@ -64,13 +66,23 @@ export function EodArena({
onPhaseChange={onPhaseChange}
onDifficultyChange={setSelectedDifficulty}
/>
<EodLeaderboard
<PeriodStandingsCard
gameKey="eod"
icon="Bomb"
refreshKey={refreshKey}
currentUserId={currentUserId}
activeTeams={activeTeams}
difficulty={selectedDifficulty}
onDifficultyChange={setSelectedDifficulty}
presence={{ participants: activeTeams, noun: "team" }}
className="max-w-[520px]"
/>
<AllTimeLeaderboard>
<EodLeaderboard
refreshKey={refreshKey}
currentUserId={currentUserId}
activeTeams={activeTeams}
difficulty={selectedDifficulty}
onDifficultyChange={setSelectedDifficulty}
/>
</AllTimeLeaderboard>
</div>
);
}

View file

@ -3,6 +3,8 @@
import { useCallback, useState } from "react";
import type { FlappyStats } from "@/app/(frontend)/minigames/flappy/actions";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { FlappyBird } from "./FlappyBird";
import { FlappyLeaderboard } from "./FlappyLeaderboard";
@ -24,7 +26,16 @@ export function FlappyArena({
return (
<div className="flex flex-col items-center gap-6">
<FlappyBird initialStats={initialStats} onGameRecorded={() => setRefreshKey((k) => k + 1)} onPhaseChange={onPhaseChange} />
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
<PeriodStandingsCard
gameKey="flappy"
icon="Bird"
refreshKey={refreshKey}
currentUserId={currentUserId}
presence={{ participants: activePilots, noun: "pilot" }}
/>
<AllTimeLeaderboard className="max-w-[420px]">
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
</AllTimeLeaderboard>
</div>
);
}

View file

@ -6,6 +6,8 @@ import { OPORD_DIFFICULTIES, type OpordDifficulty } from "@/lib/minigames/opord-
import type { OpordStats } from "@/app/(frontend)/minigames/opord/actions";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { useSidebar } from "@/components/ui/sidebar";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { cn } from "@/lib/utils";
@ -158,12 +160,22 @@ export function OpordArena({
</CardContent>
</Card>
<OpordLeaderboard
<PeriodStandingsCard
gameKey="opord"
icon="FileTextIcon"
refreshKey={refreshKey}
difficulty={difficulty}
currentUserId={currentUserId}
activeOperators={activeOperators}
presence={{ participants: activeOperators, noun: "operator" }}
className="max-w-3xl"
/>
<AllTimeLeaderboard className="max-w-3xl">
<OpordLeaderboard
refreshKey={refreshKey}
difficulty={difficulty}
currentUserId={currentUserId}
activeOperators={activeOperators}
/>
</AllTimeLeaderboard>
</div>
);
}

View file

@ -10,6 +10,8 @@ import {
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { useSidebar } from "@/components/ui/sidebar";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { cn } from "@/lib/utils";
@ -170,12 +172,22 @@ export function AimTrainerArena({
</CardContent>
</Card>
<AimTrainerLeaderboard
<PeriodStandingsCard
gameKey="qualification"
icon="Crosshair"
refreshKey={refreshKey}
difficulty={difficulty}
currentUserId={currentUserId}
activeTrainees={activeTrainees}
presence={{ participants: activeTrainees, noun: "trainee" }}
className="max-w-3xl"
/>
<AllTimeLeaderboard className="max-w-3xl">
<AimTrainerLeaderboard
refreshKey={refreshKey}
difficulty={difficulty}
currentUserId={currentUserId}
activeTrainees={activeTrainees}
/>
</AllTimeLeaderboard>
</div>
);
}

View file

@ -8,6 +8,8 @@ import {
WATCH_ACCURACY_REQUIREMENT,
} from "@/lib/minigames/custom/radio";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
import { RadioLeaderboard } from "./RadioLeaderboard";
@ -90,13 +92,23 @@ export function RadioArena({
<li>The lifetime leaderboard ranks Top Score, Top Accuracy, Fastest Sprint, and Most Messages.</li>
</ul>
</div>
<RadioLeaderboard
<PeriodStandingsCard
gameKey="radio"
icon="Radio"
refreshKey={refreshKey}
mode={mode}
modeHydrated={modeHydrated}
currentUserId={currentUserId}
activeOperators={activeOperators}
presence={{ participants: activeOperators, noun: "operator" }}
className="max-w-[520px]"
/>
<AllTimeLeaderboard>
<RadioLeaderboard
refreshKey={refreshKey}
mode={mode}
modeHydrated={modeHydrated}
currentUserId={currentUserId}
activeOperators={activeOperators}
/>
</AllTimeLeaderboard>
</div>
);
}

View file

@ -12,6 +12,7 @@ Five XP-earning minigames under one parent: routes live at `/minigames/*` (moved
- **Call for Fire: Versus (multiplayer)**: `/minigames/call-for-fire-versus`, category `multiplayer` (out of periods). Pure engine in `src/lib/minigames/call-for-fire-versus/` (`engine.ts`, `views.ts`, `types.ts`, `constants.ts`; client-safe) plus a server-only in-memory match registry in `registry.ts` (mirrors `blackjack/tables.ts`: `globalThis`-anchored Map, lobby, per-turn timeout, expiry sweep, SINGLE-INSTANCE ONLY). Each player hides a FOB fleet, then alternates fire corrections (first shot is a grid designation, later shots adjust from the last impact). `views.ts` builds per-viewer snapshots that never serialize the opponent's fleet. Client polls `fetchVersusMatch` (the in-memory SSE bus is unreliable across dev module copies, same as blackjack). Rewards on completion via `stats.ts` (`minigame:call-for-fire-versus`, profile group `callForFireVersus`).
- **Ordnance Disposal (multiplayer, real-time)**: `/minigames/bomperator` (internal key `bomperator`, label "Ordnance Disposal"), category `multiplayer` (out of periods), a 2-8 player free-for-all Bomberman-style charge-clearing drill. Same pure-engine + in-memory-registry split as CFF versus, but upgraded from turn-based to a **fixed ~20 Hz tick loop** (was ~10 Hz until v0.12.3; every tick-denominated constant doubles with the rate so real-world durations stay identical): `src/lib/minigames/bomperator/{constants,types,engine,views}.ts` are pure/client-safe (seeded RNG via `state.rngState`/`gridSeed`; `generateGrid`, `createMatchState`, `startRound`, `applyInput`, `tick`), and `registry.ts` runs one `setInterval(TICK_MS)` per live match (started on `startMatch`, cleared on complete/dissolve; `globalThis.__bomperatorMatches`; SINGLE-INSTANCE ONLY: a restart/redeploy kills live matches). Grid is 15x13 (border + even/even pillars + seeded crates with one hidden power-up each; four classic pickups bomb/range/speed/kick). Movement is grid-locked with sub-cell interpolation; charges fuse ~2.5s, cross-flames stop at walls, destroy crates, chain-detonate, and kick-push; round ends at <=1 alive; sudden death spawns random-cell explosions after the 150s timer, with a draw guard. FFA has no hidden info so `buildBomperatorView` serves every viewer the same board (`yourSeat: null` = spectator). Clients POST inputs (`sendBomperatorInput`, rate-limited 40/s) and poll `fetchBomperatorMatch` (~500ms fallback behind the SSE stream); a rolling event buffer (monotonic ids) drives client SFX without diffing. Disconnects hold the seat for `RECONNECT_WINDOW_MS` then eliminate; below two active seats the match dissolves. Rewards on completion via `stats.ts` (`minigame:bomperator`, profile group `bomperator`: matchesPlayed/matchWins/roundsWon/kills/xpEarned; XP win/loss base + per-kill bounty, chips auto-derived). Registry row ships `status: "upcoming"` (page renders `MinigameComingSoon` until an admin flips it active).
- **Client prediction & correction**: `BomperatorGame.tsx` predicts its own seat between snapshots and reconciles with a lead-aware envelope policy (helpers in `bomperator/prediction.ts`): gaps inside `max(PRED_DEADZONE, speed*(rttAvg/2 + TICK_MS/2 + PRED_ENVELOPE_BUDGET_MS)/1000)` ride untouched, anything beyond is trimmed on EVERY snapshot, and gaps past 2.5 cells ease toward the estimate at up to 2.5x run speed instead of teleporting (round resets still snap via the ack-backwards branch). Root cause of the old teleport-back: Node event-loop stalls make the server's 20Hz tick loop DROP setInterval callbacks (no catch-up), so the sim permanently lags wall clock; the old all-inputs-acked pull let that gap stack and discharge at once. `tests/int/bomperator-prediction.int.spec.ts` is an offline deterministic harness (real engine + modeled network + frame-by-frame reconcile mirror) including production-latency replay (`tests/fixtures/bomperator-prod-rtt.json`, from HAR) and a server-stall A/B proof; change client prediction in BOTH component and mirror, and run the trace scenarios before shipping. v0.12.4 lesson (reverted in v0.12.5): do not add mechanisms that trust precise latency estimates (decision nudges, projected ghost placement); real TTFB swings 31-463ms and they glitch under it.
- **Arena transport (WebSocket match replication)**: when `NEXT_PUBLIC_ARENA_URL` is baked into the bundle, the client tries a dedicated arena process first (`src/arena/`, Node 22 + `ws`, Coolify service #2, Docker target `runner-arena`): its own event loop runs the 20 Hz tick via a drift-corrected `setTimeout` chain (capped catch-up, `tick-drift` log every 30s), inputs/snapshots ride one socket (`src/arena/protocol.ts`), and RTT comes from 2s ping/pong instead of POST timing. Transport selection lives in `components/frontend/minigames/bomperator/transport.ts`: WS first, automatic fallback to the unchanged HTTP path (registry actions + SSE + slow poll) after 2 connection failures or a 5s setup timeout; absent `NEXT_PUBLIC_ARENA_URL` = pure HTTP (kill switch/rollback). Server side, `ARENA_SECRET` + `ARENA_INTERNAL_URL` make the bomperator actions proxy the lifecycle to the arena (match ownership moves); the arena holds NO Payload dependency: auth is 30s jose tickets `{uid, matchId, iat}` minted by `createArenaTicket` (query string on the WS handshake; no replay store by design), awards go back through `POST /api/minigames/bomperator/results` (secret header, idempotent by matchId). **Restarting the arena kills live matches** (process memory, like the SSE bus before it; acceptable for ~90s matches). The seq/lastInputSeq pending ledger and envelope reconcile work over both transports; the prediction harness pins the low-latency end too ("ws-grade latency" scenario).
- **Mobile / touch input**: `BomperatorTouchControls.tsx` renders a D-pad (+ stop) and plant button on coarse pointers only (`(pointer: coarse)`); the board itself accepts swipes (dominant-axis cardinal, sets direction) and taps (stop). ALL input sources feed the same `pressDir`/`releaseDir`/`stopAll` edge callbacks in `BomperatorGame.tsx` that keyboard uses, so prediction/keepalive/pending logic stays source-agnostic; held-stack priority makes D-pad + swipe coexist. Canvas is CSS-scaled (`w-full h-auto`, max 520px wrapper) with fixed internal resolution. Backgrounded-tab safety is harness-proven ("backgrounded tab" scenario: 4s rAF freeze under prod trace replay, teleports=0). E2E smoke: `tests/e2e/bomperator-mobile.e2e.spec.ts` (phone viewport, no horizontal overflow); run with `E2E_BROWSER_PATH=<playwright chromium>` when Vivaldi crashes.
- Leaderboards match active players by user id (not display name) — see commit 72715c4 if leaderboard queries look wrong.
@ -49,8 +50,10 @@ code; the invariants are:
uses core games with `countsForPeriods`; `loadMinigameRegistry` falls back to
`BUILTIN_MINIGAMES` if the collection is empty.
- **Surfaces**: `/minigames/leaderboards` (period selector + game tabs + achievements honor roll,
fed by `GET /api/minigames/leaderboards?period=current|<id>|all-time`) and a `PeriodStandingsCard`
on each Core game page. All-Time reads the untouched `profiles.progression.minigames.*` bests.
fed by `GET /api/minigames/leaderboards?period=current|<id>|all-time`) and, on each Core game
page, a current-period `PeriodStandingsCard` as the primary board with the game's all-time board
below it inside a collapsed `AllTimeLeaderboard` disclosure. All-Time reads the untouched
`profiles.progression.minigames.*` bests.
- **Notifications**: winners are notified in-app on close (`minigame:achievement`, muteable);
the Discord bot service `src/bot/services/achievementAnnouncements.ts` posts ONE embed per
window to `DISCORD_ANNOUNCE_CHANNEL_ID` and stamps `announcedAt` + `discordMessageId`.

View file

@ -0,0 +1,25 @@
import { MigrateDownArgs, MigrateUpArgs, sql } from "@payloadcms/db-postgres";
/**
* The per-prompt model override no longer carries a hardcoded default. An empty
* value falls back to the UNSLOTH_MODEL environment variable at request time.
* Clear the previously seeded value so the env var takes effect; rows an admin
* deliberately set to a different model are left alone.
*/
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "plugin_ai_instructions" ALTER COLUMN "ornith_9b_settings_model" DROP DEFAULT;
UPDATE "plugin_ai_instructions"
SET "ornith_9b_settings_model" = NULL
WHERE "ornith_9b_settings_model" = 'unsloth/Ornith-1.0-9B-GGUF';
`);
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "plugin_ai_instructions" ALTER COLUMN "ornith_9b_settings_model" SET DEFAULT 'unsloth/Ornith-1.0-9B-GGUF';
UPDATE "plugin_ai_instructions"
SET "ornith_9b_settings_model" = 'unsloth/Ornith-1.0-9B-GGUF'
WHERE "ornith_9b_settings_model" IS NULL;
`);
}

View file

@ -141,6 +141,7 @@ import * as migration_20261014_192950_add_npc_dialogue_states from './20261014_1
import * as migration_20261014_203529_add_event_log_discord_fields from './20261014_203529_add_event_log_discord_fields';
import * as migration_20261015_120000_add_bomperator_minigame_stats from './20261015_120000_add_bomperator_minigame_stats';
import * as migration_20261019_120000_add_ai_prompt_entity_context from './20261019_120000_add_ai_prompt_entity_context';
import * as migration_20261019_121500_use_env_ai_model from './20261019_121500_use_env_ai_model';
export const migrations = [
{
@ -858,4 +859,9 @@ export const migrations = [
down: migration_20261019_120000_add_ai_prompt_entity_context.down,
name: '20261019_120000_add_ai_prompt_entity_context'
},
{
up: migration_20261019_121500_use_env_ai_model.up,
down: migration_20261019_121500_use_env_ai_model.down,
name: '20261019_121500_use_env_ai_model'
},
];

View file

@ -8128,9 +8128,7 @@ export const plugin_ai_instructions = pgTable(
layout: varchar("layout").default(
'[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: "Quote text." - Author Name',
),
"ornith-9b-settings_model": varchar("ornith_9b_settings_model").default(
"unsloth/Ornith-1.0-9B-GGUF",
),
"ornith-9b-settings_model": varchar("ornith_9b_settings_model"),
updatedAt: timestamp("updated_at", { mode: "string", withTimezone: true, precision: 3 })
.defaultNow()
.notNull(),

View file

@ -121,7 +121,19 @@ const unslothProvider = createOpenAI({
baseURL: process.env.UNSLOTH_URL || "http://192.168.1.7:8888/v1",
});
const DEFAULT_MODEL = "unsloth/Ornith-1.0-9B-GGUF";
// The model-id select and its Postgres enum use a stable internal key. Changing
// that key requires a migration, so the served model is configured separately:
// point UNSLOTH_MODEL at the GGUF loaded in Unsloth Studio.
const MODEL_ID = "unsloth/Ornith-1.0-9B-GGUF";
const DEFAULT_MODEL = process.env.UNSLOTH_MODEL || MODEL_ID;
// Dropdown label for the model. UNSLOTH_MODEL_NAME wins; otherwise derive a
// readable name from UNSLOTH_MODEL, falling back to the bundled Ornith label.
const prettifyModel = (id: string) =>
(id.split("/").pop() || id).replace(/[-_]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
const MODEL_LABEL =
process.env.UNSLOTH_MODEL_NAME ||
(process.env.UNSLOTH_MODEL ? prettifyModel(process.env.UNSLOTH_MODEL) : "Ornith 1.0 9B");
// Ornith is a reasoning model: it emits a long `reasoning_content` block before
// the actual answer, and with a small token budget the reasoning consumes the
@ -773,8 +785,8 @@ export default buildConfig({
},
generationModels: [
{
id: "unsloth/Ornith-1.0-9B-GGUF",
name: "Ornith 1.0 9B",
id: MODEL_ID,
name: MODEL_LABEL,
fields: ["text", "textarea", "richText"],
handler: async (
prompt: string,
@ -851,18 +863,20 @@ export default buildConfig({
type: "group",
admin: {
condition(data) {
return data["model-id"] === "unsloth/Ornith-1.0-9B-GGUF";
return data["model-id"] === MODEL_ID;
},
},
fields: [
{
name: "model",
type: "text",
defaultValue: DEFAULT_MODEL,
admin: {
description: "Leave blank to use the UNSLOTH_MODEL environment variable.",
},
label: "Model",
},
],
label: "Ornith 9B Settings",
label: `${MODEL_LABEL} Settings`,
},
},
],

View file

@ -2,8 +2,8 @@ import { expect, test } from "@playwright/test";
/**
* Smoke coverage for the unified minigames leaderboards: the period view, the
* All-Time switch (which also reveals the cardtable games) and the inline period
* standings card on a game page.
* All-Time switch (which also reveals the cardtable games) and the period
* standings card plus collapsed all-time board on a game page.
*/
test.describe("Minigame leaderboards", () => {
test.beforeEach(async ({ page }) => {
@ -37,12 +37,21 @@ test.describe("Minigame leaderboards", () => {
await expect(page.getByRole("tab", { name: "Blackjack" })).toBeVisible();
});
test("a game page shows its anchored period standings card", async ({ page }) => {
test("a game page centers period standings with all-time collapsed", async ({ page }) => {
await page.goto("/minigames/flappy");
await expect(
page.getByRole("heading", { level: 2, name: "Anchored period standings" }),
).toBeVisible();
await expect(page.getByRole("link", { name: "All boards" })).toBeVisible();
const allTime = page.getByRole("button", { name: /All-time leaderboard/ });
await expect(allTime).toBeVisible();
await expect(allTime).toHaveAttribute("data-state", "closed");
await expect(page.getByText("Flight Simulator Leaderboard")).toHaveCount(0);
// The dev-server first navigation can hydrate slowly, so retry the toggle
// until the collapsed board actually mounts.
await expect(async () => {
await allTime.click();
await expect(page.getByText("Flight Simulator Leaderboard")).toBeVisible({ timeout: 1000 });
}).toPass({ timeout: 20_000 });
});
});