Stay disconnected when you pick Disconnect, back off reconnecting to incompatible firmwares, don't try to also connect for UI when the flasher is open

This commit is contained in:
James Babcock committed 2026-08-22 16:28:02 -07:00
1 parent 0ed242a36f
commit dc18737dfc
4 files changed
+121 -14

No files matched your search

+6 -2
View File
@@ -1,6 +1,7 @@
import { Application, Frame, ImageSource, Observable, Screen } from "@nativescript/core";
import { dashboardController } from "../g2/dashboard-controller";
import { isValidMacAddress, loadDeviceAddresses } from "../g2/device-addresses";
import { isAutoReconnectSuppressed } from "../g2/reconnect-policy";
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../graphics/image";
const LENS_ASPECT_RATIO = G2_LENS_WIDTH / G2_LENS_HEIGHT;
@@ -487,11 +488,14 @@ export class MainViewModel extends Observable {
/**
* Try to connect automatically on reaching the main page. No-op if already
* connecting/connected, or if no glasses are configured (e.g. preview-only
* users, who have nothing to connect to).
* connecting/connected, if the app is in the manual-disconnected state
* (the user picked Disconnect, the flash flow owns the glasses, or the
* firmware was found incompatible), or if no glasses are configured
* (e.g. preview-only users, who have nothing to connect to).
*/
async autoConnect(): Promise<void> {
if (this.phase !== "disconnected") return;
if (isAutoReconnectSuppressed()) return;
const addresses = loadDeviceAddresses();
if (!isValidMacAddress(addresses.right) || !isValidMacAddress(addresses.left)) return;
try {
@@ -15,6 +15,7 @@ import {
import { buildAddressSet, DeviceDiscoveryBridge } from "../native/device-discovery";
import { FirmwareFlasher, FlashProgress, FlashState } from "../native/firmware-flasher";
import { FlashPromptCommunicator, FlashPromptState } from "../native/flash-prompt-communicator";
import { resumeAutoReconnect, suppressAutoReconnect } from "../g2/reconnect-policy";
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
type FlashPhase = "intro" | "prompt" | "building" | "ready" | "flashing" | "flashed" | "error";
@@ -44,6 +45,10 @@ export class OnboardingFlashViewModel extends Observable {
constructor(options?: { mode?: FlashMode; fromOnboarding?: boolean }) {
super();
// The flash flow needs the glasses to itself: from here on the main
// page must not auto-reconnect, until an install succeeds (below) or
// the user connects explicitly.
suppressAutoReconnect();
this.mode = options?.mode ?? "install";
this.fromOnboarding = options?.fromOnboarding ?? true;
this._headline = this.mode === "uninstall" ? "Uninstall Custom Firmware" : "Flash Custom Firmware";
@@ -431,6 +436,13 @@ export class OnboardingFlashViewModel extends Observable {
this.disposeFlasher();
this.busy = false;
if (success) {
if (this.mode === "install") {
// A successful install ends the manual-disconnected state: the main
// page may auto-connect to the freshly flashed glasses. (After an
// uninstall the glasses run stock firmware, which Faceclaw would
// immediately flag as incompatible, so stay manually disconnected.)
resumeAutoReconnect();
}
this.progress = 100;
this.setPhase("flashed");
this.headline = "All Done";