Skip to content

Unify the chat workbench and application shell (startup contract fixed) - #1503

Open
Zhong-Chenchen wants to merge 17 commits into
Tencent:mainfrom
Zhong-Chenchen:fix-990
Open

Zhong-Chenchen wants to merge 17 commits into
Tencent:mainfrom
Zhong-Chenchen:fix-990

Conversation

@Zhong-Chenchen

@Zhong-Chenchen Zhong-Chenchen commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #118

这个 PR 是什么

把首页的 React 对话工作台从同源 iframe 搬到主文档的 #chatRoot,删掉 agentflow-chat-ready 握手和多种父子窗口消息,让管理导航与聊天共享同一个文档;保留 LOOP 编排与内容预览的隔离。

原 PR #990 完成了这个结构迁移,但评审时发现启动与状态的归属没有收敛成一个契约,派生出一个 P1 和若干行为回归。这个分支在原结构上把它们修掉了,并已合入最新 main(含 #1434 knowledge、#1440 aiSchedules、#1450 privileged Docker sandboxes in settings 等)。

相对 main:77 个文件,+1796 / −818,17 个提交。原 #990 将关闭,讨论历史留在那边。

修的问题

P1 · 聊天模块失败会带塌整个平台

原来 web/app/start.js 只注册 window.loopforgeBootstrap,启动被挪到 chatbot/src/main.jsx 的 effect 里。入口 JS 或其静态依赖 404 / 解析失败时该 effect 不存在,内部 .catch() 捕不到,boot() 里的鉴权、bind()、首屏路由、loader 收尾都不执行 —— 设置页、需求页全部进不去。

现在原生启动器自己持有幂等 bootPromise,聊天只消费就绪状态;聊天失败只在工作台区域内显示可重试错误,其它页面照常可用。CSS 也一并处理:聊天样式加载不再阻塞原生启动脚本,样式挂起或 404 时给区域级错误与重试,不会出现无样式工作台。

行为回归

  • 全局 CSS scope 插件此前连定时任务编辑器的 ?inline 样式一起改写,注入管理页 ShadowRoot 后匹配不到祖先,.composer 从 relative 变 static、textarea 112px 变 60px、@ 弹层失去定位。现在 scope 转换只作用于工作台样式表。
  • 同一个 ?chatSession=s-1#/collaboration,从会话详情进入会清空当前会话、从设置进入会保留。现在路由收敛成单一解析,首次加载 / 同页 hash / 跨页 / 前进后退共用,消费入站路由不再回写 URL。
  • 去掉 iframe 后按键先到 document 再到 window,Ctrl/⌘+K 会同时弹出两套搜索框并抢焦点;模型菜单展开时一次 Escape 会关掉两层。现在单点派发、下游尊重 defaultPrevented、Escape 只由最上层消费并回焦。
  • 英语模式下宿主翻译器会改写助手回答正文(新建需求 → New requirement),可复制内容不再是模型原文。现在消息正文、Markdown、产物内容与对象名标记为不可翻译,翻译只作用于 UI 标签。
  • 「执行器配置 → 返回快速接入」会把向导重置到第 0 步并清字段。现在区分「进行中」与「当前可见」,暂停不重置步骤、返回刷新凭据并清空 token。

入口与缓存

  • 恢复构建指纹入口:只有真实存在的指纹产物才 immutable,固定名继续 no-store。
  • 入口契约区分宿主挂载 / LOOP 独立入口 / 开发入口;未识别的 surface 返回 404,旧 /chatbot/ 迁移链接 302 回宿主。
  • 清掉无消费者的 subscribeState、从未赋值的 bootLoaderTimer 等死代码。

测试与门禁

  • 统一 Playwright/Chromium 版本,修好此前失效的 unified-entry 用例(它还在按 SOP 文案找元素,界面早已是 LOOP),并把确定性浏览器用例接进 head 构建的 browser job。
  • 需求交接改为即时挂载与延迟挂载两个用例,断言实际 textarea / 引用 / 项目,而不是只断言发送事件。

验证

套件 结果
go build ./...(-buildvcs=false)、go vet ./... 通过
go test ./web、定向 internal/httpapi / schedule 用例 通过
chatbot Vitest 556 通过 / 0 失败
webtest 397 通过 / 0 失败
chatbot/browser/unified-entry.test.mjs 18 项全过

合并后 git merge-base --is-ancestor origin/main HEAD 成立,分支落后 main 0 个提交。

已知限制

说明

评审发现的问题由独立评审会话复核过两轮;本分支的问题清单与解决方式逐条对应,未夹带与本 PR 无关的重构。

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.
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.
# Conflicts:
#	chatbot/src/App.jsx
#	web/app.js
#	web/syntax_test.go
#	webtest/tests/composer-flow.test.mjs
# Conflicts:
#	chatbot/src/App.jsx
#	chatbot/src/RichContent.jsx
#	chatbot/src/useChat.js
#	web/app.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 移除首页 iframe,统一前端应用入口与状态管理

1 participant