|
4 | 4 | } from "../../../src/gateway/events.js"; |
5 | 5 | import type { GatewayEventFrame } from "../api/gateway.ts"; |
6 | 6 | import type { UpdateAvailable, UpdateHoldResult, UpdateScheduleState } from "../api/types.ts"; |
7 | | -import { controlUiVersionDiffersFrom, reloadControlUiIfStale } from "../build-info.ts"; |
| 7 | +import { controlUiVersionDiffersFrom } from "../build-info.ts"; |
8 | 8 | import { t } from "../i18n/index.ts"; |
9 | 9 | import { |
10 | 10 | closeDevicePairSetup as closeDevicePairSetupState, |
@@ -40,24 +40,30 @@ import { |
40 | 40 | readOverlayOperatorAccessTransition, |
41 | 41 | } from "./overlays-access.ts"; |
42 | 42 | import { |
| 43 | + classifyUpdateRunResponse, |
43 | 44 | createPendingUpdateReconciliation, |
44 | 45 | createUpdateCampaignStatusPoller, |
45 | 46 | createUpdateStatusRefresher, |
46 | 47 | createUpdateVerificationController, |
47 | 48 | projectUpdateStatusResponse, |
48 | | - readUpdateAvailable, |
49 | | - readUpdateAvailableValue, |
50 | | - readUpdateSchedule, |
51 | | - readUpdateScheduleValue, |
52 | 49 | resolveExpectedUpdateSha, |
53 | 50 | resolveUnknownUpdateOutcomeBanner, |
54 | 51 | resolveUpdateStatusBanner, |
55 | | - UPDATE_HANDOFF_STARTED_REASON, |
56 | 52 | type ApplicationStatusBanner, |
57 | 53 | type PendingUpdateReconciliation, |
58 | 54 | type UpdateRestartStatusResponse, |
59 | 55 | type UpdateRunResponse, |
60 | 56 | } 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"; |
61 | 67 |
|
62 | 68 | type ApplicationOverlaySnapshot = { |
63 | 69 | updateAvailable: UpdateAvailable | null; |
@@ -236,7 +242,7 @@ export function createApplicationOverlays( |
236 | 242 | getHello: () => gateway.snapshot.hello, |
237 | 243 | publish, |
238 | 244 | publishBanner: publishUpdateBanner, |
239 | | - onVerifiedInstall: reloadControlUiIfStale, |
| 245 | + onVerifiedInstall: announceVerifiedUpdateInstall, |
240 | 246 | }); |
241 | 247 | const applyUpdateStatusResponse = (response: UpdateRestartStatusResponse) => { |
242 | 248 | snapshot = { |
@@ -439,6 +445,8 @@ export function createApplicationOverlays( |
439 | 445 | } |
440 | 446 | }); |
441 | 447 | synchronizeGateway(gateway.snapshot); |
| 448 | + // A reload started by the previous document's verified install lands here. |
| 449 | + announceRecordedUpdateSuccess(); |
442 | 450 |
|
443 | 451 | return { |
444 | 452 | get snapshot() { |
@@ -491,42 +499,22 @@ export function createApplicationOverlays( |
491 | 499 | ) { |
492 | 500 | return; |
493 | 501 | } |
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 }; |
517 | 507 | } |
518 | 508 | return; |
519 | 509 | } |
520 | 510 | 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 | + }; |
530 | 518 | } catch (error) { |
531 | 519 | if ( |
532 | 520 | disposed || |
|
0 commit comments