Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([issue-2932]): autocomplete sprite picker + character/place/object taxonomy
[._.]/ Adam Eivyaa31bf515e24
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 43f195b3c2..34171b47f0 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,6 +7,7 @@## Sprite Manager+- **[issue-2932] Search the sprite library, and organize it by character / place / object** — the Sprites sidebar used to dump every record as a flat wall of names under just two buckets ("Characters" and "Props"), so a standalone place or object had nowhere to live and a big library was hard to scan. It now leads with a labelled autocomplete search box: type any part of a name, id, or kind and it narrows to a bounded, keyboard-navigable suggestion list (↑/↓ to move, Enter to open, Esc to clear); the full list is one click away behind a **Browse all** disclosure. Records group under **Characters**, **Places**, and **Objects**, and the New button (now **New Sprite**) lets you pick which of those three you're creating. Existing imported prop-atlas families keep working unchanged — they simply show under Objects alongside standalone objects. The reference / walk / publish workflows remain character-only.- **[issue-2931] A character's assets now group by what they are, and you can act on them in place** — the asset browser used to be a flat dump grouped by folder name (`reference`, `grok`, `runtime`), with every tile inert. Assets are now grouped by their actual role — reference set, strips, animations, frames, atlases, review evidence, manifests — and each one carries a status badge (runtime · approved · candidate · superseded · rejected · source), so you can see at a glance which reference version is current and which have been replaced. Walk strips, frames and animations gain two buttons: **Regenerate**, which re-runs that direction's render, and **Edit in Loop Trimmer**, which jumps straight to the trimmer for that run — including for a direction you've already approved, since trims are saved separately and never overwrite the approved artwork. Regenerate is correctly greyed out when the walk set is finalized, when the direction is already approved, when its reference anchor isn't locked yet, or while a render for it is already running — and it now shares one in-flight view with the workflow panels above, so starting a render in one place immediately disables it in the other instead of letting you pay for the same render twice. An unlocked reference candidate can be re-rolled the same way. Switching between characters no longer carries a stale "Rendering…" state across from the previous one.- **[issue-2930] Sprites is now its own page, and assets are properly inspectable** — the Sprite Manager was a hidden tab inside Media Gen; it now has its own **Sprites** entry in the Create sidebar and lives at its own address, so it's directly linkable, bookmarkable, and reachable from ⌘K and voice. Old Media Gen sprite links (including links to a specific sprite) redirect to the new page and keep any deep-link state. Every surface that shows a transparent sprite — asset thumbnails, the reference set, walk-loop previews, trim results, and the compiled atlas — now paints a checkerboard behind the artwork, so a cut-out region is finally distinguishable from a black pixel instead of both reading as the same dark rectangle. Clicking any asset opens a real inspector: a pixel-perfect preview over that checkerboard, plus the file's path, dimensions, format, frame count, size, and last-modified time, with Download and Copy-path buttons. Non-image files (manifests, sidecars) open there too instead of silently downloading. An asset PortOS can't read — a truncated PNG, say — now shows its basic details rather than breaking the whole page.- **[issue-2928] Show walk previews for every imported run layout, not just one** — the walk viewer found a character's animation runs by looking in a single fixed folder, so an imported character whose source pipeline filed its runs elsewhere showed the same blank "approved ✓" card that #2924 just fixed for redraw directions. Each approved direction is now looked up by where its own approval record says its run lives, so any layout the importer produces animates. Unapproved candidates and in-flight generations still appear as before.diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex c1a14e5930..ab3eaf6259 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -138,6 +138,7 @@ grep -i "what you want to do" client/src/lib/README.md| `songProgress.js` | Pure training-progress core for the song system's memorize/learn/track mode. `deriveTrainingSections(score, lyricSections?)` slices a lead-sheet score into blank-line-separated trainable sections (each a self-contained header+block score, positional stable id, lyric-matched label); `recordAttempt(progress, scope, summary)` appends a graded take to a scope's bounded rolling history (drops zero-note takes); `scopeStats(progress, scope)`/`wholeSongStats` derive `{ attempts, best, average, last, streak, learned }` (learned = streak of ≥`LEARNED_PERCENT` takes ≥`LEARNED_STREAK`); `weakestSections(progress, sections)` ranks weak/un-attempted sections for spaced-repetition; `memorizationPercent` is the learned-section share; `hideLevelFor(average)` maps a rolling average to a progressive lyric/note-hiding level (`show`/`dim`/`hide`/`blind`). No React/audio — `useSongTraining` drives it. || `spriteCollectionActions.js` | Gating for the Sprite Manager asset collection's inline actions (#2931). `buildCollectionActions({ detail, walkPending, referencePending, generateWalk, generateAnchor, onRequestTrim })` → `{ regenerateFor(asset), trimFor(asset) }`, each returning `null` for an asset it can't act on. Regenerate mirrors the authoritative workflow surfaces exactly — a walk direction is regenerable only when its anchor is locked, the direction isn't approved, the walk set isn't finalized and no render is in flight; a reference anchor only while it's an unlocked candidate (`south`/main is excluded, since it needs a design prompt or upload). Trim is offered only for a run that actually packed a strip (the trim endpoint 409s otherwise). Pure — takes callbacks, performs no I/O. Consumes the facets from `spriteFacets.js`. || `spriteFacets.js` | Client-side facet classifier for the Sprite Manager's asset collection (#2931), mirroring the source pipeline's `classify_asset()`. `classifySpriteAsset(path)` decodes a record-relative asset path into `{ family, status, role, direction, runId }` — `status ∈ runtime/approved/candidate/superseded/rejected/source`, `role ∈ reference/strip/animation/frame/atlas/evidence/sprite/manifest` — and is total (an unknown path degrades to `sprite`/`source` rather than throwing). `classifySpriteAssets(assets)` adds the one facet only knowable across a listing: an approved asset below the highest `-vN` of its stem becomes `superseded`. `groupSpriteAssetsByRole(assets)` returns render-ready `{ role, label, assets }` sections in `SPRITE_ASSET_ROLES` order. Also exports `SPRITE_DIRECTIONS` (mirror of `server/services/sprites/prompts.js`) — the `direction`/`runId` facets are what drive the collection's Regenerate and Edit-in-Loop-Trimmer actions. Pure — no React, no I/O. |+| `spriteRecordGroups.js` | Grouping + search for the Sprite Manager sidebar's record picker (#2932). `groupSpriteRecords(records)` → ordered `[{ key, label, records }]` under **Characters / Places / Objects** (`props` folded into Objects alongside `object`, no migration). `filterSpriteRecords(records, query, limit=8)` is the autocomplete filter — multi-term (AND) substring over `name`/`id`/`kind`, capped at `limit`. `groupKeyForKind(kind)` maps a kind to its group key (unknown → `objects`). `SPRITE_RECORD_GROUPS` / `NEW_SPRITE_KINDS` back the browse disclosure and the create-panel kind selector. Pure — no React, no I/O; the page owns the per-group icons. || `tribe.js` | Pure Tribe domain helpers shared by the Tribe page and its `TribeCircleMap` visualization: `RINGS` (support→core→tribe→village Dunbar rings + the uncapped `external` "outside the tribe" classification — caps, cadence defaults, Tailwind tones + `hex`), `TRIBE_RINGS` (the four inner rings the care queue/capacity/overdue counts operate over, excluding `external`), `ENERGY` (energy tiers + `hex`), `STATUS_HEX` (cadence-status → SVG stroke color), `contactStatus(contact)` (presentation wrapper over the shared `cadenceStatus` — attaches label/tone to the missing/overdue/soon/steady/`external` state) / `daysBetween(date)` (alias of the shared `daysSinceDate`), `ringFor` / `energyFor` lookups, `tagsToArray` / `tagsToInput`, and `initialsFor(name)` (node glyph). Ring `cadenceDays` mirror `DEFAULT_RING_CADENCE` in `server/services/tribe.js`; the cadence STATE MACHINE lives in `tribeCadence.js`. || `tribeCadence.js` | Mirror of `server/lib/tribeCadence.js` — the single authoritative Tribe care-cadence rules shared by the page, the Care dashboard widget, and the proactive alert: `cadenceStatus(entity)` → `{ state, daysRemaining, daysOverdue }`, `daysSinceDate(dateStr)`, `DEFAULT_CADENCE_DAYS`, `SOON_WINDOW_DAYS`. A cross-boundary contract test asserts it never drifts from the server copy. || `streakGlyph.js` | `streakGlyph(streak)` — the single POST streak emoji (✨ / ⚡ / 🔥 by day count) shared by the POST launcher, Morse trainer, daily widget, and dashboard streak widget. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex 844535bb6e..c7dda05f3c 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -106,6 +106,7 @@ export * from './songPlayback.js';export * from './songProgress.js';export * from './spriteCollectionActions.js';export * from './spriteFacets.js';+export * from './spriteRecordGroups.js';export * from './streakGlyph.js';export * from './syncCounts.js';export * from './tabNotation.js';diff --git a/client/src/lib/spriteRecordGroups.js b/client/src/lib/spriteRecordGroups.jsnew file mode 100644index 0000000000..b644ef4e44--- /dev/null+++ b/client/src/lib/spriteRecordGroups.js@@ -0,0 +1,76 @@+/**+ * Sprite record grouping + search (#2932) — pure helpers that map a sprite+ * record's `kind` to one of the three noun groups the Sprite Manager sidebar+ * renders, and filter a record list for the autocomplete picker.+ *+ * The `props` kind is a legacy import-only value: it is folded into the+ * **Objects** group alongside `object` so imported prop atlas families need no+ * data migration and stay user-visibly identical to a UI-created object.+ *+ * Pure — no React, no I/O. The sidebar owns the per-group icons (a lib module+ * can't import lucide components without pulling React into the barrel), so the+ * groups carry a stable `key` the page maps to an icon.+ */++// Render order of the three noun groups. Each maps one or more record `kind`+// values; `object` and the legacy `props` share the Objects group.+export const SPRITE_RECORD_GROUPS = [+ { key: 'characters', label: 'Characters', kinds: ['character'] },+ { key: 'places', label: 'Places', kinds: ['place'] },+ { key: 'objects', label: 'Objects', kinds: ['object', 'props'] },+];++// The kinds a user can create through the New Sprite panel — `props` is+// import-only and never offered here.+export const NEW_SPRITE_KINDS = [+ { value: 'character', label: 'Character' },+ { value: 'place', label: 'Place' },+ { value: 'object', label: 'Object' },+];++const KIND_TO_GROUP = new Map();+for (const group of SPRITE_RECORD_GROUPS) {+ for (const kind of group.kinds) KIND_TO_GROUP.set(kind, group.key);+}++// An unknown/legacy kind lands in Objects rather than vanishing from the+// sidebar — the same fold that keeps `props` visible protects any future+// stray value until it gets its own group.+export function groupKeyForKind(kind) {+ return KIND_TO_GROUP.get(kind) || 'objects';+}++/**+ * Group records into the ordered noun groups, preserving each record's+ * incoming order within its group. Empty groups are omitted. Returns+ * `[{ key, label, records }]`.+ */+export function groupSpriteRecords(records) {+ const byKey = new Map();+ for (const record of Array.isArray(records) ? records : []) {+ const key = groupKeyForKind(record?.kind);+ const list = byKey.get(key);+ if (list) list.push(record); else byKey.set(key, [record]);+ }+ return SPRITE_RECORD_GROUPS+ .filter((g) => byKey.has(g.key))+ .map((g) => ({ key: g.key, label: g.label, records: byKey.get(g.key) }));+}++/**+ * Multi-term substring filter over a record's `name`, `id`, and `kind`. Every+ * whitespace-separated term must match somewhere (AND semantics) so "hero+ * place" narrows rather than widening. An empty/whitespace query returns the+ * list unchanged. The result is capped at `limit` (default 8) so the+ * suggestion list stays bounded regardless of library size.+ */+export function filterSpriteRecords(records, query, limit = 8) {+ const list = Array.isArray(records) ? records : [];+ const terms = String(query || '').toLowerCase().split(/\s+/).filter(Boolean);+ if (terms.length === 0) return list.slice(0, limit);+ const matches = list.filter((record) => {+ const haystack = `${record?.name || ''} ${record?.id || ''} ${record?.kind || ''}`.toLowerCase();+ return terms.every((term) => haystack.includes(term));+ });+ return matches.slice(0, limit);+}diff --git a/client/src/lib/spriteRecordGroups.test.js b/client/src/lib/spriteRecordGroups.test.jsnew file mode 100644index 0000000000..d511fbe4e8--- /dev/null+++ b/client/src/lib/spriteRecordGroups.test.js@@ -0,0 +1,83 @@+import { describe, it, expect } from 'vitest';+import {+ groupSpriteRecords,+ filterSpriteRecords,+ groupKeyForKind,+ SPRITE_RECORD_GROUPS,+ NEW_SPRITE_KINDS,+} from './spriteRecordGroups.js';++const RECORDS = [+ { id: 'pioneer', name: 'Pioneer', kind: 'character', status: 'draft' },+ { id: 'saloon', name: 'Dusty Saloon', kind: 'place', status: 'imported' },+ { id: 'lantern', name: 'Lantern', kind: 'object', status: 'draft' },+ { id: 'crates', name: 'Crate Family', kind: 'props', status: 'imported' },+];++describe('groupKeyForKind', () => {+ it('maps each kind to its noun group, folding props into objects', () => {+ expect(groupKeyForKind('character')).toBe('characters');+ expect(groupKeyForKind('place')).toBe('places');+ expect(groupKeyForKind('object')).toBe('objects');+ expect(groupKeyForKind('props')).toBe('objects');+ });++ it('parks an unknown/legacy kind in objects rather than dropping it', () => {+ expect(groupKeyForKind('mystery')).toBe('objects');+ expect(groupKeyForKind(undefined)).toBe('objects');+ });+});++describe('groupSpriteRecords', () => {+ it('groups under Characters / Places / Objects in render order', () => {+ const groups = groupSpriteRecords(RECORDS);+ expect(groups.map((g) => g.label)).toEqual(['Characters', 'Places', 'Objects']);+ });++ it('folds legacy props records into Objects alongside object (#2932 regression)', () => {+ const objects = groupSpriteRecords(RECORDS).find((g) => g.key === 'objects');+ expect(objects.records.map((r) => r.id)).toEqual(['lantern', 'crates']);+ });++ it('omits empty groups', () => {+ const groups = groupSpriteRecords([{ id: 'a', name: 'A', kind: 'character' }]);+ expect(groups.map((g) => g.key)).toEqual(['characters']);+ });++ it('tolerates a non-array input', () => {+ expect(groupSpriteRecords(null)).toEqual([]);+ });+});++describe('filterSpriteRecords', () => {+ it('returns the (bounded) full list for an empty query', () => {+ expect(filterSpriteRecords(RECORDS, '')).toHaveLength(4);+ expect(filterSpriteRecords(RECORDS, ' ')).toHaveLength(4);+ });++ it('matches multi-term substrings across name/id/kind (AND semantics)', () => {+ expect(filterSpriteRecords(RECORDS, 'dusty').map((r) => r.id)).toEqual(['saloon']);+ // "place" matches only via the kind field+ expect(filterSpriteRecords(RECORDS, 'place').map((r) => r.id)).toEqual(['saloon']);+ // both terms must match somewhere+ expect(filterSpriteRecords(RECORDS, 'crate props').map((r) => r.id)).toEqual(['crates']);+ expect(filterSpriteRecords(RECORDS, 'crate character')).toEqual([]);+ });++ it('caps the suggestion list at the limit', () => {+ const many = Array.from({ length: 20 }, (_, i) => ({ id: `c${i}`, name: `Char ${i}`, kind: 'character' }));+ expect(filterSpriteRecords(many, 'char')).toHaveLength(8);+ expect(filterSpriteRecords(many, 'char', 3)).toHaveLength(3);+ });+});++describe('exported constants', () => {+ it('SPRITE_RECORD_GROUPS covers character/place/object/props exactly once', () => {+ const kinds = SPRITE_RECORD_GROUPS.flatMap((g) => g.kinds);+ expect(kinds.sort()).toEqual(['character', 'object', 'place', 'props']);+ });++ it('NEW_SPRITE_KINDS never offers the import-only props kind', () => {+ expect(NEW_SPRITE_KINDS.map((k) => k.value)).toEqual(['character', 'place', 'object']);+ });+});diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsxindex 7950a6fdfe..1177f455d7 100644--- a/client/src/pages/Sprites.jsx+++ b/client/src/pages/Sprites.jsx@@ -1,6 +1,6 @@import { useEffect, useState, useCallback, useMemo, useRef } from 'react';import { useParams, useNavigate } from 'react-router-dom';-import { PersonStanding, Package, Download, X, RefreshCw, Plus } from 'lucide-react';+import { PersonStanding, MapPin, Package, Download, X, RefreshCw, Plus, ChevronRight, ChevronDown } from 'lucide-react';import toast from '../components/ui/Toast';import {listSpriteRecords, getSpriteRecord, importSprites, createSpriteRecord,@@ -15,8 +15,15 @@ import AssetCollection from '../components/sprites/AssetCollection.jsx';import { useAsyncAction } from '../hooks/useAsyncAction.js';import { useSpritePendingRenders } from '../hooks/useSpritePendingRenders.js';import { buildCollectionActions } from '../lib/spriteCollectionActions.js';+import {+ groupSpriteRecords, filterSpriteRecords, groupKeyForKind, NEW_SPRITE_KINDS,+} from '../lib/spriteRecordGroups.js';import { timeAgo } from '../utils/formatters.js';+// Per-group sidebar icons — the pure grouping lib keys each group; the page+// owns the lucide component mapping so the lib stays React-free.+const GROUP_ICONS = { characters: PersonStanding, places: MapPin, objects: Package };+// Sprite Manager: library over imported production sprites — characters// (reference sets, walk strips, runtime atlases) and props atlas families —// plus the source-tree importer (#2895), the phase-2 reference workflow@@ -127,21 +134,24 @@ function ImportPanel({ onImported }) {);}-function NewCharacterPanel({ onCreated }) {+function NewSpritePanel({ onCreated }) {const [open, setOpen] = useState(false);const [name, setName] = useState('');const [id, setId] = useState('');+ const [kind, setKind] = useState('character');const [create, creating] = useAsyncAction(async () => {const record = await createSpriteRecord({name: name.trim(),+ kind,...(id.trim() ? { id: id.trim() } : {}),}, { silent: true });setOpen(false);setName('');setId('');+ setKind('character');onCreated(record);- }, { errorMessage: 'Failed to create character' });+ }, { errorMessage: 'Failed to create sprite' });if (!open) {return (@@ -149,7 +159,7 @@ function NewCharacterPanel({ onCreated }) {onClick={() => setOpen(true)}className="flex items-center gap-2 px-3 py-1.5 bg-port-card border border-port-border hover:border-port-accent text-gray-300 rounded text-sm">- <Plus className="w-4 h-4" /> New Character+ <Plus className="w-4 h-4" /> New Sprite</button>);}@@ -157,11 +167,29 @@ function NewCharacterPanel({ onCreated }) {return (<div className="w-full bg-port-card border border-port-border rounded-lg p-4 space-y-3"><div className="flex items-center justify-between">- <h3 className="text-sm font-semibold text-white">New character</h3>- <button onClick={() => setOpen(false)} aria-label="Close new character panel" className="text-gray-400 hover:text-white">+ <h3 className="text-sm font-semibold text-white">New sprite</h3>+ <button onClick={() => setOpen(false)} aria-label="Close new sprite panel" className="text-gray-400 hover:text-white"><X className="w-4 h-4" /></button></div>+ <div>+ <label htmlFor="sprite-new-kind" className="block text-xs text-gray-400 mb-1">Kind</label>+ <select+ id="sprite-new-kind"+ value={kind}+ onChange={(e) => setKind(e.target.value)}+ className="w-full bg-port-bg border border-port-border rounded px-3 py-1.5 text-sm text-white"+ >+ {NEW_SPRITE_KINDS.map((k) => (+ <option key={k.value} value={k.value}>{k.label}</option>+ ))}+ </select>+ {kind !== 'character' && (+ <p className="mt-1 text-xs text-gray-600">+ Reference, walk, and publish workflows are character-only — a {kind} holds imported/uploaded assets.+ </p>+ )}+ </div><div><label htmlFor="sprite-new-name" className="block text-xs text-gray-400 mb-1">Name</label><input@@ -223,11 +251,127 @@ function RecordSection({ title, icon: Icon, items, selectedId, onSelect }) {);}-function RecordList({ records, selectedId, onSelect }) {+// Autocomplete record picker (#2932): a labelled combobox that filters the+// library by name/id/kind and navigates on Enter/click, with the full grouped+// list tucked behind a "Browse all" disclosure so the search replaces the+// DEFAULT wall of names, not the ability to browse.+function RecordPicker({ records, selectedId, onSelect }) {+ const [query, setQuery] = useState('');+ const [activeIndex, setActiveIndex] = useState(-1);+ const [browseOpen, setBrowseOpen] = useState(false);+ const inputId = 'sprite-search';+ const listId = 'sprite-search-listbox';++ const suggestions = useMemo(() => filterSpriteRecords(records, query), [records, query]);+ const groups = useMemo(() => groupSpriteRecords(records), [records]);+ const showSuggestions = query.trim().length > 0;++ // A changed query invalidates the highlighted row's index.+ useEffect(() => { setActiveIndex(-1); }, [query]);++ const commit = (record) => {+ if (!record) return;+ onSelect(record.id);+ setQuery('');+ setActiveIndex(-1);+ };++ const onKeyDown = (e) => {+ if (!showSuggestions) return;+ if (e.key === 'ArrowDown') {+ e.preventDefault();+ setActiveIndex((i) => Math.min(i + 1, suggestions.length - 1));+ } else if (e.key === 'ArrowUp') {+ e.preventDefault();+ setActiveIndex((i) => Math.max(i - 1, 0));+ } else if (e.key === 'Enter') {+ e.preventDefault();+ commit(activeIndex >= 0 ? suggestions[activeIndex] : suggestions[0]);+ } else if (e.key === 'Escape') {+ e.preventDefault();+ setQuery('');+ setActiveIndex(-1);+ }+ };++ const activeId = activeIndex >= 0 && suggestions[activeIndex]+ ? `sprite-opt-${suggestions[activeIndex].id}` : undefined;+return (- <div className="space-y-4">- <RecordSection title="Characters" icon={PersonStanding} items={records.filter((r) => r.kind === 'character')} selectedId={selectedId} onSelect={onSelect} />- <RecordSection title="Props" icon={Package} items={records.filter((r) => r.kind !== 'character')} selectedId={selectedId} onSelect={onSelect} />+ <div className="space-y-3">+ <div>+ <label htmlFor={inputId} className="block text-xs text-gray-400 mb-1">Search sprites</label>+ <div className="relative">+ <input+ id={inputId}+ type="search"+ role="combobox"+ aria-expanded={showSuggestions}+ aria-controls={listId}+ aria-autocomplete="list"+ aria-activedescendant={activeId}+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ onKeyDown={onKeyDown}+ placeholder="Filter by name, id, or kind…"+ className="w-full bg-port-bg border border-port-border rounded px-3 py-1.5 text-sm text-white"+ />+ {showSuggestions && (+ <ul+ id={listId}+ role="listbox"+ aria-label="Matching sprites"+ className="absolute z-10 mt-1 w-full max-h-72 overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-lg"+ >+ {suggestions.length === 0 ? (+ <li className="px-3 py-2 text-xs text-gray-500">No matches</li>+ ) : suggestions.map((r, i) => {+ const Icon = GROUP_ICONS[groupKeyForKind(r.kind)] || Package;+ return (+ <li key={r.id} id={`sprite-opt-${r.id}`} role="option" aria-selected={i === activeIndex}>+ <button+ type="button"+ onMouseDown={(e) => { e.preventDefault(); commit(r); }}+ onMouseEnter={() => setActiveIndex(i)}+ className={`w-full flex items-center gap-2 text-left px-3 py-2 text-sm ${i === activeIndex ? 'bg-port-accent/20 text-white' : 'text-gray-300 hover:bg-port-bg'}`}+ >+ <Icon className="w-3.5 h-3.5 shrink-0 text-gray-500" />+ <span className="font-medium truncate">{r.name}</span>+ <span className="ml-auto text-xs text-gray-500 shrink-0">{r.kind}</span>+ </button>+ </li>+ );+ })}+ </ul>+ )}+ </div>+ </div>++ <div>+ <button+ type="button"+ onClick={() => setBrowseOpen((o) => !o)}+ aria-expanded={browseOpen}+ className="flex items-center gap-1.5 text-xs text-gray-400 hover:text-white"+ >+ {browseOpen ? <ChevronDown className="w-3.5 h-3.5" /> : <ChevronRight className="w-3.5 h-3.5" />}+ Browse all ({records.length})+ </button>+ {browseOpen && (+ <div className="mt-2 space-y-4">+ {groups.map((g) => (+ <RecordSection+ key={g.key}+ title={g.label}+ icon={GROUP_ICONS[g.key]}+ items={g.records}+ selectedId={selectedId}+ onSelect={onSelect}+ />+ ))}+ </div>+ )}+ </div></div>);}@@ -375,7 +519,7 @@ export default function Sprites() {</div><div className="flex flex-col md:flex-row gap-4"><aside className="md:w-64 shrink-0 space-y-3">- <NewCharacterPanel onCreated={(record) => { refresh(); navigate(`/sprites/${record.id}`); }} />+ <NewSpritePanel onCreated={(record) => { refresh(); navigate(`/sprites/${record.id}`); }} />{/* Re-import while a sprite is open must refresh the open detail too,not just the sidebar list. */}<ImportPanel onImported={() => { refresh(); if (id) setRetryTick((t) => t + 1); }} />@@ -386,7 +530,7 @@ export default function Sprites() {No sprites yet. Import a production set from a sprite-pipeline checkout to get started.</p>) : (- <RecordList records={records} selectedId={id} onSelect={(rid) => navigate(`/sprites/${rid}`)} />+ <RecordPicker records={records} selectedId={id} onSelect={(rid) => navigate(`/sprites/${rid}`)} />)}</aside><section className="flex-1 min-w-0">@@ -408,7 +552,10 @@ export default function Sprites() {<div className="space-y-4"><div><h2 className="text-lg font-semibold text-white flex items-center gap-2">- {detail.record.kind === 'character' ? <PersonStanding className="w-5 h-5" /> : <Package className="w-5 h-5" />}+ {(() => {+ const Icon = GROUP_ICONS[groupKeyForKind(detail.record.kind)] || Package;+ return <Icon className="w-5 h-5" />;+ })()}{detail.record.name}</h2><p className="text-xs text-gray-500">diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 46d00e67c2..da4749b31a 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -2,7 +2,7 @@ import { z } from 'zod';import { ServerError } from './errorHandler.js';import { partialWithoutDefaults, emptyToUndefined, emptyToNull } from './zodCompat.js';import { WORK_TRACKERS } from './workTracker.js';-import { SPRITE_ID_PATTERN } from '../services/sprites/recordsLogic.js';+import { SPRITE_ID_PATTERN, SPRITE_RECORD_KINDS } from '../services/sprites/recordsLogic.js';import { ANCHOR_DIRECTIONS, SPRITE_DIRECTIONS } from '../services/sprites/prompts.js';import { CHROMA_KEY_HEXES } from '../services/sprites/chromaKey.js';import { QUEUEABLE_IMAGE_MODES } from '../services/imageGen/modes.js';@@ -966,6 +966,10 @@ export const spriteImportRequestSchema = z.object({export const spriteRecordUpdateSchema = z.object({name: z.string().min(1).max(200).optional(),+ // Reclassify an existing record between the noun kinds (#2932). `props` is+ // accepted so an imported family round-trips without a 400, but the UI never+ // creates one. Schema-parity with spriteCreateSchema below.+ kind: z.enum(SPRITE_RECORD_KINDS).optional(),notes: z.string().max(10000).nullable().optional(),// Fixed three-key set (#2895 decision) — manual override is limited to the// same keys the auto-selection picks from. Imported legacy records keep@@ -1018,6 +1022,10 @@ export const spriteAtlasCompileSchema = z.object({export const spriteCreateSchema = z.object({id: z.string().regex(SPRITE_ID_PATTERN).optional(),name: z.string().trim().min(1).max(200),+ // Noun taxonomy (#2932): the UI's New Sprite panel picks character/place/+ // object. `props` is accepted for parity with the enum but stays import-only+ // in practice. Absent → the service defaults to 'character'.+ kind: z.enum(SPRITE_RECORD_KINDS).optional(),spec: z.record(z.string(), z.unknown()).nullable().optional(),});diff --git a/server/routes/sprites.test.js b/server/routes/sprites.test.jsindex 19cccdf3b5..0882c527ed 100644--- a/server/routes/sprites.test.js+++ b/server/routes/sprites.test.js@@ -82,6 +82,18 @@ describe('sprites routes', () => {expect(records.createCharacter).not.toHaveBeenCalled();});+ it('POST / threads the noun kind through to createCharacter (#2932)', async () => {+ const r = await request(app).post('/api/sprites').send({ name: 'Saloon', kind: 'place' });+ expect(r.status).toBe(201);+ expect(records.createCharacter).toHaveBeenCalledWith({ name: 'Saloon', kind: 'place' });+ });++ it('POST / rejects an unknown kind at the schema', async () => {+ const bad = await request(app).post('/api/sprites').send({ name: 'Hero', kind: 'weapon' });+ expect(bad.status).toBe(400);+ expect(records.createCharacter).not.toHaveBeenCalled();+ });+it('GET /:id returns record + assets + reference set for characters', async () => {records.getRecordWithAssets.mockResolvedValueOnce({record: { id: 'pioneer', kind: 'character' },diff --git a/server/services/sprites/records.js b/server/services/sprites/records.jsindex 9b24582bbe..e489cd6362 100644--- a/server/services/sprites/records.js+++ b/server/services/sprites/records.js@@ -52,10 +52,13 @@ export async function createRecord(input, id) {}/**- * Create a character record (the reference-workflow entry point) — derives- * the id from the name when not supplied. Props families stay import-only.+ * Create a sprite record (the reference-workflow entry point for characters) —+ * derives the id from the name when not supplied. `kind` defaults to+ * `character`; the UI also creates `place`/`object` records here (#2932).+ * `props` families stay import-only. Only character records unlock the+ * reference → walk → publish workflows (gated client-side on kind).*/-export async function createCharacter({ id, name, spec = null }) {+export async function createCharacter({ id, name, spec = null, kind = 'character' }) {const recordId = id || deriveSpriteId(name);if (!isValidSpriteId(recordId)) {throw new ServerError(`Cannot derive a valid sprite id from "${name}" — pass an explicit id`, { status: 400, code: 'INVALID_SPRITE_ID' });@@ -67,7 +70,10 @@ export async function createCharacter({ id, name, spec = null }) {if (existing?.deleted) {throw new ServerError(`A deleted record still holds the id "${recordId}" (its assets remain on disk) — pass a different id`, { status: 409, code: 'ID_TOMBSTONED' });}- return createRecord({ kind: 'character', name, spec }, recordId);+ // buildSpriteRecord validates kind against SPRITE_RECORD_KINDS and falls+ // back to 'character' for anything unexpected — the Zod schema enum-gates it+ // before this point, so an out-of-set value can't reach here from the route.+ return createRecord({ kind, name, spec }, recordId);}export async function updateRecord(id, patch) {diff --git a/server/services/sprites/recordsLogic.js b/server/services/sprites/recordsLogic.jsindex fc0de06e36..df930c86f3 100644--- a/server/services/sprites/recordsLogic.js+++ b/server/services/sprites/recordsLogic.js@@ -3,14 +3,20 @@* (issue #2895, phase 1). Mirrors musicVideo/projectsLogic.js: all mutation* semantics live here so the two backends can't drift.*- * A sprite record is the db-primary metadata for one sprite subject — either a- * `character` (identity reference → anchors → walk animations → atlas) or a- * `props` family (a fixed-cell atlas of non-character sprites). Binary assets- * (reference images, strips, atlases, manifests) live on disk under- * data/sprites/<id>/ — the record holds only metadata and workflow state.+ * A sprite record is the db-primary metadata for one sprite subject — a+ * `character` (identity reference → anchors → walk animations → atlas), a+ * `place`, a standalone `object`, or an imported `props` family (a fixed-cell+ * atlas of non-character sprites). Binary assets (reference images, strips,+ * atlases, manifests) live on disk under data/sprites/<id>/ — the record holds+ * only metadata and workflow state.+ *+ * `props` is a legacy import-only value (#2932): imported prop atlas families+ * keep `kind: 'props'` and the UI folds them under the same "Objects" heading+ * as `object` — no migration, since the two are user-visibly identical. New+ * records created through the UI only ever get `character`/`place`/`object`.*/-export const SPRITE_RECORD_KINDS = ['character', 'props'];+export const SPRITE_RECORD_KINDS = ['character', 'place', 'object', 'props'];// Record ids double as the on-disk directory name under data/sprites/ — keep// them strict kebab-case so a record id can never traverse the filesystem.@@ -68,7 +74,7 @@ export function buildSpriteRecord(input, { id, now }) {// Whitelist patch — key-absent preserves, key-present applies (including an// intentional clear via null/''), per the LLM/merge convention in CLAUDE.md.-const PATCHABLE = ['name', 'status', 'spec', 'chromaKey', 'publishBinding', 'notes'];+const PATCHABLE = ['name', 'status', 'kind', 'spec', 'chromaKey', 'publishBinding', 'notes'];export function applySpriteRecordPatch(record, patch) {const next = { ...record };@@ -76,6 +82,10 @@ export function applySpriteRecordPatch(record, patch) {if (!(key in patch)) continue;if (key === 'name') next.name = trimOrNull(patch.name) || record.name;else if (key === 'status') next.status = trimOrNull(patch.status) || record.status;+ // Reclassifying is allowed (e.g. fix a mis-imported record); an unknown+ // kind is ignored rather than corrupting the record. The route's Zod+ // schema already enum-gates it — this is the defense-in-depth backstop.+ else if (key === 'kind') next.kind = SPRITE_RECORD_KINDS.includes(patch.kind) ? patch.kind : record.kind;else if (key === 'spec' || key === 'publishBinding') {next[key] = patch[key] && typeof patch[key] === 'object' ? patch[key] : null;} else next[key] = trimOrNull(patch[key]);diff --git a/server/services/sprites/recordsLogic.test.js b/server/services/sprites/recordsLogic.test.jsindex c7e1cd555d..6859a8abb6 100644--- a/server/services/sprites/recordsLogic.test.js+++ b/server/services/sprites/recordsLogic.test.js@@ -4,10 +4,17 @@ import {applySpriteRecordPatch,mergeImportedRecord,isValidSpriteId,+ SPRITE_RECORD_KINDS,} from './recordsLogic.js';const NOW = '2026-07-22T00:00:00.000Z';+describe('SPRITE_RECORD_KINDS', () => {+ it('carries the noun taxonomy plus the legacy props value (#2932)', () => {+ expect(SPRITE_RECORD_KINDS).toEqual(['character', 'place', 'object', 'props']);+ });+});+describe('isValidSpriteId', () => {it('accepts kebab-case slugs', () => {expect(isValidSpriteId('pioneer')).toBe(true);@@ -40,6 +47,15 @@ describe('buildSpriteRecord', () => {expect(r.chromaKey).toBe('#FF00FF');expect(r.importedFrom.sourceRoot).toBe('/x');});++ it('accepts the new place/object noun kinds (#2932)', () => {+ expect(buildSpriteRecord({ kind: 'place', name: 'Saloon' }, { id: 'saloon', now: NOW }).kind).toBe('place');+ expect(buildSpriteRecord({ kind: 'object', name: 'Lantern' }, { id: 'lantern', now: NOW }).kind).toBe('object');+ });++ it('falls back to character for an unknown kind', () => {+ expect(buildSpriteRecord({ kind: 'nonsense', name: 'X' }, { id: 'x', now: NOW }).kind).toBe('character');+ });});describe('applySpriteRecordPatch', () => {@@ -58,6 +74,11 @@ describe('applySpriteRecordPatch', () => {expect(next.id).toBe('hero');expect(next.deleted).toBe(false);});++ it('reclassifies kind to a valid value but ignores an unknown one (#2932)', () => {+ expect(applySpriteRecordPatch(base, { kind: 'place' }).kind).toBe('place');+ expect(applySpriteRecordPatch(base, { kind: 'bogus' }).kind).toBe('character');+ });});describe('mergeImportedRecord', () => {