Compare commits

..
Author SHA1 Message Date
Blendman974 bac1c8a239 feat: allow swapping app and system menu hold gestures 2026-11-06 04:44:39 +01:00
16 changed files with 198 additions and 731 deletions

No files matched your search

+20 -131
View File
@@ -8,11 +8,7 @@ import { IconGrid, ICON_GRID_BAND_INSET_X, ICON_GRID_HIGHLIGHT_INSET_Y, ICON_GRI
import { Layer, LayerActions, LayerContext } from "../../ui/layers"; import { Layer, LayerActions, LayerContext } from "../../ui/layers";
import { MenuLayer, type MenuItem } from "../../ui/menu"; import { MenuLayer, type MenuItem } from "../../ui/menu";
import { WINDOW_MENU_LAYOUT } from "../../ui/window-menu"; import { WINDOW_MENU_LAYOUT } from "../../ui/window-menu";
import { import { onAnySettingChanged } from "../../ui/dashboard-settings";
onAnySettingChanged, launcherLayoutSetting, enumSettingMenuItem,
ConfigSettingString, EditTextSettingLayer,
} from "../../ui/dashboard-settings";
import { getLauncherLayoutFingerprint, orderLauncherEntries, moveLauncherEntry } from "./launcher-layout";
import { createInProcessWindow } from "../../ui/shell/in-process-window"; import { createInProcessWindow } from "../../ui/shell/in-process-window";
import { import {
getFolderAssignments, getFolderAssignments,
@@ -20,7 +16,6 @@ import {
getFolderStateFingerprint, getFolderStateFingerprint,
setAppFolder, setAppFolder,
unusedNewFolderName, unusedNewFolderName,
getExplicitFolderNames, createFolder, renameFolder, folderNameError, disbandFolder,
} from "./launcher-folders"; } from "./launcher-folders";
import { shell, type ShellWindow } from "../../ui/shell/shell"; import { shell, type ShellWindow } from "../../ui/shell/shell";
@@ -71,14 +66,6 @@ type LauncherGridEntry =
* and is re-read every paint, so assistant folder tools take effect without * and is re-read every paint, so assistant folder tools take effect without
* the layer holding any copy of the state. * the layer holding any copy of the state.
*/ */
const entryKey = (entry: LauncherGridEntry) => entry.kind === "app" ? `app:${entry.appId}` : `folder:${entry.name}`;
/** Reuse the phone text editor; dismiss it if the glasses leave this page. */
class FolderNameEditorLayer extends EditTextSettingLayer {
constructor(setting: ConfigSettingString, private readonly actions: LayerActions) { super(setting); }
onRemoved(): void { void this.actions.endTextSettingEdit(); }
}
class LauncherGridLayer implements Layer { class LauncherGridLayer implements Layer {
// Watch swipes are spatial: up/down move between rows, left/right between // Watch swipes are spatial: up/down move between rows, left/right between
// columns. From the leftmost column, left keeps going out: it leaves the // columns. From the leftmost column, left keeps going out: it leaves the
@@ -87,12 +74,6 @@ class LauncherGridLayer implements Layer {
readonly acceptsDirectional = true; readonly acceptsDirectional = true;
/** Folder whose contents the grid is showing, or null for the top grid. */ /** Folder whose contents the grid is showing, or null for the top grid. */
private currentFolder: string | null = null; private currentFolder: string | null = null;
private editingFolder = false;
private moving: { key: string; label: string; folder: string | null } | null = null;
private sortEntries(entries: LauncherGridEntry[]): LauncherGridEntry[] {
return orderLauncherEntries(entries, entryKey, this.currentFolder, launcherLayoutSetting.get() === "custom");
}
private readonly grid = new IconGrid<LauncherGridEntry>({ private readonly grid = new IconGrid<LauncherGridEntry>({
items: () => this.entries(), items: () => this.entries(),
describe: (entry) => ({ describe: (entry) => ({
@@ -123,23 +104,25 @@ class LauncherGridLayer implements Layer {
const members = (getFolders().get(this.currentFolder) ?? []) const members = (getFolders().get(this.currentFolder) ?? [])
.map((appId) => byAppId.get(appId)) .map((appId) => byAppId.get(appId))
.filter(Boolean) as LauncherAppEntry[]; .filter(Boolean) as LauncherAppEntry[];
if (members.length > 0 || getExplicitFolderNames().includes(this.currentFolder)) { if (members.length > 0) {
return this.sortEntries(members.map((app): LauncherGridEntry => ({ return members
.map((app): LauncherGridEntry => ({
kind: "app", kind: "app",
label: app.label, label: app.label,
icon: app.icon, icon: app.icon,
appId: app.appId, appId: app.appId,
renderIcon: app.renderIcon, renderIcon: app.renderIcon,
}))); }))
.sort((a, b) => a.label.localeCompare(b.label));
} }
this.currentFolder = null; this.currentFolder = null;
} }
const assignments = getFolderAssignments(); const assignments = getFolderAssignments();
const entries: LauncherGridEntry[] = []; const entries: LauncherGridEntry[] = [];
// Legacy folders need a known member; explicitly created folders may be empty. // A folder cell appears only when it holds at least one known app; stale
const explicit = new Set(getExplicitFolderNames()); // assignments to removed apps are ignored.
for (const [name, members] of getFolders()) { for (const [name, members] of getFolders()) {
if (explicit.has(name) || members.some((appId) => byAppId.has(appId))) { if (members.some((appId) => byAppId.has(appId))) {
entries.push({ kind: "folder", label: name, name }); entries.push({ kind: "folder", label: name, name });
} }
} }
@@ -154,7 +137,7 @@ class LauncherGridLayer implements Layer {
}); });
} }
} }
return this.sortEntries(entries); return entries.sort((a, b) => a.label.localeCompare(b.label));
} }
/** Leave the current folder, putting the selection back on its cell. */ /** Leave the current folder, putting the selection back on its cell. */
@@ -168,16 +151,6 @@ class LauncherGridLayer implements Layer {
/** Enter a folder or launch an app; true when that left the grid (a launch). */ /** Enter a folder or launch an app; true when that left the grid (a launch). */
private async openEntry(entry: LauncherGridEntry): Promise<boolean> { private async openEntry(entry: LauncherGridEntry): Promise<boolean> {
if (this.moving) {
const moving = this.moving;
this.moving = null;
if (launcherLayoutSetting.get() === "custom" && moving.folder === this.currentFolder) {
moveLauncherEntry(this.currentFolder, this.entries().map(entryKey), moving.key, entryKey(entry));
const index = this.entries().findIndex(item => entryKey(item) === moving.key);
if (index >= 0) this.grid.selectIndex(index);
}
return false;
}
if (entry.kind === "folder") { if (entry.kind === "folder") {
this.currentFolder = entry.name; this.currentFolder = entry.name;
this.grid.resetSelection(); this.grid.resetSelection();
@@ -193,13 +166,6 @@ class LauncherGridLayer implements Layer {
/** Leave the open folder, else yield to the sidebar; true when that left the grid. */ /** Leave the open folder, else yield to the sidebar; true when that left the grid. */
private back(): boolean { private back(): boolean {
if (this.moving) {
const key = this.moving.key;
this.moving = null;
const index = this.entries().findIndex(entry => entryKey(entry) === key);
if (index >= 0) this.grid.selectIndex(index);
return false;
}
if (this.currentFolder !== null) { if (this.currentFolder !== null) {
this.exitFolder(); this.exitFolder();
return false; return false;
@@ -209,54 +175,14 @@ class LauncherGridLayer implements Layer {
} }
/** /**
* Layout and folder creation are always available. Per-icon actions need * App-specific entries for the window's context menu. Only item mode
* item mode so row navigation never edits an ambiguous selection. * pins the selection to a single cell, and only apps can move to folders,
* so anywhere else the menu falls back to just the defaults.
*/ */
menuItems(): MenuItem[] { menuItems(): MenuItem[] {
if (this.editingFolder) return [];
const entry = this.grid.selectedItem; const entry = this.grid.selectedItem;
const items: MenuItem[] = [ if (!entry || entry.kind !== "app") return [];
enumSettingMenuItem(launcherLayoutSetting, { onChange: () => { this.moving = null; this.grid.resetSelection(); } }), return [
{
label: "New folder",
onSelect: ctx => {
const name = unusedNewFolderName();
if (createFolder(name)) {
this.currentFolder = null;
this.moving = null;
this.grid.resetSelection();
this.grid.selectIndex(this.entries().findIndex(item => item.kind === "folder" && item.name === name));
}
ctx.stack.pop();
},
},
];
const folder = entry?.kind === "folder" ? entry.name : this.currentFolder;
if (folder !== null) {
items.push({ label: "Rename folder", onSelect: ctx => this.editFolderName(folder, ctx) }, {
label: "Delete folder",
onSelect: ctx => {
ctx.stack.pop();
ctx.stack.push(new MenuLayer("Delete folder? Apps stay installed.", [
{ label: "Delete folder", onSelect: confirm => {
disbandFolder(folder);
if (this.currentFolder === folder) this.currentFolder = null;
this.moving = null;
this.grid.resetSelection();
confirm.stack.pop();
} },
{ label: "Cancel", onSelect: confirm => confirm.stack.pop() },
], WINDOW_MENU_LAYOUT));
},
});
}
if (this.moving) items.push({ label: "Cancel move", onSelect: ctx => { this.back(); ctx.stack.pop(); } });
else if (entry && launcherLayoutSetting.get() === "custom") items.push({
label: "Move icon",
onSelect: ctx => { this.moving = { key: entryKey(entry), label: entry.label, folder: this.currentFolder }; ctx.stack.pop(); },
});
if (!entry || entry.kind !== "app") return items;
return [...items,
{ {
label: "Move to folder", label: "Move to folder",
onSelect: (ctx) => { onSelect: (ctx) => {
@@ -295,32 +221,6 @@ class LauncherGridLayer implements Layer {
]; ];
} }
private editFolderName(folder: string, ctx: LayerContext): void {
ctx.stack.pop();
const setting = new ConfigSettingString({
id: "launcher-folder-name", label: "Folder name", storageKey: "launcher.folderNameDraft",
defaultValue: folder, normalize: value => value ?? "",
validate: value => folderNameError(value, folder), reportInAnalytics: false,
});
setting.set(folder);
this.editingFolder = true;
const editor = new FolderNameEditorLayer(setting, ctx.actions);
ctx.stack.push(editor);
void ctx.actions.startTextSettingsEdit([setting], "Rename folder", () => {
this.editingFolder = false;
if (renameFolder(folder, setting.get())) {
if (this.currentFolder === folder) this.currentFolder = setting.get().trim();
this.moving = null;
}
ctx.stack.popIfTop(layer => layer === editor);
ctx.actions.requestRender();
}, undefined, () => {
this.editingFolder = false;
ctx.stack.popIfTop(layer => layer === editor);
ctx.actions.requestRender();
});
}
/** /**
* The folder-picker submenu: every existing folder except the app's own, * The folder-picker submenu: every existing folder except the app's own,
* plus a generated-name "New folder" (ring input has no text entry) and, * plus a generated-name "New folder" (ring input has no text entry) and,
@@ -342,9 +242,7 @@ class LauncherGridLayer implements Layer {
items.push({ items.push({
label: "New folder", label: "New folder",
onSelect: (ctx) => { onSelect: (ctx) => {
const name = unusedNewFolderName(); setAppFolder(appId, unusedNewFolderName());
createFolder(name);
setAppFolder(appId, name);
ctx.stack.pop(); ctx.stack.pop();
}, },
}); });
@@ -365,16 +263,8 @@ class LauncherGridLayer implements Layer {
const { width, height } = ctx.stack.getBaseSize(); const { width, height } = ctx.stack.getBaseSize();
const image = new GrayImage(width, height, 0); const image = new GrayImage(width, height, 0);
// The folder-name header band scales with the font. // The folder-name header band scales with the font.
const entries = this.entries(); const gridTop = this.currentFolder !== null ? GRID_TOP + font.lineHeight + 4 : ROOT_GRID_TOP;
if (this.moving && (launcherLayoutSetting.get() !== "custom" || this.moving.folder !== this.currentFolder || if (this.currentFolder !== null) {
!entries.some(entry => entryKey(entry) === this.moving!.key))) this.moving = null;
const gridTop = this.moving ? GRID_TOP + 2 * (font.lineHeight + 2)
: this.currentFolder !== null ? GRID_TOP + font.lineHeight + 4 : ROOT_GRID_TOP;
if (this.moving) {
image.drawText(font, 8, GRID_TOP - 2, truncateText(font, `Move ${this.moving.label}`, width - 16), 220);
image.drawText(font, 8, GRID_TOP + font.lineHeight, "Select position; double tap cancels", 160);
}
if (this.currentFolder !== null && !this.moving) {
image.drawText(font, 8, GRID_TOP - 2, truncateText(font, this.currentFolder, width - 16), 160); image.drawText(font, 8, GRID_TOP - 2, truncateText(font, this.currentFolder, width - 16), 160);
} }
// The grid runs to the window's bottom edge, so a row cut off there for // The grid runs to the window's bottom edge, so a row cut off there for
@@ -384,7 +274,6 @@ class LauncherGridLayer implements Layer {
} }
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> { async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
if (this.moving && event.type === "double-click") { this.back(); return; }
await this.grid.handleInput(event, ctx); await this.grid.handleInput(event, ctx);
} }
@@ -422,9 +311,9 @@ export function createLauncherWindow(options: LauncherOptions): ShellWindow {
// keeps every unrelated setting change from repainting the launcher. The // keeps every unrelated setting change from repainting the launcher. The
// launcher is pinned for the app's lifetime, so the subscription never needs // launcher is pinned for the app's lifetime, so the subscription never needs
// tearing down. // tearing down.
let lastState = `${getFolderStateFingerprint()}\n${getLauncherLayoutFingerprint()}\n${launcherAppsFingerprint(options.apps())}`; let lastState = `${getFolderStateFingerprint()}\n${launcherAppsFingerprint(options.apps())}`;
onAnySettingChanged(() => { onAnySettingChanged(() => {
const state = `${getFolderStateFingerprint()}\n${getLauncherLayoutFingerprint()}\n${launcherAppsFingerprint(options.apps())}`; const state = `${getFolderStateFingerprint()}\n${launcherAppsFingerprint(options.apps())}`;
if (state === lastState) return; if (state === lastState) return;
lastState = state; lastState = state;
created.requestRender(); created.requestRender();
+11 -51
View File
@@ -1,50 +1,14 @@
/** Launcher assignments keep their legacy format; explicitly created folders may be empty. */ /**
* Launcher folder state: which apps are grouped into which named folder.
* Stored as one JSON string (appId -> folder name) in the settings store, so
* it persists and its changes broadcast to every isolate. An unset value means
* the default grouping; any edit persists the whole map, so clearing out the
* defaults sticks. Folders exist only while at least one app is assigned to
* them — there is no separate create/delete step.
*/
import { getStringSetting, setStringSetting } from "../../native/settings-store"; import { getStringSetting, setStringSetting } from "../../native/settings-store";
import { renameLauncherFolderOrder, removeLauncherFolderOrder } from "./launcher-layout";
const STORAGE_KEY = "launcher.folders"; const STORAGE_KEY = "launcher.folders";
const NAMES_KEY = "launcher.folderNames";
/** Only user-created/renamed folders persist after their last member leaves. */
export function getExplicitFolderNames(): string[] {
try {
const value = JSON.parse(getStringSetting(NAMES_KEY, "[]"));
return Array.isArray(value) ? [...new Set(value.filter((name): name is string =>
typeof name === "string" && !!name.trim()).map(name => name.trim()))] : [];
} catch { return []; }
}
export function folderNameError(input: string, previous?: string): string | null {
const name = input.trim();
if (!name) return "Enter a folder name.";
if (name.length > FOLDER_NAME_MAX_LENGTH) return `Use at most ${FOLDER_NAME_MAX_LENGTH} characters.`;
if (/[\u0000-\u001f\u007f]/.test(name)) return "Use a single-line folder name.";
if (previous !== undefined && !getFolders().has(previous)) return "This folder no longer exists.";
for (const existing of getFolders().keys()) {
if (existing !== previous && existing.toLowerCase() === name.toLowerCase()) return "A folder with this name already exists.";
}
return null;
}
export function createFolder(input: string): boolean {
if (folderNameError(input)) return false;
setStringSetting(NAMES_KEY, JSON.stringify([...getExplicitFolderNames(), input.trim()]));
return true;
}
export function renameFolder(previous: string, input: string): boolean {
if (folderNameError(input, previous)) return false;
const name = input.trim();
if (name === previous) return true;
const assignments = getFolderAssignments();
for (const appId of Object.keys(assignments)) if (assignments[appId] === previous) assignments[appId] = name;
// Preserve position and per-folder order when the visible name changes.
renameLauncherFolderOrder(previous, name);
setStringSetting(NAMES_KEY, JSON.stringify([...getExplicitFolderNames().filter(n => n !== previous), name]));
setStringSetting(STORAGE_KEY, JSON.stringify(assignments));
return true;
}
/** The out-of-the-box grouping, applied only while the setting is unset. */ /** The out-of-the-box grouping, applied only while the setting is unset. */
const DEFAULT_ASSIGNMENTS: Record<string, string> = { const DEFAULT_ASSIGNMENTS: Record<string, string> = {
@@ -68,7 +32,7 @@ export function getFolderAssignments(): Record<string, string> {
try { try {
const parsed = JSON.parse(raw); const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {}; if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
const assignments: Record<string, string> = Object.create(null); const assignments: Record<string, string> = {};
for (const appId of Object.keys(parsed)) { for (const appId of Object.keys(parsed)) {
const folder = parsed[appId]; const folder = parsed[appId];
if (typeof folder === "string" && folder.trim()) { if (typeof folder === "string" && folder.trim()) {
@@ -94,7 +58,6 @@ export function getFolders(): Map<string, string[]> {
unsorted.set(folder, [appId]); unsorted.set(folder, [appId]);
} }
} }
for (const name of getExplicitFolderNames()) if (!unsorted.has(name)) unsorted.set(name, []);
const folders = new Map<string, string[]>(); const folders = new Map<string, string[]>();
for (const name of Array.from(unsorted.keys()).sort((a, b) => a.localeCompare(b))) { for (const name of Array.from(unsorted.keys()).sort((a, b) => a.localeCompare(b))) {
folders.set(name, unsorted.get(name)!); folders.set(name, unsorted.get(name)!);
@@ -123,8 +86,6 @@ export function disbandFolder(folder: string): number {
moved++; moved++;
} }
} }
setStringSetting(NAMES_KEY, JSON.stringify(getExplicitFolderNames().filter(name => name !== folder)));
removeLauncherFolderOrder(folder);
if (moved > 0) { if (moved > 0) {
setStringSetting(STORAGE_KEY, JSON.stringify(assignments)); setStringSetting(STORAGE_KEY, JSON.stringify(assignments));
} }
@@ -134,7 +95,7 @@ export function disbandFolder(folder: string): number {
/** /**
* An unused name for a ring-created folder ("New folder", "New folder 2", …). * An unused name for a ring-created folder ("New folder", "New folder 2", …).
* Ring input has no text entry, so new folders start with a generated name; * Ring input has no text entry, so new folders start with a generated name;
* Rename folder uses the existing phone text editor for a custom name. * the assistant's folder tools can regroup the apps under a better one.
*/ */
export function unusedNewFolderName(): string { export function unusedNewFolderName(): string {
const existing = new Set(Array.from(getFolders().keys()).map((name) => name.toLowerCase())); const existing = new Set(Array.from(getFolders().keys()).map((name) => name.toLowerCase()));
@@ -158,6 +119,5 @@ export function resolveFolderName(input: string): string {
/** Raw stored value, for cheap change detection by the launcher window. */ /** Raw stored value, for cheap change detection by the launcher window. */
export function getFolderStateFingerprint(): string { export function getFolderStateFingerprint(): string {
return JSON.stringify([getStringSetting(STORAGE_KEY, ""), getStringSetting(NAMES_KEY, ""), return getStringSetting(STORAGE_KEY, "");
getStringSetting("launcher.folderNameDraft", "")]);
} }
-60
View File
@@ -1,60 +0,0 @@
import { getStringSetting, setStringSetting } from "../../native/settings-store";
const ORDER_KEY = "launcher.order";
const scopeKey = (folder: string | null) => folder === null ? "root" : `folder:${folder}`;
function readOrders(): Record<string, string[]> {
try {
const value = JSON.parse(getStringSetting(ORDER_KEY, "{}"));
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
return Object.fromEntries(Object.entries(value).filter(([, order]) => Array.isArray(order))
.map(([scope, order]) => [scope, [...new Set((order as unknown[]).filter((id): id is string => typeof id === "string"))]]));
} catch { return {}; }
}
export function setLauncherOrder(folder: string | null, ids: readonly string[]): void {
const orders = readOrders();
orders[scopeKey(folder)] = [...new Set(ids)];
setStringSetting(ORDER_KEY, JSON.stringify(orders));
}
/** Unseen apps append alphabetically; changing sort modes never destroys saved order. */
export function orderLauncherEntries<T extends { label: string }>(
entries: T[], key: (entry: T) => string, folder: string | null, custom: boolean,
): T[] {
const order = custom ? readOrders()[scopeKey(folder)] ?? [] : [];
const rank = new Map(order.map((id, index) => [id, index]));
return entries.sort((a, b) => (rank.get(key(a)) ?? Infinity) - (rank.get(key(b)) ?? Infinity) ||
a.label.localeCompare(b.label) || key(a).localeCompare(key(b)));
}
/** Move into the target's position, without moving apps across folders. */
export function moveLauncherEntry(folder: string | null, ids: string[], source: string, target: string): boolean {
const from = ids.indexOf(source), to = ids.indexOf(target);
if (from < 0 || to < 0) return false;
const next = ids.slice();
next.splice(from, 1);
next.splice(to, 0, source);
setLauncherOrder(folder, next);
return true;
}
export function renameLauncherFolderOrder(previous: string, next: string): void {
const orders = readOrders();
const oldScope = scopeKey(previous), newScope = scopeKey(next);
if (orders[oldScope]) orders[newScope] = orders[oldScope];
delete orders[oldScope];
if (orders.root) orders.root = orders.root.map(id => id === `folder:${previous}` ? `folder:${next}` : id);
setStringSetting(ORDER_KEY, JSON.stringify(orders));
}
export function removeLauncherFolderOrder(folder: string): void {
const orders = readOrders();
delete orders[scopeKey(folder)];
if (orders.root) orders.root = orders.root.filter(id => id !== `folder:${folder}`);
setStringSetting(ORDER_KEY, JSON.stringify(orders));
}
export function getLauncherLayoutFingerprint(): string {
return JSON.stringify([getStringSetting("launcher.layout", "alphabetical"), getStringSetting(ORDER_KEY, "")]);
}
+3 -4
View File
@@ -191,7 +191,7 @@ function registerTools(options: WindowToolsOptions, registry: ToolRegistry): voi
const lines: string[] = []; const lines: string[] = [];
for (const [name, members] of getFolders()) { for (const [name, members] of getFolders()) {
const known = members.filter((appId) => appIds.indexOf(appId) >= 0).sort(); const known = members.filter((appId) => appIds.indexOf(appId) >= 0).sort();
if (known.length || members.length === 0) lines.push(`${name}: ${known.length ? known.map(describeApp).join(", ") : "(empty)"}`); if (known.length) lines.push(`${name}: ${known.map(describeApp).join(", ")}`);
} }
const assignments = getFolderAssignments(); const assignments = getFolderAssignments();
const ungrouped = appIds.filter((appId) => !assignments[appId]); const ungrouped = appIds.filter((appId) => !assignments[appId]);
@@ -237,7 +237,7 @@ function registerTools(options: WindowToolsOptions, registry: ToolRegistry): voi
{ {
name: "apps.remove_from_folder", name: "apps.remove_from_folder",
description: description:
"Move an app out of its launcher folder back to the top-level grid. Default folders disappear when their last app is removed; user-created folders can stay empty.", "Move an app out of its launcher folder back to the top-level grid. A folder disappears when its last app is removed.",
inputSchema: { inputSchema: {
type: "object", type: "object",
properties: { properties: {
@@ -276,9 +276,8 @@ function registerTools(options: WindowToolsOptions, registry: ToolRegistry): voi
(args) => { (args) => {
const folder = resolveFolderName(String(args?.folder ?? "")); const folder = resolveFolderName(String(args?.folder ?? ""));
if (!folder) return err("folder must be a non-empty name"); if (!folder) return err("folder must be a non-empty name");
const existed = getFolders().has(folder);
const moved = disbandFolder(folder); const moved = disbandFolder(folder);
if (moved === 0 && !existed) { if (moved === 0) {
const names = Array.from(getFolders().keys()); const names = Array.from(getFolders().keys());
return err( return err(
names.length names.length
+8 -7
View File
@@ -200,13 +200,6 @@ export class ConfigSettingEnum<TValue extends string, TId extends string = strin
} }
} }
export const launcherLayoutSetting = new ConfigSettingEnum({
id: "launcher-layout", label: "Layout", storageKey: "launcher.layout",
defaultValue: "alphabetical", values: ["alphabetical", "custom"] as const,
formatValue: value => value === "custom" ? "Custom" : "Alphabetical",
description: "Sort apps and folders alphabetically, or arrange icons yourself. Custom positions are remembered when switching layouts.",
});
type ConfigSettingStringOptions<TId extends string> = ConfigSettingOptions<string, TId> & { type ConfigSettingStringOptions<TId extends string> = ConfigSettingOptions<string, TId> & {
editorTitle?: string; editorTitle?: string;
glassesEditTitle?: string; glassesEditTitle?: string;
@@ -608,6 +601,14 @@ export function getBrightnessPreferences() {
curve: autoBrightnessCurveSetting.getValidValue(), fadeMs: scaleAnimationDuration(SCREEN_FADE_MS, screenFadeSetting.get()) }; curve: autoBrightnessCurveSetting.getValidValue(), fadeMs: scaleAnimationDuration(SCREEN_FADE_MS, screenFadeSetting.get()) };
} }
export const swapMenuGesturesSetting = new ConfigSettingBoolean({
id: "swap-menu-gestures",
label: "Long press for app menu",
storageKey: "input.swapMenuGestures",
defaultValue: false,
description: "Use long press for the app menu and tap then hold for the system menu. Apps using long press for a game action or voice capture keep their gestures. The app switcher keeps its system menu gestures.",
});
export const wakeToLastAppSetting = new ConfigSettingBoolean({ export const wakeToLastAppSetting = new ConfigSettingBoolean({
id: "wake-to-last-app", id: "wake-to-last-app",
label: "Wake into last app", label: "Wake into last app",
+2
View File
@@ -89,6 +89,7 @@ import {
voiceProviderSetting, voiceProviderSetting,
screenTimeoutSetting, screenTimeoutSetting,
wakeToLastAppSetting, wakeToLastAppSetting,
swapMenuGesturesSetting,
wakeWordActionSetting, wakeWordActionSetting,
watchCanUnlockSetting, watchCanUnlockSetting,
watchCrownClockwiseNextSetting, watchCrownClockwiseNextSetting,
@@ -125,6 +126,7 @@ function settingsSections(): SettingsSection[] {
}), }),
toggleSettingMenuItem(lockScreenEnabledSetting), toggleSettingMenuItem(lockScreenEnabledSetting),
toggleSettingMenuItem(wakeToLastAppSetting), toggleSettingMenuItem(wakeToLastAppSetting),
toggleSettingMenuItem(swapMenuGesturesSetting),
// A band (at one of five heights) / Tall / Full Screen; the // A band (at one of five heights) / Tall / Full Screen; the
// dashboard controller moves or reflows windows on change. // dashboard controller moves or reflows windows on change.
enumSettingMenuItem(displayLayoutSetting), enumSettingMenuItem(displayLayoutSetting),
+19 -56
View File
@@ -9,6 +9,7 @@ import {
directionalFallback, directionalFallback,
type DirectionalInputEvent, type DirectionalInputEvent,
GESTURE_SHORT_THEN_LONG_PRESS, GESTURE_SHORT_THEN_LONG_PRESS,
GESTURE_LONG_PRESS,
gestureHints, gestureHints,
InputEvent, InputEvent,
type InputEventPayload, type InputEventPayload,
@@ -52,6 +53,7 @@ import {
timeFormatSetting, timeFormatSetting,
wakeWordActionSetting, wakeWordActionSetting,
wakeToLastAppSetting, wakeToLastAppSetting,
swapMenuGesturesSetting,
windowBorderSetting, windowBorderSetting,
} from "../dashboard-settings"; } from "../dashboard-settings";
import { onAmbientCardsChanged } from "./ambient-cards"; import { onAmbientCardsChanged } from "./ambient-cards";
@@ -326,7 +328,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
*/ */
keepWindowFocus = false; keepWindowFocus = false;
constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void, title = "System") { constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void) {
// Aligned to the min-height window band (like the sidebar), wherever the // Aligned to the min-height window band (like the sidebar), wherever the
// vertical position setting currently puts it; centered over the // vertical position setting currently puts it; centered over the
// application area, i.e. the part of the screen beside a side strip // application area, i.e. the part of the screen beside a side strip
@@ -334,7 +336,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
// the strip overlays). // the strip overlays).
const width = 272; const width = 272;
const area = appViewportRect("min"); const area = appViewportRect("min");
super(title, items, { super("System", items, {
x: area.x + (((area.width - width) / 2) | 0), x: area.x + (((area.width - width) / 2) | 0),
y: area.y + 8, y: area.y + 8,
width, width,
@@ -1061,7 +1063,15 @@ class Shell {
return { shell: false, window: false }; return { shell: false, window: false };
} }
// Long-press is the shell's own gesture: it opens the system menu // Remap menu intent only. Apps still receive the canonical context-menu
// event, while owned holds (games / voice) retain their raw input.
const menuWindow = this.foregroundWindow();
const swapMenus = this.focus === "window" && swapMenuGesturesSetting.get() &&
!menuWindow?.holdToTalk && !menuWindow?.claimsLongPress?.();
const systemMenuGesture = swapMenus ? "short-then-long-press" : "long-press";
const appMenuGesture = swapMenus ? "long-press" : "short-then-long-press";
// The resolved system gesture opens the shell's own menu
// directly, never reaching the app — over the app's own context menu // directly, never reaching the app — over the app's own context menu
// too (the window closes that on system-menu-opened), while an already // too (the window closes that on system-menu-opened), while an already
// open system menu just stays. Its later generic release is consumed // open system menu just stays. Its later generic release is consumed
@@ -1069,7 +1079,7 @@ class Shell {
// app. The exception is a window that claims long-press for a move of // app. The exception is a window that claims long-press for a move of
// its own: it gets the press forwarded, with the escape timer running // its own: it gets the press forwarded, with the escape timer running
// so that holding the press long enough still opens the system menu. // so that holding the press long enough still opens the system menu.
if (event.type === "long-press") { if (event.type === systemMenuGesture) {
if (this.activeVoiceLayer || !this.stack.isAtBase()) { if (this.activeVoiceLayer || !this.stack.isAtBase()) {
return { shell: true, window: false }; return { shell: true, window: false };
} }
@@ -1091,11 +1101,11 @@ class Shell {
return { shell: true, window: true }; return { shell: true, window: true };
} }
// The 2.2.9 tap-then-hold gesture is the app's context-menu gesture: it // The resolved app-menu gesture is delivered as tap-then-hold: it
// goes to the foreground window (from the sidebar it focuses the window // goes to the foreground window (from the sidebar it focuses the window
// first), which answers with its own menu or asks for the system menu // first), which answers with its own menu or asks for the system menu
// when it has none. // when it has none.
if (event.type === "short-then-long-press") { if (event.type === appMenuGesture) {
const window = this.foregroundWindow(); const window = this.foregroundWindow();
if (window?.holdToTalk) { if (window?.holdToTalk) {
this.openEscapeMenu(); this.openEscapeMenu();
@@ -1123,7 +1133,7 @@ class Shell {
window.onFocus?.(this.lastInput); window.onFocus?.(this.lastInput);
} }
// The window owns frameId from here (render or explicit finish). // The window owns frameId from here (render or explicit finish).
await window.handleInput(event, frameId); await window.handleInput(swapMenus ? { ...event, type: "short-then-long-press" } : event, frameId);
return { shell: true, window: true }; return { shell: true, window: true };
} }
if (event.type === "long-press-release") { if (event.type === "long-press-release") {
@@ -1304,43 +1314,6 @@ class Shell {
return hidden ? this.windows.filter((window) => window !== hidden) : this.windows; return hidden ? this.windows.filter((window) => window !== hidden) : this.windows;
} }
/** Reorder visible app windows while keeping pinned/temporary slots and foreground stable. */
private moveSwitcherWindow(windowId: string, targetId: string): boolean {
const movable = this.switcherWindows().filter(window => window.closeable);
const from = movable.findIndex(window => window.windowId === windowId);
const to = movable.findIndex(window => window.windowId === targetId);
if (from < 0 || to < 0 || from === to) return false;
const foreground = this.foregroundWindow();
const ids = new Set(movable.map(window => window.windowId));
const [moved] = movable.splice(from, 1);
movable.splice(to, 0, moved!);
let index = 0;
this.windows = this.windows.map(window => ids.has(window.windowId) ? movable[index++]! : window);
if (foreground) this.selectedIndex = this.windows.indexOf(foreground);
this.config.onWindowsChanged?.();
this.config.requestShellRender();
return true;
}
/** Capture window IDs: changing titles or closing windows cannot redirect a pending move. */
private openSwitcherMoveMenu(windowId: string): void {
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
const movable = this.switcherWindows().filter(window => window.closeable);
const selected = movable.findIndex(window => window.windowId === windowId);
if (selected < 0 || movable.length < 2) return;
const items: MenuItem[] = movable.map((window, index) => ({
label: `${index + 1}. ${window.title}`,
onSelect: ctx => {
ctx.stack.pop();
this.moveSwitcherWindow(windowId, window.windowId);
},
}));
const layer = new ShellOverlayMenuLayer(items, undefined, () => this.yieldFocusToSidebar(), "Move app to position");
layer.selectItem(selected);
this.stack.push(layer);
this.config.requestShellRender();
}
/** /**
* The status bar items the switcher's selection can move onto, in order: * The status bar items the switcher's selection can move onto, in order:
* with a bottom switcher (the selection reaches them past the last * with a bottom switcher (the selection reaches them past the last
@@ -1996,17 +1969,6 @@ class Shell {
}, },
}]), }]),
); );
const movableWindows = this.switcherWindows().filter(window => window.closeable);
if (movableWindows.length > 1 && movableWindows.includes(foreground)) {
items.push({
label: "Move in app switcher",
description: "Choose this open window's position in the app switcher.",
onSelect: ctx => {
ctx.stack.pop();
this.openSwitcherMoveMenu(foreground.windowId);
},
});
}
if (brightnessSetting.get() !== "auto") { if (brightnessSetting.get() !== "auto") {
items.push({ items.push({
label: "Brightness", label: "Brightness",
@@ -2028,7 +1990,8 @@ class Shell {
// when the app has one (otherwise it opens this very menu, not worth a // when the app has one (otherwise it opens this very menu, not worth a
// hint). // hint).
const footer = foreground.hasAppMenu?.() const footer = foreground.hasAppMenu?.()
? (foreground.holdToTalk ? undefined : gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]])) ? (foreground.holdToTalk ? undefined : gestureHints([[this.focus === "window" && swapMenuGesturesSetting.get() && !foreground.claimsLongPress?.()
? GESTURE_LONG_PRESS : GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]]))
: undefined; : undefined;
const layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar()); const layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
layer.selectItem(initialSelection); layer.selectItem(initialSelection);
+7 -5
View File
@@ -1,3 +1,4 @@
import { swapMenuGesturesSetting } from "./dashboard-settings";
import { GrayImage } from "../graphics/image"; import { GrayImage } from "../graphics/image";
import { singlePlane, type Plane } from "../graphics/plane"; import { singlePlane, type Plane } from "../graphics/plane";
import { GESTURE_LONG_PRESS, GESTURE_SHORT_THEN_LONG_PRESS, gestureHints, type InputEvent } from "./gestures"; import { GESTURE_LONG_PRESS, GESTURE_SHORT_THEN_LONG_PRESS, gestureHints, type InputEvent } from "./gestures";
@@ -6,8 +7,9 @@ import { CONTEXT_MENU_DIM, MenuLayer, type MenuItem, type MenuLayout } from "./m
import type { WorkerAppReply } from "./shell/worker-window"; import type { WorkerAppReply } from "./shell/worker-window";
/** /**
* The window context menu, opened by tap-then-hold: an app's own menu, * The window context menu, opened by tap-then-hold by default: an app's own menu,
* holding its app-specific actions. The shell's system menu (long-press) * holding its app-specific actions. The menu gesture preference can swap
* these bindings unless the app owns long-press. The shell's system menu
* carries the entries every window shares — Focus app switcher, Voice input, * carries the entries every window shares — Focus app switcher, Voice input,
* Close window — so an app with nothing of its own to offer has no menu of * Close window — so an app with nothing of its own to offer has no menu of
* its own: tap-then-hold then opens the system menu in its place, so both * its own: tap-then-hold then opens the system menu in its place, so both
@@ -28,8 +30,8 @@ export const WINDOW_MENU_LAYOUT: MenuLayout = {
}; };
export class WindowMenuLayer extends MenuLayer { export class WindowMenuLayer extends MenuLayer {
constructor(title: string | null, items: MenuItem[], holdToTalk = false) { constructor(title: string | null, items: MenuItem[], holdToTalk = false, claimsLongPress = false) {
super(title, items, holdToTalk super(title, items, (holdToTalk || (swapMenuGesturesSetting.get() && !claimsLongPress))
? { ...WINDOW_MENU_LAYOUT, footer: gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "system menu"]]) } ? { ...WINDOW_MENU_LAYOUT, footer: gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "system menu"]]) }
: WINDOW_MENU_LAYOUT); : WINDOW_MENU_LAYOUT);
} }
@@ -123,7 +125,7 @@ export class WindowMenu {
handleInput: () => {}, handleInput: () => {},
}; };
const stack = new LayerStack(base, this.layerActions(), this.options.size, this.options.isFocused); const stack = new LayerStack(base, this.layerActions(), this.options.size, this.options.isFocused);
const layer = new WindowMenuLayer(title, items); const layer = new WindowMenuLayer(title, items, false, this.options.claimsLongPress?.() ?? false);
if (selectedIndex !== undefined) layer.selectItem(selectedIndex); if (selectedIndex !== undefined) layer.selectItem(selectedIndex);
stack.push(layer); stack.push(layer);
this.stack = stack; this.stack = stack;
-23
View File
@@ -1,23 +0,0 @@
# Launcher folders and layouts
Open the Apps window's app menu (tap then hold by default). Layout and New folder are available even without a single icon selected. New folder creates a persistent empty folder with an unused generated name. Select a folder, or enter it, to rename it through the existing phone text editor. Rename commits on Submit; Cancel leaves the folder unchanged. Names must be non-empty, single-line, at most 24 characters, and unique ignoring case. Delete folder requires confirmation and returns its apps to the root without uninstalling them.
Layout offers Alphabetical (the existing default) and Custom. In Custom, select an app or folder icon and choose Move icon, navigate to its destination and click to place it at that position. Double tap cancels; the watch's back from the left edge also cancels. The phone mirror can select the destination too. Moves stay within the root or current folder; Move to folder and Remove from folder remain available for changing membership. Renaming a folder preserves its root position and internal order. New apps append alphabetically after saved icons. Switching to Alphabetical retains saved custom positions for later use.
Persistence uses the existing shared settings store. The legacy launcher.folders assignment map stays compatible; new launcher.folderNames metadata preserves explicitly created/renamed empty folders. Untouched legacy folders keep disappearing when their last app is removed. launcher.layout stores the mode, and launcher.order stores root and per-folder order. Assistant folder tools remain consistent with empty folders. Existing installations retain their grouping and alphabetical layout.
Software checks cover defaults, restart, existing assignments, empty folder creation/deletion, duplicate and invalid names, rename commit/cancel, independent root/folder positions, layout toggling, new/removed apps, malformed metadata, move cancellation and deletion confirmation. TypeScript and changed-source lint are checked separately.
Hardware validation remains pending: ring row/item selection, watch directional navigation and back, moving across scroll rows, phone-mirror placement, phone rename Submit/Cancel, reopening folders and app restart. No firmware was flashed.
Independent branch validation: 1073 JavaScript tests passed, 2 skipped, 0 failed; TypeScript and changed-source lint passed.
## Open app switcher order
The system menu adds Move in app switcher when the selected window can be moved and at least two app windows are open. Its numbered position picker shows the currently open app windows in switcher order, preselects the current position, and uses window IDs internally to distinguish windows with identical titles. Choose a destination to move there, or double tap to cancel.
This arranges existing open windows independently of the launcher's Alphabetical/Custom preference. Pinned windows keep their slots and temporary status-item windows do not participate. Reordering retains the same foreground window, attention state and most-recently-used history; closing a window still returns to the most recently viewed one. New windows append as before. Open-window order lasts for those windows' lifetime; reopening the app does not restore previously closed windows or write ephemeral window IDs to settings.
Software tests cover both directions, menu integration, duplicate titles, captured source IDs, cancellation, removed source/destination, temporary and pinned windows, appending/replacing windows, foreground identity and MRU close behavior. Hardware checks remain pending for ring/watch navigation in the position picker and left/right/bottom/popup switcher placements.
Independent branch after adding open-window ordering: 1080 JavaScript tests passed, 2 skipped; TypeScript and changed-source lint passed.
+9
View File
@@ -0,0 +1,9 @@
# Configurable menu gestures
Settings > Display > Long press for app menu is off by default, preserving existing installations. When enabled with an app focused, long press opens its context menu and tap then hold opens the system menu. The preference uses the existing ConfigSettingBoolean/settings store and takes effect on subsequent input without restarting.
Windows claiming long press retain that input, their existing tap-then-hold app menu and the extended-hold system escape. Hold-to-talk windows retain voice capture and tap-then-hold for the system menu. The app switcher retains its existing bindings. Empty app menus continue to fall back to the system menu. The shell delivers the canonical tap-then-hold context-menu event to apps, so worker and EvenHub input contracts do not change. Menu gesture hints follow the preference and exceptions.
Software validation: TypeScript and changed-source lint; full JavaScript suite (1072 passed, 2 skipped on the independent branch). Routing tests cover both mappings, overlay switching, input metadata, dynamic hold ownership, switcher behavior and screen-off input. Persistence tests cover default, enabled and disabled values after store reload. App-menu hint tests cover owned holds and voice capture.
Hardware validation remains pending: test both bindings on the glasses/ring, app-specific holds, voice release, extended-hold escape, switching menus, app switcher, and restart. No firmware was flashed.
+1 -1
View File
@@ -266,7 +266,7 @@ function shellEnv({ wakeAction = 'voice-input', skipConfirmation = false } = {})
handleInput(event, ctx) { if (event.type === 'double-click') ctx.stack.pop(); } handleInput(event, ctx) { if (event.type === 'double-click') ctx.stack.pop(); }
} }
const voiceDialogs = []; const voiceDialogs = [];
const settings = { wakeWordActionSetting: { get: () => wakeAction }, brightnessSetting: { get: () => 'auto' }, const settings = { swapMenuGesturesSetting: { get: () => false }, wakeWordActionSetting: { get: () => wakeAction }, brightnessSetting: { get: () => 'auto' },
assistantSkipConfirmationSetting: { get: () => skipConfirmation } }; assistantSkipConfirmationSetting: { get: () => skipConfirmation } };
const { shell, rawInputEventToInputEvent } = load('app/ui/shell/shell.ts', { const { shell, rawInputEventToInputEvent } = load('app/ui/shell/shell.ts', {
'../../graphics/shell-scene': { encodeShellScene: () => new Uint8Array([0, 0]) }, '../../graphics/shell-scene': { encodeShellScene: () => new Uint8Array([0, 0]) },
+11
View File
@@ -59,3 +59,14 @@ test('curve drafts preview exactly while brightness keeps the previous valid sav
assert.equal(curve.validationError(), null); assert.equal(curve.validationError(), null);
assert.equal(api.getBrightnessPreferences().curve, '0:0,2:50,6:100'); assert.equal(api.getBrightnessPreferences().curve, '0:0,2:50,6:100');
}); });
test('menu gesture preference preserves defaults and survives restart in either state', () => {
const store = new Map();
let api = settingsFixture(store);
assert.equal(api.swapMenuGesturesSetting.get(), false);
api.swapMenuGesturesSetting.set(true);
api = settingsFixture(store);
assert.equal(api.swapMenuGesturesSetting.get(), true);
api.swapMenuGesturesSetting.set(false);
assert.equal(settingsFixture(store).swapMenuGesturesSetting.get(), false);
});
+1
View File
@@ -39,6 +39,7 @@ const menu = load('app/ui/menu.ts', {
function fixture(initial = '50', viewport = { x: 64, y: 124, width: 576, height: 260 }) { function fixture(initial = '50', viewport = { x: 64, y: 124, width: 576, height: 260 }) {
let value = initial, writes = 0, closed = 0; let value = initial, writes = 0, closed = 0;
const settings = { const settings = {
swapMenuGesturesSetting: { get: () => false },
brightnessSetting: { get: () => value, set: (next) => { value = next; writes++; } }, brightnessSetting: { get: () => value, set: (next) => { value = next; writes++; } },
brightnessSettingToLevel: (value) => value === 'auto' ? null : Number(value), brightnessSettingToLevel: (value) => value === 'auto' ? null : Number(value),
}; };
-239
View File
@@ -1,239 +0,0 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const vm = require('node:vm');
const ts = require('typescript');
function fixture(store = new Map()) {
const storage = { getStringSetting: (key, fallback) => store.get(key) ?? fallback,
setStringSetting: (key, value) => store.set(key, value), onSettingsStoreChanged() {},
getBooleanSetting: (_key, fallback) => fallback, setBooleanSetting() {} };
function load(file, deps, suffix = '') {
const context = { exports: {}, global: { isIOS: false }, console,
require: id => deps(id) };
vm.runInNewContext(ts.transpileModule(fs.readFileSync(file, 'utf8') + suffix, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
return context.exports;
}
const layout = load('app/apps/launcher/launcher-layout.ts', () => storage);
const folders = load('app/apps/launcher/launcher-folders.ts', id => id === './launcher-layout' ? layout : storage);
const settings = load('app/ui/dashboard-settings.ts', id => {
if (id.includes('settings-store')) return storage;
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
});
return { store, layout, folders, settings, load };
}
const plain = value => JSON.parse(JSON.stringify(value));
test('legacy assignments and alphabetical default survive creation, rename and restart', () => {
const f = fixture();
const original = plain(f.folders.getFolderAssignments());
assert.equal(f.settings.launcherLayoutSetting.get(), 'alphabetical');
assert.equal(f.folders.createFolder(' Français '), true);
assert.deepEqual(plain(f.folders.getFolders().get('Français')), []);
assert.deepEqual(plain(f.folders.getFolderAssignments()), original);
assert.equal(f.folders.renameFolder('Games', 'Jeux'), true);
const again = fixture(f.store);
assert.equal(again.folders.getFolderAssignments().blocks, 'Jeux');
assert.equal(again.folders.getFolderAssignments().calculator, 'Prototypes');
assert.equal(again.folders.getFolders().has('Français'), true);
assert.equal(again.folders.getFolders().has('Games'), false);
});
test('folder names reject blank, multiline, long and case-insensitive duplicate names', () => {
const f = fixture();
for (const name of ['', ' ', 'games', 'GAMES', 'x'.repeat(25), 'Two\nlines']) {
assert.equal(f.folders.createFolder(name), false, name);
assert.equal(f.folders.renameFolder('Prototypes', name), false, name);
}
assert.equal(f.folders.renameFolder('Games', 'games'), true);
assert.equal(f.folders.renameFolder('missing', 'New name'), false);
});
test('explicit empty folders persist, can be deleted and never reintroduce default assignments', () => {
const f = fixture(new Map([['launcher.folders', '{}']]));
assert.equal(f.folders.createFolder('Empty'), true);
f.folders.setAppFolder('test', 'Empty');
f.folders.setAppFolder('test', null);
assert.equal(fixture(f.store).folders.getFolders().has('Empty'), true);
assert.equal(f.folders.disbandFolder('Empty'), 0);
assert.equal(f.folders.getFolders().size, 0);
assert.equal(f.folders.unusedNewFolderName(), 'New folder');
f.folders.createFolder('New folder');
assert.equal(f.folders.unusedNewFolderName(), 'New folder 2');
});
test('deleting a non-empty folder ungroups all members without losing other assignments', () => {
const f = fixture();
assert.equal(f.folders.disbandFolder('Games'), 5);
assert.equal(f.folders.getFolderAssignments().blocks, undefined);
assert.equal(f.folders.getFolderAssignments().calculator, 'Prototypes');
assert.equal(fixture(f.store).folders.getFolders().has('Games'), false);
});
test('custom root and folder orders persist independently, survive renames and append new apps', () => {
const f = fixture();
const entries = [{ label: 'Alpha', id: 'app:a' }, { label: 'Beta', id: 'app:b' }, { label: 'Games', id: 'folder:Games' }];
const sort = (scope, custom = true) => plain(f.layout.orderLauncherEntries(entries.slice(), e => e.id, scope, custom)).map(e => e.id);
f.settings.launcherLayoutSetting.set('custom');
f.layout.moveLauncherEntry(null, entries.map(e => e.id), 'folder:Games', 'app:a');
f.layout.setLauncherOrder('Games', ['app:b', 'app:a']);
assert.deepEqual(sort(null), ['folder:Games', 'app:a', 'app:b']);
assert.deepEqual(sort('Games'), ['app:b', 'app:a', 'folder:Games']);
assert.deepEqual(sort(null, false), ['app:a', 'app:b', 'folder:Games']);
f.settings.launcherLayoutSetting.set('alphabetical');
f.settings.launcherLayoutSetting.set('custom');
assert.deepEqual(sort(null), ['folder:Games', 'app:a', 'app:b']);
f.folders.renameFolder('Games', 'Jeux');
const again = fixture(f.store);
assert.equal(again.settings.launcherLayoutSetting.get(), 'custom');
entries[2] = { label: 'Jeux', id: 'folder:Jeux' };
assert.deepEqual(sort(null), ['folder:Jeux', 'app:a', 'app:b']);
assert.deepEqual(sort('Jeux'), ['app:b', 'app:a', 'folder:Jeux']);
entries.push({ label: 'A newly installed app', id: 'app:new' });
assert.deepEqual(sort(null), ['folder:Jeux', 'app:a', 'app:b', 'app:new']);
f.folders.disbandFolder('Jeux');
f.folders.createFolder('Jeux');
assert.deepEqual(sort('Jeux'), ['app:new', 'app:a', 'app:b', 'folder:Jeux']);
});
test('malformed metadata is safe; moves tolerate removed apps and stale IDs', () => {
const f = fixture(new Map([['launcher.folderNames', '{bad'], ['launcher.order', '{bad']]));
assert.equal(f.folders.getExplicitFolderNames().length, 0);
assert.equal(f.layout.moveLauncherEntry(null, ['a', 'b'], 'missing', 'a'), false);
assert.equal(f.layout.moveLauncherEntry(null, ['a', 'b'], 'a', 'missing'), false);
assert.equal(f.layout.moveLauncherEntry(null, ['a', 'b'], 'a', 'b'), true);
assert.deepEqual(JSON.parse(f.store.get('launcher.order')).root, ['b', 'a']);
});
function launcherFixture() {
const f = fixture(new Map([['launcher.folders', '{}']]));
const layers = [], launches = [], deleted = [];
class IconGrid {
constructor(options) { this.options = options; this.index = null; }
get selectedItem() { return this.index === null ? null : this.options.items()[this.index] ?? null; }
resetSelection() { this.index = null; }
selectIndex(index) { this.index = index; }
enterRowMode() { this.index = null; }
async handleInput(event, ctx) {
if (event.type === 'click') await this.options.onActivate(this.selectedItem, ctx);
if (event.type === 'double-click' || event.type === 'swipe-left') this.options.onBack(ctx);
}
}
class MenuLayer { constructor(title, items) { this.title = title; this.items = items; } }
class EditTextSettingLayer { constructor(setting) { this.setting = setting; } }
let edit;
const ctx = { stack: {
push: layer => layers.push(layer), pop() { const layer = layers.pop(); layer?.onRemoved?.(); },
popIfTop(test) { if (layers.length && test(layers.at(-1))) { this.pop(); return true; } return false; },
}, actions: { requestRender() {}, endTextSettingEdit() {}, startTextSettingsEdit(settings, title, submit, toggle, cancel) {
edit = { setting: settings[0], submit, cancel };
} } };
const api = f.load('app/apps/launcher/launcher-app.ts', id => {
if (id === './launcher-folders') return f.folders;
if (id === './launcher-layout') return f.layout;
if (id.endsWith('/dashboard-settings')) return { ...f.settings, EditTextSettingLayer,
enumSettingMenuItem: setting => ({ label: setting.label }) };
if (id.endsWith('/icon-grid')) return { IconGrid, ICON_GRID_BAND_INSET_X: 0, ICON_GRID_HIGHLIGHT_INSET_Y: 0 };
if (id.endsWith('/menu')) return { MenuLayer };
if (id.endsWith('/shell/shell')) return { shell: { yieldFocusToSidebar() {} } };
return {};
}, '\nexport { LauncherGridLayer };');
const apps = [{ appId: 'a', label: 'Alpha', icon: 'a' }, { appId: 'b', label: 'Beta', icon: 'b' }, { appId: 'c', label: 'Gamma', icon: 'c' }];
const layer = new api.LauncherGridLayer({ apps: () => apps, launchApp: id => launches.push(id), uninstallApp: id => deleted.push(id) });
return { ...f, layer, ctx, layers, launches, deleted, apps, edit: () => edit,
choose(label) { const item = layer.menuItems().find(item => item.label === label); assert.ok(item, label); item.onSelect(ctx); } };
}
test('launcher menu is available in row mode and supports empty folder creation and entry', async () => {
const h = launcherFixture();
assert.deepEqual(plain(h.layer.menuItems().map(item => item.label)), ['Layout', 'New folder']);
h.choose('New folder');
const folder = h.layer.entries().find(entry => entry.kind === 'folder');
assert.equal(folder.name, 'New folder');
await h.layer.openEntry(folder);
assert.equal(h.layer.currentFolder, 'New folder');
assert.equal(h.layer.entries().length, 0);
assert.ok(h.layer.menuItems().some(item => item.label === 'Rename folder'));
});
test('folder rename uses the existing editor, commits on submit only, and preserves open folder', async () => {
const h = launcherFixture(); h.choose('New folder');
await h.layer.openEntry(h.layer.entries().find(entry => entry.kind === 'folder'));
h.choose('Rename folder');
h.edit().setting.set('Renommé');
assert.equal(h.layer.menuItems().length, 0);
assert.equal(h.folders.getFolders().has('New folder'), true);
h.edit().cancel();
assert.equal(h.folders.getFolders().has('Renommé'), false);
h.choose('Rename folder');
h.edit().setting.set('Renommé');
h.edit().submit();
assert.equal(h.layer.currentFolder, 'Renommé');
assert.equal(h.folders.getFolders().has('New folder'), false);
assert.equal(h.layers.length, 0);
});
test('moving icons reorders without launching; cancellation and alphabetical mode preserve order', async () => {
const h = launcherFixture();
h.layer.grid.selectIndex(0);
assert.equal(h.layer.menuItems().some(item => item.label === 'Move icon'), false);
h.settings.launcherLayoutSetting.set('custom');
h.choose('Move icon');
h.layer.grid.selectIndex(2);
await h.layer.handleInput({ type: 'click' }, h.ctx);
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'c', 'a']);
assert.equal(h.launches.length, 0);
h.choose('Move icon');
h.layer.grid.selectIndex(0);
await h.layer.handleInput({ type: 'double-click' }, h.ctx);
assert.equal(h.layer.moving, null);
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'c', 'a']);
h.settings.launcherLayoutSetting.set('alphabetical');
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['a', 'b', 'c']);
h.settings.launcherLayoutSetting.set('custom');
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'c', 'a']);
});
test('folder moves stay inside their scope, folder deletion is confirmed and apps are not uninstalled', async () => {
const h = launcherFixture(); h.folders.createFolder('Dossier');
h.folders.setAppFolder('a', 'Dossier'); h.folders.setAppFolder('b', 'Dossier');
await h.layer.openEntry(h.layer.entries().find(entry => entry.kind === 'folder'));
h.settings.launcherLayoutSetting.set('custom'); h.layer.grid.selectIndex(0);
h.choose('Move icon'); await h.layer.openEntry(h.layer.entries()[1]);
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'a']);
h.choose('Delete folder');
assert.equal(h.folders.getFolders().has('Dossier'), true);
h.layers.at(-1).items[0].onSelect(h.ctx);
assert.equal(h.folders.getFolders().has('Dossier'), false);
assert.equal(h.layer.currentFolder, null);
assert.equal(h.layer.entries().length, 3);
assert.equal(h.deleted.length, 0);
});
test('legacy folders with removed apps disappear while explicit empty folders remain', async () => {
const h = launcherFixture();
h.folders.setAppFolder('a', 'Legacy');
await h.layer.openEntry(h.layer.entries().find(entry => entry.kind === 'folder'));
h.apps.splice(0, 1);
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'c']);
assert.equal(h.layer.currentFolder, null);
h.folders.createFolder('Empty');
await h.layer.openEntry(h.layer.entries().find(entry => entry.kind === 'folder'));
assert.equal(h.layer.entries().length, 0);
assert.equal(h.layer.currentFolder, 'Empty');
});
test('removing the source during a move cancels without launching or corrupting order', async () => {
const h = launcherFixture(); h.settings.launcherLayoutSetting.set('custom');
h.layer.grid.selectIndex(0); h.choose('Move icon');
h.apps.splice(0, 1);
await h.layer.openEntry(h.layer.entries()[0]);
assert.equal(h.layer.moving, null);
assert.equal(h.launches.length, 0);
assert.deepEqual(plain(h.layer.entries().map(entry => entry.appId)), ['b', 'c']);
});
+106
View File
@@ -0,0 +1,106 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const vm = require('node:vm');
const ts = require('typescript');
function fixture(swap = false, app = {}) {
const source = ts.createSourceFile('shell.ts', fs.readFileSync('app/ui/shell/shell.ts', 'utf8'), ts.ScriptTarget.Latest, true);
const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name.text === 'Shell');
const route = cls.members.find(n => n.name?.getText(source) === 'routeInput');
class Overlay {}
const context = { exports: {}, ShellOverlayMenuLayer: Overlay,
swapMenuGesturesSetting: { get: () => swap }, isWatchInput: () => false };
vm.runInNewContext(ts.transpileModule(`export class Shell { ${route.getText(source)} }`, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
const s = new context.exports.Shell();
const delivered = [];
const window = { handleInput: async e => delivered.push(e), hasAppMenu: () => true, ...app };
let overlay = false, escapes = 0;
Object.assign(s, { focus: 'window', screenOn: true, lastInput: null,
foregroundWindow: () => window, cancelEscapeMenuTimer() {},
startEscapeMenuTimer() { escapes++; }, config: { requestShellRender() {} },
openEscapeMenu() { overlay = true; },
stack: { isAtBase: () => !overlay, popIfTop(fn) { if (overlay && fn(new Overlay())) { overlay = false; return true; } return false; } },
});
return { s, delivered, setSwap: value => { swap = value; }, overlay: () => overlay, escapes: () => escapes,
input: type => s.routeInput({ type, source: 'ring', timestampMs: 42 }, 17) };
}
for (const swap of [false, true]) {
test(`menu routing, overlay switching and metadata with inversion ${swap}`, async () => {
const h = fixture(swap);
const system = swap ? 'short-then-long-press' : 'long-press';
const app = swap ? 'long-press' : 'short-then-long-press';
await h.input(app);
assert.equal(h.delivered.at(-1).type, 'short-then-long-press');
assert.equal(h.delivered.at(-1).source, 'ring');
assert.equal(h.delivered.at(-1).timestampMs, 42);
await h.input(system);
assert.equal(h.overlay(), true);
await h.input(app);
assert.equal(h.overlay(), false);
assert.equal(h.delivered.length, 2);
});
for (const app of [{ claimsLongPress: () => true }, { holdToTalk: true }]) {
test(`owned long press remains intact with inversion ${swap}: ${JSON.stringify(Object.keys(app))}`, async () => {
const h = fixture(swap, app);
await h.input('long-press');
assert.equal(h.delivered[0].type, 'long-press');
assert.equal(h.escapes(), app.holdToTalk ? 0 : 1);
await h.input('short-then-long-press');
if (app.holdToTalk) assert.equal(h.overlay(), true);
else assert.equal(h.delivered[1].type, 'short-then-long-press');
});
}
}
test('gesture inversion never wakes a sleeping screen', async () => {
const h = fixture(true); h.s.screenOn = false;
await h.input('long-press'); await h.input('short-then-long-press');
assert.equal(h.delivered.length, 0); assert.equal(h.overlay(), false);
});
test('the switcher retains its existing gestures when inversion is enabled', async () => {
for (const type of ['long-press', 'short-then-long-press']) {
const snapshots = [];
for (const swap of [false, true]) {
const h = fixture(swap); h.s.focus = 'sidebar';
await h.input(type);
snapshots.push({ overlay: h.overlay(), delivered: h.delivered.map(e => e.type) });
}
assert.deepEqual(snapshots[0], snapshots[1]);
}
});
test('the setting applies immediately and follows changing app hold ownership', async () => {
let claims = false;
const h = fixture(false, { claimsLongPress: () => claims });
h.setSwap(true);
await h.input('long-press');
assert.equal(h.delivered.at(-1).type, 'short-then-long-press');
claims = true;
await h.input('long-press');
assert.equal(h.delivered.at(-1).type, 'long-press');
claims = false;
await h.input('long-press');
assert.equal(h.delivered.at(-1).type, 'short-then-long-press');
});
test('app menu hints reflect inversion, voice capture and owned holds', () => {
const source = ts.createSourceFile('window-menu.ts', fs.readFileSync('app/ui/window-menu.ts', 'utf8'), ts.ScriptTarget.Latest, true);
const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name.text === 'WindowMenuLayer');
let swap = false;
const context = { exports: {}, MenuLayer: class { constructor(_title, _items, layout) { this.layout = layout; } },
WINDOW_MENU_LAYOUT: { footer: 'long-press' }, GESTURE_SHORT_THEN_LONG_PRESS: 'tap-hold',
swapMenuGesturesSetting: { get: () => swap }, gestureHints: hints => hints[0][0] };
vm.runInNewContext(ts.transpileModule(cls.getText(source), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
const hint = (voice = false, claims = false) => new context.exports.WindowMenuLayer('App', [], voice, claims).layout.footer;
assert.equal(hint(), 'long-press');
swap = true;
assert.equal(hint(), 'tap-hold');
assert.equal(hint(false, true), 'long-press');
assert.equal(hint(true), 'tap-hold');
});
-154
View File
@@ -1,154 +0,0 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const vm = require('node:vm');
const ts = require('typescript');
function fixture() {
const source = ts.createSourceFile('shell.ts', fs.readFileSync('app/ui/shell/shell.ts', 'utf8'), ts.ScriptTarget.Latest, true);
const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name.text === 'Shell');
const names = new Set(['moveSwitcherWindow', 'openSwitcherMoveMenu', 'switcherWindows', 'foregroundWindow',
'openEscapeMenu', 'registerWindow', 'removeWindow', 'noteWindowVisible', 'mostRecentWindowIndex']);
const methods = cls.members.filter(n => names.has(n.name?.getText(source)));
assert.equal(methods.length, names.size);
const overlay = source.statements.find(n => ts.isClassDeclaration(n) && n.name.text === 'ShellOverlayMenuLayer');
class MenuLayer {
constructor(title, items) { this.title = title; this.items = items; }
selectItem(index) { this.selectedIndex = index; }
}
const context = { exports: {}, MenuLayer, appViewportRect: () => ({ x: 0, y: 0, width: 576 }),
CONTEXT_MENU_DIM: 0.5, brightnessSetting: { get: () => 'auto' }, makeInputEvent: e => e,
appFullscreenSetting: () => ({ get: () => false }), appKeepAwakeSetting: () => ({ label: 'Keep screen awake' }),
toggleSettingMenuItem: setting => ({ label: setting.label }),
swapMenuGesturesSetting: { get: () => false }, GESTURE_SHORT_THEN_LONG_PRESS: 'tap-hold',
};
vm.runInNewContext(ts.transpileModule(`${overlay.getText(source)}\nexport class Shell { ${methods.map(n => n.getText(source)).join('\n')} }`, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
const s = new context.exports.Shell();
const foregroundCalls = [], closed = [], input = [];
const window = (windowId, appId = windowId, closeable = true, title = windowId) => ({
windowId, appId, closeable, title, requestRender() {},
setForeground: value => foregroundCalls.push([windowId, value]),
close: () => closed.push(windowId), handleInput: event => input.push([windowId, event.type]),
});
const launcher = window('launcher', 'launcher', false, 'Apps');
const first = window('terminal:one', 'terminal', true, 'Terminal');
const second = window('terminal:two', 'terminal', true, 'Terminal');
const third = window('calendar', 'calendar', true, 'Calendar');
const layers = [];
let changed = 0, renders = 0;
Object.assign(s, {
windows: [launcher, first, second, third], selectedIndex: 1, focus: 'sidebar', screenOn: true,
attention: new Map(), mruWindowIds: ['terminal:one', 'calendar', 'terminal:two', 'launcher'],
config: { voiceInputEnabled: false, onWindowsChanged: () => changed++, requestShellRender: () => renders++ },
yieldFocusToSidebar() { this.focus = 'sidebar'; },
stack: { isAtBase: () => !layers.length, push: layer => layers.push(layer),
pop: () => layers.pop()?.onRemoved?.() },
});
return { s, launcher, first, second, third, window, foregroundCalls, closed, input,
ids: () => Array.from(s.windows, w => w.windowId), changed: () => changed, renders: () => renders,
menu: () => layers.at(-1), choose(label) {
const item = layers.at(-1).items.find(item => item.label === label);
assert.ok(item, label); item.onSelect({ stack: s.stack });
} };
}
test('moving open windows in either direction keeps foreground, MRU and pinned launcher stable', () => {
const h = fixture(); h.s.focus = 'window';
const mru = Array.from(h.s.mruWindowIds);
assert.equal(h.s.moveSwitcherWindow(h.first.windowId, h.third.windowId), true);
assert.deepEqual(h.ids(), ['launcher', 'terminal:two', 'calendar', 'terminal:one']);
assert.equal(h.s.foregroundWindow(), h.first);
assert.equal(h.s.selectedIndex, 3);
assert.equal(h.s.focus, 'window');
assert.deepEqual(Array.from(h.s.mruWindowIds), mru);
assert.deepEqual(h.foregroundCalls, []);
assert.deepEqual(h.closed, []);
assert.equal(h.changed(), 1); assert.equal(h.renders(), 1);
assert.equal(h.s.moveSwitcherWindow(h.first.windowId, h.second.windowId), true);
assert.deepEqual(h.ids(), ['launcher', 'terminal:one', 'terminal:two', 'calendar']);
assert.equal(h.s.foregroundWindow(), h.first);
});
test('system menu opens a numbered position picker and moves the captured window, even with duplicate titles', () => {
const h = fixture();
h.s.openEscapeMenu(); h.choose('Move in app switcher');
assert.equal(h.menu().title, 'Move app to position');
assert.deepEqual(Array.from(h.menu().items, item => item.label), ['1. Terminal', '2. Terminal', '3. Calendar']);
assert.equal(h.menu().selectedIndex, 0);
// A delayed focus change must not move a different app than the menu captured.
h.s.selectedIndex = 2;
h.choose('3. Calendar');
assert.deepEqual(h.ids(), ['launcher', 'terminal:two', 'calendar', 'terminal:one']);
assert.equal(h.s.foregroundWindow(), h.second);
assert.equal(h.menu(), undefined);
assert.equal(h.s.focus, 'sidebar');
});
test('cancelling the picker and choosing the current slot leave ordering unchanged', () => {
const h = fixture(); const before = h.ids();
h.s.openSwitcherMoveMenu(h.first.windowId); h.s.stack.pop();
assert.deepEqual(h.ids(), before);
h.s.openSwitcherMoveMenu(h.first.windowId); h.choose('1. Terminal');
assert.deepEqual(h.ids(), before);
assert.equal(h.changed(), 0);
});
test('closing the pending source or destination prevents a stale move from affecting another window', () => {
for (const removed of ['terminal:one', 'calendar']) {
const h = fixture(); h.s.openSwitcherMoveMenu(h.first.windowId);
h.s.removeWindow(removed);
const afterClose = h.ids();
h.choose('3. Calendar');
assert.deepEqual(h.ids(), afterClose);
assert.equal(h.menu(), undefined);
}
});
test('temporary status windows and pinned slots stay fixed, including selected status foreground', () => {
const h = fixture();
const hidden = h.window('notifications:temporary');
const pinned = h.window('another-pinned', 'pinned', false);
h.s.windows.splice(2, 0, hidden, pinned);
h.s.selectedIndex = 2;
h.s.selectedStatus = { transient: true, host: hidden, item: { key: 'notification' } };
assert.equal(h.s.moveSwitcherWindow(hidden.windowId, h.first.windowId), false);
h.s.moveSwitcherWindow(h.first.windowId, h.third.windowId);
assert.deepEqual(h.ids(), ['launcher', 'terminal:two', 'notifications:temporary', 'another-pinned', 'calendar', 'terminal:one']);
assert.equal(h.s.foregroundWindow(), hidden);
assert.equal(h.s.selectedStatus.host, hidden);
h.s.openEscapeMenu();
assert.ok(!h.menu().items.some(item => item.label === 'Move in app switcher'));
h.s.stack.pop();
h.s.openSwitcherMoveMenu(h.first.windowId);
assert.deepEqual(Array.from(h.menu().items, item => item.label), ['1. Terminal', '2. Calendar', '3. Terminal']);
});
test('new windows append, replacements keep their slot, and closing uses unchanged recency after a move', () => {
const h = fixture(); h.s.moveSwitcherWindow(h.first.windowId, h.third.windowId);
h.s.registerWindow(h.window('new'));
assert.equal(h.ids().at(-1), 'new');
const replacement = h.window(h.second.windowId, 'terminal', true, 'Renamed session');
h.s.registerWindow(replacement);
assert.equal(h.s.windows[1], replacement);
assert.equal(h.s.foregroundWindow(), h.first);
h.s.removeWindow(h.first.windowId);
assert.equal(h.s.foregroundWindow(), h.third);
});
test('pinned, missing, single-window, screen-off and overlay cases cannot start a reorder', () => {
const h = fixture(); const before = h.ids();
for (const [from, to] of [['launcher', 'calendar'], ['calendar', 'launcher'], ['missing', 'calendar']]) {
assert.equal(h.s.moveSwitcherWindow(from, to), false);
}
h.s.openSwitcherMoveMenu('missing'); assert.equal(h.menu(), undefined);
h.s.screenOn = false; h.s.openSwitcherMoveMenu(h.first.windowId); assert.equal(h.menu(), undefined);
h.s.screenOn = true; h.s.stack.push({});
h.s.openSwitcherMoveMenu(h.first.windowId); assert.equal(h.menu().title, undefined); h.s.stack.pop();
assert.deepEqual(h.ids(), before);
h.s.selectedIndex = 0; h.s.openEscapeMenu();
assert.ok(!h.menu().items.some(item => item.label === 'Move in app switcher')); h.s.stack.pop();
h.s.windows = [h.launcher, h.first]; h.s.selectedIndex = 1; h.s.openEscapeMenu();
assert.ok(!h.menu().items.some(item => item.label === 'Move in app switcher'));
});