Skip to content

fix(console): 打包 console 时注入本仓库 client,杜绝新 UI + 旧 client 漂移#2513

Merged
os-zhuang merged 2 commits into
mainfrom
claude/console-bundle-own-client
Jul 2, 2026
Merged

fix(console): 打包 console 时注入本仓库 client,杜绝新 UI + 旧 client 漂移#2513
os-zhuang merged 2 commits into
mainfrom
claude/console-bundle-own-client

Conversation

@baozhoutao

Copy link
Copy Markdown
Contributor

Fixes #2512

问题

@objectstack/console@11.5.0 运行时报 "The connected @objectstack/client does not support async import jobs."。

根因:build-console.shobjectui 自己的 lockfile 安装依赖后打包,console bundle 里的 client 版本由 objectui lockfile 决定。发版时新 client 还没上 npm,objectui lockfile 不可能指向它 → 发布产物 = 新导入 UI + client 11.2.0(无 data.createImportJob)。已在 os-tianshun-ehr 逐环验证(实际 serve 的 dist 中 import/jobs 出现 0 次)。

按旧机制,今后凡是给 client 加新 API 且 UI 依赖,都要「发 framework → objectui bump pin → framework 再发一版」两段式。本 PR 终结这个问题。

改动(仅 scripts/build-console.sh)

  1. 构建 console 前 export OBJECTSTACK_CLIENT_DIST=<framework>/packages/client,vite 把本仓库、本版本的 client 打进 bundle(objectui 的 apps/console/vite.config.ts 钩子,main 已有;pinned SHA 缺钩子时报错退出,不静默漂移)。client dist 缺失时先构建。
  2. 构建拆两步:deps 走 turbo(可缓存、与 env 无关),console 本体直接跑自己的 build 脚本——turbo v2 strict env 会剥掉未声明的环境变量,第一次注入尝试就是这样静默失败的(实测复现)。objectui 侧同步在 turbo.json 声明该 env(fix(deps): bump @objectstack/client 到 ^11.5.0,修复 console 产物打包旧 client 导致异步导入不可用 objectui#2146)。
  3. 产物 canary 断言:构建完成后 dist/assets 必须含 import/jobs(CONSOLE_BUNDLE_CANARY 可换),否则脚本失败——旧 client 再也不可能静默发布出去。

验证

当前 pinned SHA 1432efe81(lockfile 仍解析 client 11.2.0)上完整跑 scripts/build-console.sh:

  • 修改前产物:import/jobs 0 次(即线上 11.5.0 的状态)
  • 修改后产物:import/jobs 进入 dist/assets,canary 断言通过,脚本 exit 0

即:不等 objectui 换 SHA,以现 pin 重打 dist 即可发 @objectstack/console@11.5.1 修复线上。

另外 objectui 侧真实链路 E2E(真 console + npm client@11.5.0 + 真后端,后台导入→历史→撤销)已通过,见 objectstack-ai/objectui#2146

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 2, 2026 4:53am

Request Review

@github-actions github-actions Bot added the size/s label Jul 2, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling labels Jul 2, 2026
@os-zhuang
os-zhuang merged commit b990bc2 into main Jul 2, 2026
15 checks passed
@os-zhuang
os-zhuang deleted the claude/console-bundle-own-client branch July 2, 2026 12:29
The console SPA inlines @objectstack/client, and the version came from
objectui's own lockfile — which necessarily lags the framework whenever
a release adds new client APIs (the new client isn't on npm when
objectui's lockfile is written). 11.5.0 shipped the new import UI
bundled against client 11.2.0, so the console threw "The connected
@objectstack/client does not support async import jobs." at runtime.

build-console.sh now exports OBJECTSTACK_CLIENT_DIST=packages/client so
vite aliases the bundled client to this repo's own build — the bundled
client always matches the framework release, eliminating the
framework → objectui pin-bump → framework re-release round-trip.

Details:
- Fail hard if the pinned objectui SHA lacks the vite.config.ts hook.
- Build the client dist first if missing.
- Split the build: deps via turbo, the console app via its own build
  script directly — turbo v2 strict env strips undeclared vars, which
  is exactly how the first injection attempt silently produced a stale
  bundle.
- Post-build canary (CONSOLE_BUNDLE_CANARY, default 'import/jobs')
  asserts the fresh client actually landed in dist/assets.

Verified: rebuilt at the currently pinned SHA 1432efe81 (whose lockfile
still resolves client 11.2.0) — dist now contains the import/jobs
routes; before this change it had zero occurrences.

Fixes #2512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build-console.sh 打包 console 时应注入本仓库 client,否则新 UI + 旧 client 漂移(11.5.0 已发生)

2 participants