From ec12a4845b83271095555e89f36054db2df3b52c Mon Sep 17 00:00:00 2001 From: Chris Lee Date: Sun, 30 Aug 2026 10:19:28 -0400 Subject: [PATCH] Fix onboarding firmware-check: kind mismatch broke every real result classifyOnboardingFirmware() (firmware-compat.ts) returns kind values of "custom" | "flashable-stock" | "newer-stock" | "unknown", but applyClassification()'s switch (onboarding-firmware-check-view-model.ts) checked for "flashable" / "newer" -- names borrowed from the unrelated CheckPhase type used a few lines later via setPhase(). Since kind was typed as plain string, nothing caught the mismatch at compile time. Effect: any device that successfully reported a firmware version (stock, flashable-stock, or newer-stock alike) fell through to the switch's default case and showed "Connected, but couldn't read a firmware version" -- the hard-block message meant for when the probe gets no data at all. Confirmed on real hardware (glasses on 2.2.9.22): the BLE probe read the version correctly every time, logged it correctly, and the UI still reported it as unreadable. Fix: match the real OnboardingFirmwareKind strings, and tighten the parameter's type from `string` to `OnboardingFirmwareKind` so this category of typo fails to compile instead of failing silently. --- .../onboarding-firmware-check-view-model.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/phone-ui/onboarding-firmware-check-view-model.ts b/app/phone-ui/onboarding-firmware-check-view-model.ts index ff8ace3b..88850ced 100644 --- a/app/phone-ui/onboarding-firmware-check-view-model.ts +++ b/app/phone-ui/onboarding-firmware-check-view-model.ts @@ -7,7 +7,7 @@ import { hasExtractedEvenHubFonts, type FirmwareProgress, } from "../g2/firmware-builder"; -import { classifyOnboardingFirmware, FLASHABLE_STOCK_VERSION_TEXT } from "../g2/firmware-compat"; +import { classifyOnboardingFirmware, FLASHABLE_STOCK_VERSION_TEXT, type OnboardingFirmwareKind } from "../g2/firmware-compat"; import { DeviceInfoProbe, DeviceInfoState } from "../native/device-info-probe"; import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state"; import { formatErrorMessage } from "../util/format-error"; @@ -193,8 +193,16 @@ export class OnboardingFirmwareCheckViewModel extends Observable { } } - private applyClassification(kind: string, version: string, capabilities: string): void { + private applyClassification(kind: OnboardingFirmwareKind, version: string, capabilities: string): void { this.busy = false; + // `kind` is classifyOnboardingFirmware's OnboardingFirmwareKind ("custom" | + // "flashable-stock" | "newer-stock" | "unknown") -- NOT CheckPhase's shorter + // "flashable"/"newer" (used below via setPhase for _phase/primaryLabel/etc). + // The two types share two of four names, so a typo'd case label here type-checks + // fine as long as `kind` stays plain `string`, but silently falls through to + // `default` (the hard "couldn't read a firmware version" error) for every real + // stock-firmware version, flashable or newer alike -- onboarding was unusable for + // any device that ever reached this switch with an actual reported version. switch (kind) { case "custom": if (!hasExtractedEvenHubFonts()) { @@ -203,14 +211,14 @@ export class OnboardingFirmwareCheckViewModel extends Observable { } this.showCustomReady(version, capabilities, false); break; - case "flashable": + case "flashable-stock": this.setPhase("flashable"); this.headline = "Ready to Install"; this.status = `Your glasses run stock firmware ${version}. This is compatible — tap Install Firmware to flash ` + "Faceclaw's custom firmware."; break; - case "newer": + case "newer-stock": this.setPhase("newer"); this.headline = "Unrecognized Firmware"; this.status =