Skip to content

fix(desktop): 补齐启动所需的 Unicode 11 终端依赖 - #3969

Merged
deepcoldy merged 1 commit into
deepcoldy:masterfrom
MaxzMeng:fix/desktop-unicode11-runtime
Nov 28, 2026
Merged

deepcoldy merged 1 commit into
deepcoldy:masterfrom
MaxzMeng:fix/desktop-unicode11-runtime

Conversation

@MaxzMeng

Copy link
Copy Markdown
Contributor

问题与修复

在 macOS 桌面版 3.59.35 点击「启动」时,内置 CLI 报 ERR_MODULE_NOT_FOUND: Cannot find package '@xterm/addon-unicode11'。CLI 启动时会加载 HC 的 screen-mirror,其中静态导入了这个包。桌面打包脚本使用 bun install --production,因此原先列在 devDependencies 的插件没有进入安装包。

将 @xterm/addon-unicode11 移入 dependencies 并同步 bun.lock,沿用已锁定的 0.9.0。桌面运行时测试增加了对该生产依赖的检查。

验证

  • 在 macOS arm64 上,分别用修复前后的清单和锁文件运行 scripts/prepare-desktop-runtime.mjs,将生成的运行时解压到仓库外,避免从开发环境加载依赖。用打包脚本提供的 Node 22.20.0 执行 dist/cli.js --version,修复前复现上述错误(退出码 1),修复后输出源码版本 0.0.0(退出码 0)。
  • bun run build 和 bun run desktop:bundle 均通过。
  • bun run test test/desktop/desktop-bundled-runtime.test.ts test/desktop-bundle-contract.test.ts test/hc-screen-mirror.test.ts test/terminal-width-generated.test.ts 通过,共 49 项。新增用例在原依赖清单上失败,调整后通过。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T09:47:31.394075Z c8b955a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@deepcoldy

Copy link
Copy Markdown
Owner

你好,这个 PR 的自动评审群已建,麻烦点击链接加入群聊、查看评审意见并跟进后续修改:
https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=7ecqf9d6-c66a-4152-8a9e-d7a7e1b8036b

另外你暂时不在自动拉群名单里,也可以把 GitHub 账号和飞书信息补进名单文档,补好后后续评审会自动拉你进群:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe

(本条为自动流程发出的提示消息)

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查结论:代码层面可合,未发现 P1/P2/P3 问题。

审查对象:head c8b955ab6ba608c47f0e2d3951f8875fdbd3ea01,base 64ada8a24ee7317b976ccfc826ca6cade2cd8521;3 个文件,+9/-2。合并状态为 MERGEABLE。

根因与影响面核验

  • src/adapters/backend/hc/screen-mirror.ts:9 与 src/core/traex-first-prompt-readiness.ts:13 都在模块顶层静态导入 @xterm/addon-unicode11,并经 src/worker.ts:529、src/worker.ts:755 进入 worker 的静态模块图。生产安装漏包时,Node 会在模块图加载阶段直接抛 ERR_MODULE_NOT_FOUND,模块内部兜底没有机会执行。
  • scripts/prepare-desktop-runtime.mjs:49-56 使用 bun install --production --frozen-lockfile --ignore-scripts --os darwin --cpu '*',因此 package.json:78 的依赖分类正是桌面运行时是否携带该包的决定因素;bun.lock:12 同步移动 workspace 清单,解析条目仍锁定 0.9.0,integrity 未变且没有传递依赖。
  • 其余仍留在 devDependencies 的 xterm 浏览器包只由 dashboard 浏览器入口或构建脚本引用;worker 的 Web 终端 vendor 资源来自生成的内嵌数据,不在运行时逐一 require.resolve 这些包。未发现需要随本 PR 一并移动的同类运行时依赖。
  • test/desktop/desktop-bundled-runtime.test.ts:95-100 新增的生产依赖分类断言覆盖了本次回归点,未新增 src 文本快照式断言。

本轮实际验证

  • bun run test test/desktop/desktop-bundled-runtime.test.ts test/desktop-bundle-contract.test.ts test/hc-screen-mirror.test.ts test/terminal-width-generated.test.ts:4 个文件、49/49 通过。
  • bun run typecheck:通过。
  • bun run build && bun run desktop:bundle:均通过;构建审计与资源审计通过。
  • 在两个仓库外的空目录中,分别使用 base/head 的清单与锁文件,按桌面脚本相同参数做隔离生产安装:base 的 202 个包中没有该 addon;head 的 203 个包中包含 @xterm/[email protected],并由 Node 实际解析、动态导入,确认 Unicode11Addon 导出为函数;两种安装均未带入 electron。
  • 变异复验:将该包从 dependencies 移回 devDependencies 后,新增用例在 test/desktop/desktop-bundled-runtime.test.ts:99 按预期失败;恢复后工作树干净。
  • 本机 Bun 为 1.4.4,与 packageManager 钉版一致;git diff --check 通过。

验证边界与 CI

本轮在 Linux 上验证,没有重新执行 macOS Electron 真机启动;PR 描述中的 macOS arm64 打包运行时前后对照覆盖该项。外部 fork 的 workflow 已获批,完整 CI、bun-test、bun-binary 与 PostgreSQL 检查当前已开始排队,合码前仍需等待这些检查在该 head 上全部通过。

@deepcoldy
deepcoldy merged commit ff23ee1 into deepcoldy:master Nov 28, 2026
17 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

感谢贡献!这个问题的定位很准确:桌面运行时用 bun install --production 暂存,而 @xterm/addon-unicode11 被 worker 模块图顶层静态引用,留在 devDependencies 会导致启动时 ERR_MODULE_NOT_FOUND。移到 dependencies 并补生产依赖断言后已合入 master,暂无后续事项。

@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.37

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.

2 participants