Skip to content

feat(updater): show download progress in the update command - #1212

Merged
iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
twodogegg:feat/cli-update-download-progress
Nov 26, 2026
Merged

iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
twodogegg:feat/cli-update-download-progress

Conversation

@twodogegg

Copy link
Copy Markdown
Contributor

Summary

codexhost update 会在终端跟踪下载,安装和重启仍由后台 Updater 完成。npm 显示实际已缓存的包数,DMG、Windows 安装包和 Linux 压缩包显示字节进度,有总大小时显示百分比。交互终端原位刷新,重定向时输出普通文本。

CLI 使用现有更新状态文件获取进度,覆盖正在运行的 Host 和独立更新。准备阶段先进入下载状态,下载和校验完成后才发布可交接的状态。

Related issues

无 / N/A

UI Demo

终端输出示例,来自隔离 npm registry 实测。

Updating codexhost 1.0.0 → 1.1.0...
Downloading update... 1/2 npm packages ready
Download complete.

Test plan

  • macOS ARM64、Node 24.22.0。在隔离 npm registry 中延迟平台包下载,确认 CLI 在等待期间显示 1/2,完成后显示后台交接消息。原生安装与服务重启用测试 Helper 模拟。
  • 通过 tsc -b packages/harness-discovery packages/host-runtime packages/console-server。
  • 使用 tests/vitest.config.js 跑更新相关 6 个测试文件,64 项通过,1 项 Windows 专用用例跳过。终端轮询调整后重跑 CLI 测试,9 项通过。
  • Prettier 和 git diff --check 通过。Windows 和 Linux 实机升级待验证。

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能

    • 更新安装期间显示下载进度:npm 安装显示已缓存包数,其他安装显示已下载体积、总体积和百分比;总体积未知时仅显示已下载体积。
    • 下载完成后,后台继续安装并重启。
  • 改进

    • 命令行实时显示更新进度;下载失败或连续 15 分钟无进展时会提示错误。

更新管理器现在报告 npm 下载进度,并将进度写入更新状态。Host 和 Console Server 透传该状态,命令行轮询并显示下载进度。相关契约、测试和运维文档也已更新。

Changes: 更新下载进度

Layer / File(s) Summary
下载进度契约与状态校验
packages/update-manager/src/npm-registry.ts、packages/shared-contracts/src/updates.ts、packages/shared-contracts/src/index.ts、packages/update-manager/src/status.ts、packages/shared-contracts/test/updates.test.ts
新增 npm 下载进度类型和 schema。更新状态可包含 npmDownload,后台状态解析会校验该字段。
npm 缓存与更新状态写入
packages/update-manager/src/npm-registry.ts、packages/update-manager/src/status.ts、packages/update-manager/src/update-manager.ts、packages/update-manager/test/npm-registry.test.ts、packages/update-manager/test/update-manager.test.ts
npm 包逐个缓存,并在缓存过程中报告进度。更新管理器将进度写入状态文件,并调整失败处理、准备状态创建和安装路径校验。测试验证缓存进度及状态文件重命名失败后的准备状态。
状态透传与命令行进度显示
packages/host-runtime/src/update-coordinator.ts、packages/console-server/src/updates.ts、packages/console-server/src/update-cli.ts、packages/host-runtime/test/update-coordinator.test.ts、packages/console-server/test/update-cli.test.ts、docs/operations/codexhost-console.md
Host 和 Console Server 在进度存在时透传 npmDownload。命令行轮询更新状态,显示 npm 包数或下载字节进度;TTY 上的实时进度以内联方式显示。测试和运维文档覆盖这些变化。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant runUpdateCommand
  participant BackgroundUpdateManager
  participant prefetchNpmRelease
  participant npm
  participant statusFile
  runUpdateCommand->>BackgroundUpdateManager: 启动更新
  BackgroundUpdateManager->>prefetchNpmRelease: 传入进度回调
  prefetchNpmRelease->>npm: 逐个缓存 npm 包
  npm-->>prefetchNpmRelease: 返回缓存结果
  prefetchNpmRelease-->>BackgroundUpdateManager: 报告下载进度
  BackgroundUpdateManager->>statusFile: 写入进度状态
  runUpdateCommand->>statusFile: 轮询更新状态
  statusFile-->>runUpdateCommand: 返回下载进度
  runUpdateCommand-->>runUpdateCommand: 输出进度消息
Loading

Possibly related PRs

  • BytePioneer-AI/codex-host#1214:该 PR 调整本地 npm Updater 的安装参数,使 CLI 与同版本平台包共同安装;本 PR 的进度计数覆盖 npm 缓存的这些包。

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 9e5b3

The update command now shows download progress while the background Updater still handles install and restart. No actionable merge-blocking risk was identified in the supplied changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“feat(updater): show download progress in the update command”概括了本 PR 的主要变更:codexhost update 命令现在在终端显示下载进度。变更摘要中的 CLI 进度显示、npm 缓存包计数、字节和百分比进度、共享状态契约扩展均与此标题相符。标题简短、具体,没有使用模糊词语。
Description check Passed 描述说明了 codexhost update 在终端跟踪下载的行为:npm 显示已缓存包数,DMG、Windows 安装包和 Linux 压缩包显示字节进度及百分比,交互终端原位刷新,重定向时输出普通文本。描述还说明 CLI 使用现有更新状态文件,并给出了测试计划。该描述与变更集直接相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3667374 and 9e5b3cb.

Files selected for processing: 2

  • packages/host-runtime/test/update-coordinator.test.ts
  • packages/update-manager/test/update-manager.test.ts
Files skipped from review as they are similar to previous changes: 1

  • packages/host-runtime/test/update-coordinator.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Vitest
  • GitHub Check: Web Host tests
  • GitHub Check: Check macos-26
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check windows-latest
  • GitHub Check: Static checks
Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Use package public exports for cross-package dependencies.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/update-manager/test/update-manager.test.ts
Learnings: 1

Learning: 2026-11-17T12:08:43.655Z

Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-17T12:08:43.655Z
Learning: Source excerpt:
# Repository Guidelines

## Testing & Completion

- Writing tests. Every test is code to maintain and CI time to pay; add one only when it earns that.
  - Small, low-risk changes need no new tests. Add focused tests for high-risk or cross-package changes, or when asked.
  - A new test must catch a regression the existing tests would miss. Extend the nearest existing case or `test.each` instead of adding near-duplicates.
  - Assert observable behavior (inputs, outputs, protocol messages, persisted state), not internal call order, private state, or mock call counts.
  - Mock only external boundaries (network, clock, real CLIs, the OS), never the code under test. Avoid large snapshots and long literal expectations that can only be updated mechanically.
  - A bug-fix test must fail before the fix. Never weaken assertions or delete tests just to make a change pass; report the conflict instead.
  - When a change makes existing tests redundant or ties them to removed internals...

Applied to files:

  • packages/update-manager/test/update-manager.test.ts

@iruriQ
iruriQ merged commit f291415 into BytePioneer-AI:main Nov 26, 2026
8 checks passed
@iruriQ

iruriQ commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

感谢贡献!我们已完成深审与端到端实测:验证了 shared-contracts 边界合规与 Rust UpdateStatusProbe 向后兼容、真实 createBackgroundUpdateManager 落盘进度与 TTY / 非 TTY 终端输出渲染,以及失败清理边界(191/191 聚焦单测全绿、CI 8/8 通过),现已合并。

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