Skip to content

Commit e7ba2e1

Browse files
fix(ui): give the Gateway update a visible, truthful outcome (#121686)
* fix(ui): give the Gateway update a visible, truthful outcome Confirming an update in the Control UI could end in nothing the operator could see. The sidebar card only knew `updateRunning`, which clears as soon as `update.run` answers, so a dev-channel handoff — git pull, install, full build, restart — spent minutes back on the stale "N commits behind" call to action. A verified install then published a null banner, so success was never announced at all, and the reload that a verified install triggers would have destroyed any in-memory notice anyway. The lifecycle was already recorded; nothing rendered it. Feed the sidebar the reconciliation fact the settings page already uses, narrate the wait in the shell callout that survives the restart, and record the verified result so it outlives the reload it causes. Failures now name their cause. The updater already stores the failing step and its captured output in the restart sentinel and `update.status` returns it whole, so a disk-full install reads "The update failed at install: ENOSPC: no space left on device" instead of a reason slug plus "see the gateway logs". Missing handoff-reason guidance is filled in, and the duplicate post-restart banner resolver is folded into the shared one. Also fixes a callout clipped by the fixed shell chrome controls, and the "Available 246 commits behind" double framing in the confirmation. * fix(ui): report the Gateway update in the dialog that starts it Follow-up to the first pass: the shell-top callout was the wrong surface for this. The dialog the operator clicked is now the one that reports the whole update, and the ambient surfaces are the fallback for anyone who leaves it. Confirming no longer closes the dialog. It becomes stateful — the danger button turns into a disabled "Updating…" with a spinner, and the body narrates the phases in place: installing, then "The Gateway is restarting. This page disconnects and reconnects on its own." The dialog is mounted on document.body, outside the shell, so losing the connection cannot unmount the only surface still reporting. A request the Gateway never accepts stops spinning after a bounded grace and says so. A failure lands in the dialog with its recorded cause and next step. Success still arrives after the reload a verified install triggers, so it stays a toast — no dialog exists by then. The shell-top status callout is gone. The same outcome now renders beside the sidebar update card that started the update, and stays hidden while the dialog owns the report so the two surfaces never duplicate each other. Splits the wire-payload readers out of update-overlay-helpers into update-schedule-dto and moves update.run answer classification next to them, keeping both owners under the file-size budget. * fix(ui): keep the update dialog open through the install in E2E and use a defined warn token * refactor(ui): wire the update progress stream into the floating card and drop unused video capture * fix(ui): report the current update, not the previous failure The dialog subscribed to progress before starting the update. Producers replay their current snapshot synchronously on subscribe, so a retry still carrying the previous attempt's failure banner painted that old error as this update's outcome. Start the request first, and treat a failure present on the subscribe emit as the previous attempt's: an accepted run clears the banner before its first await, so a failure that survives means the request was refused, which the accept timer already reports truthfully. * fix(ui): keep update helpers internal * chore(perf): raise startup-JS budget to 350 KiB Approved by maintainer Vyctor on 2026-08-11. Trigger: after #121734, main measured 326650 B—6 B below the prior 319 KiB hard ceiling. Current main subsequently moved the ceiling to 320 KiB; this records the authorized final 350 KiB decision for #121686. * fix(ui): announce update success without session storage Show the verified install identity directly when the current document does not reload, so denied session storage cannot suppress the operator-visible outcome. * test(ui): isolate update toast in overlay tests The Node-only overlay suite now reaches the direct non-reload success toast. Mock the DOM-owned toast boundary so reconciliation assertions can complete without a browser document.
1 parent fe4cff7 commit e7ba2e1

34 files changed

Lines changed: 1440 additions & 436 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"startupJsGzipBytes": 326657,
3-
"reason": "chat header project lead-in (#121734); CI-measured merge-ref bytes",
2+
"startupJsGzipBytes": 328285,
3+
"reason": "Gateway update outcome (#121686); Testbox-measured exact-head bytes",
44
"updatedAt": "2026-08-11"
55
}

‎scripts/check-control-ui-performance.mts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const CONTROL_UI_STARTUP_JS_GZIP_TOLERANCE_BYTES = 1024;
2828
const controlUiPerformanceBudgets = {
2929
startupJsRequests: 18,
3030
startupCssRequests: 1,
31-
// 320 KiB maintainer-approved 2026-08 after the chat header project lead-in;
32-
// CI measured 326657 B, one byte above the prior 319 KiB cap.
33-
startupJsGzipBytes: 320 * KIB,
31+
// 350 KiB maintainer-approved by Vyctor 2026-08-11 for #121686;
32+
// #121734 left main 6 B below the prior 319 KiB hard ceiling.
33+
startupJsGzipBytes: 350 * KIB,
3434
// 45 KiB CSS ceilings maintainer-approved 2026-07 alongside the interleaved
3535
// sidebar zone styling; headroom over the ~36.5 KiB post-diet baseline.
3636
startupCssGzipBytes: 45 * KIB,

‎ui/src/app/app-host-native-shell.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ describe("OpenClaw shell update affordance", () => {
397397
latestVersion: "2026.7.2",
398398
channel: "stable" as const,
399399
},
400-
updateRunning: false,
400+
updateBusy: false,
401401
canUpdate: true,
402402
onUpdate: vi.fn(),
403403
refreshRequired: false,
@@ -487,7 +487,7 @@ describe("OpenClaw shell update affordance", () => {
487487
const shared = {
488488
onboarding: true,
489489
updateAvailable: null,
490-
updateRunning: false,
490+
updateBusy: false,
491491
onUpdate: vi.fn(),
492492
refreshRequired: true,
493493
onRefresh: vi.fn(),

‎ui/src/app/app-shell-view.ts‎

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
loadSettings,
3939
normalizeCatalogOpenTarget,
4040
} from "./settings.ts";
41+
import type { UpdateProgress } from "./update-confirmation.ts";
4142

4243
const EMPTY_OUTBOX_COUNT_FOR_SESSION = () => 0;
4344
const EMPTY_SESSION_HAS_DRAFT = () => false;
@@ -122,6 +123,29 @@ export function renderApplicationShell(host: ShellViewHost) {
122123
: EMPTY_SESSION_HAS_DRAFT;
123124
const navigationSnapshot = context.navigation.snapshot;
124125
const overlaySnapshot = context.overlays.snapshot;
126+
// The install keeps running after `update.run` answers, so the reconciliation
127+
// — not the request — decides how long the update surfaces stay busy.
128+
const updateBusy = overlaySnapshot.updateRunning || overlaySnapshot.updateReconciliationPending;
129+
// The update dialog outlives this render and the connection, so it reads live
130+
// snapshots rather than the values captured here.
131+
const watchUpdateProgress = (listener: (progress: UpdateProgress) => void) => {
132+
const emit = () => {
133+
const update = context.overlays.snapshot;
134+
const banner = update.updateStatusBanner;
135+
listener({
136+
busy: update.updateRunning || update.updateReconciliationPending,
137+
connected: context.gateway.snapshot.phase === "connected",
138+
failure: banner && banner.tone !== "info" ? banner.text : null,
139+
});
140+
};
141+
const stopOverlays = context.overlays.subscribe(emit);
142+
const stopGateway = context.gateway.subscribe(emit);
143+
emit();
144+
return () => {
145+
stopOverlays();
146+
stopGateway();
147+
};
148+
};
125149
const terminalAvailable = isTerminalAvailable(
126150
gatewaySnapshot,
127151
context.config.current.terminalEnabled ?? false,
@@ -232,7 +256,9 @@ export function renderApplicationShell(host: ShellViewHost) {
232256
updateAvailable: navigationSurfaceHidden ? null : overlaySnapshot.updateAvailable,
233257
updateSchedule: navigationSurfaceHidden ? null : overlaySnapshot.updateSchedule,
234258
heldUpdateCampaignId: overlaySnapshot.heldUpdateCampaignId,
235-
updateRunning: overlaySnapshot.updateRunning,
259+
updateBusy,
260+
updateStatusBanner: overlaySnapshot.updateStatusBanner,
261+
watchUpdateProgress,
236262
canUpdate,
237263
canHoldUpdate,
238264
onUpdate: () => void context.overlays.runUpdate(),
@@ -267,7 +293,9 @@ export function renderApplicationShell(host: ShellViewHost) {
267293
updateAvailable: navigationSurfaceHidden ? null : overlaySnapshot.updateAvailable,
268294
updateSchedule: navigationSurfaceHidden ? null : overlaySnapshot.updateSchedule,
269295
heldUpdateCampaignId: overlaySnapshot.heldUpdateCampaignId,
270-
updateRunning: overlaySnapshot.updateRunning,
296+
updateBusy,
297+
updateStatusBanner: overlaySnapshot.updateStatusBanner,
298+
watchUpdateProgress,
271299
canUpdate,
272300
canHoldUpdate,
273301
onUpdate: () => void context.overlays.runUpdate(),
@@ -294,8 +322,7 @@ export function renderApplicationShell(host: ShellViewHost) {
294322
runtimeConfig.configLoading ||
295323
runtimeConfig.configSaving ||
296324
(runtimeConfig.configFormDirty && runtimeConfig.configFormMode === "raw") ||
297-
overlaySnapshot.updateRunning ||
298-
overlaySnapshot.updateReconciliationPending,
325+
updateBusy,
299326
onRetry: () => void context.runtimeConfig.save(),
300327
onReload: () => void context.runtimeConfig.discardDraft(),
301328
onApply: () => void context.runtimeConfig.apply(),
@@ -450,18 +477,15 @@ export function renderApplicationShell(host: ShellViewHost) {
450477
}}
451478
></openclaw-update-banner>`
452479
: nothing}
453-
<openclaw-update-banner
454-
.props=${{
455-
statusBanner: overlaySnapshot.updateStatusBanner,
456-
}}
457-
></openclaw-update-banner>
458480
${renderFloatingUpdateCard({
459481
navigationSurfaceHidden,
460482
onboarding,
461483
updateAvailable: overlaySnapshot.updateAvailable,
462484
updateSchedule: overlaySnapshot.updateSchedule,
463485
heldUpdateCampaignId: overlaySnapshot.heldUpdateCampaignId,
464-
updateRunning: overlaySnapshot.updateRunning,
486+
updateBusy,
487+
statusBanner: overlaySnapshot.updateStatusBanner,
488+
watchUpdateProgress,
465489
canUpdate,
466490
canHoldUpdate,
467491
onUpdate: () => void context.overlays.runUpdate(),

‎ui/src/app/navigation-surface.browser.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe.skipIf(!hasBrowserLayout)("navigation surface browser layout", () => {
5252
navigationSurfaceHidden: true,
5353
onboarding: false,
5454
updateAvailable: null,
55-
updateRunning: false,
55+
updateBusy: false,
5656
onUpdate: () => undefined,
5757
refreshRequired: true,
5858
onRefresh: () => undefined,

‎ui/src/app/navigation-surface.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { html, nothing } from "lit";
22
import type { ApplicationContext } from "./context.ts";
3+
import type { UpdateProgress } from "./update-confirmation.ts";
34

45
export function navigationSurfaceIsHidden(params: {
56
onboarding: boolean;
@@ -18,7 +19,9 @@ export function renderFloatingUpdateCard(params: {
1819
updateAvailable: ApplicationContext["overlays"]["snapshot"]["updateAvailable"];
1920
updateSchedule?: ApplicationContext["overlays"]["snapshot"]["updateSchedule"];
2021
heldUpdateCampaignId?: string | null;
21-
updateRunning: boolean;
22+
updateBusy: boolean;
23+
statusBanner?: ApplicationContext["overlays"]["snapshot"]["updateStatusBanner"];
24+
watchUpdateProgress?: (listener: (progress: UpdateProgress) => void) => () => void;
2225
canUpdate?: boolean;
2326
canHoldUpdate?: boolean;
2427
onUpdate: () => void;
@@ -36,7 +39,9 @@ export function renderFloatingUpdateCard(params: {
3639
.updateAvailable=${params.updateAvailable}
3740
.updateSchedule=${params.updateSchedule ?? null}
3841
.heldUpdateCampaignId=${params.heldUpdateCampaignId ?? null}
39-
.updateRunning=${params.updateRunning}
42+
.updateBusy=${params.updateBusy}
43+
.statusBanner=${params.statusBanner ?? null}
44+
.watchUpdateProgress=${params.watchUpdateProgress}
4045
.canUpdate=${params.canUpdate ?? false}
4146
.canHoldUpdate=${params.canHoldUpdate ?? false}
4247
.onUpdate=${params.onUpdate}

‎ui/src/app/overlays-update-race.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {
1111
type RequestFn,
1212
} from "./overlays-access.test-support.ts";
1313
import { createApplicationOverlays } from "./overlays.ts";
14-
import { UPDATE_HANDOFF_STARTED_REASON } from "./update-overlay-helpers.ts";
14+
15+
vi.mock("../lib/toast.ts", () => ({ showToast: vi.fn() }));
1516

1617
const UNKNOWN_OUTCOME_TEXT =
1718
"The update request may have been accepted, but the Gateway did not report a final result after reconnect. Run `openclaw update status` before retrying.";
19+
const UPDATE_HANDOFF_STARTED_REASON = "managed-service-handoff-started";
1820

1921
function installUpdateTranslations() {
2022
const translations: Record<string, string> = {

‎ui/src/app/overlays.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import {
1313
type RequestFn,
1414
} from "./overlays-access.test-support.ts";
1515
import { createApplicationOverlays } from "./overlays.ts";
16-
import { UPDATE_HANDOFF_STARTED_REASON } from "./update-overlay-helpers.ts";
1716

1817
vi.mock("../build-info.ts", () => ({
1918
controlUiVersionDiffersFrom: (gatewayVersion: string | undefined) =>
2019
Boolean(gatewayVersion?.trim() && gatewayVersion.trim() !== "1.0.0"),
2120
reloadControlUiIfStale: vi.fn(),
2221
}));
22+
vi.mock("../lib/toast.ts", () => ({ showToast: vi.fn() }));
2323
const { peekStoredDeviceIdentityIdMock } = vi.hoisted(() => ({
2424
peekStoredDeviceIdentityIdMock: vi.fn((): string | null => "browser-1"),
2525
}));
@@ -29,6 +29,7 @@ vi.mock("../lib/nodes/index.ts", () => ({
2929

3030
const HANDOFF_POLL_MS = 1_000;
3131
const RESTART_VERIFICATION_TIMEOUT_MS = 10_000;
32+
const UPDATE_HANDOFF_STARTED_REASON = "managed-service-handoff-started";
3233

3334
function installUpdateTranslations() {
3435
const translations: Record<string, string> = {

‎ui/src/app/overlays.ts‎

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from "../../../src/gateway/events.js";
55
import type { GatewayEventFrame } from "../api/gateway.ts";
66
import type { UpdateAvailable, UpdateHoldResult, UpdateScheduleState } from "../api/types.ts";
7-
import { controlUiVersionDiffersFrom, reloadControlUiIfStale } from "../build-info.ts";
7+
import { controlUiVersionDiffersFrom } from "../build-info.ts";
88
import { t } from "../i18n/index.ts";
99
import {
1010
closeDevicePairSetup as closeDevicePairSetupState,
@@ -40,24 +40,30 @@ import {
4040
readOverlayOperatorAccessTransition,
4141
} from "./overlays-access.ts";
4242
import {
43+
classifyUpdateRunResponse,
4344
createPendingUpdateReconciliation,
4445
createUpdateCampaignStatusPoller,
4546
createUpdateStatusRefresher,
4647
createUpdateVerificationController,
4748
projectUpdateStatusResponse,
48-
readUpdateAvailable,
49-
readUpdateAvailableValue,
50-
readUpdateSchedule,
51-
readUpdateScheduleValue,
5249
resolveExpectedUpdateSha,
5350
resolveUnknownUpdateOutcomeBanner,
5451
resolveUpdateStatusBanner,
55-
UPDATE_HANDOFF_STARTED_REASON,
5652
type ApplicationStatusBanner,
5753
type PendingUpdateReconciliation,
5854
type UpdateRestartStatusResponse,
5955
type UpdateRunResponse,
6056
} from "./update-overlay-helpers.ts";
57+
import {
58+
readUpdateAvailable,
59+
readUpdateAvailableValue,
60+
readUpdateSchedule,
61+
readUpdateScheduleValue,
62+
} from "./update-schedule-dto.ts";
63+
import {
64+
announceRecordedUpdateSuccess,
65+
announceVerifiedUpdateInstall,
66+
} from "./update-success-notice.ts";
6167

6268
type ApplicationOverlaySnapshot = {
6369
updateAvailable: UpdateAvailable | null;
@@ -236,7 +242,7 @@ export function createApplicationOverlays(
236242
getHello: () => gateway.snapshot.hello,
237243
publish,
238244
publishBanner: publishUpdateBanner,
239-
onVerifiedInstall: reloadControlUiIfStale,
245+
onVerifiedInstall: announceVerifiedUpdateInstall,
240246
});
241247
const applyUpdateStatusResponse = (response: UpdateRestartStatusResponse) => {
242248
snapshot = {
@@ -439,6 +445,8 @@ export function createApplicationOverlays(
439445
}
440446
});
441447
synchronizeGateway(gateway.snapshot);
448+
// A reload started by the previous document's verified install lands here.
449+
announceRecordedUpdateSuccess();
442450

443451
return {
444452
get snapshot() {
@@ -491,42 +499,22 @@ export function createApplicationOverlays(
491499
) {
492500
return;
493501
}
494-
const status = response.result?.status ?? (response.ok === true ? "ok" : "error");
495-
const expectedVersion =
496-
response.result?.after?.version?.trim() || pendingUpdate.expectedVersion;
497-
const expectedSha = response.result?.after?.sha?.trim() || pendingUpdate.expectedSha;
498-
if (
499-
response.ok === true &&
500-
status === "skipped" &&
501-
response.result?.reason === UPDATE_HANDOFF_STARTED_REASON &&
502-
response.handoff?.status === "started"
503-
) {
504-
pendingUpdate = { expectedVersion, expectedSha, kind: "handoff" };
505-
return;
506-
}
507-
if (response.ok === true && status === "ok") {
508-
pendingUpdate = { expectedVersion, expectedSha, kind: "restart" };
509-
if (response.restart?.coalesced === true) {
510-
snapshot = {
511-
...snapshot,
512-
updateStatusBanner: {
513-
tone: "info",
514-
text: t("updates.coalescedRestart"),
515-
},
516-
};
502+
const accepted = classifyUpdateRunResponse(response, pendingUpdate);
503+
if (accepted) {
504+
pendingUpdate = accepted.pending;
505+
if (accepted.banner) {
506+
snapshot = { ...snapshot, updateStatusBanner: accepted.banner };
517507
}
518508
return;
519509
}
520510
pendingUpdate = null;
521-
if (response.ok !== true || status !== "ok") {
522-
snapshot = {
523-
...snapshot,
524-
updateStatusBanner: resolveUpdateStatusBanner({
525-
status,
526-
reason: response.result?.reason,
527-
}),
528-
};
529-
}
511+
snapshot = {
512+
...snapshot,
513+
updateStatusBanner: resolveUpdateStatusBanner({
514+
status: response.result?.status ?? "error",
515+
reason: response.result?.reason,
516+
}),
517+
};
530518
} catch (error) {
531519
if (
532520
disposed ||

0 commit comments

Comments
 (0)