Skip to content

fix(js): resolve gray rollouts in client.checkUpdate and switch to the downloaded version - #667

Merged
sunnylqm merged 1 commit into
masterfrom
claude/js-client-fixes
Oct 15, 2026
Merged

sunnylqm merged 1 commit into
masterfrom
claude/js-client-fixes

Conversation

@sunnylqm

@sunnylqm sunnylqm commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

架构审查里 JS 层的两个用户可见缺陷,外加一处品牌文案。

修了什么

  • client.checkUpdate 返回按本设备解析后的结果。 解析依据是本设备的灰度分桶和正在运行的版本,provider 原本就是这样呈现的。以前只有 provider 做这一步,所以直接调用 client.checkUpdate() 再 downloadUpdate() 的用户会无视灰度比例、装上根版本;afterCheckUpdate 收到的也是未解析的原始响应。provider 不再重复解析。
  • useUpdate().switchVersion() 与 switchVersionLater() 不带参数时,切到已下载的版本。 client 只接受已下载的版本;只有在还没下载过任何版本时,才退回用最近一次检查到的版本。以前的场景是:下载完 A 之后,又一次检查发现了更新的 B,updateInfo 变成 B,这时「立即更新」就成了没有任何提示的空操作。provider 现在通过 client.getDownloadedHash() 读取已下载版本,不再直接读 client 模块的 sharedState。
  • 「bundle 未注册」提示里的命令按品牌显示。 Cresc 用户看到的是 cresc uploadIpa 等,不再是 pushy。

行为变化

直接调用 client.checkUpdate() 的返回值不再带 expVersion 字段。灰度命中时,返回的就是灰度版本本身。通过 provider 或 useUpdate() 使用的应用不受影响。

验证

  • bun lint 通过,bun test 437 个用例全部通过。
  • 新增 2 个用例,并确认它们在修复前的代码上会失败:
    • 灰度比例为 100% 时返回灰度版本,为 0% 时返回根版本,两种情况下都不带 expVersion。
    • 下载 A 之后又检查到 B,此时不带参数调用 switchVersionLater(),切换目标是 A。

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added a way for integrations to retrieve the hash of the currently downloaded update.
  • Bug Fixes
    • Update checks now return the release resolved for the current device, including when using a recent cached result.
    • Choosing to switch versions later now targets the downloaded update, even if a newer release is found in a subsequent check.
    • Update guidance now displays the appropriate command name for the client.

…e downloaded version

- client.checkUpdate now returns the result resolved for this device (gray
  rollout bucket, running version), as the provider already presented it.
  Before, only the provider resolved it: a direct client.checkUpdate() ->
  downloadUpdate() ignored the rollout percentage and installed the root
  release, and afterCheckUpdate saw the unresolved response. The provider no
  longer resolves a second time.
- useUpdate().switchVersion() / switchVersionLater() without an argument
  target the downloaded version (the only one the client accepts), falling
  back to the last checked info only before any download. A check that found
  a newer release after the download used to turn "switch now" into a silent
  no-op. The provider reads it through client.getDownloadedHash() instead of
  the client module's sharedState.
- The unknown-bundle warning names the brand's own CLI (cresc for Cresc).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e345ce0-1285-4cce-8412-781b3d2eb7b6
📥 Commits

Reviewing files that changed from the base of the PR and between b6cd731 and 5a774a9.

📒 Files selected for processing: 6
  • src/__tests__/client.test.ts
  • src/__tests__/provider.contract.test.tsx
  • src/client.ts
  • src/locales/en.ts
  • src/locales/zh.ts
  • src/provider.tsx

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

📝 Walkthrough

The client resolves update-check results for the current device. The provider uses the resolved result and can switch to the downloaded update hash. Unknown-bundle warnings use the CLI name selected for the client type.

Changes: Update check and switching flow

Layer / File(s) Summary
Resolve check results for the current device
src/client.ts, src/__tests__/client.test.ts, src/locales/en.ts, src/locales/zh.ts
The client resolves cached and fetched results for the current device before returning them and notifying completion. Tests cover full and zero rollout results. Unknown-bundle messages use a CLI placeholder.
Provider check results and version switching
src/client.ts, src/provider.tsx, src/__tests__/provider.contract.test.tsx
The provider uses the result returned by the client. Version-switch actions prefer the downloaded hash and fall back to the latest checked hash. The contract test verifies that a later switch targets the downloaded hash.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5a774

The reviewed update-check and version-switching changes have no identified issue that needs resolution before merge.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the two primary changes: resolving gray rollouts in client.checkUpdate and switching to the downloaded version.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6…
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 docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • 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

Comment @coderabbitai help to get the list of available commands.

@sunnylqm
sunnylqm merged commit 2b5d541 into master Oct 15, 2026
15 of 16 checks passed
@sunnylqm sunnylqm mentioned this pull request Oct 16, 2026
sunnylqm added a commit that referenced this pull request Oct 17, 2026
Bump package.json and harmony/pushy/oh-package.json5 together, with the
bilingual release notes. Ships everything since 10.60.0: the shared native
round engine (#673-#681), the cross-platform alignment and fixes (#664,
#666, #671, #687, #688), the JS client fixes and split (#667, #684, #685),
the bounded host prepareBundle (#669), the generated cross-platform contract
(#683, #686) and the trimmed npm package (#670).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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