import { notFound } from "next/navigation"; import Link from "next/link"; import { prisma } from "@streamclipper/db"; import { fetchChannelStatuses } from "../../../lib/apiDaemon"; import { deleteRawSegment, deleteCandidateSegment, deleteChannel, stopSession, forceStartCapture, retryRender, cancelRender, } from "../../actions"; import { DeleteButton } from "../../components/DeleteButton"; import { ConfirmButton } from "../../components/ConfirmButton"; import { LiveLogViewer } from "../../components/LiveLogViewer"; import { SessionTimer } from "../../components/SessionTimer"; export const dynamic = "force-dynamic"; const STATUS_BADGE: Record = { PENDING: "muted", PROCESSED: "ok", DISCARDED: "err", PENDING_STT: "warn", TRANSCRIBED: "ok", RENDERING: "warn", READY: "ok", FAILED: "err", }; function transcriptPreview(transcriptJson: unknown): string | null { if (!transcriptJson || typeof transcriptJson !== "object") return null; const text = (transcriptJson as { text?: string }).text; return text ? text.slice(0, 240) : null; } export default async function ChannelDetailPage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const [channel, statuses] = await Promise.all([ prisma.channel.findUnique({ where: { id }, include: { sessions: { orderBy: { startedAt: "desc" }, include: { segments: { orderBy: { createdAt: "desc" }, include: { candidates: { orderBy: { createdAt: "desc" }, include: { short: true } } }, }, }, }, }, }), fetchChannelStatuses(), ]); if (!channel) notFound(); const status = statuses.get(channel.id); const activeSession = channel.sessions.find((s) => s.endedAt === null); return ( <>

← Kanal Durumu

{channel.name}

{channel.youtubeHandle} · {channel.channelId}

Canlı Durum {status?.recording ? "🔴 Kayıtta" : "Kayıtta değil"} {status?.recording && activeSession && ( <> {" · "} )} {status?.recording && activeSession && (
)}
Aktif: {channel.isActive ? "evet" : "hayır"} ·{" "} Son kontrol: {channel.lastCheckedAt ? new Date(channel.lastCheckedAt).toLocaleString("tr-TR") : "—"}
{status === undefined && (

api-daemon'dan canlı durum alınamadı (servis erişilemez olabilir).

)} {status?.lastPollError && (
son poll hatası
              {status.lastPollError}
            
)} {status?.recording && activeSession?.liveVideoId && activeSession.liveVideoId !== "forced" && (