Clipador: subpáginas, jogos, idioma por canal e juiz com Gemini e IA reserva
- Clipador em subpáginas (Cortes, Sessões, Fontes, Jogos, Ajustes) com moldura comum, lista + diálogo dos cortes e submenu na barra lateral. - Perfis de jogo (o que a IA sabe de cada jogo), parar pausa o monitor e idioma por fonte e por canal de publicação (migração v9: accounts.language). - Juiz: Gemini CLI como terceiro provedor e IA reserva por chamada — se a IA escolhida cair por cota, login, chave ou rede, a próxima da ordem de Configurações → IA responde (com pausa da que caiu). Lê data/ai/settings.json e o cofre data/ai/vault.bin (DPAPI) escritos pelo painel; contrato em doc/ia.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
"use client";
|
||||
// Ajustes do Clipador (/clipper/settings), em abas: Juiz (IA) — provedor, modelos e o que a IA faz sozinha;
|
||||
// Serviço — versão, ferramentas, transcrição e parâmetros do .env; Idiomas e públicos — como o idioma da fonte
|
||||
// (transcrição e IA) se relaciona com o idioma do canal de publicação (público). Os dados vêm do ClipperProvider.
|
||||
import Link from "next/link";
|
||||
import type { ReactNode } from "react";
|
||||
import { PROVIDER_LABEL, formatScore, languageLabel } from "./clipper-client";
|
||||
import { JudgeForm } from "./clipper-judge";
|
||||
import { useClipper, useClipperData } from "./clipper-provider";
|
||||
import { BroadcastIcon, GlobeIcon, MicIcon, RefreshIcon, ServerIcon, SparkIcon, UsersIcon } from "./icons";
|
||||
import { Tabs } from "./tabs";
|
||||
import { Badge, Button, Card, Feedback, Spinner, cx } from "./ui";
|
||||
|
||||
type TabId = "juiz" | "servico" | "idiomas";
|
||||
|
||||
export function SettingsPage() {
|
||||
return (
|
||||
<Tabs<TabId> label="Seções dos ajustes do Clipador"
|
||||
items={[
|
||||
{ id: "juiz", label: "Juiz (IA)", icon: <SparkIcon size={16} /> },
|
||||
{ id: "servico", label: "Serviço", icon: <ServerIcon size={16} /> },
|
||||
{ id: "idiomas", label: "Idiomas e públicos", icon: <GlobeIcon size={16} /> },
|
||||
]}
|
||||
panels={{ juiz: <JudgeTab />, servico: <ServiceTab />, idiomas: <LanguagesTab /> }} />
|
||||
);
|
||||
}
|
||||
|
||||
function JudgeTab() {
|
||||
const { judge, setJudge, refresh, refreshing } = useClipper();
|
||||
if (!judge) {
|
||||
return (
|
||||
<Card>
|
||||
<div className="grid justify-items-start gap-3">
|
||||
<Feedback ok={false}>Não foi possível ler a configuração do juiz.</Feedback>
|
||||
<Button variant="secondary" size="sm" onClick={() => void refresh(true)} disabled={refreshing}>
|
||||
{refreshing ? <Spinner className="size-3.5" /> : <RefreshIcon size={15} />}Tentar de novo
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
return <JudgeForm key={JSON.stringify([judge.provider, judge.model, judge.minScore, judge.available])} judge={judge} onSaved={setJudge} />;
|
||||
}
|
||||
|
||||
/* ---------- Serviço ---------- */
|
||||
|
||||
function ServiceTab() {
|
||||
const { refresh, refreshing } = useClipper();
|
||||
const { status } = useClipperData();
|
||||
const j = status.judge;
|
||||
return (
|
||||
<Card eyebrow={<><ServerIcon size={13} />Serviço</>} title={<span className="flex flex-wrap items-center gap-3">Clipador <Badge tone="success">online</Badge><span className="text-sm font-normal text-fg-subtle">v{status.version} · 127.0.0.1:4520</span></span>}
|
||||
description="O que o serviço encontrou no PC e os parâmetros com que está rodando. Os valores do .env valem depois de reiniciar o serviço."
|
||||
actions={<Button variant="ghost" size="sm" onClick={() => void refresh(true)} disabled={refreshing}>{refreshing ? <Spinner className="size-3.5" /> : <RefreshIcon size={15} />}Atualizar</Button>}>
|
||||
<dl className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
|
||||
<Group icon={<ServerIcon size={14} />} title="Ferramentas">
|
||||
<Tool name="Streamlink" path={status.tools.streamlink} />
|
||||
<Tool name="FFmpeg" path={status.tools.ffmpeg} />
|
||||
</Group>
|
||||
<Group icon={<MicIcon size={14} />} title="Transcrição">
|
||||
<Row label="Serviço de voz">
|
||||
{!status.voice.configured ? <span className="text-fg-subtle">não configurado</span>
|
||||
: status.voice.online ? <span className="text-success">online (Whisper, porta 4510)</span>
|
||||
: <span className="text-warning">offline</span>}
|
||||
</Row>
|
||||
<Row label="Trechos">a cada {status.settings.segmentS} s</Row>
|
||||
</Group>
|
||||
<Group icon={<SparkIcon size={14} />} title="Juiz (IA)">
|
||||
<Row label="Provedor">
|
||||
{j.provider === "off" ? <span>desligado <span className="text-xs text-fg-subtle">· só heurística</span></span>
|
||||
: <span className="flex flex-wrap items-center gap-2">{PROVIDER_LABEL[j.provider]}{j.available ? <Badge tone="success">disponível</Badge> : <Badge tone="danger">indisponível</Badge>}</span>}
|
||||
</Row>
|
||||
{j.provider !== "off" && <Row label="Modelo"><span className="font-mono text-xs">{j.model}</span> · nota mínima {formatScore(j.minScore)}</Row>}
|
||||
</Group>
|
||||
<Group icon={<GlobeIcon size={14} />} title="Gravação e idioma">
|
||||
<Row label="Idioma padrão">
|
||||
<span>{languageLabel(status.settings.language)}</span>
|
||||
<span className="block text-xs text-fg-subtle">Muda em <code>clipper/.env</code> (<code>CLIPPER_LANGUAGE</code>); cada fonte pode ter o seu em <Link href="/clipper/sources" className="underline underline-offset-2 hover:text-fg">Fontes</Link>.</span>
|
||||
</Row>
|
||||
<Row label="Monitor das fontes">checa a cada {status.settings.pollS} s</Row>
|
||||
<Row label="Gravação guardada">{status.settings.keepHours} h depois da live (depois só ficam os cortes)</Row>
|
||||
</Group>
|
||||
</dl>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function Group({ icon, title, children }: { icon: ReactNode; title: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="grid content-start gap-2.5">
|
||||
<h3 className="flex items-center gap-1.5 text-eyebrow font-semibold text-fg-subtle uppercase">{icon}{title}</h3>
|
||||
<div className="grid gap-2 text-sm">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Row({ label, children }: { label: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="grid gap-0.5 sm:grid-cols-[9rem_minmax(0,1fr)] sm:gap-3">
|
||||
<dt className="text-[0.8125rem] text-fg-subtle">{label}</dt>
|
||||
<dd className="min-w-0 text-fg">{children}</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Tool({ name, path }: { name: string; path: string | null }) {
|
||||
return (
|
||||
<Row label={name}>
|
||||
<span className="flex items-start gap-2">
|
||||
<span className={cx("mt-1.5 size-1.5 shrink-0 rounded-full", path ? "bg-success" : "bg-danger")} aria-hidden="true" />
|
||||
{path ? <span className="font-mono text-xs break-all text-fg-muted">{path}</span> : <span className="text-danger">não encontrado — rode o setup.bat</span>}
|
||||
</span>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
/* ---------- Idiomas e públicos ---------- */
|
||||
|
||||
function LanguagesTab() {
|
||||
const { status } = useClipperData();
|
||||
return (
|
||||
<Card eyebrow={<><GlobeIcon size={13} />Idiomas e públicos</>} title="Dois idiomas, dois lugares"
|
||||
description="O idioma em que a live é falada e o idioma do público que recebe o corte são coisas diferentes, e cada um se configura no seu lugar.">
|
||||
<div className="grid gap-5 md:grid-cols-2">
|
||||
<Explain icon={<BroadcastIcon size={16} />} title="Idioma da fonte" where={<Link href="/clipper/sources" className="underline underline-offset-2 hover:text-fg">Fontes</Link>}>
|
||||
O que o streamer fala. Guia a transcrição (Whisper) e os textos que a IA escreve para o corte (título, legenda, hashtags).
|
||||
Sem escolha, vale o padrão do serviço: <strong className="font-medium text-fg">{languageLabel(status.settings.language)}</strong>.
|
||||
</Explain>
|
||||
<Explain icon={<UsersIcon size={16} />} title="Idioma do canal de publicação" where={<Link href="/accounts" className="underline underline-offset-2 hover:text-fg">Canais de publicação</Link>}>
|
||||
O público que recebe o corte: um canal em português para o Brasil, outro em inglês para fora. Ao publicar, o painel avisa quando o
|
||||
idioma do corte é diferente do idioma do canal.
|
||||
</Explain>
|
||||
</div>
|
||||
<p className="mt-5 rounded-control border border-line bg-sunken/40 px-4 py-3 text-[0.8125rem] leading-relaxed text-fg-muted">
|
||||
<strong className="font-medium text-fg">Próxima etapa:</strong> versões traduzidas de um corte (legenda queimada e textos em outro idioma, a partir da
|
||||
mesma sessão) para os canais em outro idioma. O modelo já tem onde encaixar; hoje cada corte sai no idioma da fonte.
|
||||
</p>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function Explain({ icon, title, where, children }: { icon: ReactNode; title: string; where: ReactNode; children: ReactNode }) {
|
||||
return (
|
||||
<div className="grid content-start gap-2 rounded-control border border-line bg-raised/40 px-4 py-3.5">
|
||||
<h3 className="flex items-center gap-2 text-sm font-semibold text-fg"><span className="text-accent">{icon}</span>{title}</h3>
|
||||
<p className="text-[0.8125rem] leading-relaxed text-fg-muted">{children}</p>
|
||||
<p className="text-xs text-fg-subtle">Onde: {where}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user