Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 记录不自洽(minVersion > 自身 version)时不进入强更

guyonge28e59a1153e
diff --git a/apps/mobile/src/update/bundleUpdate.test.ts b/apps/mobile/src/update/bundleUpdate.test.ts
index adc99309af..a38a48d5b1 100644
--- a/apps/mobile/src/update/bundleUpdate.test.ts
+++ b/apps/mobile/src/update/bundleUpdate.test.ts
@@ -124,6 +124,26 @@ describe('evaluateBundleUpdate', () => {
expect(r.needsUpdate).toBe(true); // runtimeVersion 不同 → 仍是可跳过的普通更新
});
+ it('minVersion 高于该记录自己的 version → 不强更(装完仍低于门槛,阻断屏会没有出口)', () => {
+ // 发布链侧 assertMinVersionUsable 已禁止这种记录;客户端兜底手工改过 / 历史遗留的指针。
+ const r = evaluateBundleUpdate({
+ currentRuntimeVersion: 'rtv-old',
+ currentVersion: '1.0.0',
+ latest: { ...VALID, version: '1.1.0', minVersion: '1.2.0' },
+ });
+ expect(r.forced).toBe(false);
+ expect(r.needsUpdate).toBe(true); // 仍是可跳过的普通更新
+ });
+
+ it('minVersion 等于该记录的 version → 正常强更(边界)', () => {
+ const r = evaluateBundleUpdate({
+ currentRuntimeVersion: 'rtv-old',
+ currentVersion: '1.0.0',
+ latest: { ...VALID, version: '1.2.0', minVersion: '1.2.0' },
+ });
+ expect(r.forced).toBe(true);
+ });
+
it('缺 currentVersion → 不强更(无法比较,fail-open)', () => {
const r = evaluateBundleUpdate({
currentRuntimeVersion: 'rtv-new',
diff --git a/apps/mobile/src/update/bundleUpdate.ts b/apps/mobile/src/update/bundleUpdate.ts
index a099cb0224..f3819d4056 100644
--- a/apps/mobile/src/update/bundleUpdate.ts
+++ b/apps/mobile/src/update/bundleUpdate.ts
@@ -120,15 +120,19 @@ export function evaluateBundleUpdate({
const current = String(currentRuntimeVersion ?? '').trim();
if (!current) return NO_UPDATE;
- // 强更额外要求 record 自己带 version:拿不到目标版本就无法证明"装上它就能解除阻断"
- // (阻断态的自愈全靠这个可比较的版本:见 forcedUpdateRecheck 的新鲜度门)。
- // 发布链侧 assertMinVersionUsable 已保证"有 minVersion 必有 version",这里是客户端兜底:
- // 记录异常时退化成可跳过的普通更新提示,而不是把用户关进一个无法自愈的阻断屏。
+ // 强更要求这条记录本身**能被满足**:
+ // - 带 version:拿不到目标版本就无法证明"装上它就能解除阻断"(阻断态自愈全靠这个
+ // 可比较的版本,见 forcedUpdateRecheck 的新鲜度门);
+ // - minVersion ≤ version:否则唯一提供的安装目标仍低于门槛,用户装完照旧被强更,
+ // 阻断屏成了没有出口的死屋,只能等运维改指针。
+ // 发布链侧 assertMinVersionUsable 已经保证这两条,这里是客户端兜底(手工改过的 / 历史
+ // 遗留的指针也不能把人关死):记录不自洽时退化成可跳过的普通更新提示。
const forced = Boolean(
record.minVersion &&
record.version &&
currentVersion &&
- compareVersions(String(currentVersion), record.minVersion) < 0,
+ compareVersions(String(currentVersion), record.minVersion) < 0 &&
+ compareVersions(record.version, record.minVersion) >= 0,
);
if (!forced && record.runtimeVersion === current) return NO_UPDATE;