"use client"; import { useEffect, useRef } from "react"; import { Check, Plus, X } from "lucide-react"; import { ThinkingIndicator } from "@/components/ThinkingIndicator"; import { Button } from "@/components/ui/Button"; import { SectionHeader } from "@/components/ui/SectionHeader"; import { StatusNote } from "@/components/ui/StatusNote"; import { useContinue } from "@/lib/workbench/useContinue"; interface ContinuePanelProps { projectId: string; chapterNo: number; // 插入选中候选到正文(追加到章末)。 onInsert: (text: string) => void; onClose: () => void; } // 续写结果卡(内联,非模态):打开即读该章前文续写一条候选;可「再来一个」累加多候选, // 作者点某条「插入正文」才落回草稿(HITL,不静默写入)。 export function ContinuePanel({ projectId, chapterNo, onInsert, onClose, }: ContinuePanelProps) { const { status, candidates, generate } = useContinue(); const ranRef = useRef(false); useEffect(() => { if (ranRef.current) return; ranRef.current = true; void generate(projectId, chapterNo); }, [projectId, chapterNo, generate]); const busy = status === "generating"; return (
{candidates.length === 0 && busy ? (
) : null} {candidates.length === 0 && status === "error" ? ( ) : null}
); }