feat: 深度研究支持独立新报告与原文改写,并完善沙箱、模型管理与全文改写

新报告不再覆盖当前文件卡片,写入时打开沙箱;步骤条仅在改写原文时位于卡片上方。同时补齐改写本地回退、模型管理与会商第三步相关改动。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-21 21:46:04 +08:00
1 parent 11f928bc95
commit a5a9c952e8
63 files changed
+4113 -929

No files matched your search

@@ -24,6 +24,8 @@ import {
Loader2,
Network,
Paperclip,
Pause,
Play,
Sparkles,
X,
} from "lucide-react";
@@ -103,6 +105,7 @@ export interface Step2PanelProps {
// ─── State ────────────────────────────────────────────────────
step2RoundtableDialogues: Step2Dialogue[];
isInitializing: boolean;
isRoundTableRunning: boolean;
isOrchestrating: boolean;
pendingClarification: ClarificationPayload | null;
clarificationDraft: string;
@@ -153,6 +156,7 @@ export interface Step2PanelProps {
setSelectedAgentId: React.Dispatch<React.SetStateAction<number | null>>;
// ─── Handlers ─────────────────────────────────────────────────
onPauseRoundtable: () => void;
onResumeRoundtable: () => void;
onHandleInjectToRoundtable: (files?: File[]) => void;
onSubmitClarification: (answer: string) => void;
onSavePersona: (id: number) => void;
@@ -173,6 +177,7 @@ export function Step2Panel(props: Step2PanelProps) {
headerRightSlot,
step2RoundtableDialogues,
isInitializing,
isRoundTableRunning,
isOrchestrating,
pendingClarification,
clarificationDraft,
@@ -204,6 +209,7 @@ export function Step2Panel(props: Step2PanelProps) {
setAgentConfigs,
setSelectedAgentId,
onPauseRoundtable,
onResumeRoundtable,
onHandleInjectToRoundtable,
onSubmitClarification,
onSavePersona,
@@ -476,7 +482,38 @@ export function Step2Panel(props: Step2PanelProps) {
))}
</select>
)}
{/* 后台挂起:查看历史记录时隐藏(isViewingHistory),
{!isRoundTableRunning ? (
<button
type="button"
onClick={onResumeRoundtable}
title="恢复自动研讨"
className={
useStep1InputAppearance
? "eightbf-roundtable__resume-button"
: "bg-emerald-100 hover:bg-emerald-200 text-emerald-800 text-[calc(10px*var(--ui-font-scale,1))] font-bold px-2.5 py-1 rounded-xl flex items-center gap-1 transition border border-emerald-200/40 shadow-sm"
}
>
{!useStep1InputAppearance && (
<Play className="w-3.5 h-3.5 fill-emerald-800" />
)}
恢复会商
</button>
) : (
<button
type="button"
onClick={onPauseRoundtable}
title="暂停当前会商编排,可稍后恢复"
className={
useStep1InputAppearance
? "eightbf-roundtable__pause-button"
: "bg-amber-100 hover:bg-amber-200 text-amber-800 text-[calc(10px*var(--ui-font-scale,1))] font-bold px-2.5 py-1 rounded-xl flex items-center gap-1 transition border border-amber-200/40 shadow-sm"
}
>
{!useStep1InputAppearance && <Pause className="w-3.5 h-3.5" />}
暂停会商
</button>
)}
{/* 后台挂起:放在暂停/恢复按钮右侧。查看历史记录时隐藏(isViewingHistory),
重新从第一步进入第二步研讨时(isViewingHistory 为假)正常显示。 */}
{SHOW_BACKGROUND_SUSPEND && !isViewingHistory && (
<button
@@ -9,7 +9,7 @@
* 布局对齐 Step3ReportMode(HTML 绘制):左栏研讨原料源卡 + 右栏沙箱。两者并存、
* 互不影响(report 画 HTML 看板,summary 写 Markdown 报告 + 问答)。
*/
import { useEffect, useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState, type FormEvent } from "react";
import { createPortal } from "react-dom";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
@@ -21,11 +21,15 @@ import {
Loader2,
PanelLeftClose,
PanelLeftOpen,
Paperclip,
Pause,
RefreshCw,
SendHorizontal,
Sparkles,
X,
} from "lucide-react";
import { AutoGrowTextarea } from "@/components/ui/auto-grow-textarea";
import { useArtifacts } from "@/components/workspace/artifacts";
import { useLocalSettings } from "@/core/settings";
import { cn } from "@/lib/utils";
@@ -204,11 +208,13 @@ export function Step3SummaryMode({
? "正在初始化总结线程…"
: phase === "streaming"
? "方案总结报告智能体撰写中…"
: phase === "done"
? "总结完成"
: phase === "error"
? "总结失败"
: "待总结";
: phase === "paused"
? "已暂停"
: phase === "done"
? "总结完成"
: phase === "error"
? "总结失败"
: "待总结";
return (
<div className="flex h-full min-h-0 flex-col text-slate-800">
@@ -222,6 +228,7 @@ export function Step3SummaryMode({
{(phase === "creating" || phase === "streaming") && (
<Loader2 className="w-3 h-3 animate-spin" />
)}
{phase === "paused" && <Pause className="w-3 h-3 text-amber-600" />}
{phase === "done" && <CheckCircle className="w-3 h-3 text-emerald-600" />}
{statusLabel}
</span>
@@ -521,6 +528,7 @@ function AgentProgressPanel({
const [askText, setAskText] = useState("");
// 输入框携带的本地附件(点发送时连同指令一起上传到总结线程)。
const [askFiles, setAskFiles] = useState<File[]>([]);
const fileInputRef = useRef<HTMLInputElement>(null);
const addAskFiles = (picked: File[]) => {
if (picked.length > 0) {
@@ -530,6 +538,10 @@ function AgentProgressPanel({
});
}
};
const pickFiles = (e: React.ChangeEvent<HTMLInputElement>) => {
addAskFiles(Array.from(e.target.files ?? []));
e.target.value = "";
};
const removeFile = (idx: number) => setAskFiles((prev) => prev.filter((_, i) => i !== idx));
const submitAsk = () => {
@@ -540,6 +552,10 @@ function AgentProgressPanel({
setAskFiles([]);
onAsk(text, hasFiles ? askFiles : undefined);
};
const handleAskSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
submitAsk();
};
return (
<div
@@ -567,7 +583,7 @@ function AgentProgressPanel({
</div>
</div>
) : (
<div className="shrink-0 flex items-center gap-2 border-b border-slate-100 bg-white px-4 py-2.5">
<div className="shrink-0 flex items-center justify-between gap-2 border-b border-slate-100 bg-white px-4 py-2.5">
<div className="flex items-center gap-2 min-w-0">
<div className="w-6 h-6 shrink-0 rounded-lg bg-gradient-to-tr from-primary to-[var(--brand-200)] flex items-center justify-center text-white text-xs shadow-sm">
报
@@ -577,6 +593,44 @@ function AgentProgressPanel({
<div className="text-[10px] text-slate-400 truncate">据各席位成果撰写 Markdown 总结报告</div>
</div>
</div>
<div className="flex items-center gap-2 shrink-0">
<select
id="step3-summary-model-select"
value={selectedModel}
onChange={(e) => setSelectedModel(e.target.value)}
disabled={busy || availableModels.length === 0}
title={
availableModels.length === 0
? "未在 config.yaml 中配置任何模型"
: busy
? "撰写中不可切换;完成后或重新生成时生效"
: "切换撰写使用的推理模型(下次生成生效)"
}
className="shrink-0 max-w-[180px] bg-slate-50/50 border border-slate-200 rounded-xl px-2.5 py-1.5 text-[11px] font-bold text-slate-700 cursor-pointer focus:outline-none focus:border-primary focus:ring-1 focus:ring-[var(--brand-200)]/50 disabled:opacity-50 disabled:cursor-not-allowed dark:bg-secondary dark:text-foreground dark:border-border"
>
{availableModels.length === 0 && (
<option value="">未配置模型</option>
)}
{availableModels.map((m) => (
<option key={m.name} value={m.name}>
{m.display_name && m.display_name !== m.name
? `${m.display_name} (${m.name})`
: m.name}
</option>
))}
</select>
{busy && (
<button
type="button"
onClick={onPause}
title="暂停当前生成(沙箱保留已生成内容,之后可继续修改或重新生成)"
className="bg-white border border-amber-200 text-amber-700 hover:bg-amber-50 text-[10.5px] font-bold px-2.5 py-1.5 rounded-xl flex items-center gap-1 transition"
>
<Pause className="w-3.5 h-3.5" />
暂停
</button>
)}
</div>
</div>
)}
@@ -631,6 +685,13 @@ function AgentProgressPanel({
</div>
)}
{phase === "paused" && (
<div className="flex items-center gap-2 text-xs font-bold text-amber-600">
<Pause className="w-4 h-4" />
已暂停。可在下方输入修改要求继续,或点右上角「重新生成」。
</div>
)}
{phase === "done" && (
<div className="flex items-center gap-2 text-xs font-bold text-emerald-600">
<CheckCircle className="w-4 h-4" />
@@ -648,38 +709,114 @@ function AgentProgressPanel({
)}
</div>
<div className="position-roundtable-intent-page eightbf-roundtable-step3-input shrink-0">
<PositionIntentInput
value={askText}
onValueChange={setAskText}
attachedFiles={askFiles}
onAddFiles={addAskFiles}
onRemoveFile={removeFile}
charactersLeft={Math.max(0, 500 - askText.length)}
isSending={busy}
canSend={askText.trim().length > 0 || askFiles.length > 0}
pendingClarification={false}
onSend={submitAsk}
onStop={onPause}
onFollowUp={() => undefined}
onSkip={() => undefined}
hideUtilityActions
onEnterRoundtable={() => undefined}
enterButtonLabel=""
intentReady={null}
hideEnterRoundtable
onManualSave={() => undefined}
onTriggerToast={() => undefined}
modelOptions={availableModels.map((model) => ({
label: model.display_name && model.display_name !== model.name
? `${model.display_name} (${model.name})`
: model.name,
value: model.name,
}))}
selectedModel={selectedModel}
onSelectedModelChange={setSelectedModel}
/>
</div>
{useStep1Chrome ? (
<div className="position-roundtable-intent-page eightbf-roundtable-step3-input shrink-0">
<PositionIntentInput
value={askText}
onValueChange={setAskText}
attachedFiles={askFiles}
onAddFiles={addAskFiles}
onRemoveFile={removeFile}
charactersLeft={Math.max(0, 500 - askText.length)}
isSending={busy}
canSend={askText.trim().length > 0 || askFiles.length > 0}
pendingClarification={false}
onSend={submitAsk}
onStop={onPause}
onFollowUp={() => undefined}
onSkip={() => undefined}
hideUtilityActions
onEnterRoundtable={() => undefined}
enterButtonLabel=""
intentReady={null}
hideEnterRoundtable
onManualSave={() => undefined}
onTriggerToast={() => undefined}
modelOptions={availableModels.map((model) => ({
label: model.display_name && model.display_name !== model.name
? `${model.display_name} (${model.name})`
: model.name,
value: model.name,
}))}
selectedModel={selectedModel}
onSelectedModelChange={setSelectedModel}
/>
</div>
) : (
<form onSubmit={handleAskSubmit} className="shrink-0 border-t border-slate-100 bg-white px-3 py-3">
{askFiles.length > 0 && (
<div className="mb-2 flex flex-wrap gap-1.5">
{askFiles.map((file, idx) => (
<span
key={`${file.name}-${file.size}-${idx}`}
className="inline-flex items-center gap-1.5 bg-white border border-slate-200 rounded-lg pl-2 pr-1 py-1 text-[11px] text-slate-600 max-w-[200px]"
>
<FileText className="w-3 h-3 shrink-0 text-primary" />
<span className="truncate font-medium" title={file.name}>
{file.name}
</span>
<span className="shrink-0 text-slate-400">{formatBytes(file.size)}</span>
<button
type="button"
onClick={() => removeFile(idx)}
className="shrink-0 p-0.5 rounded hover:bg-slate-200 text-slate-400 hover:text-slate-600 transition"
title="移除"
>
<X className="w-3 h-3" />
</button>
</span>
))}
</div>
)}
<div className="flex items-end gap-2 rounded-2xl border border-slate-200 bg-slate-50/70 px-3 py-2 focus-within:border-primary/60 focus-within:bg-white focus-within:ring-2 focus-within:ring-[var(--brand-200)]/40">
<AutoGrowTextarea
maxHeight={224}
value={askText}
onChange={(e) => setAskText(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
e.currentTarget.form?.requestSubmit();
}
}}
rows={1}
placeholder={
busy
? "生成中也可随时插话干预:发送将打断当前轮并据此继续…"
: "继续对话:改报告(如「执行路线写细些」)或提问"
}
className="min-h-8 max-h-56 flex-1 resize-none bg-transparent py-1.5 text-xs leading-relaxed text-slate-800 placeholder:text-slate-400 focus:outline-none"
/>
<input ref={fileInputRef} type="file" multiple className="hidden" onChange={pickFiles} />
<button
type="button"
onClick={() => fileInputRef.current?.click()}
title="上传参考文件(智能体将读取文件内容辅助总结/修改)"
className="mb-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-white border border-slate-200 text-slate-500 hover:text-primary hover:bg-slate-50 transition active:scale-95"
>
<Paperclip className="h-4 w-4" />
</button>
{busy && (
<button
type="button"
onClick={onPause}
title="暂停当前生成"
className="mb-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-amber-100 border border-amber-200/60 text-amber-700 hover:bg-amber-200 transition active:scale-95"
>
<Pause className="h-4 w-4" />
</button>
)}
<button
type="submit"
disabled={askText.trim().length === 0 && askFiles.length === 0}
title={busy ? "打断当前轮并发送" : "发送(智能体自行判断改报告 or 回答)"}
className="mb-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary text-white transition hover:bg-[var(--brand-900)] disabled:cursor-not-allowed disabled:opacity-50"
>
<SendHorizontal className="h-4 w-4" />
</button>
</div>
</form>
)}
</div>
);
}
@@ -55,7 +55,7 @@ const SUMMARY_AGENT_NAME = "roundtable-summary";
/** 结构化抽取智能体 id —— 入库轮由它(走 ingest run policy)真正调用入库技能。 */
const STRUCTURE_AGENT_NAME = "roundtable-structure";
export type SummaryPhase = "idle" | "creating" | "streaming" | "done" | "error";
export type SummaryPhase = "idle" | "creating" | "streaming" | "paused" | "done" | "error";
interface UseStep3SummaryOptions {
intentReady: ReportIntent | null;
@@ -1883,12 +1883,15 @@ export function useStep3Summary(
[pendingFlowClarification, ask],
);
/** 暂停当前生成:中断在途请求 + 把流式气泡收尾为「已暂停」+ 状态回 done。 */
/** 暂停当前生成:中断在途请求 + 把流式气泡收尾为「已暂停」。 */
const pause = useCallback(() => {
if (!runningRef.current) return;
abort();
flowAborterRef.current?.abort();
flowAborterRef.current = null;
ingestRunRef.current += 1;
freezeStreaming("已暂停");
setPhase((p) => (p === "creating" || p === "streaming" ? "done" : p));
setPhase("paused");
setFlowPhase((p) => (p === "extracting" || p === "validating" ? "idle" : p));
}, [abort, freezeStreaming]);
const start = useCallback(() => {
@@ -2537,6 +2537,7 @@ export default function RoundtablePlanningPage({
headerRightSlot={step2HeaderRightSlot}
step2RoundtableDialogues={step2.step2RoundtableDialogues}
isInitializing={step2.isInitializing}
isRoundTableRunning={step2.isRoundTableRunning}
isOrchestrating={step2.isOrchestrating}
pendingClarification={step2.pendingClarification}
clarificationDraft={step2.clarificationDraft}
@@ -2564,6 +2565,7 @@ export default function RoundtablePlanningPage({
openArtifactFromStep={step2.openArtifactFromStep}
openArtifactPreview={step2.openArtifactPreview}
onPauseRoundtable={step2.pauseRoundtable}
onResumeRoundtable={step2.resumeRoundtable}
onHandleInjectToRoundtable={step2.handleInjectToRoundtable}
setClarificationDraft={step2.setClarificationDraft}
setCustomAgentInput={step2.setCustomAgentInput}