Skip to content

fix(updater): prefetch both packages before SSH updates - #1318

Closed
ChaceLyee2101 wants to merge 1 commit into
BytePioneer-AI:mainfrom
ChaceLyee2101:fix/ssh-prefetch-required-update-packages
Closed

ChaceLyee2101 wants to merge 1 commit into
BytePioneer-AI:mainfrom
ChaceLyee2101:fix/ssh-prefetch-required-update-packages

Conversation

@ChaceLyee2101

Copy link
Copy Markdown
Contributor

Summary

The SSH updater could replace the CLI while the required native package was unavailable. npm could then exit successfully after removing the previous optional package. The remote service could stay online with an installation that could no longer restart.

  • Prefetch the exact target CLI and platform tarballs with the remote npm before installing or stopping the service. A failed download leaves both the old installation and the running service in place.
  • Prefer the npm cache during installation. The self-updater retains the existing payload layout so the recorded Shim can shut down the previous Host. The legacy SSH path requires both packages in the install transaction.
  • Document the preparation step in the remote update instructions.

Related issues

Refs #1316. This covers both update paths. Repairing an already damaged installation from the connection card is a separate part of the report. See also #1214 and #1065.

UI Demo

N/A (updater behavior).

Test plan

  • Both new regressions failed on the old code and passed with the fixes. cargo test --offline --locked -p codexhost-updater passed 46 unit tests and 3 integration tests.
  • A temporary loopback npm registry on macOS served the target CLI and returned 404 for the target platform tarball. The actual native updater preserved both installed packages and made zero lifecycle calls. After restoring the tarball, the same installation updated both packages in place and ran the restart steps with fixture commands.
  • Windows-target Clippy, Cargo formatting, documentation Prettier, and git diff --check passed. No live SSH service was changed.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Summary

Summary by CodeRabbit

  • 功能改进
    • 远程更新会在安装前下载所需组件;若下载失败,将保留当前安装和服务。
    • 更新时会根据远程计算机的平台选择对应组件,并优先使用已下载的内容进行安装。
  • 文档
    • 补充说明:远程更新、重启或修复可能中断正在进行的会话。

Changes

远程更新

Layer / File(s) Summary
自更新路径缓存与安装
crates/updater/src/npm.rs, crates/updater/src/remote.rs
更新前解析全局安装布局,并分别缓存所需包。缓存失败时,安装不会开始;安装命令使用 --prefer-offline 和 --include=optional。测试覆盖缓存失败、成功更新和重启流程。
SSH 更新缓存与安装
crates/updater/src/ssh.rs, crates/updater/src/ssh/tests.rs, docs/platforms/remote/remote-ssh-host.md, docs/platforms/remote/remote-ssh-host.zh-CN.md
脚本根据远端平台和架构缓存 CLI 包与平台包,再安装两者。缓存失败时返回状态码 53。测试验证缓存失败时保留远端清单并清理锁。文档补充了下载失败时保留现有安装和服务的说明。

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Updater as SSH 更新脚本
  participant Node as 远端 Node
  participant npm as 远端 npm
  participant Service as 远端服务
  Updater->>Node: 查询平台与架构
  Updater->>npm: 缓存 CLI 包和平台包
  npm-->>Updater: 返回缓存结果
  Updater->>npm: 使用 --prefer-offline 安装两个包
  Updater->>Service: 停止并重新启动服务
Loading

可能相关的问题

  • Issue 1316 描述目标平台包不可用时旧平台包被移除,导致旧安装无法重启。本 PR 在安装前缓存目标 CLI 包和平台包;其中“修复已损坏安装”的需求不在本 PR 范围内。

可能相关的 PR

Suggested reviewers: bytepioneer-ai, twodogegg, ump45nose

  • 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

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.

1 participant