Don't show the Compass app on hardware (ie G1s) that can't support it

This commit is contained in:
James Babcock committed 2026-11-06 15:13:46 -08:00
1 parent 38c52ebc31
commit 0cc263c5d2
16 files changed
+202 -49

No files matched your search

+7
View File
@@ -30,6 +30,13 @@ export type AppDefinition = {
boot?: (ctx: AppContext) => void;
/** False for apps that must not appear in the launcher grid (the launcher itself). */
showInLauncher?: boolean;
/**
* False while the paired glasses can't run the app (absent means they can).
* It then leaves the launcher grid and what mirrors it: the watch remote and
* the apps.launch tool. A window restored from before a re-pair still opens,
* so the app needs to say what's wrong rather than assume it never runs.
*/
isSupported?: () => boolean;
/** Present on the app that handles text shared via the Android share intent. */
openSharedText?: (ctx: AppContext, title: string, text: string) => void;
/**
+5 -10
View File
@@ -10,7 +10,7 @@ import {
type CompassDiagnostics,
} from "../../native/compass";
import { wrapText } from "../../graphics/textwrap";
import { glassesTypeSetting } from "../../ui/dashboard-settings";
import { glassesHaveCompass } from "../../ui/dashboard-settings";
import { type InputEvent } from "../../ui/gestures";
import { type Layer, type LayerContext } from "../../ui/layers";
import { lineStep } from "../../ui/metrics";
@@ -152,7 +152,7 @@ class CompassLayer implements Layer {
}
private statusText(): string {
if (noCompassSensor()) return "These glasses have no compass sensor";
if (!glassesHaveCompass()) return "These glasses have no compass sensor";
if (this.firmwareStatus !== null) return this.firmwareStatus;
if (!this.enabled) return "Compass paused";
if (this.rawHeading === null) return "Waiting for compass data…";
@@ -208,7 +208,7 @@ class CompassLayer implements Layer {
image.drawText(small, Math.round(cx - small.measureText(line) / 2), y, line, 125);
y += smallStep;
}
if (!noCompassSensor()) {
if (glassesHaveCompass()) {
const accuracyText = magneticAccuracyText(this.diagnostics);
image.drawText(small, width - ACCURACY_RIGHT_PAD - small.measureText(accuracyText), ACCURACY_TOP_PAD, accuracyText, 175);
}
@@ -220,15 +220,10 @@ class CompassLayer implements Layer {
// "Uncalibrated" prompt advertises, and re-calibrating is a normal thing to
// want once the glasses have been taken off and put back on.
handleInput(event: InputEvent, ctx: LayerContext): void {
if (event.type === "click" && !noCompassSensor()) this.openCalibration(ctx);
if (event.type === "click" && glassesHaveCompass()) this.openCalibration(ctx);
}
}
/** A G1 has an accelerometer and a gyroscope, but no magnetometer. */
function noCompassSensor(): boolean {
return glassesTypeSetting.get() === "g1";
}
export function createCompassAppWindow(options: InProcessAppOptions): InProcessWindow {
let requestRender = () => {};
const layer = new CompassLayer(() => requestRender());
@@ -240,7 +235,7 @@ export function createCompassAppWindow(options: InProcessAppOptions): InProcessW
icon: "compass",
closeable: true,
actions: options.actions,
menuItems: () => noCompassSensor() ? [] : [
menuItems: () => !glassesHaveCompass() ? [] : [
{
label: "Calibrate",
onSelect: (ctx) => {
+2
View File
@@ -1,3 +1,4 @@
import { glassesHaveCompass } from "../../ui/dashboard-settings";
import { type AppDefinition } from "../app-definition";
import { COMPASS_SURFACE_ID, COMPASS_WINDOW_ID, createCompassAppWindow } from "./compass-app";
@@ -5,6 +6,7 @@ const compassApp: AppDefinition = {
appId: "compass",
title: "Compass",
icon: "compass",
isSupported: glassesHaveCompass,
launch: (ctx) => ctx.launchInProcessApp(COMPASS_WINDOW_ID, COMPASS_SURFACE_ID, createCompassAppWindow),
};
+26 -13
View File
@@ -1,4 +1,4 @@
import { ConfigSettingBoolean, ConfigSettingEnum } from "../../ui/dashboard-settings";
import { ConfigSettingBoolean, ConfigSettingEnum, glassesHaveCompass } from "../../ui/dashboard-settings";
import { QUADRANT_LAYOUT, SIX_SLOT_LAYOUT, slotsVerticallyAdjacent, type GlanceLayout } from "./layout";
import { type GlanceWidgetId } from "./widget";
import { glanceWidgetSpans } from "./widgets";
@@ -23,6 +23,11 @@ export function glanceSlotChoiceLabel(choice: GlanceSlotChoice): string {
return SLOT_CHOICE_LABELS[choice] ?? choice;
}
/** Whether the paired glasses can drive this widget; if not, it is left out of the slot picker. */
function slotChoiceAvailable(choice: GlanceSlotChoice): boolean {
return choice !== "compass" || glassesHaveCompass();
}
/**
* Slot order follows QUADRANT_LAYOUT: top left, top right, bottom left, bottom
* right. Calendar in both right slots merges into one double-height region.
@@ -146,18 +151,26 @@ export const glanceShowLinesSetting = new ConfigSettingBoolean({
export function glanceSlotSettings(layout: GlanceLayout = glanceLayout()): ConfigSettingEnum<GlanceSlotChoice>[] {
const grid = layout === QUADRANT_LAYOUT || layout === SIX_SLOT_LAYOUT;
const storageId = grid ? QUADRANT_LAYOUT.id : layout.id;
return layout.slots.map(
(slot, index) =>
new ConfigSettingEnum<GlanceSlotChoice>({
id: `glanceboard-${layout.id}-slot-${index}`,
label: slot.label,
storageKey: `glanceboard.${storageId}.slot.${index}`,
defaultValue: (grid ? DEFAULT_QUADRANT_CHOICES[index] : undefined) ?? "none",
values: SLOT_CHOICES,
formatValue: glanceSlotChoiceLabel,
description: `Which widget fills the ${slot.label.toLowerCase()} slot of the Glanceboard.`,
}),
);
return layout.slots.map((slot, index) => {
const defaultValue: GlanceSlotChoice = (grid ? DEFAULT_QUADRANT_CHOICES[index] : undefined) ?? "none";
return new ConfigSettingEnum<GlanceSlotChoice>({
id: `glanceboard-${layout.id}-slot-${index}`,
label: slot.label,
storageKey: `glanceboard.${storageId}.slot.${index}`,
defaultValue,
values: SLOT_CHOICES.filter(slotChoiceAvailable),
// A stored choice the glasses can't drive reads as Empty, not the slot's
// default (which could put a widget on the board twice). The stored value
// stays, so pairing glasses that can drive it brings it back.
normalize: (value) => {
const choice = value as GlanceSlotChoice;
if (!SLOT_CHOICES.includes(choice)) return defaultValue;
return slotChoiceAvailable(choice) ? choice : "none";
},
formatValue: glanceSlotChoiceLabel,
description: `Which widget fills the ${slot.label.toLowerCase()} slot of the Glanceboard.`,
});
});
}
/**
+1 -1
View File
@@ -11,7 +11,7 @@ import {
export function launcherEntries(apps: readonly AppDefinition[]) {
return [
...apps
.filter((app) => app.showInLauncher !== false)
.filter((app) => app.showInLauncher !== false && app.isSupported?.() !== false)
.map((app) => ({
appId: app.appId,
label: app.title,
+12 -10
View File
@@ -5,11 +5,11 @@
* mirrors what the user can do from the launcher grid and the sidebar.
*
* The launchable set is the built-in launcher apps plus whatever EvenHub
* packages are installed right now, matching the launcher grid. Installs and
* uninstalls change that set at runtime, so the tools re-register (replacing
* themselves by name) whenever it changes to keep the id enums and
* descriptions current; register() fires the tools-changed broadcast that
* propagates the new specs to the assistant backends.
* packages are installed right now, matching the launcher grid. Installs,
* uninstalls and pairing different glasses change that set at runtime, so the
* tools re-register (replacing themselves by name) whenever it changes to keep
* the id enums and descriptions current; register() fires the tools-changed
* broadcast that propagates the new specs to the assistant backends.
*/
import { shell, type ShellWindow } from "../ui/shell/shell";
import type { AppDefinition } from "../apps/app-definition";
@@ -30,8 +30,8 @@ import { onAnySettingChanged } from "../ui/dashboard-settings";
import { toolRegistry, type ToolRegistry, type ToolResult } from "./tool-registry";
export type WindowToolsOptions = {
/** The built-in launcher apps; installed EvenHub apps are added dynamically. */
apps: readonly AppDefinition[];
/** The built-in launcher apps for the paired glasses; installed EvenHub apps are added dynamically. */
apps: () => readonly AppDefinition[];
/** Launch (or focus) an app exactly as the launcher grid would. */
launchApp: (appId: string) => Promise<void> | void;
/** Repaint the shell surface so the sidebar reflects a focus change. */
@@ -47,9 +47,11 @@ export function registerWindowTools(
if (registered) return;
registered = true;
registerTools(options, registry);
let fingerprint = getInstalledEvenHubFingerprint();
const launchableFingerprint = () =>
`${getInstalledEvenHubFingerprint()}\n${options.apps().map((app) => app.appId).join()}`;
let fingerprint = launchableFingerprint();
onAnySettingChanged(() => {
const current = getInstalledEvenHubFingerprint();
const current = launchableFingerprint();
if (current === fingerprint) return;
fingerprint = current;
registerTools(options, registry);
@@ -58,7 +60,7 @@ export function registerWindowTools(
function registerTools(options: WindowToolsOptions, registry: ToolRegistry): void {
const installedApps = getInstalledEvenHubApps();
const apps = new Map(options.apps.map((app) => [app.appId, app.title]));
const apps = new Map(options.apps().map((app) => [app.appId, app.title]));
for (const app of installedApps) {
apps.set(installedEvenHubAppId(app.packageId), app.name);
}
+4 -4
View File
@@ -195,8 +195,8 @@ const LOW_BATTERY_PERCENT = 5;
const EVEN_APP_DETECTED_MESSAGE =
"The Even Realities app appears to be running. If Faceclaw has trouble connecting, open its app settings and force stop it.";
// The launcher grid's app list; also fixes the app ids apps.launch accepts.
const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
// The launcher grid's app list for the paired glasses; also fixes the app ids apps.launch accepts.
const launchableApps = () => ALL_APPS.filter((app) => app.showInLauncher !== false && app.isSupported?.() !== false);
/**
* The global settings window viewport sizes depend on: the paired glasses'
@@ -422,7 +422,7 @@ class DashboardController {
registerRoamTools((appId) => this.launchApp(appId));
// apps.* tools mirror the launcher grid and sidebar (launch, focus, close).
registerWindowTools({
apps: LAUNCHABLE_APPS,
apps: launchableApps,
launchApp: (appId) => this.launchApp(appId),
requestShellRender: () => this.requestShellRender(),
});
@@ -506,7 +506,7 @@ class DashboardController {
assistant: text => shell.sendToAssistant(text),
});
this.wearRemote = new WearRemote({
apps: LAUNCHABLE_APPS,
apps: launchableApps,
injectInput: (kind) => this.injectSyntheticRingInput(kind, "watch"),
launchApp: (appId) => this.launchApp(appId),
connect: () => this.connect(),
+2 -2
View File
@@ -272,7 +272,7 @@ export class IosPreviewController {
// The header's EvenHub phone-UI button hides while that UI is showing.
onPhoneShownChanged(() => this.syncEvenHubPhoneUi())
registerSystemTools()
registerWindowTools({ apps: ALL_APPS.filter(app => !iosAppUnavailableReason(app.appId)),
registerWindowTools({ apps: () => ALL_APPS.filter(app => app.isSupported?.() !== false && !iosAppUnavailableReason(app.appId)),
launchApp: id => this.launchApp(id), requestShellRender: () => this.requestShellRender() })
registerNavigateTools(id => this.launchApp(id))
registerRoamTools(id => this.launchApp(id))
@@ -280,7 +280,7 @@ export class IosPreviewController {
iosVoiceInput.onSpeechEnd(() => this.syncContinuousCapture())
for (const app of ALL_APPS) if (app.appId !== 'launcher' && !iosAppUnavailableReason(app.appId)) app.boot?.(this.buildAppContext(app))
this.wearRemote = new WearRemote({
apps: ALL_APPS.filter(app => app.showInLauncher !== false && !iosAppUnavailableReason(app.appId)),
apps: () => ALL_APPS.filter(app => app.showInLauncher !== false && app.isSupported?.() !== false && !iosAppUnavailableReason(app.appId)),
injectInput: kind => this.injectWatchInput(kind),
launchApp: id => this.launchApp(id),
// The watch's Connect/Disconnect are explicit user choices, like the phone's own buttons.
+3 -3
View File
@@ -115,8 +115,8 @@ const WATCH_BATTERY_MAX_AGE_MS = 4 * 60 * 60_000;
/** What the dashboard controller lends the watch remote. */
export type WearRemoteHost = {
/** The launcher-grid apps; installed EvenHub packages are added dynamically. */
apps: readonly AppDefinition[];
/** The launcher-grid apps for the paired glasses; installed EvenHub packages are added dynamically. */
apps: () => readonly AppDefinition[];
injectInput: (kind: WearRemoteInputKind) => Promise<void>;
launchApp: (appId: string) => Promise<void>;
connect: () => Promise<void>;
@@ -320,7 +320,7 @@ export class WearRemote {
/** Launchable apps, matching the launcher grid and the apps.launch tool. */
private listApps(): Array<{ appId: string; title: string }> {
const apps = this.host.apps.map((app) => ({ appId: app.appId, title: app.title }));
const apps = this.host.apps().map((app) => ({ appId: app.appId, title: app.title }));
for (const installed of getInstalledEvenHubApps()) {
apps.push({ appId: installedEvenHubAppId(installed.packageId), title: installed.name });
}
+9
View File
@@ -396,6 +396,15 @@ export const glassesTypeSetting = new ConfigSettingEnum<GlassesType>({
reportInAnalytics: false,
});
/**
* Whether the paired glasses can report a heading. A G1 has an accelerometer
* and a gyroscope but no magnetometer; the RayNeo iO's firmware has no compass
* messages.
*/
export function glassesHaveCompass(): boolean {
return glassesTypeSetting.get() === "g2";
}
const APP_SWITCHER_POSITION_LABELS: Record<AppSwitcherPosition, string> = {
left: "Left",
right: "Right",