This commit is contained in:
James Babcock committed 2026-10-26 00:45:27 -07:00
commit bc57557f04
32 files changed
+652 -151

No files matched your search

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- History icon for the keyboard-input panel's recent-inputs button.
Material Design "history" glyph (Apache 2.0); base fill is overridden by
tint-color in app.css. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF333333"
android:pathData="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z" />
</vector>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Glasses half of the keyboard-input panel's visibility button (dimmed
while the dialog is hidden on the glasses): two lens frames, bridge and
temple stubs. Base fill is overridden by tint-color in app.css. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF333333"
android:fillType="evenOdd"
android:pathData="M4.5 8h3a3 3 0 0 1 3 3v1.5a3 3 0 0 1-3 3h-3a3 3 0 0 1-3-3v-1.5a3 3 0 0 1 3-3zM4.75 9.75h2.5a1.5 1.5 0 0 1 1.5 1.5v1a1.5 1.5 0 0 1-1.5 1.5h-2.5a1.5 1.5 0 0 1-1.5-1.5v-1a1.5 1.5 0 0 1 1.5-1.5zM16.5 8h3a3 3 0 0 1 3 3v1.5a3 3 0 0 1-3 3h-3a3 3 0 0 1-3-3v-1.5a3 3 0 0 1 3-3zM16.75 9.75h2.5a1.5 1.5 0 0 1 1.5 1.5v1a1.5 1.5 0 0 1-1.5 1.5h-2.5a1.5 1.5 0 0 1-1.5-1.5v-1a1.5 1.5 0 0 1 1.5-1.5z" />
<path
android:fillColor="#FF333333"
android:pathData="M10 10.25Q12 8.25 14 10.25V12Q12 10 10 12zM0 8h3v1.75H0zM21 8h3v1.75h-3z" />
</vector>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Phone half of the keyboard-input panel's visibility button (dimmed while
the dialog is hidden on the phone). Material Design "smartphone" glyph
(Apache 2.0); base fill is overridden by tint-color in app.css. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF333333"
android:pathData="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z" />
</vector>
@@ -0,0 +1,13 @@
{
"images": [
{
"idiom": "universal",
"filename": "ic_input_history@3x.png",
"scale": "3x"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@@ -0,0 +1,13 @@
{
"images": [
{
"idiom": "universal",
"filename": "ic_show_glasses@3x.png",
"scale": "3x"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,13 @@
{
"images": [
{
"idiom": "universal",
"filename": "ic_show_phone@3x.png",
"scale": "3x"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

+1 -1
View File
@@ -13,7 +13,7 @@
<key>CFBundleDisplayName</key>
<string>Faceclaw</string>
<key>CFBundleShortVersionString</key>
<string>0.8.4</string>
<string>0.8.5</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
+2 -1
View File
@@ -1,6 +1,6 @@
# Changelog
## 0.8.5 - Future
## 0.8.5 - 2026-10-25
### Features
@@ -18,6 +18,7 @@
* Fix a bug on iOS that would cause corrupted installs of EvenHub apps
* EvenHub apps can use the glasses microphone on iOS (such as Chess's voice moves, which said "Mic unavailable")
* EvenHub apps on iOS should now be able to use the mic
* Fix a bug that caused fade-in on wake to be shown at the wrong depth on iOS
## 0.8.4 - 2026-10-17
+54
View File
@@ -154,6 +154,60 @@ Button.-primary {
color: #222222;
}
/* Keyboard-input panel: tighter than the setting editor, with the text
* box's edges in line with the title and the one-strip buttons (the theme's
* 16dp TextView side margins doubled the inset). */
.system-name-modal.keyboard-input-panel {
margin: 8;
padding: 8 16 12 16;
}
.keyboard-input-panel TextView {
margin: 4 0 0 0;
padding: 6;
}
/* Glasses-only: the field stays focused for the IME but is an invisible
* sliver; the hint line takes its place. */
.keyboard-input-panel TextView.keyboard-input-field-hidden {
opacity: 0;
height: 1;
min-height: 0;
margin: 0;
padding: 0;
}
.system-name-modal Label.keyboard-input-hidden-hint,
.ns-dark .system-name-modal Label.keyboard-input-hidden-hint {
color: #666666;
padding: 8 0;
}
.keyboard-input-buttons {
margin-top: 8;
}
.keyboard-input-panel Button,
.keyboard-input-panel Button.-primary {
margin: 0;
font-size: 16;
}
.keyboard-input-panel Button.keyboard-input-gap {
margin-left: 8;
}
/* Flat icon buttons in the panel's title row (the modal stays light in dark
* mode, so one tint). */
.panel-icon-button {
padding: 6 8;
}
.panel-icon {
height: 20;
tint-color: #333333;
}
/* Modal behind the action bar's warning triangle: the problem-status warnings
* that used to sit inline on the main page, each with its fix-it button.
* The width is set from the view model (near-full-width on phones, capped on
+15
View File
@@ -56,6 +56,9 @@ Page.main-page {
color: #222222;
padding: 16;
}
/* The modal stays light in dark mode; outgun the theme's `.ns-dark .h2`
* (white) so the title doesn't go white-on-light-gray. */
.main-page .system-name-modal .h2 { color: #222222; }
.main-page .system-name-modal TextView {
margin: 0;
padding: 4;
@@ -67,3 +70,15 @@ Page.main-page {
.main-landscape .system-name-modal { padding: 6 12; }
.main-landscape .system-name-modal .h2 { visibility: collapse; }
.main-landscape .system-name-modal Button { padding: 6 8; margin-top: 0; margin-bottom: 0; }
/* Keyboard-input panel: the one-strip buttons and title-row icons (see app.css). */
.main-page .system-name-modal.keyboard-input-panel { padding: 8 16 12 16; }
.main-landscape .system-name-modal.keyboard-input-panel { padding: 6 12; }
.main-page .keyboard-input-panel TextView { margin: 4 0 0 0; padding: 6; }
.main-page .keyboard-input-panel TextView.keyboard-input-field-hidden { opacity: 0; height: 1; min-height: 0; margin: 0; padding: 0; }
.main-page .keyboard-input-hidden-hint { color: #666666; padding: 8 0; }
.main-page .keyboard-input-buttons { margin-top: 8; }
.main-page .keyboard-input-panel Button { margin: 0; }
.main-page .keyboard-input-panel Button.keyboard-input-gap { margin-left: 8; }
.main-page .panel-icon-button { padding: 6 8; }
.main-page .panel-icon { height: 20; tint-color: #333333; }
+5 -22
View File
@@ -124,12 +124,10 @@ export type DashboardSnapshot = {
activeTextEditorToggleValue: boolean;
activeTextEditorToggleVisible: boolean;
/**
* The keyboard dialog is up on the glasses (opened by the phone's keyboard
* button): the phone shows its typing panel, with a send button per
* destination in the glasses menu's row order.
* The keyboard dialog is open (opened by the phone's keyboard button): the
* phone shows its typing panel, driven by keyboardInputSession.
*/
keyboardInputActive: boolean;
keyboardInputTargets: ReadonlyArray<{ id: string; label: string }>;
evenAppConflictMessage: string;
evenAppConflictWarningVisible: boolean;
firmwareWarningMessage: string;
@@ -1122,7 +1120,6 @@ class DashboardController {
activeTextEditorToggleValue: this.activeTextEditorToggle?.setting.get() ?? false,
activeTextEditorToggleVisible: this.activeTextEditorToggle !== null,
keyboardInputActive: this.keyboardInput !== null,
keyboardInputTargets: this.keyboardInput?.targets ?? [],
evenAppConflictMessage: this.evenAppConflictMessage,
evenAppConflictWarningVisible: this.evenAppConflictMessage.length > 0,
firmwareWarningMessage: this.firmwareWarningMessage,
@@ -1321,23 +1318,9 @@ class DashboardController {
shell.startKeyboardInput();
}
/** The phone's typing panel changed: mirror the text on the glasses. */
setKeyboardInputText(text: string): void {
shell.noteUserActivity();
this.keyboardInput?.setText(text);
}
/** Send to one destination, or (no id: the IME's send key) the one highlighted on the glasses. */
sendKeyboardInput(targetId?: string): void {
if (targetId) {
this.keyboardInput?.sendTo(targetId);
} else {
this.keyboardInput?.send();
}
}
discardKeyboardInput(): void {
this.keyboardInput?.discard();
/** The open keyboard dialog, for the phone's typing panel (KeyboardInputViewModel). */
get keyboardInputSession(): KeyboardInputSession | null {
return this.keyboardInput;
}
setActiveTextEditorToggleValue(value: boolean): void {
+23 -4
View File
@@ -131,6 +131,8 @@ export class IosPreviewController {
private clockMinute = -1
private shellRenderInProgress = false
private shellRenderQueued = false
/** The shell woke; the next shell render unblanks the compositor after submitting. */
private unblankAfterShellRender = false
private nextFrameId = 1
private nextWorkerFrame = 0
private inputQueue: Promise<void> = Promise.resolve()
@@ -199,6 +201,9 @@ export class IosPreviewController {
send: () => { if (this.active && !this.glassesLocked) session.send() },
sendTo: id => { if (this.active && !this.glassesLocked) session.sendTo(id) },
discard: () => session.discard(),
get visibility() { return session.visibility },
setVisibility: visibility => { if (this.active && !this.glassesLocked) session.setVisibility(visibility) },
get history() { return session.history },
} : null),
prepareVoiceCapture: () => this.prepareVoiceCapture(),
getScreenTimeoutMs: () => null,
@@ -211,7 +216,12 @@ export class IosPreviewController {
},
onScreenStateChanged: on => {
if (on) this.glance.dismiss()
void this.display?.setScreenBlanked(!on).catch(error => this.fail(error))
// A wake unblanks only once the next shell render has staged an awake
// scene: unblanking composites the retained one, painted while asleep
// with no chrome and depth 0, and that first frame is the one the
// brightness fade-in starts on.
this.unblankAfterShellRender = on
if (!on) void this.display?.setScreenBlanked(true).catch(error => this.fail(error))
this.requestShellRender()
},
})
@@ -521,10 +531,19 @@ export class IosPreviewController {
await this.displayReady
const display = this.display
if (!display) return
const startedAt = Date.now()
const bytes = shell.paintScene()
// Taken with the paint, so a render that painted before the wake can't unblank.
const unblank = this.unblankAfterShellRender
this.unblankAfterShellRender = false
const frameId = this.allocateFrameId()
await display.submitShellScene(bytes, Date.now() - startedAt, frameId)
try {
const startedAt = Date.now()
const bytes = shell.paintScene()
await display.submitShellScene(bytes, Date.now() - startedAt, frameId)
} finally {
// Even if the render failed, so the screen doesn't stay dark; not if it
// went back to sleep meanwhile (that sleep re-blanked).
if (unblank && shell.isScreenOn()) await display.setScreenBlanked(false)
}
// Backpressure: the next shell render waits for this one to reach the
// glasses (the preview target resolves immediately; nothing transmits).
await display.waitForFrameFinished(frameId, FRAME_TRANSMIT_BACKPRESSURE_TIMEOUT_MS)
+14 -1
View File
@@ -11,6 +11,11 @@ export interface WrapFont {
export type WrapTextOptions = {
preserveLeadingWhitespace?: boolean;
/**
* A word too wide for a line of its own starts on the current line and is
* split at the width, rather than first being pushed to a line of its own.
* Words that fit on a line still wrap whole.
*/
breakLongWords?: boolean;
};
@@ -89,17 +94,20 @@ function wrapParagraph(font: WrapFont, paragraph: string, targetWidth: number, o
while (start < paragraph.length) {
let best = -1;
let overflow = -1;
for (const candidate of wrapOffsets) {
if (candidate <= start) continue;
if (measureSpan(widths, candidate) - measureSpan(widths, start) <= targetWidth) {
best = candidate;
continue;
}
overflow = candidate;
break;
}
const splitOffset = furthestFittingOffset(widths, start, targetWidth);
if (opts.breakLongWords && splitOffset > start && (best < 0 || splitOffset > trimEndOffset(paragraph, best))) {
if (opts.breakLongWords && splitOffset > start && splitOffset > best
&& (best < 0 || (overflow >= 0 && wordWidth(paragraph, widths, best, overflow) > targetWidth))) {
best = splitOffset;
}
if (best < 0) {
@@ -157,6 +165,11 @@ function measureSpan(widths: Map<number, number>, offset: number): number {
return widths.get(offset) ?? 0;
}
/** Width of the word between two wrap offsets, without surrounding whitespace. */
function wordWidth(text: string, widths: Map<number, number>, from: number, to: number): number {
return measureSpan(widths, trimEndOffset(text, to)) - measureSpan(widths, skipLeadingWhitespace(text, from));
}
function skipLeadingWhitespace(text: string, offset: number): number {
let cursor = offset;
while (cursor < text.length) {
+28 -6
View File
@@ -1,18 +1,40 @@
<GridLayout rows="auto,*,auto" maxHeight="280" xmlns="http://schemas.nativescript.org/tns.xsd"
class="system-name-modal"
class="system-name-modal keyboard-input-panel"
visibility="{{ keyboardInputVisibility }}"
horizontalAlignment="stretch"
verticalAlignment="bottom">
<Label row="0" text="Keyboard input" class="h2" />
<!-- Title, then the history button (recent sent messages) and the
visibility button, which cycles both / phone only / glasses only and
dims the half of its phone+glasses pair where the dialog is hidden.
rows="auto" on the grids: an implicit star row balloons in here. -->
<GridLayout row="0" rows="auto" columns="*,auto,auto">
<Label col="0" text="Keyboard input" class="h2" verticalAlignment="center" />
<GridLayout col="1" rows="auto" class="panel-icon-button" opacity="{{ keyboardInputHistoryOpacity }}"
accessible="true" accessibilityRole="button" accessibilityLabel="Recent inputs"
tap="{{ onKeyboardInputHistoryTap }}">
<Image src="res://ic_input_history" class="panel-icon" />
</GridLayout>
<StackLayout col="2" orientation="horizontal" class="panel-icon-button"
accessible="true" accessibilityRole="button" accessibilityLabel="{{ keyboardInputVisibilityDescription }}"
tap="{{ onKeyboardInputVisibilityTap }}">
<Image src="res://ic_show_phone" class="panel-icon" opacity="{{ keyboardInputPhoneIconOpacity }}" />
<Image src="res://ic_show_glasses" class="panel-icon" opacity="{{ keyboardInputGlassesIconOpacity }}" />
</StackLayout>
</GridLayout>
<TextView row="1"
id="keyboardInputField"
class="{{ keyboardInputFieldClass }}"
text="{{ keyboardInputText }}"
hint="Type a message"
textChange="{{ onKeyboardInputTextChange }}" />
<!-- Wraps onto a second line when the labels don't fit side by side. -->
<FlexboxLayout row="2" flexWrap="wrap" class="m-t-8">
<Label row="1" text="Shown on the glasses only. Tap to type." textWrap="true"
class="keyboard-input-hidden-hint"
visibility="{{ keyboardInputGlassesOnlyVisibility }}"
tap="{{ onKeyboardInputGlassesOnlyHintTap }}" />
<!-- One strip: at most two destinations (assistant, app) plus Discard. -->
<FlexboxLayout row="2" flexWrap="nowrap" class="keyboard-input-buttons">
<Button text="{{ keyboardInputPrimaryTargetLabel }}" tap="{{ onKeyboardInputPrimarySendTap }}" visibility="{{ keyboardInputPrimaryTargetVisibility }}" flexGrow="1" class="-primary" />
<Button text="{{ keyboardInputSecondaryTargetLabel }}" tap="{{ onKeyboardInputSecondarySendTap }}" visibility="{{ keyboardInputSecondaryTargetVisibility }}" flexGrow="1" />
<Button text="Discard" tap="{{ onKeyboardInputDiscardTap }}" flexGrow="1" />
<Button text="{{ keyboardInputSecondaryTargetLabel }}" tap="{{ onKeyboardInputSecondarySendTap }}" visibility="{{ keyboardInputSecondaryTargetVisibility }}" flexGrow="1" class="keyboard-input-gap" />
<Button text="Discard" tap="{{ onKeyboardInputDiscardTap }}" flexGrow="1" class="keyboard-input-gap" />
</FlexboxLayout>
</GridLayout>
+98 -9
View File
@@ -1,7 +1,32 @@
import { Observable } from '@nativescript/core'
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
import { Dialogs, Observable, type EventData, type TextView, type View } from '@nativescript/core'
import type { KeyboardInputSession, KeyboardInputVisibility } from '../ui/shell/keyboard-input'
/** Phone editor for the shell's keyboard session, using the shared XML panel. */
/** The visibility button's cycle: both → phone only → glasses only → both. */
const NEXT_VISIBILITY: Record<KeyboardInputVisibility, KeyboardInputVisibility> = { both: 'phone', phone: 'glasses', glasses: 'both' }
const VISIBILITY_DESCRIPTIONS: Record<KeyboardInputVisibility, string> = {
both: 'Shown on phone and glasses', phone: 'Shown on phone only', glasses: 'Shown on glasses only',
}
/**
* Phone button text for the glasses' send-target labels, short enough for
* every button to share one strip. Unlisted labels (the assistant overlay's
* "Send") are already short.
*/
const SHORT_TARGET_LABELS: Record<string, string> = { 'Send to Assistant': 'To Assistant', 'Type Into App': 'To App' }
const HISTORY_LABEL_LENGTH = 80
const DIMMED_ICON_OPACITY = 0.3
/** One history entry as a single line, truncated for the picker. */
function historyLabel(text: string): string {
const line = text.replace(/\s+/g, ' ').trim()
return line.length > HISTORY_LABEL_LENGTH ? `${line.slice(0, HISTORY_LABEL_LENGTH - 1)}…` : line
}
/**
* Phone editor for the shell's keyboard session: the binding context of the
* shared keyboard-input-panel.xml on both platforms (Android's MainViewModel
* hands it the session from the dashboard controller, iOS's main page from
* the preview controller).
*/
export class KeyboardInputViewModel extends Observable {
private session: KeyboardInputSession | null = null
private text = ''
@@ -10,17 +35,24 @@ export class KeyboardInputViewModel extends Observable {
if (session === this.session) return
this.session = session
this.text = ''
for (const property of ['keyboardInputText', 'keyboardInputVisibility', 'keyboardInputPrimaryTargetLabel',
'keyboardInputPrimaryTargetVisibility', 'keyboardInputSecondaryTargetLabel', 'keyboardInputSecondaryTargetVisibility']) {
this.notifyPropertyChange(property, this.get(property))
}
this.notifyPanel(['keyboardInputText', 'keyboardInputVisibility', 'keyboardInputPrimaryTargetLabel',
'keyboardInputPrimaryTargetVisibility', 'keyboardInputSecondaryTargetLabel', 'keyboardInputSecondaryTargetVisibility',
'keyboardInputHistoryOpacity'])
this.notifyVisibilityMode()
}
private notifyPanel(properties: string[]): void {
for (const property of properties) this.notifyPropertyChange(property, this.get(property))
}
private notifyVisibilityMode(): void {
this.notifyPanel(['keyboardInputPhoneIconOpacity', 'keyboardInputGlassesIconOpacity', 'keyboardInputVisibilityDescription',
'keyboardInputFieldClass', 'keyboardInputGlassesOnlyVisibility'])
}
get keyboardInputVisibility(): 'visible' | 'collapse' { return this.session ? 'visible' : 'collapse' }
get keyboardInputText(): string { return this.text }
set keyboardInputText(text: string) { this.text = text; this.session?.setText(text) }
private targetLabel(index: number): string {
const target = this.session?.targets[index]
return target?.id === 'assistant' ? 'Send to Agent' : target?.id === 'app' ? 'Type into App' : target?.label ?? ''
const label = this.session?.targets[index]?.label ?? ''
return SHORT_TARGET_LABELS[label] ?? label
}
get keyboardInputPrimaryTargetLabel(): string { return this.targetLabel(0) }
get keyboardInputSecondaryTargetLabel(): string { return this.targetLabel(1) }
@@ -38,4 +70,61 @@ export class KeyboardInputViewModel extends Observable {
this.session.sendTo(target.id)
}
onKeyboardInputDiscardTap(): void { this.session?.discard() }
// ---- visibility button: where the dialog shows ----
//
// Glasses-only keeps the text field focused (so the IME keeps typing into
// it) but shrinks it to an invisible sliver; a hint line stands in for it
// and refocuses it if the IME was dismissed.
private get visibilityMode(): KeyboardInputVisibility { return this.session?.visibility ?? 'both' }
get keyboardInputPhoneIconOpacity(): number { return this.visibilityMode === 'glasses' ? DIMMED_ICON_OPACITY : 1 }
get keyboardInputGlassesIconOpacity(): number { return this.visibilityMode === 'phone' ? DIMMED_ICON_OPACITY : 1 }
get keyboardInputVisibilityDescription(): string { return VISIBILITY_DESCRIPTIONS[this.visibilityMode] }
get keyboardInputFieldClass(): string { return this.visibilityMode === 'glasses' ? 'keyboard-input-field-hidden' : '' }
get keyboardInputGlassesOnlyVisibility(): 'visible' | 'collapse' { return this.visibilityMode === 'glasses' ? 'visible' : 'collapse' }
onKeyboardInputVisibilityTap(): void {
if (!this.session) return
this.session.setVisibility(NEXT_VISIBILITY[this.visibilityMode])
this.notifyVisibilityMode()
}
onKeyboardInputGlassesOnlyHintTap(args: EventData): void {
focusField(args.object as View)
}
// ---- history button: recent sent messages (in memory, newest first) ----
get keyboardInputHistoryOpacity(): number { return this.session?.history.length ? 1 : DIMMED_ICON_OPACITY }
async onKeyboardInputHistoryTap(args: EventData): Promise<void> {
const session = this.session
if (!session?.history.length) return
const entries = new Map<string, string>()
for (const entry of session.history) {
const label = historyLabel(entry)
if (!entries.has(label)) entries.set(label, entry)
}
const choice = await Dialogs.action({ title: 'Recent inputs', cancelButtonText: 'Cancel', actions: [...entries.keys()] })
const text = entries.get(choice)
if (text === undefined || session !== this.session) return
const field = fieldNear(args.object as View)
this.keyboardInputText = text
// Through the view, not a property change: its textChange handler then
// syncs the model and session the same way typing does.
if (field) field.text = text
focusField(args.object as View, text.length)
}
}
function fieldNear(view: View): TextView | undefined {
return view.page?.getViewById<TextView>('keyboardInputField')
}
/** Focus the panel's field (bringing the IME back), optionally placing the caret. */
function focusField(view: View, caret?: number): void {
setTimeout(() => {
const field = fieldNear(view)
if (!field) return
field.focus()
if (caret !== undefined) field.setSelection(caret)
}, 0)
}
+3 -2
View File
@@ -182,7 +182,8 @@
the phone's end of the keyboard dialog on the glasses
(ui/shell/keyboard-input.ts). Same placement and collapsing rules
as the setting editor above. Enter inserts a newline; the send
buttons pick a destination directly. -->
<rc:keyboard-input-panel />
buttons pick a destination directly. Bound to its own model
(KeyboardInputViewModel, shared with iOS). -->
<rc:keyboard-input-panel bindingContext="{{ keyboardInputModel }}" />
</GridLayout>
</Page>
+10 -73
View File
@@ -1,4 +1,5 @@
import { RemoteControlsViewModel } from './remote-controls-view-model';
import { KeyboardInputViewModel } from './keyboard-input-view-model';
import { BleBandwidthMeter } from "./ble-bandwidth-meter";
import {
Application,
@@ -52,8 +53,6 @@ export class MainViewModel extends RemoteControlsViewModel {
private _activeTextEditorToggleValue = false;
private _activeTextEditorToggleVisible = false;
private _keyboardInputActive = false;
private _keyboardInputTargets: ReadonlyArray<{ id: string; label: string }> = [];
private _keyboardInputText = "";
private _evenAppConflictMessage = "";
private _evenAppConflictWarningVisible = false;
private _firmwareWarningMessage = "";
@@ -103,8 +102,8 @@ export class MainViewModel extends RemoteControlsViewModel {
this.activeTextEditorToggleLabel = snapshot.activeTextEditorToggleLabel;
this.activeTextEditorToggleValue = snapshot.activeTextEditorToggleValue;
this.activeTextEditorToggleVisible = snapshot.activeTextEditorToggleVisible;
// Targets before active: the panel's buttons are labelled when it appears.
this.keyboardInputTargets = snapshot.keyboardInputTargets;
// Session before active: the panel is filled in when it appears.
this.keyboardInputModel.setSession(dashboardController.keyboardInputSession);
this.keyboardInputActive = snapshot.keyboardInputActive;
this.evenAppConflictMessage = snapshot.evenAppConflictMessage;
this.evenAppConflictWarningVisible = snapshot.evenAppConflictWarningVisible;
@@ -494,11 +493,13 @@ export class MainViewModel extends RemoteControlsViewModel {
// ---- keyboard-input panel (the keyboard button beside the mic button) ----
//
// The dialog lives on the glasses (ui/shell/keyboard-input.ts); this panel
// is the phone's end of it: the text field the IME types into and a send
// button per destination. The field's text is the panel's own state, never
// echoed back from the controller (see setActiveTextSettingValue for why);
// it is cleared whenever a dialog opens or closes.
// The dialog lives on the glasses (ui/shell/keyboard-input.ts); the panel
// is the phone's end of it, bound to keyboardInputModel (shared with iOS).
// Its text is the panel's own state, never echoed back from the controller
// (see setActiveTextSettingValue for why); it is cleared whenever a dialog
// opens or closes.
readonly keyboardInputModel = new KeyboardInputViewModel();
get keyboardInputActive(): boolean {
return this._keyboardInputActive;
@@ -507,78 +508,14 @@ export class MainViewModel extends RemoteControlsViewModel {
set keyboardInputActive(value: boolean) {
if (this._keyboardInputActive === value) return;
this._keyboardInputActive = value;
this.keyboardInputText = "";
this.notifyPropertyChange("keyboardInputActive", value);
this.notifyPropertyChange("keyboardInputVisibility", this.keyboardInputVisibility);
this.notifyPropertyChange("controlsVisibility", this.controlsVisibility);
}
get keyboardInputVisibility(): "visible" | "collapse" {
return this._keyboardInputActive ? "visible" : "collapse";
}
get keyboardInputText(): string {
return this._keyboardInputText;
}
set keyboardInputText(value: string) {
if (this._keyboardInputText === value) return;
this._keyboardInputText = value;
this.notifyPropertyChange("keyboardInputText", value);
}
set keyboardInputTargets(value: ReadonlyArray<{ id: string; label: string }>) {
this._keyboardInputTargets = value;
this.notifyPropertyChange("keyboardInputPrimaryTargetLabel", this.keyboardInputPrimaryTargetLabel);
this.notifyPropertyChange("keyboardInputPrimaryTargetVisibility", this.keyboardInputPrimaryTargetVisibility);
this.notifyPropertyChange("keyboardInputSecondaryTargetLabel", this.keyboardInputSecondaryTargetLabel);
this.notifyPropertyChange("keyboardInputSecondaryTargetVisibility", this.keyboardInputSecondaryTargetVisibility);
}
// The glasses menu has at most two destinations (assistant, app), so the
// panel has a fixed pair of buttons rather than a repeater.
get keyboardInputPrimaryTargetLabel(): string {
return this._keyboardInputTargets[0]?.label ?? "";
}
get keyboardInputPrimaryTargetVisibility(): "visible" | "collapse" {
return this._keyboardInputTargets[0] ? "visible" : "collapse";
}
get keyboardInputSecondaryTargetLabel(): string {
return this._keyboardInputTargets[1]?.label ?? "";
}
get keyboardInputSecondaryTargetVisibility(): "visible" | "collapse" {
return this._keyboardInputTargets[1] ? "visible" : "collapse";
}
onKeyboardTap(): void {
dashboardController.startKeyboardInput();
}
onKeyboardInputTextChange(args: { value?: string; object?: { text?: string } }): void {
const text = args.object?.text ?? args.value ?? "";
// Track the draft so closing the dialog emits a clear even when the
// binding hasn't updated the model. Avoid echoing edits into the IME.
this._keyboardInputText = text;
dashboardController.setKeyboardInputText(text);
}
onKeyboardInputPrimarySendTap(): void {
const target = this._keyboardInputTargets[0];
if (target) dashboardController.sendKeyboardInput(target.id);
}
onKeyboardInputSecondarySendTap(): void {
const target = this._keyboardInputTargets[1];
if (target) dashboardController.sendKeyboardInput(target.id);
}
onKeyboardInputDiscardTap(): void {
dashboardController.discardKeyboardInput();
}
get evenAppConflictMessage(): string {
return this._evenAppConflictMessage;
}
+12 -1
View File
@@ -102,6 +102,15 @@ export interface Layer {
readonly depth?: number;
paintParts?(): Plane[];
readonly paintOverBase?: boolean;
/**
* True when this layer stands in for `below`, a stacked layer directly
* beneath it (or beneath another layer it stands in for): when this layer
* calls paintBelow, the stack skips `below` and paints what is under it
* instead. A submenu replacing the menu it opened from uses this, so the
* hidden menu costs no plane and its dimUnderneath doesn't dim the content
* a second time; popping the submenu still returns to it.
*/
replacesLayerBelow?(below: Layer): boolean;
/**
* Dim everything painted beneath this layer: a 0..1 brightness factor
* applied to the pixels and glyphs of every plane below it in the stack
@@ -326,7 +335,9 @@ export class LayerStack {
return [ownPlane];
}
const dim = layer.dimUnderneath || 1;
const below = this.paintLayer(layer.paintOverBase ? 0 : index - 1, dimSoFar * dim, raw);
let belowIndex = layer.paintOverBase ? 0 : index - 1;
while (belowIndex > 0 && layer.replacesLayerBelow?.(this.layers[belowIndex]!)) belowIndex--;
const below = this.paintLayer(belowIndex, dimSoFar * dim, raw);
return [...(!raw && dim < 1 ? dimPlanes(below, dim) : below), ownPlane];
}
}
+5 -4
View File
@@ -192,12 +192,13 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
drawIcon: options.drawIcon ?? windowIcon(options.icon, options.iconLetter),
handleInput: async (event, frameId) => {
// The shell opened its system menu over this window; close our own
// context menu so the two never stack. Never forwarded to app layers.
// context menu (and any window submenus open from it) so the two never
// stack. Never forwarded to app layers.
if (event.type === "system-menu-opened") {
options.onSystemMenuOpened?.();
if (stack.popIfTop((layer) => layer instanceof WindowMenuLayer)) {
requestRender();
}
let closedMenu = false;
while (stack.popIfTop((layer) => layer instanceof WindowMenuLayer)) closedMenu = true;
if (closedMenu) requestRender();
return;
}
// The default tap-then-hold response: the window menu (or the system
+88 -6
View File
@@ -8,6 +8,16 @@ import { type VoiceSendTarget } from "./voice-input";
/** A menu row: a send target, or Discard (no target). */
type KeyboardMenuRow = InputDialogRow & { target?: VoiceSendTarget };
/**
* Where the keyboard dialog shows: on both ends, only the phone's typing panel
* (the glasses carry on as if no dialog were open), or only the glasses (the
* phone hides its copy of the text but keeps the IME typing into it).
*/
export type KeyboardInputVisibility = "both" | "phone" | "glasses";
/** Sent messages kept for the phone's history button. */
const MAX_HISTORY = 20;
/**
* The phone side's handle on an open keyboard-input dialog: the phone types
* into it and picks where the text goes. The layer itself implements this;
@@ -25,6 +35,10 @@ export type KeyboardInputSession = {
send(): void;
sendTo(targetId: string): void;
discard(): void;
readonly visibility: KeyboardInputVisibility;
setVisibility(visibility: KeyboardInputVisibility): void;
/** Messages sent from keyboard dialogs since the app started, newest first. */
readonly history: ReadonlyArray<string>;
};
export type KeyboardInputLayerOptions = {
@@ -33,6 +47,16 @@ export type KeyboardInputLayerOptions = {
onClosed: () => void;
/** Pop this layer off the shell stack. */
dismiss: () => void;
/**
* Put the layer back on the shell stack, or take it off without ending the
* session (phone-only visibility; onRemoved is ignored while hiding).
*/
setShownOnGlasses: (shown: boolean) => void;
/** Starting visibility; the shell pushes the layer only if it isn't "phone". */
visibility: KeyboardInputVisibility;
onVisibilityChanged: (visibility: KeyboardInputVisibility) => void;
/** Shared, newest-first list this layer adds its sent message to. */
history: string[];
/** Ordered send destinations shown as the first menu rows. */
sendTargets: VoiceSendTarget[];
/** Which send target is highlighted by default (entry-point dependent). */
@@ -52,10 +76,16 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
private text = "";
private readonly menu: Menu<KeyboardMenuRow>;
private closed = false;
private currentVisibility: KeyboardInputVisibility;
// Set while the shell takes the layer off the stack for phone-only typing.
private hiding = false;
private readonly actions: LayerActions;
private readonly onClosed: () => void;
private readonly dismiss: () => void;
private readonly setShownOnGlasses: (shown: boolean) => void;
private readonly onVisibilityChanged: (visibility: KeyboardInputVisibility) => void;
private readonly sentHistory: string[];
private readonly sendTargets: VoiceSendTarget[];
private readonly defaultTargetIndex: number;
@@ -63,6 +93,10 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
this.actions = options.actions;
this.onClosed = options.onClosed;
this.dismiss = options.dismiss;
this.setShownOnGlasses = options.setShownOnGlasses;
this.currentVisibility = options.visibility;
this.onVisibilityChanged = options.onVisibilityChanged;
this.sentHistory = options.history;
this.sendTargets = options.sendTargets;
const defaultIndex = options.defaultTargetIndex ?? 0;
this.defaultTargetIndex = Math.min(Math.max(0, defaultIndex), Math.max(0, this.sendTargets.length - 1));
@@ -73,6 +107,33 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
return this.sendTargets.map((target) => ({ id: target.id, label: target.label }));
}
get visibility(): KeyboardInputVisibility {
return this.currentVisibility;
}
get history(): ReadonlyArray<string> {
return this.sentHistory;
}
/** Whether the dialog is on the glasses (the shell stack) rather than phone-only. */
get shownOnGlasses(): boolean {
return this.currentVisibility !== "phone";
}
setVisibility(visibility: KeyboardInputVisibility): void {
if (this.closed || visibility === this.currentVisibility) return;
const wasShown = this.shownOnGlasses;
this.currentVisibility = visibility;
this.onVisibilityChanged(visibility);
if (this.shownOnGlasses === wasShown) return;
this.hiding = !this.shownOnGlasses;
try {
this.setShownOnGlasses(this.shownOnGlasses);
} finally {
this.hiding = false;
}
}
setText(text: string): void {
if (this.closed || this.text === text) return;
this.text = text;
@@ -90,7 +151,23 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
}
discard(): void {
if (!this.closed) this.dismiss();
this.close();
}
private close(): void {
if (this.closed) return;
// Phone-only, there is no stack entry to pop; end the session directly.
if (this.shownOnGlasses) {
this.dismiss();
} else {
this.finish();
}
}
private finish(): void {
if (this.closed) return;
this.closed = true;
this.onClosed();
}
private sendToTarget(target: VoiceSendTarget): void {
@@ -99,7 +176,11 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
// An empty message has nothing to deliver; the dialog stays up for the
// phone to keep typing (the glasses row is drawn dim for the same reason).
if (!text) return;
this.dismiss();
const previous = this.sentHistory.indexOf(text);
if (previous >= 0) this.sentHistory.splice(previous, 1);
this.sentHistory.unshift(text);
this.sentHistory.length = Math.min(this.sentHistory.length, MAX_HISTORY);
this.close();
target.onSend(text);
}
@@ -140,12 +221,12 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
if (row.target) {
this.sendToTarget(row.target);
} else {
this.dismiss();
this.close();
}
return;
}
case "double-click":
this.dismiss();
this.close();
return;
default:
return;
@@ -153,7 +234,8 @@ export class KeyboardInputLayer implements Layer, KeyboardInputSession {
}
onRemoved(): void {
this.closed = true;
this.onClosed();
// Taken off the glasses for phone-only typing: the session carries on.
if (this.hiding) return;
this.finish();
}
}
+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;
+10
View File
@@ -33,6 +33,16 @@ export class WindowMenuLayer extends MenuLayer {
? { ...WINDOW_MENU_LAYOUT, footer: gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "system menu"]]) }
: WINDOW_MENU_LAYOUT);
}
/**
* A window submenu (Settings, Spotify, ...) opens in place of the window
* menu it came from, which it would mostly cover anyway: the window content
* shows beneath it, dimmed once, rather than the parent menu dimming it a
* second time and costing a plane of its own.
*/
replacesLayerBelow(below: Layer): boolean {
return below instanceof WindowMenuLayer;
}
}
export type WindowMenuOptions = {
+1 -1
View File
@@ -1,2 +1,2 @@
export const FACECLAW_VERSION = "0.8.4";
export const FACECLAW_VERSION = "0.8.5";
export const USER_AGENT = "Faceclaw/"+FACECLAW_VERSION;
+6 -3
View File
@@ -366,7 +366,7 @@ test('iOS preview voice uses the phone microphone, while connected capture stays
test('iOS continuous capture is shared by windows and restarts after a disconnect, a lock or backgrounding', async () => {
const calls = [], claims = [], providers = [];
// Models the bridge's continuous state: listening on a source, or draining after a stop.
const bridge = { source: null, draining: false, recording: '',
const bridge = { source: null, draining: false, recording: '', rawSession: undefined,
supportsContinuous: voice => voice.provider !== 'onboard',
get continuousSource() { return this.source; },
get continuousActive() { return !!this.source || this.draining; },
@@ -378,7 +378,8 @@ test('iOS continuous capture is shared by windows and restarts after a disconnec
stopContinuousCapture: async () => { calls.push(['stop']); bridge.drain(); },
handleSessionEnded() { if (bridge.source === 'glasses') bridge.drain(); },
stopPhoneCapture() { if (bridge.source === 'phone') bridge.drain(); },
recordTo: name => { bridge.recording = name; } };
recordTo: name => { bridge.recording = name; },
setRawSession: session => { bridge.rawSession = session; } };
const settings = { ...voiceSettings, voiceProviderSetting: { get: () => 'whisper-server' },
whisperServerUrlSetting: { get: () => 'http://whisper.local:8000' }, whisperServerLanguageSetting: { get: () => 'en' },
saveTranscribeAudioSetting: { get: () => true } };
@@ -427,11 +428,13 @@ test('iOS continuous capture is shared by windows and restarts after a disconnec
session('connected'); await settle();
assert.deepEqual(calls, [['glasses', true]]);
// Locking drains; unlocking resumes.
// Locking drains; unlocking resumes. EvenHub apps' raw mic tap follows the lock too.
calls.length = 0; host.setGlassesLocked(true); drained(); await settle();
assert.deepEqual(calls, []);
assert.equal(bridge.rawSession, null, 'locking unbinds the raw mic session');
host.setGlassesLocked(false); await settle();
assert.deepEqual(calls, [['glasses', true]]);
assert.equal(bridge.rawSession, host.communicator, 'unlocking rebinds it to the connected session');
// A failed capture is not retried in a loop, only on the next session.
calls.length = 0; bridge.source = null; drained(); await settle();
+1 -1
View File
@@ -140,7 +140,7 @@ function fixture() {
"../native/compass.ios": { bindCompassSession() {}, receiveCompassEvent() {} },
'@nativescript/core': { File: { fromPath: () => ({ writeTextSync() {} }) },
knownFolders: { documents: () => ({ path: '/tmp' }) }, path },
'../native/ios-voice-input': { iosVoiceInput: { handleSessionEnded() {}, stopPhoneCapture() {}, onSpeechEnd: () => () => {} } },
'../native/ios-voice-input': { iosVoiceInput: { handleSessionEnded() {}, stopPhoneCapture() {}, setRawSession() {}, onSpeechEnd: () => () => {} } },
'../native/cloud-stt-provider': { transcriptionKey: voice => voice.provider },
'../ui/shell/voice-activity': { voiceActivity: { setActive() {}, isActive: () => false, subscribe: () => () => {} } },
'../native/faceclaw-communicator.ios': { FaceclawCommunicatorBridge, resolveIosPeripherals: async addresses => addresses },
+105 -9
View File
@@ -1,19 +1,26 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
function fixture() {
function fixture({ choose } = {}) {
class Observable { get(key) { return this[key]; } notifyPropertyChange() {} }
const { KeyboardInputViewModel } = loader({}, { '@nativescript/core': { Observable } })('app/phone-ui/keyboard-input-view-model.ts');
const model = new KeyboardInputViewModel(), sent = [], text = [];
const dialogs = [];
const Dialogs = { action: async options => { dialogs.push(options); return choose ? choose(options.actions) : options.cancelButtonText; } };
const { KeyboardInputViewModel } = loader({ setTimeout: callback => callback() },
{ '@nativescript/core': { Observable, Dialogs } })('app/phone-ui/keyboard-input-view-model.ts');
const model = new KeyboardInputViewModel(), sent = [], text = [], visibilities = [];
const session = { targets: [{ id: 'assistant', label: 'Send to Assistant' }, { id: 'app', label: 'Type Into App' }],
setText: value => text.push(value), sendTo: id => sent.push(id), discard: () => model.setSession(null) };
setText: value => text.push(value), sendTo: id => sent.push(id), discard: () => model.setSession(null),
visibility: 'both', setVisibility(value) { visibilities.push(value); this.visibility = value; },
history: [] };
model.setSession(session);
return { model, session, sent, text };
const field = { text: '', focused: 0, selection: null, focus() { this.focused++; }, setSelection(start) { this.selection = start; } };
const button = { page: { getViewById: id => id === 'keyboardInputField' ? field : undefined } };
return { model, session, sent, text, visibilities, dialogs, field, button };
}
test('multiline keyboard editor routes Agent and App buttons to distinct shell destinations', () => {
test('multiline keyboard editor routes Assistant and App buttons to distinct shell destinations', () => {
const h = fixture();
assert.equal(h.model.keyboardInputPrimaryTargetLabel, 'Send to Agent');
assert.equal(h.model.keyboardInputSecondaryTargetLabel, 'Type into App');
assert.equal(h.model.keyboardInputPrimaryTargetLabel, 'To Assistant');
assert.equal(h.model.keyboardInputSecondaryTargetLabel, 'To App');
h.model.onKeyboardInputTextChange({ object: { text: 'First line\nSecond line' } });
h.model.onKeyboardInputPrimarySendTap();
h.model.onKeyboardInputSecondarySendTap();
@@ -26,7 +33,96 @@ test('discard and shell-side closure reset the editor; unsupported destinations
assert.equal(h.model.keyboardInputText, '');
assert.equal(h.model.keyboardInputVisibility, 'collapse');
h.model.setSession({ ...h.session, targets: [{ id: 'assistant', label: 'Send' }] });
assert.equal(h.model.keyboardInputPrimaryTargetLabel, 'Send to Agent');
assert.equal(h.model.keyboardInputPrimaryTargetLabel, 'Send');
assert.equal(h.model.keyboardInputSecondaryTargetVisibility, 'collapse');
h.model.onKeyboardInputSecondarySendTap(); assert.deepEqual(h.sent, []);
});
test('visibility button cycles both, phone only, glasses only; glasses-only hides the field but keeps it', () => {
const h = fixture();
const state = () => [h.model.keyboardInputPhoneIconOpacity, h.model.keyboardInputGlassesIconOpacity,
h.model.keyboardInputFieldClass, h.model.keyboardInputGlassesOnlyVisibility];
assert.deepEqual(state(), [1, 1, '', 'collapse']);
h.model.onKeyboardInputVisibilityTap();
assert.deepEqual(state(), [1, 0.3, '', 'collapse']);
h.model.onKeyboardInputVisibilityTap();
assert.deepEqual(state(), [0.3, 1, 'keyboard-input-field-hidden', 'visible']);
h.model.onKeyboardInputGlassesOnlyHintTap({ object: h.button });
assert.equal(h.field.focused, 1);
h.model.onKeyboardInputVisibilityTap();
assert.deepEqual(h.visibilities, ['phone', 'glasses', 'both']);
assert.equal(h.model.keyboardInputVisibilityDescription, 'Shown on phone and glasses');
});
test('history button lists recent inputs on one line each and puts the pick in the field', async () => {
const long = 'x'.repeat(100);
const h = fixture({ choose: actions => actions[1] });
assert.equal(h.model.keyboardInputHistoryOpacity, 0.3);
await h.model.onKeyboardInputHistoryTap({ object: h.button });
assert.equal(h.dialogs.length, 0);
h.session.history = ['first line\n second', long];
h.model.setSession(null); h.model.setSession(h.session);
assert.equal(h.model.keyboardInputHistoryOpacity, 1);
await h.model.onKeyboardInputHistoryTap({ object: h.button });
assert.deepEqual([...h.dialogs[0].actions], ['first line second', `${'x'.repeat(79)}…`]);
assert.equal(h.model.keyboardInputText, long);
assert.equal(h.text.at(-1), long);
assert.equal(h.field.text, long);
assert.equal(h.field.selection, 100);
});
function layerFixture(visibility = 'both', history = []) {
const menu = { items: [], setItems(items) { this.items = items; }, get selectedItem() { return this.items[0]; } };
const { KeyboardInputLayer } = loader({}, {
'./input-dialog': { createInputDialogMenu: () => menu, paintInputDialog() {} },
})('app/ui/shell/keyboard-input.ts');
const stack = new Set(), events = [];
const layer = new KeyboardInputLayer({
actions: { requestRender() {} },
onClosed: () => events.push('closed'),
dismiss: () => { if (stack.delete(layer)) layer.onRemoved(); },
setShownOnGlasses: shown => { if (shown) stack.add(layer); else if (stack.delete(layer)) layer.onRemoved(); },
visibility, onVisibilityChanged: value => events.push(`visibility:${value}`), history,
sendTargets: [{ id: 'app', label: 'Type Into App', onSend: text => events.push(`sent:${text}`) }],
});
if (layer.shownOnGlasses) stack.add(layer);
// The shell's sleep path: the stack is cleared and each layer told.
const clearStack = () => { for (const removed of [...stack]) { stack.delete(removed); removed.onRemoved(); } };
return { layer, stack, events, history, clearStack };
}
test('phone-only takes the dialog off the glasses without ending the session', () => {
const f = layerFixture();
f.layer.setVisibility('phone');
assert.equal(f.stack.size, 0);
assert.deepEqual(f.events, ['visibility:phone']);
f.clearStack();
f.layer.setText('typed while hidden'); f.layer.sendTo('app');
assert.deepEqual(f.events, ['visibility:phone', 'closed', 'sent:typed while hidden']);
f.layer.setVisibility('both');
assert.equal(f.stack.size, 0);
});
test('shown again on the glasses, the dialog closes with the stack as before', () => {
const f = layerFixture('phone');
assert.equal(f.stack.size, 0);
f.layer.setVisibility('glasses');
assert.equal(f.stack.size, 1);
f.layer.setVisibility('both');
assert.deepEqual(f.events, ['visibility:glasses', 'visibility:both']);
f.clearStack();
assert.deepEqual(f.events.at(-1), 'closed');
const discarded = layerFixture('phone');
discarded.layer.discard();
assert.deepEqual(discarded.events, ['closed']);
});
test('sent messages go into the shared history newest first, without duplicates or blanks', () => {
const history = [];
for (const text of ['one', ' ', 'two', 'one ']) {
const f = layerFixture('both', history);
f.layer.setText(text); f.layer.sendTo('app');
}
assert.deepEqual(history, ['one', 'two']);
for (let i = 0; i < 25; i++) {
const f = layerFixture('phone', history);
f.layer.setText(`message ${i}`); f.layer.sendTo('app');
}
assert.equal(history.length, 20);
assert.equal(history[0], 'message 24');
});
+16
View File
@@ -64,6 +64,22 @@ test('context menu surface and selected row both use +4 without changing the app
assert.deepEqual(closed.image.pixels,base.pixels);
assert.deepEqual(wire.presentationRecords(prepareFrameDraws(closed.draws)),[]);
});
test('a submenu that replaces its parent menu skips the parent plane and dims the content once',()=>{
const base=new graphics.GrayImage(100,90,200);
const stack=new LayerStack({paint:()=>base},noopLayerActions,{width:100,height:90});
const layout={x:10,y:8,width:80,minHeight:70,maxHeight:70,dimUnderneath:0.5};
class SubmenuLayer extends MenuLayer { replacesLayerBelow(below) { return below instanceof MenuLayer; } }
const parent=new MenuLayer('PARENT',[{label:'SUB',onSelect(){}}],layout);
stack.push(parent);
stack.push(new SubmenuLayer('CHILD',[{label:'ITEM',onSelect(){}}],layout));
stack.push(new SubmenuLayer('GRANDCHILD',[{label:'ITEM',onSelect(){}}],layout));
const painted=stack.paint();
assert.equal(painted.length,2);
assert.equal(painted[0].image.pixels[0],100);
assert.equal(stack.baseDim(),0.5);
stack.pop();stack.pop();
assert.equal(stack.paint().length,2);
});
test('text page paints at the stack size, not the lens size',()=>{
// An app window's stack is its viewport; a lens-sized plane is rejected by
// the compositor as larger than the window surface.
+35
View File
@@ -0,0 +1,35 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { wrapText } = require('../.test-build/app/graphics/textwrap.js');
// Monospace: every character is one unit wide, so widths count characters.
const mono = {
measureText: (text) => [...text].length,
getGlyph: () => ({ dwidthX: 1 }),
};
test('breakLongWords keeps words that fit on a line whole', () => {
const text = 'Spotify plays on whichever of your devices is open';
const expected = ['Spotify plays on', 'whichever of your', 'devices is open'];
assert.deepEqual(wrapText(mono, text, 18), expected);
assert.deepEqual(wrapText(mono, text, 18, { breakLongWords: true }), expected);
});
test('breakLongWords splits a word wider than a line, starting it on the current line', () => {
assert.deepEqual(
wrapText(mono, 'see abcdefghijklmnop end', 8, { breakLongWords: true }),
['see abcd', 'efghijkl', 'mnop end'],
);
});
test('a word wider than a line is split when nothing else fits', () => {
assert.deepEqual(wrapText(mono, 'abcdefghij', 4), ['abcd', 'efgh', 'ij']);
assert.deepEqual(wrapText(mono, 'abcdefghij', 4, { breakLongWords: true }), ['abcd', 'efgh', 'ij']);
});
test('wrapping still breaks after slashes and hyphens', () => {
assert.deepEqual(
wrapText(mono, 'URI: http://127.0.0.1:43823/spotify-callback', 20, { breakLongWords: true }),
['URI: http://', '127.0.0.1:43823/', 'spotify-callback'],
);
});
+1
View File
@@ -20,6 +20,7 @@
"../app/apps/terminal/hub-header.ts",
"../app/g2/ios-peripheral-identity.ts",
"../app/graphics/image.ts",
"../app/graphics/textwrap.ts",
"../app/graphics/battery.ts",
"../app/graphics/plane.ts",
"../app/graphics/shell-scene.ts",