Skip to content

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

refactor([unify-canoncard-variation-card-into-a-single]): unify CanonCard + variation card via shared EntryCard shell

[._.]/ Adam Eivy2139351eaf46
diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsx
index fe3636a92d..e9f3c7669f 100644
--- a/client/src/components/pipeline/CanonCard.jsx
+++ b/client/src/components/pipeline/CanonCard.jsx
@@ -5,12 +5,16 @@
*
* Used by NounsStage (per-series, pre-Phase B) and UniverseCanonSection
* (per-universe, embedded in UniverseBuilder).
+ *
+ * Renders through `EntryCard` so the locked accent, title row, action column,
+ * and thumbnail stay in lock-step with the variation card.
*/
import { useEffect, useRef, useState } from 'react';
import { Loader2, ImagePlus, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, ChevronDown, ChevronRight, Star, Square } from 'lucide-react';
import useMediaJobProgress from '../../hooks/useMediaJobProgress';
import MediaJobThumb from './MediaJobThumb';
+import EntryCard from '../universe/EntryCard';
// Setting metadata enums — kept in lock-step with `SETTING_INT_EXT` and
// `SETTING_TIME_OF_DAY` in `server/lib/storyBible.js`. Mirror is fine: a
@@ -239,6 +243,13 @@ export default function CanonCard({
// pipeline view just needs to respect it.
const blockedByLock = locked;
+ // Visual at-a-glance without scrolling to the footer ref grid. Falls back
+ // to the first ref when nothing is pinned so a freshly-rendered entry isn't
+ // thumbnail-less just because the user hasn't picked a primary yet.
+ const thumbnailRef = (entry.primaryImageRef && refs.includes(entry.primaryImageRef))
+ ? entry.primaryImageRef
+ : (refs[0] || null);
+
// settledRef prevents duplicate completion callbacks under React 18
// StrictMode's mount→cleanup→mount double-fire in dev. MediaJobThumb
// opens its own subscription for visuals; ours coexists, filtered by
@@ -257,131 +268,138 @@ export default function CanonCard({
}
}, [inFlightJobId, status, filename, error, entry.id, onJobCompleted, onJobFailed]);
- return (
- <li className={`rounded border bg-port-bg/60 p-2 ${locked ? 'border-port-accent/40' : 'border-port-border'}`}>
- <div className="flex items-start gap-3">
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-2 flex-wrap">
- <span className="text-sm text-white font-medium truncate">{entry.name}</span>
- {entry.aliases?.length ? (
- <span className="text-[10px] text-gray-500 truncate">
- aka {entry.aliases.join(', ')}
- </span>
- ) : null}
- {locked ? (
- <span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[9px] uppercase tracking-wider">
- <Lock size={9} /> Locked
- </span>
- ) : null}
- {entry.sourceSeriesId ? (
- <span
- className="inline-flex items-center px-1.5 py-0.5 rounded bg-port-card border border-port-border text-[9px] uppercase tracking-wider text-gray-400"
- title={`Introduced by series ${entry.sourceSeriesId}`}
- >
- from series
- </span>
- ) : null}
- </div>
- {tags.length > 0 ? (
- <div className="flex items-center gap-1 mt-1 flex-wrap">
- {tags.map((tag) => (
- <span key={tag} className="px-1.5 py-0.5 rounded-full bg-port-card border border-port-border text-[9px] text-gray-400">
- {tag}
- </span>
- ))}
- </div>
- ) : null}
- <p className="text-xs text-gray-400 mt-1 line-clamp-3 whitespace-pre-wrap">
- {description || <em className="text-gray-600">No description yet.</em>}
- </p>
- {kind.key === 'settings' && onPatchEntry && !locked ? (
- <div className="flex flex-wrap items-center gap-2 mt-2">
- <ChipPicker
- label="INT/EXT"
- value={entry.intExt}
- options={INT_EXT_OPTIONS}
- onChange={(v) => onPatchEntry(entry.id, { intExt: v })}
- />
- <ChipPicker
- label="Time"
- value={entry.timeOfDay}
- options={TIME_OF_DAY_OPTIONS}
- onChange={(v) => onPatchEntry(entry.id, { timeOfDay: v })}
- />
- </div>
- ) : kind.key === 'settings' && (entry.intExt || entry.timeOfDay) ? (
- <div className="flex flex-wrap items-center gap-1 mt-2">
- {entry.intExt ? <ReadonlyChip>{entry.intExt}</ReadonlyChip> : null}
- {entry.timeOfDay ? <ReadonlyChip>{entry.timeOfDay}</ReadonlyChip> : null}
- </div>
- ) : null}
- {kind.key === 'characters' ? (
- <WardrobeSection
- wardrobes={Array.isArray(entry.wardrobes) ? entry.wardrobes : []}
- editable={!!onPatchEntry && !locked}
- onChange={(next) => onPatchEntry?.(entry.id, { wardrobes: next })}
- />
- ) : null}
+ const title = (
+ <div className="flex items-center gap-2 flex-wrap">
+ <span className="text-sm text-white font-medium truncate">{entry.name}</span>
+ {entry.aliases?.length ? (
+ <span className="text-[10px] text-gray-500 truncate">
+ aka {entry.aliases.join(', ')}
+ </span>
+ ) : null}
+ {locked ? (
+ <span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[9px] uppercase tracking-wider">
+ <Lock size={9} /> Locked
+ </span>
+ ) : null}
+ {entry.sourceSeriesId ? (
+ <span
+ className="inline-flex items-center px-1.5 py-0.5 rounded bg-port-card border border-port-border text-[9px] uppercase tracking-wider text-gray-400"
+ title={`Introduced by series ${entry.sourceSeriesId}`}
+ >
+ from series
+ </span>
+ ) : null}
+ </div>
+ );
+
+ const body = (
+ <>
+ {tags.length > 0 ? (
+ <div className="flex items-center gap-1 mt-1 flex-wrap">
+ {tags.map((tag) => (
+ <span key={tag} className="px-1.5 py-0.5 rounded-full bg-port-card border border-port-border text-[9px] text-gray-400">
+ {tag}
+ </span>
+ ))}
</div>
- <div className="shrink-0 flex flex-col gap-1 items-stretch">
- {onToggleLock ? (
- <button
- type="button"
- onClick={() => onToggleLock(entry.id, !locked)}
- disabled={togglingLock}
- className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
- title={locked
- ? `Unlock ${entry.name} so refine / differentiate / re-extract can modify it`
- : `Lock ${entry.name} so AI passes don't rewrite it`}
- >
- {togglingLock ? <Loader2 size={10} className="animate-spin" /> : (locked ? <Unlock size={10} /> : <Lock size={10} />)}
- {locked ? 'Unlock' : 'Lock'}
- </button>
- ) : null}
- {kind.key === 'characters' && onRefine ? (
- <button
- type="button"
- onClick={() => onRefine(entry.id)}
- disabled={refining || refineDisabled || blockedByLock}
- className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
- title={blockedByLock
- ? `Unlock ${entry.name} to refine`
- : `Rewrite ${entry.name}'s description so they render distinct from every other character`}
- >
- {refining ? <Loader2 size={10} className="animate-spin" /> : <WandSparkles size={10} />}
- AI: differentiate
- </button>
- ) : null}
- <button
- type="button"
- onClick={onRender}
- disabled={!description.trim() || !!inFlightJobId || blockedByLock}
- className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
- title={blockedByLock
- ? `Unlock ${entry.name} to render a new reference`
- : (description.trim() ? `Render a canonical reference image for ${entry.name}` : 'Add a description first')}
- >
- {inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <ImagePlus size={10} />}
- Render reference
- </button>
- {kind.key === 'settings' && onRenderCleanPlate ? (
- <button
- type="button"
- onClick={() => onRenderCleanPlate(entry)}
- disabled={!description.trim() || !!inFlightJobId || blockedByLock}
- className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
- title={blockedByLock
- ? `Unlock ${entry.name} to render a clean plate`
- : (description.trim()
- ? `Render an empty-location plate for ${entry.name} — no people, edge-to-edge`
- : 'Add a description first')}
- >
- {inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <Square size={10} />}
- Clean plate
- </button>
- ) : null}
+ ) : null}
+ <p className="text-xs text-gray-400 mt-1 line-clamp-3 whitespace-pre-wrap">
+ {description || <em className="text-gray-600">No description yet.</em>}
+ </p>
+ {kind.key === 'settings' && onPatchEntry && !locked ? (
+ <div className="flex flex-wrap items-center gap-2 mt-2">
+ <ChipPicker
+ label="INT/EXT"
+ value={entry.intExt}
+ options={INT_EXT_OPTIONS}
+ onChange={(v) => onPatchEntry(entry.id, { intExt: v })}
+ />
+ <ChipPicker
+ label="Time"
+ value={entry.timeOfDay}
+ options={TIME_OF_DAY_OPTIONS}
+ onChange={(v) => onPatchEntry(entry.id, { timeOfDay: v })}
+ />
+ </div>
+ ) : kind.key === 'settings' && (entry.intExt || entry.timeOfDay) ? (
+ <div className="flex flex-wrap items-center gap-1 mt-2">
+ {entry.intExt ? <ReadonlyChip>{entry.intExt}</ReadonlyChip> : null}
+ {entry.timeOfDay ? <ReadonlyChip>{entry.timeOfDay}</ReadonlyChip> : null}
</div>
- </div>
+ ) : null}
+ {kind.key === 'characters' ? (
+ <WardrobeSection
+ wardrobes={Array.isArray(entry.wardrobes) ? entry.wardrobes : []}
+ editable={!!onPatchEntry && !locked}
+ onChange={(next) => onPatchEntry?.(entry.id, { wardrobes: next })}
+ />
+ ) : null}
+ </>
+ );
+
+ const actions = (
+ <div className="flex flex-col gap-1 items-stretch">
+ {onToggleLock ? (
+ <button
+ type="button"
+ onClick={() => onToggleLock(entry.id, !locked)}
+ disabled={togglingLock}
+ className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
+ title={locked
+ ? `Unlock ${entry.name} so refine / differentiate / re-extract can modify it`
+ : `Lock ${entry.name} so AI passes don't rewrite it`}
+ >
+ {togglingLock ? <Loader2 size={10} className="animate-spin" /> : (locked ? <Unlock size={10} /> : <Lock size={10} />)}
+ {locked ? 'Unlock' : 'Lock'}
+ </button>
+ ) : null}
+ {kind.key === 'characters' && onRefine ? (
+ <button
+ type="button"
+ onClick={() => onRefine(entry.id)}
+ disabled={refining || refineDisabled || blockedByLock}
+ className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
+ title={blockedByLock
+ ? `Unlock ${entry.name} to refine`
+ : `Rewrite ${entry.name}'s description so they render distinct from every other character`}
+ >
+ {refining ? <Loader2 size={10} className="animate-spin" /> : <WandSparkles size={10} />}
+ AI: differentiate
+ </button>
+ ) : null}
+ <button
+ type="button"
+ onClick={onRender}
+ disabled={!description.trim() || !!inFlightJobId || blockedByLock}
+ className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
+ title={blockedByLock
+ ? `Unlock ${entry.name} to render a new reference`
+ : (description.trim() ? `Render a canonical reference image for ${entry.name}` : 'Add a description first')}
+ >
+ {inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <ImagePlus size={10} />}
+ Render reference
+ </button>
+ {kind.key === 'settings' && onRenderCleanPlate ? (
+ <button
+ type="button"
+ onClick={() => onRenderCleanPlate(entry)}
+ disabled={!description.trim() || !!inFlightJobId || blockedByLock}
+ className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
+ title={blockedByLock
+ ? `Unlock ${entry.name} to render a clean plate`
+ : (description.trim()
+ ? `Render an empty-location plate for ${entry.name} — no people, edge-to-edge`
+ : 'Add a description first')}
+ >
+ {inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <Square size={10} />}
+ Clean plate
+ </button>
+ ) : null}
+ </div>
+ );
+
+ const footer = (
+ <>
{(refs.length > 0 || inFlightJobId) ? (
<div className="flex items-center gap-2 mt-2 flex-wrap">
{inFlightJobId ? (
@@ -450,6 +468,26 @@ export default function CanonCard({
))}
</div>
) : null}
- </li>
+ </>
+ );
+
+ const thumbnail = thumbnailRef
+ ? {
+ filename: thumbnailRef,
+ alt: `${entry.name} reference`,
+ onClick: () => onPreview?.(thumbnailRef),
+ isPrimary: !!entry.primaryImageRef && entry.primaryImageRef === thumbnailRef,
+ }
+ : null;
+
+ return (
+ <EntryCard
+ locked={locked}
+ thumbnail={thumbnail}
+ title={title}
+ body={body}
+ actions={actions}
+ footer={footer}
+ />
);
}
diff --git a/client/src/components/universe/EntryCard.jsx b/client/src/components/universe/EntryCard.jsx
new file mode 100644
index 0000000000..142a7eaa93
--- /dev/null
+++ b/client/src/components/universe/EntryCard.jsx
@@ -0,0 +1,71 @@
+/**
+ * Shared card shell for canon entries (CanonCard) and category variations
+ * (VariationCard). Both render through this so the locked-accent border +
+ * slot layout stay in sync — visual drift is the bug this guards against.
+ * Each slot accepts a ReactNode; consumers own their internal layout (e.g.
+ * column vs. row for `actions`) so EntryCard stays unopinionated.
+ */
+
+import { Star } from 'lucide-react';
+
+export default function EntryCard({
+ locked = false,
+ thumbnail = null,
+ title = null,
+ body = null,
+ actions = null,
+ footer = null,
+}) {
+ const borderClass = locked ? 'border-port-accent/40' : 'border-port-border';
+ return (
+ <li className={`rounded border bg-port-bg/60 p-2 ${borderClass}`}>
+ <div className="flex items-start gap-3">
+ {thumbnail ? <EntryCardThumbnail {...thumbnail} /> : null}
+ <div className="flex-1 min-w-0">
+ {title}
+ {body}
+ </div>
+ {actions ? <div className="shrink-0">{actions}</div> : null}
+ </div>
+ {footer}
+ </li>
+ );
+}
+
+function EntryCardThumbnail({ filename, alt, onClick, isPrimary = false }) {
+ const img = (
+ <img
+ src={`/data/images/${filename}`}
+ alt={alt || filename}
+ className="w-full h-full object-cover"
+ loading="lazy"
+ />
+ );
+ const frame = (
+ <div className={`relative w-12 h-12 shrink-0 rounded overflow-hidden border ${
+ isPrimary ? 'border-port-accent' : 'border-port-border'
+ }`}>
+ {img}
+ {isPrimary ? (
+ <span
+ title="Primary reference image"
+ className="absolute top-0.5 right-0.5 p-0.5 rounded bg-port-accent text-white"
+ >
+ <Star size={8} fill="currentColor" />
+ </span>
+ ) : null}
+ </div>
+ );
+ if (!onClick) return frame;
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ title={`Preview ${alt || filename}`}
+ aria-label={`Preview ${alt || filename}`}
+ className="p-0 bg-transparent border-0 cursor-zoom-in"
+ >
+ {frame}
+ </button>
+ );
+}
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsx
index 728028774f..e646032caa 100644
--- a/client/src/pages/UniverseBuilder.jsx
+++ b/client/src/pages/UniverseBuilder.jsx
@@ -33,6 +33,7 @@ import { RUNNER_FAMILIES } from '../lib/runnerFamilies';
import ShareToButton from '../components/sharing/ShareToButton';
import OriginBadge from '../components/sharing/OriginBadge';
import UniverseCanonSection from '../components/universe/UniverseCanonSection';
+import EntryCard from '../components/universe/EntryCard';
import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../lib/imageGenBackends';
import { PIPELINE_IMAGE_DEFAULTS, readPipelineImageSettings } from '../lib/pipelineImageDefaults';
import { normalizeSlugline } from '../lib/scenePrompt';
@@ -2411,119 +2412,31 @@ export function CategoryEditor({
) : (
<ul className="flex flex-col gap-1.5 max-h-72 overflow-y-auto">
{variations.map((v, idx) => (
- <li key={`${v.label}-${idx}`} className={`bg-port-bg border rounded p-2 text-sm ${v.locked ? 'border-port-accent/50' : 'border-port-border'}`}>
- {editIdx === idx ? (
- <div className="flex flex-col gap-1">
- <input
- value={editLabel}
- onChange={(e) => setEditLabel(e.target.value)}
- className="bg-port-card border border-port-border rounded px-2 py-1 text-white text-sm"
- maxLength={120}
- />
- <textarea
- value={editPrompt}
- onChange={(e) => setEditPrompt(e.target.value)}
- rows={3}
- className="bg-port-card border border-port-border rounded px-2 py-1 text-white text-sm"
- maxLength={2000}
- />
- <div className="flex gap-2">
- <button onClick={saveEdit} className="text-xs px-2 py-1 bg-port-accent text-white rounded min-h-[40px] sm:min-h-0">Save</button>
- <button onClick={() => setEditIdx(null)} className="text-xs px-2 py-1 bg-port-bg text-gray-300 rounded min-h-[40px] sm:min-h-0">Cancel</button>
- </div>
- </div>
- ) : (
- <div className="flex items-start justify-between gap-2">
- <div className="flex-1 min-w-0">
- <div className="text-white font-medium truncate">{v.label}</div>
- <div className="text-xs text-gray-400 line-clamp-2">{v.prompt}</div>
- </div>
- <div className="flex items-center gap-1 shrink-0">
- {onPromote && (() => {
- const promoteTitle = !canPromote
- ? 'Save the universe first to enable promote'
- : requiresTargetKind
- ? 'Promote to canon — pick a trunk'
- : 'Promote to canon — LLM expands this variation into a full canon entry';
- return (
- <div className="relative" ref={pickerIdx === idx ? pickerWrapRef : null}>
- <button
- onClick={() => {
- if (requiresTargetKind) {
- setPickerIdx(pickerIdx === idx ? null : idx);
- return;
- }
- runPromote(idx, v);
- }}
- disabled={!canPromote || promotingIdx !== null}
- className="p-1 text-gray-400 hover:text-port-success disabled:opacity-30 disabled:cursor-not-allowed rounded"
- title={promoteTitle}
- aria-haspopup={requiresTargetKind ? 'menu' : undefined}
- aria-expanded={requiresTargetKind ? pickerIdx === idx : undefined}
- >
- {promotingIdx === idx
- ? <Loader2 size={14} className="animate-spin" />
- : <ArrowUpCircle size={14} />}
- </button>
- {pickerIdx === idx && requiresTargetKind && (
- <div
- role="menu"
- className="absolute right-0 top-full mt-1 z-20 w-44 bg-port-card border border-port-border rounded shadow-lg p-1 flex flex-col gap-0.5"
- >
- <div className="px-2 pt-1 pb-1 text-[10px] uppercase tracking-wide text-gray-500">
- Promote to canon as…
- </div>
- {TRUNK_TABS.map((trunk) => (
- <button
- key={trunk.kind}
- role="menuitem"
- onClick={() => runPromote(idx, v, { targetKind: trunk.kind })}
- className="text-left text-xs px-2 py-1.5 text-gray-200 hover:bg-port-success/20 rounded"
- >
- {trunk.label}
- </button>
- ))}
- </div>
- )}
- </div>
- );
- })()}
- {onRenderVariation && (
- <button
- onClick={() => onRenderVariation(v)}
- disabled={!canRender}
- className="p-1 text-gray-400 hover:text-port-accent disabled:opacity-30 disabled:cursor-not-allowed rounded"
- title={canRender ? 'Render this variation' : 'Save the world and configure a render backend to enable'}
- >
- <Play size={14} />
- </button>
- )}
- <button
- onClick={() => toggleLockAt(idx)}
- className={`p-1 rounded ${v.locked ? 'text-port-accent hover:bg-port-accent/20' : 'text-gray-500 hover:text-gray-300'}`}
- title={v.locked ? 'Locked — AI expand will preserve this variation' : 'Lock this variation against AI expand'}
- aria-pressed={!!v.locked}
- >
- {v.locked ? <Lock size={14} /> : <Unlock size={14} />}
- </button>
- <button
- onClick={() => startEdit(idx, v)}
- className="p-1 text-gray-400 hover:text-port-accent rounded"
- title="Edit"
- >
- <Edit3 size={14} />
- </button>
- <button
- onClick={() => removeAt(idx)}
- className="p-1 text-gray-400 hover:text-red-400 rounded"
- title="Remove"
- >
- <X size={14} />
- </button>
- </div>
- </div>
- )}
- </li>
+ <VariationCard
+ key={`${v.label}-${idx}`}
+ variation={v}
+ idx={idx}
+ editMode={editIdx === idx}
+ editLabel={editLabel}
+ editPrompt={editPrompt}
+ setEditLabel={setEditLabel}
+ setEditPrompt={setEditPrompt}
+ saveEdit={saveEdit}
+ cancelEdit={() => setEditIdx(null)}
+ startEdit={() => startEdit(idx, v)}
+ toggleLock={() => toggleLockAt(idx)}
+ remove={() => removeAt(idx)}
+ onPromote={onPromote}
+ canPromote={canPromote}
+ requiresTargetKind={requiresTargetKind}
+ promotingIdx={promotingIdx}
+ pickerIdx={pickerIdx}
+ setPickerIdx={setPickerIdx}
+ pickerWrapRef={pickerWrapRef}
+ runPromote={runPromote}
+ onRenderVariation={onRenderVariation}
+ canRender={canRender}
+ />
))}
</ul>
)}
@@ -2531,6 +2444,136 @@ export function CategoryEditor({
);
}
+// Renders through `EntryCard` so the locked accent + layout stay in
+// lock-step with `CanonCard`.
+function VariationCard({
+ variation: v, idx, editMode,
+ editLabel, editPrompt, setEditLabel, setEditPrompt,
+ saveEdit, cancelEdit, startEdit, toggleLock, remove,
+ onPromote, canPromote, requiresTargetKind, promotingIdx,
+ pickerIdx, setPickerIdx, pickerWrapRef, runPromote,
+ onRenderVariation, canRender,
+}) {
+ const locked = !!v.locked;
+ if (editMode) {
+ return (
+ <EntryCard
+ locked={locked}
+ body={(
+ <div className="flex flex-col gap-1">
+ <input
+ value={editLabel}
+ onChange={(e) => setEditLabel(e.target.value)}
+ className="bg-port-card border border-port-border rounded px-2 py-1 text-white text-sm"
+ maxLength={120}
+ />
+ <textarea
+ value={editPrompt}
+ onChange={(e) => setEditPrompt(e.target.value)}
+ rows={3}
+ className="bg-port-card border border-port-border rounded px-2 py-1 text-white text-sm"
+ maxLength={2000}
+ />
+ <div className="flex gap-2">
+ <button onClick={saveEdit} className="text-xs px-2 py-1 bg-port-accent text-white rounded min-h-[40px] sm:min-h-0">Save</button>
+ <button onClick={cancelEdit} className="text-xs px-2 py-1 bg-port-bg text-gray-300 rounded min-h-[40px] sm:min-h-0">Cancel</button>
+ </div>
+ </div>
+ )}
+ />
+ );
+ }
+
+ const promoteTitle = !canPromote
+ ? 'Save the universe first to enable promote'
+ : requiresTargetKind
+ ? 'Promote to canon — pick a trunk'
+ : 'Promote to canon — LLM expands this variation into a full canon entry';
+
+ const title = <div className="text-sm text-white font-medium truncate">{v.label}</div>;
+ const body = <div className="text-xs text-gray-400 line-clamp-2 mt-1">{v.prompt}</div>;
+ const actions = (
+ <div className="flex items-center gap-1">
+ {onPromote && (
+ <div className="relative" ref={pickerIdx === idx ? pickerWrapRef : null}>
+ <button
+ onClick={() => {
+ if (requiresTargetKind) {
+ setPickerIdx(pickerIdx === idx ? null : idx);
+ return;
+ }
+ runPromote(idx, v);
+ }}
+ disabled={!canPromote || promotingIdx !== null}
+ className="p-1 text-gray-400 hover:text-port-success disabled:opacity-30 disabled:cursor-not-allowed rounded"
+ title={promoteTitle}
+ aria-haspopup={requiresTargetKind ? 'menu' : undefined}
+ aria-expanded={requiresTargetKind ? pickerIdx === idx : undefined}
+ >
+ {promotingIdx === idx
+ ? <Loader2 size={14} className="animate-spin" />
+ : <ArrowUpCircle size={14} />}
+ </button>
+ {pickerIdx === idx && requiresTargetKind && (
+ <div
+ role="menu"
+ className="absolute right-0 top-full mt-1 z-20 w-44 bg-port-card border border-port-border rounded shadow-lg p-1 flex flex-col gap-0.5"
+ >
+ <div className="px-2 pt-1 pb-1 text-[10px] uppercase tracking-wide text-gray-500">
+ Promote to canon as…
+ </div>
+ {TRUNK_TABS.map((trunk) => (
+ <button
+ key={trunk.kind}
+ role="menuitem"
+ onClick={() => runPromote(idx, v, { targetKind: trunk.kind })}
+ className="text-left text-xs px-2 py-1.5 text-gray-200 hover:bg-port-success/20 rounded"
+ >
+ {trunk.label}
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+ {onRenderVariation && (
+ <button
+ onClick={() => onRenderVariation(v)}
+ disabled={!canRender}
+ className="p-1 text-gray-400 hover:text-port-accent disabled:opacity-30 disabled:cursor-not-allowed rounded"
+ title={canRender ? 'Render this variation' : 'Save the world and configure a render backend to enable'}
+ >
+ <Play size={14} />
+ </button>
+ )}
+ <button
+ onClick={toggleLock}
+ className={`p-1 rounded ${locked ? 'text-port-accent hover:bg-port-accent/20' : 'text-gray-500 hover:text-gray-300'}`}
+ title={locked ? 'Locked — AI expand will preserve this variation' : 'Lock this variation against AI expand'}
+ aria-pressed={locked}
+ >
+ {locked ? <Lock size={14} /> : <Unlock size={14} />}
+ </button>
+ <button
+ onClick={startEdit}
+ className="p-1 text-gray-400 hover:text-port-accent rounded"
+ title="Edit"
+ >
+ <Edit3 size={14} />
+ </button>
+ <button
+ onClick={remove}
+ className="p-1 text-gray-400 hover:text-red-400 rounded"
+ title="Remove"
+ >
+ <X size={14} />
+ </button>
+ </div>
+ );
+
+ return <EntryCard locked={locked} title={title} body={body} actions={actions} />;
+}
+
// Tab nav — desktop shows a horizontal pill row; mobile collapses to a
// <select> dropdown (CLAUDE.md "Mobile responsive"). The Other tab only
// renders when at least one un-kinded bucket exists, per Phase C spec.