forked from Blendman974/faceclaw
[verified] merge upstream c162c8e6 into all-features
This commit is contained in:
commit
5790e98d27
176 files changed
+5311
-2307
No files matched your search
@@ -75,10 +75,11 @@ import { ALL_APPS } from "../apps/all-apps";
|
||||
import { type AppContext, type AppDefinition, type AppLaunchParams, type TextEditorHost } from "../apps/app-definition";
|
||||
import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-process-window";
|
||||
import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence";
|
||||
import { appViewportRect, isOnSwitcherEdge, screenHeight, screenWidth, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { appViewportRect, isOnSwitcherEdge, screenHeight, screenWidth, sidebarStripVisible, windowEdges, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { sameEdges } from "../ui/viewport";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, glassesModelName, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, getHeadUpPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, openAiTranscriptionModelSetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, shouldPopUpNewNotification, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesModelName, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, getHeadUpPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, openAiTranscriptionModelSetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveRecordingSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, shouldPopUpNewNotification, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -111,8 +112,6 @@ type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging"
|
||||
|
||||
export type DashboardSnapshot = {
|
||||
phase: ConnectionPhase;
|
||||
/** Last-known battery levels: the glasses, their charging case, the R1 ring and a Wear OS watch. */
|
||||
batteries: ReturnType<typeof shell.getBatteryLevels>;
|
||||
status: string;
|
||||
displayPreview: ImageSource | null;
|
||||
/**
|
||||
@@ -156,7 +155,7 @@ export type DashboardSnapshot = {
|
||||
previewMode: boolean;
|
||||
/**
|
||||
* The foreground glasses window's EvenHub phone UI, when it can be opened
|
||||
* (the action bar's app-icon button); null otherwise.
|
||||
* (the app-icon button under the mirror); null otherwise.
|
||||
*/
|
||||
evenHubPhoneUi: PhoneUiButton | null;
|
||||
};
|
||||
@@ -204,14 +203,16 @@ const launchableApps = () => ALL_APPS.filter((app) => app.showInLauncher !== fal
|
||||
* screen, the display mode's size (a band's position only moves windows), whether the app switcher
|
||||
* takes width beside windows, height below them or neither (a popup), and
|
||||
* the chrome rows each window loses to it: below them, whether the status
|
||||
* bar joins the row (dropping the top bar); with a popup, whether the
|
||||
* status bar keeps rows of its own and the window frame (where the status
|
||||
* bar goes only moves windows).
|
||||
* bar joins the row (dropping the top bar, for the window frame's top row
|
||||
* if it has a frame); with a popup, whether the status bar keeps rows of its
|
||||
* own and the window frame (where the status bar goes only moves windows).
|
||||
*/
|
||||
function viewportSizesKey(): string {
|
||||
const position = appSwitcherPositionSetting.get();
|
||||
const switcher = position === "bottom" ? `row|${statusBarPositionSetting.get()}`
|
||||
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`
|
||||
const statusBar = statusBarPositionSetting.get();
|
||||
const framed = windowBorderSetting.get() === "all";
|
||||
const switcher = position === "bottom" ? `row|${statusBar}|${statusBar === "bottom" && framed}`
|
||||
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${framed}`
|
||||
: "strip";
|
||||
const layout = displayLayoutSetting.get();
|
||||
return `${screenWidth()}x${screenHeight()}|${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
|
||||
@@ -431,7 +432,7 @@ class DashboardController {
|
||||
launchApp: (appId) => this.launchApp(appId),
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
});
|
||||
// The action bar's EvenHub phone-UI button hides while that UI is showing.
|
||||
// The main page's EvenHub phone-UI button hides while that UI is showing.
|
||||
onPhoneShownChanged(() => this.emit());
|
||||
shell.configure({
|
||||
actions: {
|
||||
@@ -489,12 +490,15 @@ class DashboardController {
|
||||
this.syncVoiceWake();
|
||||
// Display mode size first: a reflow repositions every surface too, so
|
||||
// the band-position check after it then has nothing left to do.
|
||||
this.applyDisplayModeIfChanged();
|
||||
const resized = this.applyDisplayModeIfChanged();
|
||||
this.applyVerticalPositionIfChanged();
|
||||
this.applyAppLayoutsIfChanged();
|
||||
const appsResized = this.applyAppLayoutsIfChanged();
|
||||
// Either reflow hands windows their new edges along with their size.
|
||||
if (!resized && !appsResized) this.applyWindowEdgesIfChanged();
|
||||
this.syncAssistantBridgeIfChanged();
|
||||
this.retargetContinuousCapture();
|
||||
this.syncLockScreenSettingIfChanged();
|
||||
this.syncContinuousRecording();
|
||||
// A Preview color or scaling change should show on the mirror at once,
|
||||
// not at the next composited frame (cheap: floor-limited, dedup'd on
|
||||
// the Java side).
|
||||
@@ -586,9 +590,9 @@ class DashboardController {
|
||||
* that support resizing receive the new viewport. Other worker windows are
|
||||
* closed and launched again at the new size.
|
||||
*/
|
||||
private applyDisplayModeIfChanged(): void {
|
||||
private applyDisplayModeIfChanged(): boolean {
|
||||
const sizes = viewportSizesKey();
|
||||
if (sizes === this.lastViewportSizes) return;
|
||||
if (sizes === this.lastViewportSizes) return false;
|
||||
this.lastViewportSizes = sizes;
|
||||
// The reflow below reconfigures every surface, covering any move too.
|
||||
this.lastWindowPlacement = windowPlacementKey();
|
||||
@@ -620,6 +624,22 @@ class DashboardController {
|
||||
})().catch((error) => {
|
||||
this.appendLog(`display mode change failed: ${this.formatError(error)}`);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A setting changed what some windows' edges touch (geometry.ts
|
||||
* windowEdges: a border line, or blank space) without resizing them, as
|
||||
* the Border setting does under a top status bar: those windows lay out
|
||||
* again with the padding their new edges suggest. Their surfaces stay as
|
||||
* they are.
|
||||
*/
|
||||
private applyWindowEdgesIfChanged(): void {
|
||||
for (const window of Array.from(shell.getWindows())) {
|
||||
const laidOut = window.layoutSize?.();
|
||||
if (!laidOut || !window.relayout || sameEdges(laidOut.edges, windowEdges(window.appId))) continue;
|
||||
window.relayout();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,10 +688,10 @@ class DashboardController {
|
||||
};
|
||||
}
|
||||
|
||||
private applyAppLayoutsIfChanged(): void {
|
||||
private applyAppLayoutsIfChanged(): boolean {
|
||||
const layouts = this.appLayouts();
|
||||
const changed = Object.keys(layouts).filter((appId) => layouts[appId] !== this.lastAppLayouts[appId]);
|
||||
if (!changed.length) return;
|
||||
if (!changed.length) return false;
|
||||
this.lastAppLayouts = layouts;
|
||||
void (async () => {
|
||||
for (const window of Array.from(shell.getWindows())) {
|
||||
@@ -682,6 +702,7 @@ class DashboardController {
|
||||
shell.foregroundWindow()?.requestRender();
|
||||
this.requestShellRender();
|
||||
})().catch((error) => this.appendLog(`app layout change failed: ${this.formatError(error)}`));
|
||||
return true;
|
||||
}
|
||||
|
||||
private applyVerticalPositionIfChanged(): void {
|
||||
@@ -1224,11 +1245,10 @@ class DashboardController {
|
||||
alarmReliabilityMessage: this.alarmReliabilityMessage,
|
||||
previewMode: this.isPreviewDisplayActive(),
|
||||
evenHubPhoneUi: phoneUiButton(),
|
||||
batteries: shell.getBatteryLevels(),
|
||||
};
|
||||
}
|
||||
|
||||
/** Overlay an EvenHub app's phone UI (the action bar's app-icon button). */
|
||||
/** Overlay an EvenHub app's phone UI (the app-icon button under the mirror). */
|
||||
showEvenHubPhoneUi(windowId: string): void {
|
||||
showEvenHubPhoneUi(windowId);
|
||||
}
|
||||
@@ -2236,12 +2256,14 @@ class DashboardController {
|
||||
|
||||
private startContinuousVoiceCapture(client: string, options: ContinuousCaptureOptions = {}): void {
|
||||
this.continuousClients.set(client, options);
|
||||
this.syncContinuousRecording();
|
||||
this.retargetContinuousCapture();
|
||||
this.ensureContinuousCapture(true);
|
||||
}
|
||||
|
||||
private stopContinuousVoiceCapture(client: string): void {
|
||||
if (!this.continuousClients.delete(client)) return;
|
||||
this.syncContinuousRecording();
|
||||
if (this.continuousClients.size > 0) {
|
||||
// The window that needed its own provider may be the one that left.
|
||||
this.retargetContinuousCapture();
|
||||
@@ -2267,6 +2289,18 @@ class DashboardController {
|
||||
void this.beginVoiceCapture("continuous").finally(() => this.syncContinuousClaim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Record to the first client's requested name while Save Recording is on
|
||||
* (it is toggled from those windows' menus, so this also runs when a
|
||||
* setting changes).
|
||||
*/
|
||||
private syncContinuousRecording(): void {
|
||||
const name = saveRecordingSetting.get()
|
||||
? Array.from(this.continuousClients.values(), (options) => options.recordAs).find(Boolean) ?? ""
|
||||
: "";
|
||||
voiceControlBridge.recordTo(name);
|
||||
}
|
||||
|
||||
/** Move a running continuous capture onto the provider its windows now call for. */
|
||||
private retargetContinuousCapture(): void {
|
||||
voiceControlBridge.retargetContinuousCapture(this.voiceCaptureOptions(this.communicator));
|
||||
@@ -2316,7 +2350,6 @@ class DashboardController {
|
||||
whisperServerUrl: whisperServerUrlSetting.get(),
|
||||
whisperServerModel: whisperServerModelSetting.get(),
|
||||
whisperServerApiKey: whisperServerApiKeySetting.get(),
|
||||
saveRecording: saveVoiceRecordingsSetting.get(),
|
||||
// "My voice only" (Microphones app): verify command utterances
|
||||
// against the enrolled wearer voice-print; non-matching speakers'
|
||||
// finals are suppressed by the bridge.
|
||||
|
||||
@@ -80,7 +80,7 @@ export type BatteryLevels = {
|
||||
};
|
||||
|
||||
/**
|
||||
* The phone Settings tab's battery row: each device whose level is known,
|
||||
* The phone settings page's battery row: each device whose level is known,
|
||||
* e.g. "G2 100% · Case 98% ⚡ · R1 72%" (⚡ = charging), or "" when none
|
||||
* is. Levels are the last known ones (the case only reports while the glasses
|
||||
* are docked), so ⚡ appears only while it is live: the glasses and Case only
|
||||
|
||||
@@ -47,13 +47,13 @@ import { makeInputEvent, type InputEvent, type InputEventPayload } from '../ui/g
|
||||
import { noopLayerActions, type ContinuousCaptureOptions, type LayerActions } from '../ui/layers'
|
||||
import { TextViewerLayer } from '../apps/files/text-viewer'
|
||||
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
|
||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type ScreenRect } from '../ui/shell/geometry'
|
||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, windowEdges, type ScreenRect } from '../ui/shell/geometry'
|
||||
import { mirrorToPanelFraction, phonePreviewCrop } from './phone-preview-crop'
|
||||
import { onAnySettingChanged,
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting, voiceProviderSetting, elevenLabsApiKeySetting,
|
||||
openAiApiKeySetting, openAiTranscriptionModelSetting, sonioxApiKeySetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage,
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting, glassesTypeSetting, shouldPopUpNewNotification } from '../ui/dashboard-settings'
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveRecordingSetting, glassesTypeSetting, shouldPopUpNewNotification } from '../ui/dashboard-settings'
|
||||
import { transcriptionKey, type VoiceProviderSelection } from '../native/cloud-stt-provider'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from '../apps/onboarding/onboarding-progress'
|
||||
@@ -366,7 +366,7 @@ export class IosPreviewController {
|
||||
this.logBluetooth(`Phone background; glasses ${this.state.phase}`)
|
||||
this.flushBluetoothLog()
|
||||
}
|
||||
/** Overlay an EvenHub app's phone UI (the header's app-icon button). */
|
||||
/** Overlay an EvenHub app's phone UI (the app-icon button under the mirror). */
|
||||
showEvenHubPhoneUi(windowId: string): void {
|
||||
showOnPhone(windowId)
|
||||
}
|
||||
@@ -425,6 +425,7 @@ export class IosPreviewController {
|
||||
this.offSettings = onAnySettingChanged(() => {
|
||||
this.syncContinuousCapture()
|
||||
this.syncLockSetting()
|
||||
this.syncContinuousRecording()
|
||||
this.pushBrightness()
|
||||
this.relayout()
|
||||
shell.foregroundWindow()?.requestRender()
|
||||
@@ -511,7 +512,9 @@ export class IosPreviewController {
|
||||
await target.setSurfaceVisible(window.surfaceId, shell.foregroundWindow()?.windowId === window.windowId)
|
||||
}
|
||||
private relayout(): void {
|
||||
const layout = shell.getWindows().map(window => JSON.stringify(appViewportRect(window.heightMode, window.appId))).join(";")
|
||||
// Each window's rect, and what its edges touch (which sets its padding).
|
||||
const layout = shell.getWindows().map(window =>
|
||||
JSON.stringify([appViewportRect(window.heightMode, window.appId), windowEdges(window.appId)])).join(";")
|
||||
if (layout === this.lastLayout) return
|
||||
this.lastLayout = layout
|
||||
for (const window of shell.getWindows()) {
|
||||
@@ -1116,7 +1119,7 @@ export class IosPreviewController {
|
||||
* Continuous capture on behalf of `client` (one id per window: Transcribe,
|
||||
* Translate, Teleprompter, Calculator); it runs while any client wants it, as
|
||||
* on Android. `recordAs` names a WAV of the audio in Downloads when Save
|
||||
* Transcribe audio is on.
|
||||
* Recording is on.
|
||||
*/
|
||||
private startContinuousVoiceCapture(client: string, options: ContinuousCaptureOptions = {}): void {
|
||||
this.continuousClients.set(client, options)
|
||||
@@ -1205,9 +1208,12 @@ export class IosPreviewController {
|
||||
private syncContinuousClaim(): void {
|
||||
voiceActivity.setActive(this.continuousClients.size > 0 && iosVoiceInput.continuousActive, CONTINUOUS_CAPTURE_HOLDER)
|
||||
}
|
||||
/** Record to the first client's requested name while Save Transcribe audio is on. */
|
||||
/**
|
||||
* Record to the first client's requested name while Save Recording is on (it is
|
||||
* toggled from those windows' menus, so this also runs when a setting changes).
|
||||
*/
|
||||
private syncContinuousRecording(): void {
|
||||
const name = saveTranscribeAudioSetting.get() ? [...this.continuousClients.values()].map(options => options.recordAs).find(Boolean) ?? '' : ''
|
||||
const name = saveRecordingSetting.get() ? [...this.continuousClients.values()].map(options => options.recordAs).find(Boolean) ?? '' : ''
|
||||
iosVoiceInput.recordTo(name)
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user