diff --git a/frontend/app/features/platform/ModelPlatformApp.tsx b/frontend/app/features/platform/ModelPlatformApp.tsx index 8bf9fc5..9474406 100644 --- a/frontend/app/features/platform/ModelPlatformApp.tsx +++ b/frontend/app/features/platform/ModelPlatformApp.tsx @@ -184,6 +184,15 @@ function AuthenticatedModelPlatformApp() { selectedIdRef.current = nextSelectedId; return nextSelectedId; }); + // 同时更新打开的标签页 + setOpenTabIds((current) => { + const firstNotebook = items.find((item) => item.script_type === "notebook")?.script_id + ?? items[0]?.script_id; + if (!firstNotebook) return []; + // 如果当前标签页已经包含,则保持不变 + if (current.includes(firstNotebook)) return current; + return [firstNotebook]; + }); } catch (error) { setApiOnline(false); setToast({ @@ -200,6 +209,20 @@ function AuthenticatedModelPlatformApp() { void load(); }, []); + // 切换 Workspace 时重置状态并重新加载 + useEffect(() => { + setScripts([]); + setDirectories([]); + setSelectedId(null); + setOpenTabIds([]); + setLatestVersion(null); + setEmbeddedJupyterUrl(null); + setEditSession(null); + editSessionRef.current = null; + selectedIdRef.current = null; + void load(); + }, [currentWorkspace.workspace_id]); + useEffect(() => { if (!toast) return; const timer = window.setTimeout(() => setToast(null), 3200);