Repository navigation
Unify the chat workbench and application shell - #990
Zhong-Chenchen wants to merge 13 commits into
Conversation
Keep upstream main's newer chat, credential, runner, SOP and settings behaviour and re-apply the unified entry changes on top of it instead of reverting them. - The workbench mounts in the page (#chatRoot) and the shell talks to it through window.loopforgePlatform; the iframe bridge stays only for embedded surfaces such as the SOP orchestrator and previews. - Project, session, issue, theme, sidebar, environment, credential, assistant-preference, quick-access-return and requirement-handoff updates travel through the shared application state. - /chatbot/ still redirects to the platform entry, except for embedded ?surface= requests, so the SOP orchestrator panel keeps working. - Upstream tests are kept: chatbot vitest, webtest and the Go suites pass as they do on main.
7742f7c to
c427d50
Compare
The platform shell links a single /chatbot/assets/workbench.css. Vite split the static CSS graph into workbench.css and workbench2.css, so the unified workbench loaded only the first half: the home hero and composer lost their layout and the executor and mention menus overflowed the viewport at short and mobile sizes. Disable CSS code splitting so the pinned stylesheet name holds the whole graph.
The platform translates the chat UI inside the unified shell, including aria-labels, so the chip's "移除引用 <name>" label became "Remove reference <translated name>" and lost the reference's own name. Split the accessible name into a translated prefix and a name node that opts out of translation, matching the visible chip, and let the references spec expect the English prefix in the English variants.
Resolve the requirement-composer source assertion: the handoff now travels
through platformNotify('mentionIssue') and upstream renamed the SOP label to
LOOP.
There was a problem hiding this comment.
我自己把这个 PR 过了一遍(head 0a208c13e,base c039a78a),思路是认可的:把首页那个 React 工作台从 iframe 里搬出来直接挂到主文档的 #chatRoot,顺手删掉 agentflow-chat-ready 握手和一堆父子窗口消息 —— 这个方向没问题,也没看到重复 createRoot() 或者漏清的事件订阅。顺手说一句,#1286 那个 SOP→LOOP 的重命名它没有漏合:菜单里已经是 LOOP 了,而 type=sop、surface=sop-designer、agentflow-sop-designer-* 本来就是 #1286 要保留的协议字串,机械改反而会坏。
我拉了两个独立工作树(head 和 base 各一个),跑了构建、单测、前端测试和五个 Chromium 场景。
构建与测试
| 套件 | head | base |
|---|---|---|
go build ./...(-buildvcs=false)/ go vet ./... |
通过 | 通过 |
| Go 单测,顶层 | 3173 通过 / 9 失败 | 3111 通过 / 10 失败 |
| Go 单测,含子测试 | 4966 / 15 | 4869 / 16 |
| Vitest | 538 通过 / 0 失败 | 534 通过 / 1 失败 |
| webtest | 317 通过 / 0 失败(覆盖率 86.35%) | 315 通过 / 0 失败(86.29%) |
没找到 head 独有的失败;base 独有的只有 engine.TestParallelBranchesExecuteConcurrently,head 那 9 项它也有(浏览器启动、Git 动态库 curl_global_trace、runner/SOP 四条、助手两条)。base 那条 Vitest 失败是 message-queue-hook.test.jsx 的排队回执,单独复跑两边都 24/24,不稳定,不能当成这个 PR 修了什么。internal/httpapi 两边都撞上 10 分钟包超时,上面计数只含实际跑完的用例。
五个场景(无头 Chromium,同提交编译的 fixture,真实 httpapi.New + go:embed 产物)
| 场景 | head | base |
|---|---|---|
a. 拦截 /chatbot/assets/workbench.js 后访问 /#/settings |
模块被中止,boot=true、loader aria-busy、view="",/api/bootstrap 0 次,设置页打不开 |
同一路径没被请求,boot=false、view="settings",/api/bootstrap 1 次 |
b. 390×600 新建 AI 定时任务、输入 @ |
textarea 高 60px,.composer 是 static;@ 弹层也是 static,offsetParent 变成 .schedule-modal-card,在文档流里占位 |
textarea 112px,.composer 是 relative;弹层 absolute,offsetParent 是 .composer |
c. 进入 ?chatSession=s-1#/collaboration,从详情 / 从设置改同一 hash |
详情→工作台:无选中行,session 变 "",URL 里 chatSession 被移除;设置→工作台:选 s-1 |
两种路径都保留 s-1 |
d. 1280×400 输入框聚焦后 Ctrl+K |
命令面板和聊天搜索框都打开,焦点在 #commandSearch,对中心点做命中测试,聊天搜索的覆盖层挡住了它自己的输入框 |
从聊天输入框触发只开聊天搜索;焦点在宿主时只开命令面板 |
e. 英语模式,助手回答 {"message":"新建需求"} |
正文显示 New requirement |
正文显示 新建需求 |
入口资源与契约
| 请求 | head | base |
|---|---|---|
/chatbot/assets/workbench.js |
200,no-store,647,968 B |
404;实际入口 main-DF5Gx06O.js 是 immutable、647,636 B |
/chatbot/assets/workbench.css |
200,no-store,334,360 B |
404;两个带指纹的 stylesheet 各 immutable,合计 307,613 B |
/chatbot/?surface=unknown |
挂 standalone 工作台 App | 挂 standalone 工作台 App |
/chatbot/?surface=sop-designer |
挂 standalone SOP designer | 挂 standalone SOP designer |
/chatbot/ |
302 到 /#/collaboration,宿主 #chatRoot 挂工作台 |
200,直接挂 standalone 工作台 App |
具体问题:
-
[P1] 聊天模块挂掉会把整个平台带塌(
web/app/start.js:3、chatbot/src/main.jsx:36、web/app.js:905)
start.js现在只注册window.loopforgeBootstrap,自己不调 boot 了,启动挪到main.jsx的 effect 里。那么入口 JS 或其依赖 404 / 解析失败的时候,这个 effect 压根不存在,里面的.catch()也就抓不到 ——boot()里的鉴权、bind()、首屏路由、loader 收尾全部不跑,需求页、设置页都进不去(a 场景实测就是这么卡住的)。这个我觉得得改回由原生启动器持有幂等的bootPromise,聊天只去消费;聊天自己失败就在工作台区域里显示可重试的错误,别影响别的页面。顺便说,webtest/lib/load-app.mjs:235是跳过模块直接手动start()的,所以现有测试刚好绕过了这条路。 -
[P2]
?inline的 CSS 也被加了#chatRoot前缀(chatbot/vite.config.js:8、chatbot/src/prompt-editor-entry.jsx:73)
scope 插件是全局套的,定时任务编辑器那份?inline样式被改成#chatRoot :host/#chatRoot .composer textarea,然后注进管理页的 ShadowRoot 里 —— 那儿没有#chatRoot祖先,全部匹配不上。mount()还是成功,宿主接着把原生 textarea 藏了,所以用户看不到报错,只看到编辑器塌了:.composer从relative变成static,@弹层跟着从绝对定位变成在文档流里占位。建议只在工作台的 stylesheet 上做 scope 转换。 -
[P2] 同一个会话 URL 的含义得看你是从哪进来的(
web/app.js:1006、web/app.js:2026、chatbot/src/useChat.js:675)
同页和跨视图走了两套解析:同页发现没有路由 id 就把chatSession删了发个空 session,跨视图反而回退去读 query。而且 React 收到路由事件就直接open(),所以不只是地址不同,当前生成视图和输入上下文都会被清掉(c 场景:同一个 URL,从详情进来 session 变成空串,从设置进来是s-1)。建议先把裸路由的语义定死,然后初次加载、同页 hash、跨页、前进后退全走同一个解析函数。 -
[P2] 快捷键被吃了两次(
web/app.js:1362、chatbot/src/App.jsx:843)
没了 iframe 以后,按键先到document再到window。原生那边preventDefault()拦不住 window 上的 React handler,而后者只看工作台可不可见,不看事件有没有被消费过,于是两边各开一个(d 场景:两个都可见,焦点在命令面板,而且聊天搜索的覆盖层还挡住了它自己的输入框)。建议集中决定一次派给谁,下游认defaultPrevented,Escape 只给最上层。 -
[P2] 英语模式会改助手回答的正文(
chatbot/src/RichContent.jsx:367、web/i18n.js:90)
用户气泡和部分引用它排掉了,但助手 Markdown 的容器类是.markdown,不在排除列表那个.markdown-body里,所以「新建需求」被翻成New requirement(e 场景,两边对照很干净)。这个对可复制内容来说性质不一样 —— 显示出来已经不是模型原文了。建议把消息正文、产物内容、对象名都标成不可翻译,只在 UI 标签的位置翻。 -
[P2] 从「执行器配置」返回会把快速接入向导打回第 0 步(
chatbot/src/App.jsx:423、chatbot/src/QuickAccessWizard.jsx:872)
去设置时setQuickAccessOpen(false),返回时再置 true,向导的 reopening effect 把它当成新开一轮,回到第 0 步并把填过的东西清了。main 上 iframe 只是被隐藏,所以向导能保住步骤。建议把「正在进行的向导」和「当前可见」分开。 -
[P3] 这份用来验证统一入口的浏览器用例本身是坏的(
chatbot/browser/unified-entry.test.mjs:100、.github/workflows/platform.yml:168)
实际跑了一遍:前面的挂载、草稿保留、主题、会话路由都过了,最后切到英语、输入@之后,locator('#chatRoot .mention-options [role="option"]')过滤hasText: 'SOP'等满 30 秒超时 —— 界面早就叫 LOOP 了。另外npm test跑的是 Vitest,CI 跑的是e2e/下的 Playwright,这份根本不在门禁里;原来「交接延后 / 冷挂载恢复」那两条断言被换成了往事件中心塞个订阅者再比一下 root 节点,实际覆盖不到。
不阻塞的两条:
- 入口现在固定叫
workbench.js/workbench.css,no-store且不带指纹,等于每次导航要重下 647,968 B JS + 334,360 B CSS;base 那两个入口是带指纹、immutable的。建议恢复 #1231 那种指纹文件名,有指纹才 immutable。 internal/httpapi/studio.go:118只判断surface是不是空,所以/chatbot/?surface=unknown和?surface=sop-designer返回的字节完全一样(564 B),靠前端 JS 按 query 选组件,未识别的 surface 会直接挂一整套 standalone App,而不是 302 回宿主。另外subscribeState没消费者、bootLoaderTimer从来没被赋过非零值,可以一起清掉。
结论:先别合。 P1 那条影响面太大,2、3、4、5 也都是用户能直接踩到的。不用重写原生管理页,也不用把 iframe 加回来,把启动归属、会话路由、样式作用域这三条边界收干净就行。
Problem and changes
The home page embeds the React chat workbench in a same-origin iframe, splitting routing, project and session context, theme, and initialization across documents. This change mounts the workbench directly in the main document and introduces an explicit shared state and application interface for chat and management views. Navigation away keeps chat mounted so conversations and drafts remain available.
Existing management views remain native modules, integrated through the shared routing and state boundary; they are not rewritten as React pages in this change. The old
/chatbot/entry redirects to the main application, while preview and other purpose-specific iframes remain. Chat styles are scoped to avoid conflicts. The standalone development host retains its existing requirement handoff listener; the unified application uses the in-document interface.Closes #118
Validation
main:npm test(57 files, 376 tests);npm run build;node --test webtest/tests/app-shell.test.mjs webtest/tests/loader.test.mjs(11 tests);git diff --check.design.md.