Skip to content

Commit 14dfa90

Browse files
committed
fix(update): make automatic update recovery actionable
1 parent 48bfd0b commit 14dfa90

18 files changed

Lines changed: 262 additions & 101 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"startupJsGzipBytes": 347598,
3-
"reason": "Automatic update outcome continuity: one scoped pending/verified browser notice, admission deadline, and shared status refresh ownership measured 347598 B in the isolated production build (+821 B, 0.24%); fixed 358400 B cap and allowances unchanged",
2+
"startupJsGzipBytes": 347792,
3+
"reason": "Final automatic update lifecycle ownership and stale hold response fencing measured 347792 B in the canonical isolated production build (+1015 B, 0.29% from the original baseline); fixed 358400 B cap and allowances unchanged",
44
"updatedAt": "2026-09-01"
55
}

‎docs/install/updating.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ Off by default. Enable it in `~/.openclaw/openclaw.json`:
372372

373373
You can also choose the update channel and enable automatic updates from
374374
**Settings → Updates** (`/settings/updates`) in the Control UI.
375+
**Check for updates** controls the existing `update.checkOnStart` setting.
376+
When it is off, **Automatic updates** is disabled but keeps your saved preference;
377+
turning checks back on resumes discovery and any enabled automatic-update policy.
378+
This does not change your separate feature-statistics preference.
375379
Recorded failures on that page include typed **Check status** and **Retry
376380
update** actions when the connected Gateway supports them. See [Update
377381
troubleshooting](/install/update-troubleshooting) for reason codes, guided

‎extensions/amazon-bedrock-mantle/discovery.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ describe("bedrock mantle discovery", () => {
726726
// Implicit provider resolution
727727
// ---------------------------------------------------------------------------
728728

729-
it("resolves implicit provider when bearer token is set", async () => {
729+
it("resolves implicit provider with introductory pricing when bearer token is set", async () => {
730+
vi.spyOn(Date, "now").mockReturnValue(Date.UTC(2026, 8, 1) - 1);
730731
const mockFetch = vi.fn().mockResolvedValue(
731732
modelDiscoveryResponse({
732733
data: [{ id: "anthropic.claude-sonnet-4-6", object: "model" }],

‎extensions/anthropic/index.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "openclaw/plugin-sdk/plugin-test-runtime";
1313
// Anthropic tests cover index plugin behavior.
1414
import { createRequireRecord } from "openclaw/plugin-sdk/test-fixtures";
15-
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
15+
import { afterAll, beforeEach, describe, expect, it, onTestFinished, vi } from "vitest";
1616

1717
const { probeClaudeCliAuthStatusMock } = vi.hoisted(() => ({
1818
probeClaudeCliAuthStatusMock: vi.fn(),
@@ -79,6 +79,7 @@ type Claude5ContractCase = {
7979
checksMedia?: boolean;
8080
restoresMissingCost?: boolean;
8181
checksCliPolicy?: boolean;
82+
pricingAtMs?: number;
8283
};
8384

8485
const ANTHROPIC_SETUP_TOKEN = `sk-ant-oat01-${"a".repeat(80)}`;
@@ -702,10 +703,11 @@ describe("anthropic provider replay hooks", () => {
702703
checksCliPolicy: true,
703704
},
704705
{
705-
name: "resolves Claude Sonnet 5 with its exact API contract",
706+
name: "resolves Claude Sonnet 5 with its introductory API pricing",
706707
modelId: "claude-sonnet-5",
707708
cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 },
708709
thinkingLevelMap: { xhigh: "xhigh", max: "max" },
710+
pricingAtMs: Date.UTC(2026, 8, 1) - 1,
709711
},
710712
];
711713

@@ -718,7 +720,12 @@ describe("anthropic provider replay hooks", () => {
718720
checksMedia,
719721
restoresMissingCost,
720722
checksCliPolicy,
723+
pricingAtMs,
721724
}) => {
725+
if (pricingAtMs !== undefined) {
726+
const clock = vi.spyOn(Date, "now").mockReturnValue(pricingAtMs);
727+
onTestFinished(() => clock.mockRestore());
728+
}
722729
const provider = await registerSingleProviderPlugin(anthropicPlugin);
723730
const resolved = provider.resolveDynamicModel?.({
724731
provider: "anthropic",

‎src/cli/update-finalization-output.test-support.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export const assertConfigWriteAllowedInCurrentMode = () => {};
3434
const stubs = new Map<string, string>([
3535
[sourceUrl("../commands/doctor.ts"), doctorSource],
3636
[sourceUrl("../config/config.ts"), snapshotSource],
37-
[
38-
sourceUrl("../infra/update-check.ts"),
39-
"export const resolveUpdateInstallKind = async () => { throw new Error('Unexpected install check'); };",
40-
],
4137
[
4238
sourceUrl("../plugins/installed-plugin-index-records.ts"),
4339
"export const loadInstalledPluginIndexInstallRecords = async () => ({});",

‎ui/src/app/update-overlay-helpers.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,10 @@ describe("update status localization", () => {
467467
status: "error",
468468
reason: "build-failed",
469469
installKind: "git",
470-
installedVersion: null,
471-
installedSha: "before",
472-
targetVersion: null,
473-
targetSha: "after",
470+
beforeVersion: null,
471+
beforeSha: "before",
472+
afterVersion: null,
473+
afterSha: "after",
474474
failure: { step: "build", detail: "Type check failed" },
475475
});
476476
});

‎ui/src/app/update-overlay-helpers.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export type RecordedUpdateAttempt = {
1616
status: string;
1717
reason: string;
1818
installKind: string | null;
19-
installedVersion: string | null;
20-
installedSha: string | null;
21-
targetVersion: string | null;
22-
targetSha: string | null;
19+
beforeVersion: string | null;
20+
beforeSha: string | null;
21+
afterVersion: string | null;
22+
afterSha: string | null;
2323
failure: UpdateFailureCause | null;
2424
};
2525

@@ -157,10 +157,10 @@ function readRecordedUpdateAttempt(
157157
status: sentinel.status,
158158
reason: stats?.reason?.trim() || "unexpected-error",
159159
installKind: stats?.mode?.trim() || null,
160-
installedVersion: stats?.before?.version?.trim() || null,
161-
installedSha: stats?.before?.sha?.trim() || null,
162-
targetVersion: stats?.after?.version?.trim() || null,
163-
targetSha: stats?.after?.sha?.trim() || null,
160+
beforeVersion: stats?.before?.version?.trim() || null,
161+
beforeSha: stats?.before?.sha?.trim() || null,
162+
afterVersion: stats?.after?.version?.trim() || null,
163+
afterSha: stats?.after?.sha?.trim() || null,
164164
failure: readUpdateFailureCause(sentinel),
165165
};
166166
}

‎ui/src/e2e/updates-settings.e2e.test.ts‎

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const suite = createControlUiE2eSuite({
1616
const captureProof = process.env.OPENCLAW_CAPTURE_UI_PROOF === "1";
1717

1818
suite.define(() => {
19-
it("locks update policy while an automatic apply runs and reports its terminal failure", async () => {
19+
it("locks update policy while an automatic apply runs and shows readable recovery guidance", async () => {
2020
const artifactDir = captureProof
2121
? createControlUiE2eArtifactDir("updates-automatic-lifecycle")
2222
: null;
@@ -56,6 +56,7 @@ suite.define(() => {
5656
expect((await page.goto(`${suite.server.baseUrl}settings/updates`))?.status()).toBe(200);
5757
await gateway.waitForRequest("update.status");
5858
const policy = page.getByRole("switch", { name: "Automatic updates" });
59+
const checks = page.getByRole("switch", { name: "Check for updates" });
5960
await policy.waitFor();
6061
await expect.poll(() => policy.isDisabled()).toBe(false);
6162

@@ -84,6 +85,7 @@ suite.define(() => {
8485
}
8586
expect(await status.textContent()).toContain("Applying update");
8687
expect(await policy.isDisabled()).toBe(true);
88+
expect(await checks.isDisabled()).toBe(true);
8789
expect(await page.locator("wa-radio-group").getAttribute("disabled")).not.toBeNull();
8890
expect(
8991
await page.getByRole("button", { name: "Updating…", exact: true }).isDisabled(),
@@ -92,28 +94,50 @@ suite.define(() => {
9294
await gateway.setMethodResponse("update.status", {
9395
sentinel: {
9496
kind: "update",
95-
status: "error",
97+
status: "skipped",
9698
ts: now,
97-
stats: { mode: "npm", reason: "global-install-failed" },
99+
stats: { mode: "npm", reason: "managed-service-handoff-unavailable" },
98100
},
99101
schedule,
100102
});
101103
await gateway.emitGatewayEvent("update.available", { schedule });
102-
await status.filter({ hasText: "global-install-failed" }).waitFor();
104+
await status.filter({ hasText: "Stop the foreground Gateway" }).waitFor();
103105
expect(await policy.isDisabled()).toBe(false);
106+
expect(await checks.isDisabled()).toBe(false);
104107
expect(await gateway.getRequests("update.run")).toHaveLength(0);
108+
await status.scrollIntoViewIfNeeded();
105109
if (artifactDir) {
106110
await page.screenshot({
107111
animations: "disabled",
108112
fullPage: true,
109-
path: path.join(artifactDir, "02-automatic-failure.png"),
113+
path: path.join(artifactDir, "02-automatic-recovery.png"),
110114
});
111115
}
116+
const geometry = await status.evaluate((element) => {
117+
const row = element.closest(".settings-row");
118+
const title = row?.querySelector(".settings-row__title");
119+
if (!row || !title) {
120+
throw new Error("Missing update status row or title");
121+
}
122+
const bounds = element.getBoundingClientRect();
123+
const rowBounds = row.getBoundingClientRect();
124+
const titleBounds = title.getBoundingClientRect();
125+
return {
126+
insideRow: bounds.left >= rowBounds.left && bounds.right <= rowBounds.right,
127+
overlapsTitle:
128+
bounds.left < titleBounds.right &&
129+
bounds.right > titleBounds.left &&
130+
bounds.top < titleBounds.bottom &&
131+
bounds.bottom > titleBounds.top,
132+
overflows: element.scrollWidth > element.clientWidth,
133+
};
134+
});
135+
expect(geometry).toEqual({ insideRow: true, overlapsTitle: false, overflows: false });
112136
},
113137
);
114138
});
115139

116-
it("renders live campaign status without requesting config.schema", async () => {
140+
it("resumes disabled update checks through autosave and renders the live campaign", async () => {
117141
if (captureProof) {
118142
await mkdir(path.join(suite.artifactDir, "updates-settings"), { recursive: true });
119143
}
@@ -133,7 +157,9 @@ suite.define(() => {
133157
: {}),
134158
},
135159
async ({ page }) => {
136-
const config = { update: { auto: { enabled: true }, channel: "stable" } };
160+
const config = {
161+
update: { auto: { enabled: true }, channel: "stable", checkOnStart: false },
162+
};
137163
const gateway = await installMockGateway(page, {
138164
featureMethods: ["config.get", "config.set", "config.apply", "update.run"],
139165
methodResponses: {
@@ -158,6 +184,37 @@ suite.define(() => {
158184
await gateway.waitForRequest("config.get");
159185
expect(await gateway.getRequests("config.schema")).toHaveLength(0);
160186

187+
const content = page.locator("#control-ui-main");
188+
await content.getByText("Updates", { exact: true }).waitFor();
189+
const checks = content.getByRole("switch", { name: "Check for updates", exact: true });
190+
const automatic = content.getByRole("switch", { name: "Automatic updates", exact: true });
191+
await expect.poll(() => automatic.isChecked()).toBe(true);
192+
if (captureProof) {
193+
await page.screenshot({
194+
animations: "disabled",
195+
fullPage: true,
196+
path: path.join(
197+
suite.artifactDir,
198+
"updates-settings",
199+
"00-updates-checks-disabled.png",
200+
),
201+
});
202+
}
203+
expect(await checks.isChecked()).toBe(false);
204+
expect(await automatic.isDisabled()).toBe(true);
205+
await content
206+
.locator(".settings-row__title")
207+
.filter({ hasText: /^Check for updates$/ })
208+
.click();
209+
const checksSaved = await gateway.waitForRequest("config.set");
210+
const checksRaw = (checksSaved.params as { raw?: unknown }).raw;
211+
expect(typeof checksRaw).toBe("string");
212+
expect(JSON.parse(String(checksRaw))).toMatchObject({
213+
update: { checkOnStart: true, channel: "stable", auto: { enabled: true } },
214+
});
215+
await expect.poll(() => automatic.isDisabled()).toBe(false);
216+
expect(await automatic.isChecked()).toBe(true);
217+
161218
await gateway.emitGatewayEvent("update.available", {
162219
updateAvailable: {
163220
currentVersion: "2026.8.1",
@@ -180,8 +237,6 @@ suite.define(() => {
180237
},
181238
});
182239

183-
const content = page.locator("#control-ui-main");
184-
await content.getByText("Updates", { exact: true }).waitFor();
185240
const timer = content.locator("[role='timer']");
186241
await expect.poll(() => timer.textContent()).toContain("Updating in 0:");
187242
const firstCountdown = await timer.textContent();
@@ -200,8 +255,15 @@ suite.define(() => {
200255
});
201256
}
202257

258+
const writesBeforeChannelChange = (await gateway.getRequests("config.set")).length;
203259
await content.getByRole("radio", { name: "Beta", exact: true }).click();
204-
const configSet = await gateway.waitForRequest("config.set");
260+
await expect
261+
.poll(async () => (await gateway.getRequests("config.set")).length)
262+
.toBe(writesBeforeChannelChange + 1);
263+
const configSet = (await gateway.getRequests("config.set")).at(-1);
264+
if (!configSet) {
265+
throw new Error("Missing channel config write");
266+
}
205267
const raw = (configSet.params as { raw?: unknown }).raw;
206268
expect(typeof raw).toBe("string");
207269
expect(JSON.parse(String(raw))).toMatchObject({ update: { channel: "beta" } });
@@ -249,6 +311,9 @@ suite.define(() => {
249311
expect(await page.getByRole("switch", { name: "Automatic updates" }).isDisabled()).toBe(
250312
true,
251313
);
314+
expect(await page.getByRole("switch", { name: "Check for updates" }).isDisabled()).toBe(
315+
true,
316+
);
252317
expect(await page.getByRole("button", { name: "Update now" }).isDisabled()).toBe(true);
253318
expect(await gateway.getRequests("config.schema")).toHaveLength(0);
254319

‎ui/src/i18n/locales/en.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,16 @@ export const en: TranslationMap = {
557557
policyTitle: "Update policy",
558558
channel: "Release channel",
559559
channelDescription: "Choose which OpenClaw release track this Gateway follows.",
560+
checkForUpdates: "Check for updates",
561+
checkForUpdatesDescription: "Periodically check for new versions and show update notices.",
560562
automaticUpdates: "Automatic updates",
561563
automaticUpdatesDescription:
562564
"Schedule available updates automatically. Dev auto-updates apply to git checkouts.",
563565
devPackageAutomaticHint:
564566
"Automatic dev updates require a source (git) install. This install is a package install — use stable or beta for automatic updates.",
565567
extendedStableAutomaticHint:
566568
"Extended stable reports available releases but never installs them automatically.",
567-
checksDisabledAutomaticHint:
568-
"Update checks are disabled. Set update.checkOnStart to true to resume automatic updates.",
569+
checksDisabledAutomaticHint: "Turn on Check for updates to resume automatic updates.",
569570
statusTitle: "Update status",
570571
scheduleStatus: "Status",
571572
commits: "Commits",
@@ -582,8 +583,8 @@ export const en: TranslationMap = {
582583
updateNowDescription: "Install the available update and restart the Gateway.",
583584
latestAttempt: "Latest update attempt",
584585
attemptedAt: "Attempted",
585-
attemptTarget: "Target",
586-
installedIdentity: "Installed",
586+
beforeUpdate: "Before update",
587+
afterAttempt: "After attempt",
587588
attemptInstallKind: "Attempt install type",
588589
attemptReason: "Reason code",
589590
failedStep: "Failure details",

‎ui/src/pages/config/config-page.test.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,20 @@ describe("ConfigPage Updates integration", () => {
851851
}
852852
channel.value = "beta";
853853
channel.dispatchEvent(new Event("change"));
854-
const automatic = container.querySelector<HTMLElement & { checked: boolean }>("wa-switch");
854+
const policySwitches = [
855+
...container.querySelectorAll<HTMLElement & { checked: boolean }>("wa-switch"),
856+
];
857+
const checks = policySwitches.find(
858+
(control) => control.textContent?.trim() === "Check for updates",
859+
);
860+
if (!checks) {
861+
throw new Error("Missing update checks control");
862+
}
863+
checks.checked = false;
864+
checks.dispatchEvent(new Event("change"));
865+
const automatic = policySwitches.find(
866+
(control) => control.textContent?.trim() === "Automatic updates",
867+
);
855868
if (!automatic) {
856869
throw new Error("Missing automatic update control");
857870
}
@@ -863,6 +876,7 @@ describe("ConfigPage Updates integration", () => {
863876
await nextFrame();
864877

865878
expect(patchForm).toHaveBeenCalledWith(["update", "channel"], "beta");
879+
expect(patchForm).toHaveBeenCalledWith(["update", "checkOnStart"], false);
866880
expect(patchForm).toHaveBeenCalledWith(["update", "auto", "enabled"], true);
867881
// Settings shares the sidebar card's confirmation gate: nothing runs on the click itself.
868882
expect(runUpdate).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)