diff --git a/core/frontend/src/App.tsx b/core/frontend/src/App.tsx index 39e0203..635376e 100644 --- a/core/frontend/src/App.tsx +++ b/core/frontend/src/App.tsx @@ -567,7 +567,13 @@ export function App() { onBack={() => navigate("projects")} onCreate={async (payload) => { const created = await action(() => api.createProject(payload), "项目已创建"); - if (created) navigate("pipeline", { projectId: created.id }); + if (created) { + // 立刻把新项目落到 detail/列表,避免后台 hydrate 期间 pipeline 先闪出旧项目数据 + // (旧项目的脚本会污染新项目的脚本助手 chat) + setProjectDetail(created); + setProjects((prev) => (prev.some((p) => p.id === created.id) ? prev : [created, ...prev])); + navigate("pipeline", { projectId: created.id }); + } }} onCreateProduct={(payload) => action(() => api.createProduct(payload), "")} /> @@ -657,6 +663,7 @@ export function App() { const textModel = modelConfigs.find((m) => m.capability === "text" && m.status === "active") || modelConfigs.find((m) => m.capability === "text"); return ( (null); // 对话记录(本地会话态):生成动作可追溯,不再是「点了按钮、对话区永远空着」 // kind=progress:进度提示流(行33),steps 逐条滚动出现,done 后折叠成一行结果 - type ChatMsg = { id: number; role: "ai" | "user"; text: string; time: string; kind?: "progress"; steps?: string[]; done?: boolean }; + type ChatMsg = { id: number; role: "ai" | "user"; text: string; time: string; kind?: "progress"; steps?: string[]; done?: boolean; auto?: boolean }; const nowHm = () => new Date().toTimeString().slice(0, 5); const msgIdRef = useRef(1); const nextMsgId = () => msgIdRef.current++; @@ -591,13 +591,14 @@ export function PipelinePage(props: { } } catch { /* 解析失败则回退默认 */ } return currentScript - ? [{ id: nextMsgId(), role: "ai", text: `当前已有 ${currentScript.segments?.length ?? 0} 镜脚本(${currentScript.is_adopted ? "已采用" : "待采用"})。直接输入修改意见可整体重写。`, time: nowHm() }] + ? [{ id: nextMsgId(), role: "ai", auto: true, text: `当前已有 ${currentScript.segments?.length ?? 0} 镜脚本(${currentScript.is_adopted ? "已采用" : "待采用"})。直接输入修改意见可整体重写。`, time: nowHm() }] : []; }); - // 落盘:丢掉未完成的 progress 流(那是临时态),只保留最近 60 条 + // 落盘:auto 派生提示(「已有N镜」)不落盘——它跟当前脚本状态绑定,持久化会在切项目时串台; + // 未完成的 progress 流也不落盘(临时态);只保留最近 60 条真实对话 useEffect(() => { try { - const slim = chatMsgs.filter((m) => m.kind !== "progress" || m.done).slice(-60); + const slim = chatMsgs.filter((m) => !m.auto && (m.kind !== "progress" || m.done)).slice(-60); localStorage.setItem(chatKey, JSON.stringify(slim)); } catch { /* localStorage 不可用则忽略 */ } }, [chatKey, chatMsgs]);