fix(core): 彻底修进入新建项目串台旧项目脚本

上一版没根治:action() 的后台 refreshProjectDetail 用旧 activeProjectId 拉到旧项目,
异步写回 projectDetail,而 pipelineProject=projectDetail||activeProject 无条件优先用它,
导致刚建的空项目仍渲染上一个项目的脚本(实测 Playwright 复现)。
改为渲染时校验 projectDetail.id===activeProjectId 才采用,否则回退 activeProject(列表项
已含完整嵌套脚本)。配合上一版的乐观 setProjectDetail/插入 projects + key=project.id,
新建项目即时显示空态+行30 三选项。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-06-16 18:27:44 +08:00
co-authored by Claude Opus 4.8
parent 3313269438
commit a0ffb6fc8e
+4 -1
View File
@@ -326,6 +326,7 @@ export function App() {
async function refreshProjectDetail() { async function refreshProjectDetail() {
if (!activeProjectId) return; if (!activeProjectId) return;
const detail = await api.project(activeProjectId).catch(() => null); const detail = await api.project(activeProjectId).catch(() => null);
// 写进 projectDetail;渲染处 pipelineProject 会校验 id 是否仍是当前激活项目,故后台旧请求写回也不会串台
if (detail) setProjectDetail(detail); if (detail) setProjectDetail(detail);
} }
@@ -658,7 +659,9 @@ export function App() {
const here = crumbLabels[page] || routeLabels[page] || "工作台"; const here = crumbLabels[page] || routeLabels[page] || "工作台";
// 生产管线 · 全屏 bespoke 布局(自带顶栏 + 步进器),脱离常规 shell // 生产管线 · 全屏 bespoke 布局(自带顶栏 + 步进器),脱离常规 shell
const pipelineProject = projectDetail || activeProject; // projectDetail 只有在确实是当前激活项目时才用;否则回退 activeProject。
// 否则后台 refreshProjectDetail 拿旧 id 的结果会把刚进入的新项目串成上一个项目(实测发现)。
const pipelineProject = projectDetail && projectDetail.id === activeProjectId ? projectDetail : activeProject;
if (page === "pipeline" && pipelineProject) { if (page === "pipeline" && pipelineProject) {
const textModel = modelConfigs.find((m) => m.capability === "text" && m.status === "active") || modelConfigs.find((m) => m.capability === "text"); const textModel = modelConfigs.find((m) => m.capability === "text" && m.status === "active") || modelConfigs.find((m) => m.capability === "text");
return ( return (