"use client"; import { useState } from "react"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { VoicePick, type Engine } from "./CharacterPresets"; // --------------------------------------------------------------------------- // PROPOSED CHARACTERS (characters C3; components/projects/VoicesPanel.tsx; /api/report/voices; the CLI is `umtool // cast assign`). Propose: a character for each post author with none, BY RULE -- a stock voice from a fixed rotation, // no model. Each proposal is applied to NOTHING until a person acts: Accept (this video's character, named on that // author's items that name none; no take touched), Change (its voice, name, anonymity), Reject. "Ask the model too" // is optional and visibly so: the page works with no model configured. // --------------------------------------------------------------------------- export type Proposal = { id: string; name: string; handles: string[]; synthetic?: { voice?: string; speed?: number }; recorded?: { direction?: string }; anonymous?: boolean; shown?: string; by: "rule" | "model" | "person"; why?: string; model?: string; items?: string[]; }; type PostFn = (body: Record) => Promise | null>; const input = "rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[3px] text-[11.5px] text-text outline-none focus:border-signal"; const pretty = (spec: string) => spec.replace(":", " · "); /** The engines a proposal may name a voice of (cast.mjs STOCK_VOICES: Kokoro and Orpheus). */ const STOCK_ENGINES = new Set(["kokoro", "orpheus"]); function ProposalRow({ x, engines, busy, post, onChanged }: { x: Proposal; engines: Engine[]; busy: boolean; post: PostFn; onChanged: (what: string) => void }) { const [edit, setEdit] = useState(false); const [f, setF] = useState({ voice: x.synthetic?.voice ?? "", name: x.name, anonymous: !!x.anonymous, shown: x.shown ?? "" }); const cell = "border-t border-seam px-2 py-1 align-top"; const label = x.anonymous ? x.shown ?? x.name : x.name; const send = async (body: Record, what: string) => { const j = await post(body); if (j) onChanged(what); return j; }; const save = async () => { const body: Record = { op: "proposal-change", id: x.id }; if (f.voice && f.voice !== x.synthetic?.voice) body.voice = f.voice; if (f.name.trim() && f.name.trim() !== x.name) body.name = f.name.trim(); if (f.anonymous !== !!x.anonymous) body.anonymous = f.anonymous; if (f.anonymous && f.shown.trim() && f.shown.trim() !== (x.shown ?? "")) body.shown = f.shown.trim(); if (Object.keys(body).length === 2) { setEdit(false); return; } if (await send(body, `proposal ${x.id} changed`)) setEdit(false); }; return ( {label} {x.anonymous && anonymous} {x.handles.map((h) => `@${h}`).join(" ")}
{x.by === "model" ? `the model${x.model ? ` (${x.model})` : ""}` : x.by === "person" ? "changed by you — never sent to a model" : "by rule"} {x.why && x.by !== "person" ? ` · ${x.why}` : ""}
{x.synthetic?.voice ? pretty(x.synthetic.voice) : "—"} {typeof x.synthetic?.speed === "number" ? ` ×${x.synthetic.speed}` : ""} {x.recorded?.direction &&
“{x.recorded.direction}”
} {(x.items ?? []).length ? `${x.items!.length} item${x.items!.length === 1 ? "" : "s"}: ${x.items!.join(", ")}` : "no item to name"} {edit ? ( setF({ ...f, voice: v })} engines={engines} /> setF({ ...f, name: e.target.value })} className={cn(input, "w-36")} aria-label="its name" /> {f.anonymous && setF({ ...f, shown: e.target.value })} placeholder="shown as (Anon n)" className={cn(input, "w-28")} aria-label="the name it is shown under" />} ) : ( <> {" "} {" "} )} ); } /** The proposed characters, and the buttons that make them (by rule; the model only when asked). */ export function ProposedCharacters({ proposed, engines, busy, post, onChanged, modelState = null, onModel, modelRunning = false, }: { proposed: Proposal[]; engines: Engine[]; busy: boolean; post: PostFn; onChanged: (what: string) => void; modelState?: { route: string | null; model: string | null; why: string | null } | null; // "Ask the model too": the panel starts the job and follows it. onModel: () => void; modelRunning?: boolean; }) { const stock = engines.filter((e) => STOCK_ENGINES.has(e.id)); const send = async (body: Record, what: (j: Record) => string) => { const j = await post(body); if (j) onChanged(what(j)); }; const count = (j: Record) => (Array.isArray(j.proposed) ? j.proposed.length : 0); return (

proposed · {proposed.length}

{proposed.length > 0 && ( {proposed.map((x) => ( ))}
)}
{proposed.length > 1 && ( )} {modelState?.route && {modelState.route}{modelState.model ? ` · ${modelState.model}` : ""}}
); }