Fix an iOS issue where depth would be incorrect on first frame of fade-in on wake; also refine the keyboard input dialog

This commit is contained in:
James Babcock committed 2026-10-25 15:59:45 -07:00
1 parent 22f869d31c
commit 361b514f9a
21 files changed
+546 -138

No files matched your search

+37 -7
View File
@@ -20,7 +20,7 @@ import {
import { Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
import { CONTEXT_MENU_DIM, MenuLayer, type MenuItem } from "../menu";
import { VoiceInputLayer, type VoiceSendTarget } from "./voice-input";
import { KeyboardInputLayer, type KeyboardInputSession } from "./keyboard-input";
import { KeyboardInputLayer, type KeyboardInputSession, type KeyboardInputVisibility } from "./keyboard-input";
import { voiceActivity } from "./voice-activity";
import { AssistantLayer } from "./assistant";
import { AssistantSession, type AssistantBackendConfig } from "../../assistant/session";
@@ -310,6 +310,9 @@ const noopActions: LayerActions = noopLayerActions;
*/
const LONG_PRESS_ESCAPE_MENU_MS = 4000;
/** Settings-store key for the keyboard dialog's last-chosen KeyboardInputVisibility. */
const KEYBOARD_INPUT_VISIBILITY_KEY = "keyboardInput.visibility";
/** Shell-surface overlay menu (the system menu); closing it returns focus to the sidebar. */
class ShellOverlayMenuLayer extends MenuLayer {
/**
@@ -455,6 +458,8 @@ class Shell {
private readonly trayIcons = new Map<string, { icon: GrayImage; widget?: TrayWidget }>();
private activeVoiceLayer: VoiceInputLayer | null = null;
private activeKeyboardLayer: KeyboardInputLayer | null = null;
// Messages sent from keyboard dialogs, newest first; in memory only.
private readonly keyboardInputHistory: string[] = [];
// App-posted notifications that are open or queued, by key.
private readonly appNotifications = new Map<string, AppNotification>();
private readonly notificationModals = new NotificationModalQueue<NotificationPopup>({
@@ -1194,7 +1199,7 @@ class Shell {
const foreground = this.foregroundWindow()?.windowId ?? "none";
if (!this.screenOn) return `fg=${foreground} target=screen-off`;
if (this.activeVoiceLayer) return `fg=${foreground} target=voice`;
if (this.activeKeyboardLayer) return `fg=${foreground} target=keyboard`;
if (this.activeKeyboardLayer?.shownOnGlasses) return `fg=${foreground} target=keyboard`;
if (!this.stack.isAtBase()) return `fg=${foreground} target=shell-overlay`;
return `fg=${foreground} target=${this.focus}`;
}
@@ -1583,12 +1588,16 @@ class Shell {
* continues that conversation; otherwise it goes to the usual destinations
* with Send to Assistant highlighted. Returns the session the phone types
* into (the already-open one if there is one), or null while a voice
* dialog is up.
* dialog is up. The phone can keep the dialog off the glasses (see
* KeyboardInputVisibility); that choice persists across dialogs.
*/
startKeyboardInput(): KeyboardInputSession | null {
if (this.activeKeyboardLayer) return this.activeKeyboardLayer;
if (this.activeVoiceLayer || this.foregroundWindow()?.isVoiceCapturing?.()) return null;
if (!this.screenOn) this.wake("sidebar");
const storedVisibility = getStringSetting(KEYBOARD_INPUT_VISIBILITY_KEY, "both");
const visibility: KeyboardInputVisibility =
storedVisibility === "phone" || storedVisibility === "glasses" ? storedVisibility : "both";
if (visibility !== "phone" && !this.screenOn) this.wake("sidebar");
const assistantLayer = this.assistantLayer;
const assistantSession = this.assistantSession;
let targets: VoiceSendTarget[];
@@ -1598,7 +1607,15 @@ class Shell {
{
id: "assistant",
label: "Send",
onSend: (text) => this.runAssistantTurn(assistantSession, assistantLayer, text),
// Phone-only, the overlay can close while the dialog is open; the
// text then starts a fresh overlay on the same conversation.
onSend: (text) => {
if (this.assistantLayer === assistantLayer) {
this.runAssistantTurn(assistantSession, assistantLayer, text);
} else {
this.sendToAssistant(text);
}
},
},
];
} else {
@@ -1616,16 +1633,29 @@ class Shell {
}
},
dismiss: () => {
this.stack.popIfTop((top) => top === layer);
// Wherever it sits: a menu opened over the dialog stays open.
this.stack.remove(layer);
// A send or discard from the phone side arrives outside the input
// path, so nothing else asks for the repaint.
this.config.requestShellRender();
},
setShownOnGlasses: (shown) => {
if (shown) {
if (!this.screenOn) this.wake("sidebar");
this.stack.push(layer);
} else {
this.stack.remove(layer);
}
this.config.requestShellRender();
},
visibility,
onVisibilityChanged: (value) => setStringSetting(KEYBOARD_INPUT_VISIBILITY_KEY, value),
history: this.keyboardInputHistory,
sendTargets: targets,
defaultTargetIndex: defaultIndex,
});
this.activeKeyboardLayer = layer;
this.stack.push(layer);
if (layer.shownOnGlasses) this.stack.push(layer);
this.config.onKeyboardInputChanged?.(layer);
this.config.requestShellRender();
return layer;