From 63b7a13df1cbc3137a8e309d03174c7d2e9eccb9 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sat, 29 Aug 2026 11:41:49 -0700 Subject: [PATCH] Gate R1 direct connection behind a dev setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
Prompts Used Currently we receive user input events from the R1 ring mainly via the G2 glasses, which have their own connection to ring, and we also try to connect to the ring directly; but the direct connection currently winds up not workign reliably. Let's add a "Ring connection mode" to the Developer section of the Settings app, with options "Only via glasses" (new default) and "Direct". If the "Only via glasses" option is selected, we don't open a bluetooth connection to the ring at all. > Done. Build + typecheck pass. > > **Changes:** > > - `app/ui/dashboard-settings.ts:393` — new `ringConnectionModeSetting` (`ConfigSettingEnum`), values `"glasses"` (default, displayed "Only via glasses") and `"direct"`, stored under `developer.ringConnectionMode`. > - `app/ui/dashboard/settings-menus.ts:182` — added it as the first row of the Developer section. > - `app/g2/dashboard-controller.ts:988` — `connect()` now computes `ringAddress = mode === "direct" ? addresses.ring : ""` and passes that to `FaceclawCommunicatorBridge` (and into the connect log line). > > The gate works by handing the Java communicator an empty ring address: `FaceclawBleCommunicator.hasRingAddress()` then returns false, so `tryConnectRing`/`shouldAttemptRingConnect`/the teardown `disconnect(ringAddress)` all short-circuit — no GATT connection to the ring is ever opened, and the retry loop never fires. Gestures still arrive over the glasses' own link to the ring, unchanged. > > Since the mode is read at connect time, changing it while connected takes effect on the next connection; the setting's description says so. If you'd rather it apply live (drop/raise the ring link without cycling the glasses), that needs a small new Java method on the communicator — say the word and I'll add it.
--- app/g2/dashboard-controller.ts | 11 ++++++++--- app/ui/dashboard-settings.ts | 13 +++++++++++++ app/ui/dashboard/settings-menus.ts | 4 ++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index 5ba35a8b..4bd52ef1 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -58,7 +58,7 @@ import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-p import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence"; import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry"; import { type LayerActions } from "../ui/layers"; -import { assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, brightnessSetting, brightnessSettingToLevel, displayModeSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; +import { assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, brightnessSetting, brightnessSettingToLevel, displayModeSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization"; import { getInstalledEvenHubAppById, @@ -981,8 +981,13 @@ class DashboardController { this.refreshEvenAppStatus(); this.setPhase("connecting"); this.setStatus("Connecting to the glasses..."); + // "Only via glasses" (the default) means the phone never opens its own + // link to the ring: the glasses relay its gestures to us anyway, and the + // direct link is currently unreliable. An empty address disables every + // direct-ring code path in the communicator. + const ringAddress = ringConnectionModeSetting.get() === "direct" ? addresses.ring : ""; this.appendLog( - `Using configured arms: R=${addresses.right} L=${addresses.left}${addresses.ring ? ` ring=${addresses.ring}` : ""}`, + `Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`, ); let communicator: FaceclawCommunicatorBridge | null = null; @@ -999,7 +1004,7 @@ class DashboardController { communicator = new FaceclawCommunicatorBridge({ right: addresses.right, left: addresses.left, - ring: addresses.ring, + ring: ringAddress, }); this.communicator = communicator; this.offLog = communicator.onLog((line) => { diff --git a/app/ui/dashboard-settings.ts b/app/ui/dashboard-settings.ts index 6a723296..d2ae86d4 100644 --- a/app/ui/dashboard-settings.ts +++ b/app/ui/dashboard-settings.ts @@ -390,6 +390,19 @@ export const suspendEvenHubWhenScreenOffSetting = new ConfigSettingBoolean({ description: "Suspend the EvenHub session while the display is off. This significantly improves battery life, but increases the latency of waking the screen.", }); +export type RingConnectionMode = "glasses" | "direct"; + +export const ringConnectionModeSetting = new ConfigSettingEnum({ + id: "ring-connection-mode", + label: "Ring connection", + storageKey: "developer.ringConnectionMode", + defaultValue: "glasses", + values: ["glasses", "direct"], + formatValue: (value) => (value === "direct" ? "Direct" : "Only via glasses"), + description: + "How R1 ring input reaches the phone. Only via glasses: the ring's own link to the glasses carries its gestures, and the phone never opens a Bluetooth connection to the ring. Direct: also connect to the ring from the phone (currently unreliable). Takes effect on the next connection to the glasses.", +}); + export type VoiceProvider = "onboard" | "elevenlabs" | "whisper" | "soniox"; const voiceProviderLabels: Record = { diff --git a/app/ui/dashboard/settings-menus.ts b/app/ui/dashboard/settings-menus.ts index 45464c61..a66cf2cf 100644 --- a/app/ui/dashboard/settings-menus.ts +++ b/app/ui/dashboard/settings-menus.ts @@ -41,6 +41,7 @@ import { mirrorTouchSetting, openAiApiKeySetting, previewColorSetting, + ringConnectionModeSetting, roamApiTokenSetting, roamGraphNameSetting, sonioxApiKeySetting, @@ -176,6 +177,9 @@ function settingsSections(): SettingsSection[] { { label: "Developer", items: [ + // Whether the phone opens its own BLE link to the R1 ring; the + // glasses relay ring gestures either way. Applied at connect time. + enumSettingMenuItem(ringConnectionModeSetting), toggleSettingMenuItem(saveVoiceRecordingsSetting), toggleSettingMenuItem(firmwareDebugFlagsSetting), toggleSettingMenuItem(suspendEvenHubWhenScreenOffSetting),