Gate R1 direct connection behind a dev setting

<details>
<summary>Prompts Used</summary>
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<RingConnectionMode>`), 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.
</details>
This commit is contained in:
James Babcock committed 2026-08-29 11:41:49 -07:00
1 parent 268fe24093
commit 63b7a13df1
3 files changed
+25 -3

No files matched your search

+8 -3
View File
@@ -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) => {
+13
View File
@@ -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<RingConnectionMode>({
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<VoiceProvider, string> = {
+4
View File
@@ -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),