From 5566db60392c348bc868f8adaae5f5423a70212d Mon Sep 17 00:00:00 2001 From: GCWing Date: Sat, 14 Mar 2026 18:03:28 +0800 Subject: [PATCH] feat(workspace): revamp miniapp and shell scene flows Replace the old toolbox flow with dedicated miniapp scenes and richer workspace navigation so shell, assistant workspaces, and chat sessions open in the right context. Tighten session persistence and ordering to keep the new multi-scene workflow stable across switches and restarts. Made-with: Cursor --- MiniApp/Demo/git-graph/README.md | 8 +- MiniApp/Skills/miniapp-dev/SKILL.md | 20 +- MiniApp/Skills/miniapp-dev/architecture.md | 27 +- pnpm-lock.yaml | 220 ++++++++++++++- src/apps/desktop/src/api/commands.rs | 33 +++ src/apps/desktop/src/lib.rs | 1 + .../core/src/service/workspace/service.rs | 45 +++ src/web-ui/package.json | 9 +- .../src/app/components/NavPanel/MainNav.tsx | 157 ++++++----- .../src/app/components/NavPanel/NavPanel.scss | 26 +- .../NavPanel/components/MiniAppEntry.tsx | 123 ++++++++ .../NavPanel/components/ToolboxEntry.tsx | 176 ------------ .../src/app/components/NavPanel/config.ts | 7 - .../sections/sessions/SessionsSection.scss | 4 +- .../sections/sessions/SessionsSection.tsx | 25 +- .../sections/workspaces/WorkspaceItem.tsx | 25 +- .../workspaces/WorkspaceListSection.scss | 47 +++- .../workspaces/WorkspaceListSection.tsx | 165 ++++++++++- .../src/app/components/SceneBar/types.ts | 2 +- src/web-ui/src/app/hooks/useSceneManager.ts | 4 +- src/web-ui/src/app/layout/AppLayout.tsx | 21 +- .../src/app/layout/FloatingMiniChat.tsx | 6 +- src/web-ui/src/app/scenes/SceneViewport.scss | 36 --- src/web-ui/src/app/scenes/SceneViewport.tsx | 40 +-- .../MiniAppGalleryScene.scss} | 2 +- .../scenes/miniapps/MiniAppGalleryScene.tsx | 20 ++ .../{toolbox => miniapps}/MiniAppScene.scss | 0 .../{toolbox => miniapps}/MiniAppScene.tsx | 24 +- .../components/MiniAppCard.scss | 3 - .../components/MiniAppCard.tsx | 0 .../components/MiniAppRunner.tsx | 0 .../hooks/useMiniAppBridge.ts | 0 .../miniapps/hooks/useMiniAppCatalogSync.ts | 80 ++++++ .../miniAppStore.ts} | 22 +- .../utils/buildMiniAppThemeVars.ts | 0 .../utils/miniAppIcons.tsx | 0 .../views/MiniAppGalleryView.scss} | 4 +- .../views/MiniAppGalleryView.tsx} | 62 ++-- src/web-ui/src/app/scenes/registry.ts | 6 +- src/web-ui/src/app/scenes/shell/ShellNav.scss | 119 +++++++- src/web-ui/src/app/scenes/shell/ShellNav.tsx | 156 ++++++++++- .../app/scenes/shell/hooks/useShellEntries.ts | 107 +++---- .../src/app/scenes/toolbox/ToolboxScene.tsx | 49 ---- .../scenes/toolbox/hooks/useMiniAppList.ts | 53 ---- src/web-ui/src/app/types/index.ts | 2 +- .../components/Tooltip/Tooltip.tsx | 21 +- .../src/flow_chat/components/ChatInput.scss | 106 +++++-- .../src/flow_chat/components/ChatInput.tsx | 45 ++- .../src/flow_chat/components/WelcomePanel.tsx | 40 ++- .../components/btw/BtwSessionPanel.scss | 7 +- .../components/btw/BtwSessionPanel.tsx | 7 +- .../modern/ModernFlowChatContainer.tsx | 10 +- .../components/toolbar-mode/ToolbarMode.tsx | 5 +- .../flow_chat/services/BtwThreadService.ts | 45 +-- .../src/flow_chat/services/FlowChatManager.ts | 3 +- .../flow-chat-manager/EventHandlerModule.ts | 26 +- .../flow-chat-manager/PersistenceModule.ts | 35 +-- .../flow-chat-manager/SessionModule.ts | 7 +- .../src/flow_chat/store/FlowChatStore.ts | 264 ++++++++++++------ .../tool-cards/MiniAppToolDisplay.tsx | 2 +- .../flow_chat/tool-cards/TerminalToolCard.tsx | 16 +- src/web-ui/src/flow_chat/types/flow-chat.ts | 5 +- .../flow_chat/utils/sessionMetadata.test.ts | 261 +++++++++++++++++ .../src/flow_chat/utils/sessionMetadata.ts | 249 +++++++++++++++++ .../flow_chat/utils/sessionOrdering.test.ts | 58 ++++ .../src/flow_chat/utils/sessionOrdering.ts | 22 ++ .../api/service-api/GlobalAPI.ts | 14 + .../contexts/WorkspaceContext.tsx | 21 ++ .../services/business/workspaceManager.ts | 167 ++++++++++- src/web-ui/src/locales/en-US/common.json | 18 +- src/web-ui/src/locales/en-US/flow-chat.json | 10 +- src/web-ui/src/locales/zh-CN/common.json | 18 +- src/web-ui/src/locales/zh-CN/flow-chat.json | 10 +- src/web-ui/src/main.tsx | 13 + .../shared/services/openShellSessionTarget.ts | 45 +++ .../services/sceneOpenTargetResolver.ts | 2 +- src/web-ui/src/shared/types/global-state.ts | 5 + .../src/shared/types/session-history.ts | 13 +- src/web-ui/src/shared/utils/tabUtils.ts | 51 +++- .../tools/terminal/components/Terminal.tsx | 100 ++++--- tests/e2e/specs/l1-navigation.spec.ts | 8 +- 81 files changed, 2742 insertions(+), 923 deletions(-) create mode 100644 src/web-ui/src/app/components/NavPanel/components/MiniAppEntry.tsx delete mode 100644 src/web-ui/src/app/components/NavPanel/components/ToolboxEntry.tsx rename src/web-ui/src/app/scenes/{toolbox/ToolboxScene.scss => miniapps/MiniAppGalleryScene.scss} (78%) create mode 100644 src/web-ui/src/app/scenes/miniapps/MiniAppGalleryScene.tsx rename src/web-ui/src/app/scenes/{toolbox => miniapps}/MiniAppScene.scss (100%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/MiniAppScene.tsx (91%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/components/MiniAppCard.scss (96%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/components/MiniAppCard.tsx (100%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/components/MiniAppRunner.tsx (100%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/hooks/useMiniAppBridge.ts (100%) create mode 100644 src/web-ui/src/app/scenes/miniapps/hooks/useMiniAppCatalogSync.ts rename src/web-ui/src/app/scenes/{toolbox/toolboxStore.ts => miniapps/miniAppStore.ts} (68%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/utils/buildMiniAppThemeVars.ts (100%) rename src/web-ui/src/app/scenes/{toolbox => miniapps}/utils/miniAppIcons.tsx (100%) rename src/web-ui/src/app/scenes/{toolbox/views/GalleryView.scss => miniapps/views/MiniAppGalleryView.scss} (94%) rename src/web-ui/src/app/scenes/{toolbox/views/GalleryView.tsx => miniapps/views/MiniAppGalleryView.tsx} (83%) delete mode 100644 src/web-ui/src/app/scenes/toolbox/ToolboxScene.tsx delete mode 100644 src/web-ui/src/app/scenes/toolbox/hooks/useMiniAppList.ts create mode 100644 src/web-ui/src/flow_chat/utils/sessionMetadata.test.ts create mode 100644 src/web-ui/src/flow_chat/utils/sessionMetadata.ts create mode 100644 src/web-ui/src/flow_chat/utils/sessionOrdering.test.ts create mode 100644 src/web-ui/src/flow_chat/utils/sessionOrdering.ts create mode 100644 src/web-ui/src/shared/services/openShellSessionTarget.ts diff --git a/MiniApp/Demo/git-graph/README.md b/MiniApp/Demo/git-graph/README.md index 86c8a8f9..c2115c82 100644 --- a/MiniApp/Demo/git-graph/README.md +++ b/MiniApp/Demo/git-graph/README.md @@ -70,11 +70,11 @@ miniapps/git-graph/ 3. **Install dependencies**: inside the MiniApp's app directory, run: - `bun install` or `npm install` (matching the runtime BitFun detected) - - Or use the "Install Dependencies" action in Toolbox (calls `miniapp_install_deps`) + - Or use the "Install Dependencies" action in the Mini Apps gallery (calls `miniapp_install_deps`) 4. **Compile**: to regenerate `compiled.html`, call `miniapp_recompile` or let BitFun compile automatically when the MiniApp is opened. -5. Open the MiniApp in the Toolbox scene, pick a repository, and the Git Graph will appear. +5. Open the MiniApp in the Mini Apps gallery, pick a repository, and the Git Graph will appear. ### Permissions @@ -159,11 +159,11 @@ miniapps/git-graph/ 3. **安装依赖**:在 MiniApp 的 app 目录下执行: - `bun install` 或 `npm install`(与 BitFun 检测到的运行时一致) - - 或在 Toolbox 中对该 MiniApp 执行「安装依赖」操作(调用 `miniapp_install_deps`) + - 或在 Mini Apps 画廊中对该 MiniApp 执行「安装依赖」操作(调用 `miniapp_install_deps`) 4. **编译**:若需重新生成 `compiled.html`,可调用 `miniapp_recompile` 或由 BitFun 在打开该 MiniApp 时自动编译。 -5. 在 Toolbox 场景中打开该 MiniApp,选择仓库后即可查看 Git Graph。 +5. 在 Mini Apps 画廊中打开该 MiniApp,选择仓库后即可查看 Git Graph。 ### 权限说明 diff --git a/MiniApp/Skills/miniapp-dev/SKILL.md b/MiniApp/Skills/miniapp-dev/SKILL.md index 14b7206d..904527df 100644 --- a/MiniApp/Skills/miniapp-dev/SKILL.md +++ b/MiniApp/Skills/miniapp-dev/SKILL.md @@ -1,6 +1,6 @@ --- name: miniapp-dev -description: Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, toolbox scene, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/toolbox/. Also use when the user mentions MiniApp, toolbox, bridge, or zero-dialect. +description: Develops and maintains the BitFun MiniApp system (Zero-Dialect Runtime). Use when working on miniapp modules, Mini Apps gallery, bridge scripts, agent tool (InitMiniApp), permission policy, or any code under src/crates/core/src/miniapp/ or src/web-ui/src/app/scenes/miniapps/. Also use when the user mentions MiniApp, miniapps, bridge, or zero-dialect. --- # BitFun MiniApp V2 开发指南 @@ -52,14 +52,16 @@ src/crates/core/src/agentic/tools/implementations/ ### 前端 ``` -src/web-ui/src/app/scenes/toolbox/ -├── ToolboxScene.tsx / .scss -├── toolboxStore.ts -├── views/ GalleryView, AppRunnerView +src/web-ui/src/app/scenes/miniapps/ +├── MiniAppGalleryScene.tsx / .scss +├── MiniAppScene.tsx / .scss +├── miniAppStore.ts +├── views/ MiniAppGalleryView ├── components/ MiniAppCard, MiniAppRunner (iframe 带 data-app-id) -└── hooks/ - ├── useMiniAppBridge.ts # 仅处理 worker.call → workerCall() + dialog.open/save/message - └── useMiniAppList.ts +├── hooks/ +│ ├── useMiniAppBridge.ts # worker.call → workerCall() + dialog.open/save/message +│ └── useMiniAppCatalogSync.ts # 列表与运行态同步 +└── utils/ miniAppIcons.tsx, buildMiniAppThemeVars.ts src/web-ui/src/infrastructure/api/service-api/MiniAppAPI.ts # runtimeStatus, workerCall, workerStop, installDeps, recompile src/web-ui/src/flow_chat/tool-cards/MiniAppToolDisplay.tsx # InitMiniAppDisplay @@ -213,7 +215,7 @@ body { ### 前端事件 -后端 `miniapp-created` / `miniapp-updated` / `miniapp-deleted`,前端 `useMiniAppList` 监听刷新。 +后端 `miniapp-created` / `miniapp-updated` / `miniapp-deleted` / `miniapp-worker-*`,前端 `useMiniAppCatalogSync` 统一监听并刷新 store。 ## 场景注册检查清单 diff --git a/MiniApp/Skills/miniapp-dev/architecture.md b/MiniApp/Skills/miniapp-dev/architecture.md index 458cb52c..21af1078 100644 --- a/MiniApp/Skills/miniapp-dev/architecture.md +++ b/MiniApp/Skills/miniapp-dev/architecture.md @@ -7,8 +7,8 @@ AI 对话 → GenerateMiniApp Tool → MiniAppManager::create() → storage.rs 持久化 source + meta.json → compiler.rs 生成 compiled_html(注入 Bridge) → emit miniapp-created 事件 - → 前端 useMiniAppList 监听 → 刷新 GalleryView - → 用户点击「打开」→ AppRunnerView → MiniAppRunner + → 前端 useMiniAppCatalogSync 监听 → 刷新 MiniAppGalleryView + → 用户点击「打开」→ MiniAppScene → MiniAppRunner →