Various UI tweaks

Fix missing submenu indicators and change their appearance. Clean up
styling in the Terminal app and move Settings to the top-level menu.
Remove right padding from the bottom bar.
This commit is contained in:
James Babcock committed 2026-10-02 12:19:25 -07:00
1 parent eff32d4a5a
commit 295922effd
12 files changed
+95 -96

No files matched your search

+1 -17
View File
@@ -1,4 +1,4 @@
import { MenuLayer, drawSubmenuIndicator, type MenuItem } from "../../ui/menu";
import { MenuLayer, submenuItem, type MenuItem } from "../../ui/menu";
import { ScreenTestLayer } from "./screen-test";
import { InputEventsLayer } from "./input-events";
import { shell } from "../../ui/shell/shell";
@@ -11,9 +11,7 @@ import { ResourceUsageLayer } from "./resource-usage";
import { LoadAppFromQrLayer, LoadAppFromUrlLayer } from "./load-app";
import { unicodeTestMenu } from "./unicode-test";
import { type AppContext } from "../app-definition";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { appViewportSize } from "../../ui/shell/geometry";
import { LIST_ROW_TEXT_INSET } from "../../ui/metrics";
import {
createInProcessWindow,
YieldAtRootLayer,
@@ -36,20 +34,6 @@ const MENU_LAYOUT = {
opaque: true,
};
/** A row that opens a nested page: the label plus a right-edge ">". */
function submenuItem(label: string, onSelect: MenuItem["onSelect"]): MenuItem {
return {
label,
onSelect,
render: ({ image, x, y, width, height, selected, disabled, text }) => {
const font = getDefaultSmallFont();
const value = disabled ? 70 : selected ? 255 : 200;
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, text, value);
drawSubmenuIndicator(image, font, x, y, width, height, value);
},
};
}
type OpenPage = (ctx: Parameters<MenuItem["onSelect"]>[0]) => void;
/** The diagnostic demos, one level down from the root menu. */
+1 -1
View File
@@ -174,7 +174,7 @@ export class EvenHubStoreLayer implements Layer {
for (const [index, line] of wrapText(font, message, width - LIST_X * 2).entries()) {
image.drawText(font, LIST_X, headerH + 16 + index * lineStep(font), line, 190);
}
image.drawText(font, LIST_X, height - font.lineHeight - 4, `${GESTURE_CLICK} edit credentials`, 105);
image.drawText(font, LIST_X, height - font.lineHeight - 4, `${GESTURE_CLICK} log in`, 105);
return image;
}
+1 -15
View File
@@ -1,14 +1,13 @@
import { imageFromAsciiArt } from "../../graphics/image";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { appViewportSize } from "../../ui/shell/geometry";
import { LIST_ROW_TEXT_INSET } from "../../ui/metrics";
import {
MenuLayer,
TextPageLayer,
drawRightValueMenuItem,
drawSubmenuIndicator,
drawToggleMenuItem,
openModalMenu,
submenuItem,
type MenuItem,
} from "../../ui/menu";
import { enumSettingMenuItem, toggleSettingMenuItem } from "../../ui/dashboard-settings";
@@ -73,19 +72,6 @@ const MENU_LAYOUT = {
opaque: true,
};
function submenuItem(label: string, onSelect: MenuItem["onSelect"]): MenuItem {
return {
label,
onSelect,
render: ({ image, x, y, width, height, selected, disabled, text }) => {
const font = getDefaultSmallFont();
const value = disabled ? 70 : selected ? 255 : 200;
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, text, value);
drawSubmenuIndicator(image, font, x, y, width, height, value);
},
};
}
/** Persist a config change and re-apply it live when the array is streaming. */
function updateMicConfig(mutate: (config: MicConfig) => MicConfig): void {
const updated = mutate(loadMicConfig());
+4 -10
View File
@@ -19,6 +19,7 @@ import {
drawRightValueMenuItem,
drawSubmenuIndicator,
drawToggleMenuItem,
submenuItem,
type MenuItem,
} from "../../ui/menu";
import { Menu, type MenuDrawArgs } from "../../ui/menu-core";
@@ -938,16 +939,9 @@ function windowMenuItems(): MenuItem[] {
enumSettingMenuItem(navigateDisplayModeSetting),
enumSettingMenuItem(navigateVerticalPositionSetting),
);
items.push({
label: "Saved destinations",
onSelect: (ctx) => {
ctx.stack.push(new WindowMenuLayer("Saved destinations", savedDestinationMenuItems()));
},
render: ({ image, x, y, width, height, text }) => {
image.drawText(smallFont, x, y + LIST_ROW_TEXT_INSET, text, 200);
drawSubmenuIndicator(image, smallFont, x - 10, y, width + 20, height, 150);
},
});
items.push(submenuItem("Saved destinations", (ctx) => {
ctx.stack.push(new WindowMenuLayer("Saved destinations", savedDestinationMenuItems()));
}));
items.push({
label: navigateRememberRecentSetting.label,
onSelect: () => {
+6 -3
View File
@@ -1,11 +1,14 @@
import { wrapText, type WrapFont } from '../../graphics/textwrap';
/** Left edge of the hub's title line (and of a wrapped status block under it). */
export const HUB_TITLE_X = 12;
/** Keep short status on the title row; give long errors their full width. */
export function layoutHubHeader(font: WrapFont, title: string, status: string, width: number, step: number) {
const inlineX = 18 + font.measureText(title) + 16;
const inlineX = HUB_TITLE_X + font.measureText(title) + 16;
const inline = !/[\r\n]/.test(status) && font.measureText(status) <= Math.max(0, width - inlineX - 12);
const lines = inline ? [status] : wrapText(font, status, Math.max(1, width - 30));
const x = inline ? inlineX : 18;
const lines = inline ? [status] : wrapText(font, status, Math.max(1, width - HUB_TITLE_X - 12));
const x = inline ? inlineX : HUB_TITLE_X;
const y = inline ? 10 : 10 + step;
return { x, y, lines, listTop: inline ? 16 + step : 16 + step * (1 + lines.length) };
}
+37 -23
View File
@@ -38,7 +38,7 @@ import { GrayImage, type UiFont } from "../../graphics/image";
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
import { prepareFrameDraws } from "../../graphics/glyph-wire";
import { getDefaultSmallFont, getTerminalFontConfig } from "../../graphics/ui-fonts";
import { layoutHubHeader } from "./hub-header";
import { HUB_TITLE_X, layoutHubHeader } from "./hub-header";
import { TERMINAL_ICON_GLYPHS, type IconActivity } from "../../graphics/icons";
import {
drawSessionRow,
@@ -65,9 +65,9 @@ import {
import { terminalFontPickerMenuItem } from "../../ui/font-picker";
import { connectionDisplayName, loadConnections, parseConnectionString, saveConnections, TERMINAL_CONNECTIONS_KEY, updateConnection, type TerminalConnection } from "./connections";
import { TerminalEmulator } from "./terminal-emulator";
import { drawSubmenuIndicator, type MenuItem } from "../../ui/menu";
import { drawSubmenuIndicator, submenuItem, type MenuItem } from "../../ui/menu";
import { Menu, type MenuDrawArgs } from "../../ui/menu-core";
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../../ui/metrics";
import { lineStep, listRowHeight } from "../../ui/metrics";
import { WindowMenu, WindowMenuLayer } from "../../ui/window-menu";
import { appViewportSize } from "../../ui/shell/geometry";
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
@@ -1052,17 +1052,9 @@ function connectedControls(): ControlConnection[] {
function windowMenuItems(window: TerminalWindow): MenuItem[] {
const items: MenuItem[] = [
{
label: "Settings",
onSelect: (ctx) => {
ctx.stack.push(new WindowMenuLayer("Terminal settings", settingsMenuItems()));
},
render: ({ image, x, y, width, height, text }) => {
const font = chromeFont();
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, text, 200);
drawSubmenuIndicator(image, font, x - 10, y, width + 20, height, 150);
},
},
submenuItem("Settings", (ctx) => {
ctx.stack.push(new WindowMenuLayer("Terminal settings", settingsMenuItems()));
}),
];
if (window.kind === "hub") {
const connected = connectedControls();
@@ -1227,6 +1219,14 @@ type HubItem = {
* when it has an onSelect (launch a shell on that host).
*/
heading?: boolean;
/**
* Top-level action (Manage Connections, Settings, Connect <host>): drawn
* unindented like a heading but at full brightness, rather than as an
* indented session row.
*/
topLevel?: boolean;
/** Opens a nested menu: a right-edge ">" marks the row. */
submenu?: boolean;
/** Session with recent output: an animated indicator marks the row. */
active?: boolean;
/** Glyph of the view window showing this session (the number column). */
@@ -1236,8 +1236,12 @@ type HubItem = {
/** Vertical offset of a row's text line from the top of its selection box. */
const HUB_ROW_TEXT_INSET = 4;
/** Horizontal inset of the list's selection boxes from the viewport edges. */
const HUB_LIST_X = 20;
/** Left edge of the list's selection boxes. */
const HUB_LIST_LEFT = 12;
/** Right inset of the selection boxes, clear of the scrollbar. */
const HUB_LIST_RIGHT = 20;
/** Left padding of unindented (heading and top-level) row text inside its selection box. */
const HUB_TOP_LEVEL_TEXT_X = 6;
/** The hub window's list, created on first use so openWindow stays free of paint dependencies. */
function hubMenu(window: HubWindow): Menu<HubItem> {
@@ -1252,10 +1256,12 @@ function hubMenu(window: HubWindow): Menu<HubItem> {
return window.list;
}
function drawHubRow({ image, item, x, y, width, selected }: MenuDrawArgs<HubItem>): void {
function drawHubRow({ image, item, x, y, width, height, selected }: MenuDrawArgs<HubItem>): void {
const font = chromeFont();
if (item.heading) {
image.drawText(font, x, y + HUB_ROW_TEXT_INSET, item.label, selected ? 255 : 140);
if (item.heading || item.topLevel) {
const value = selected ? 255 : item.heading ? 140 : 200;
image.drawText(font, x + HUB_TOP_LEVEL_TEXT_X, y + HUB_ROW_TEXT_INSET, item.label, value);
if (item.submenu) drawSubmenuIndicator(image, font, x, y, width, height, value);
return;
}
// Activity gutter, open-window number column, then the label, truncated
@@ -1322,8 +1328,15 @@ function hubSessionItems(window: HubWindow): HubItem[] {
const items: HubItem[] = [
{
label: "Manage Connections",
topLevel: true,
onSelect: () => setHubMode(window, "connections"),
},
{
label: "Settings",
topLevel: true,
submenu: true,
onSelect: () => windowMenu(window).open(settingsMenuItems(), "Terminal settings"),
},
];
const connected = connectedControls();
const multiHost = connected.length > 1;
@@ -1366,6 +1379,7 @@ function hubSessionItems(window: HubWindow): HubItem[] {
if (control.config.enabled && control.state?.phase === "connecting") continue;
items.push({
label: `Connect ${connectionDisplayName(control.config)}`,
topLevel: true,
onSelect: () => connectControl(control),
});
}
@@ -1675,14 +1689,14 @@ function paintHub(window: HubWindow): GrayImage {
// No border box: the shell chrome (top bar + sidebar) already frames the app.
// Long statuses get a wrapped block and move the list below it.
const title = window.mode === "connections" ? "Terminal - Connections" : "Terminal";
image.drawText(font, 18, 10, title, 220);
image.drawText(font, HUB_TITLE_X, 10, title, 220);
const header = layoutHubHeader(font, title, hubStatusLine(window), window.viewportWidth, step);
header.lines.forEach((line, index) => image.drawText(font, header.x, header.y + index * step, line, 170));
let listTop = header.listTop;
if (window.mode === "sessions" && controls.size === 0) {
image.drawText(font, 24, listTop, "Add a g2mirror:// connection to get started, see:", 150);
image.drawText(font, 24, listTop + step, "https://github.com/jimrandomh/g2mirror", 190);
image.drawText(font, HUB_TITLE_X + 6, listTop, "Add a g2mirror:// connection to get started, see:", 150);
image.drawText(font, HUB_TITLE_X + 6, listTop + step, "https://github.com/jimrandomh/g2mirror", 190);
listTop += 2 * step + 6;
}
@@ -1694,7 +1708,7 @@ function paintHub(window: HubWindow): GrayImage {
const listHeight = window.viewportHeight - 6 - listTop;
list.paint(
image,
{ x: HUB_LIST_X, y: listTop - 2, width: window.viewportWidth - 2 * HUB_LIST_X, height: listHeight },
{ x: HUB_LIST_LEFT, y: listTop - 2, width: window.viewportWidth - HUB_LIST_LEFT - HUB_LIST_RIGHT, height: listHeight },
window.focused,
);
list.drawScrollbar(image, window.viewportWidth - 10, listTop, listHeight - 4);
+2 -2
View File
@@ -5,7 +5,7 @@ import { copyRemoteToken, remoteInterfaces } from '../../native/remote-input';
import { TextViewerLayer } from '../../apps/files/text-viewer';
import { ConfigSettingString, textSettingMenuItem } from '../dashboard-settings';
import { getDefaultSmallFont } from '../../graphics/ui-fonts';
import { drawRightValueMenuItem, type MenuItem } from '../menu';
import { drawRightValueMenuItem, submenuItem, type MenuItem } from '../menu';
import { type LayerContext } from '../layers';
import { openSettingsSubMenu } from './settings-panel';
@@ -86,5 +86,5 @@ function openTokens(ctx: LayerContext): void {
]);
}
export function remoteInputMenuItem(): MenuItem {
return { label: 'Input tokens', description: 'Allow another app to provide ring/watch input, type into the foreground window, or send messages to the voice assistant. Create tokens with individual permissions and revoke them here.', onSelect: openTokens };
return submenuItem('Input tokens', openTokens, { description: 'Allow another app to provide ring/watch input, type into the foreground window, or send messages to the voice assistant. Create tokens with individual permissions and revoke them here.' });
}
+11 -11
View File
@@ -24,7 +24,7 @@ import {
} from "../../native/asr-model";
import { TextViewerLayer } from "../../apps/files/text-viewer";
import type { LayerContext } from "../layers";
import { drawRightValueMenuItem, openModalMenu, type MenuItem } from "../menu";
import { drawRightValueMenuItem, openModalMenu, submenuItem, type MenuItem } from "../menu";
import { shell } from "../shell/shell";
import {
anthropicApiKeySetting,
@@ -262,17 +262,17 @@ function customizationRows(): () => MenuItem[] {
}
function autoBrightnessMenuItem(): MenuItem {
return {
label: "Auto-brightness",
description: "Adjust the minimum, maximum, and ambient-light curve used by Auto brightness.",
onSelect: (ctx) => {
return submenuItem(
"Auto-brightness",
(ctx) => {
openSettingsSubMenu(ctx, "Auto-brightness", [
enumSettingMenuItem(autoBrightnessMinSetting),
enumSettingMenuItem(autoBrightnessMaxSetting),
textSettingMenuItem(autoBrightnessCurveSetting),
]);
},
};
{ description: "Adjust the minimum, maximum, and ambient-light curve used by Auto brightness." },
);
}
/**
@@ -310,16 +310,16 @@ function batteryIndicatorsMenuItem(): MenuItem {
/** The Customization section's "Animations" row: opens a modal submenu of animation toggles. */
function animationsMenuItem(): MenuItem {
return {
label: "Animations",
description: "Turn off menu and icon-grid motion, or the fade when the screen turns on and off.",
onSelect: (ctx) => {
return submenuItem(
"Animations",
(ctx) => {
openSettingsSubMenu(ctx, "Animations", [
toggleSettingMenuItem(menuAnimationSetting),
toggleSettingMenuItem(screenFadeSetting),
]);
},
};
{ description: "Turn off menu and icon-grid motion, or the fade when the screen turns on and off." },
);
}
const LOCAL_MODEL_GB = `${(LOCAL_MODEL.sizeBytes / 1e9).toFixed(1)}GB`;
+21 -2
View File
@@ -140,7 +140,7 @@ export function drawListScrollbar(
}
/**
* Draw a ">" submenu indicator inset at the right edge of a row's selection
* Draw a "▶>" submenu indicator inset at the right edge of a row's selection
* highlight box, vertically centered within it. Pass the same rect as the
* row's drawSelectionHighlight call (the row need not actually be selected).
*/
@@ -153,12 +153,31 @@ export function drawSubmenuIndicator(
highlightHeight: number,
value: number,
): void {
const arrow = ">";
const arrow = "▶";
const x = highlightX + highlightWidth - font.measureText(arrow) - 4;
const y = centeredTextY(font, highlightY, highlightHeight);
image.drawText(font, x, y, arrow, value);
}
/** A row that opens a nested menu: the label plus a right-edge ">". */
export function submenuItem(
label: string,
onSelect: MenuItem["onSelect"],
options: Pick<MenuItem, "description" | "disabled"> = {},
): MenuItem {
return {
...options,
label,
onSelect,
render: ({ image, x, y, width, height, selected, disabled, text }) => {
const font = getDefaultSmallFont();
const value = disabled ? 70 : selected ? 255 : 200;
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, text, value);
drawSubmenuIndicator(image, font, x, y, width, height, value);
},
};
}
export function drawToggleMenuItem(
image: GrayImage,
font: UiFont,
+3 -4
View File
@@ -71,9 +71,8 @@ const ROW_STEP = ROW_ICON_SIZE + ICON_SPACING;
// (whose last is the divider, which the row has no use for) centred in the
// row below its separator line.
const ROW_STATUS_TOP = 1 + ((SWITCHER_ROW_HEIGHT - TOP_BAR_HEIGHT) >> 1);
// Its clock ends this far from the row's right end, as the top bar's starts
// from its left; batteries keep the top bar's clock-to-icons gap from it.
const ROW_STATUS_EDGE_MARGIN = 10;
// Its clock ends flush with the row's right end, which is the window's
// right edge; batteries keep the top bar's clock-to-icons gap from it.
const ROW_CLOCK_GAP = 16;
// Between the windows' end of the row (its scroll chevron) and the status.
const ROW_STATUS_GAP = 8;
@@ -501,7 +500,7 @@ export class ShellChromeLayer implements Layer {
const top = row.y + ROW_STATUS_TOP;
const font = getDefaultMediumFont();
const clock = clockText();
const clockX = row.x + row.width - ROW_STATUS_EDGE_MARGIN - font.measureText(clock);
const clockX = row.x + row.width - font.measureText(clock);
image.drawText(font, clockX, top + Math.max(0, ((TOP_BAR_HEIGHT - font.lineHeight) / 2) | 0), clock, 210);
// The battery block keeps its usual right margin inside the edge it's given.
const batteryLeft = this.drawTopBarBatteries(image, state, top, clockX - ROW_CLOCK_GAP + BATTERY_BLOCK_RIGHT_MARGIN);
+3 -3
View File
@@ -302,10 +302,10 @@ test('the switcher row lays out windows, free space, notifications, widgets, bat
assert.deepEqual(Array.from(parts, (p) => [p.shellKey, p.depth ?? 0]), [[1, 0], [2, -2]]);
const [row, status] = parts;
// Right to left from the row's end (x=608), centred under its separator
// line (y=366): "Thu Oct 2 9:41" (56px) 10px in; the battery block (label
// line (y=366): "Thu Oct 2 9:41" (56px) flush with it; the battery block (label
// 20 + gap 5 + gauge 21) 16px before it; the 30px widget 10px before that;
// then the two notification icons, 8px clear of the widget.
const clockX = 608 - 10 - 56, batteryLeft = clockX - 16 - 46, trayLeft = batteryLeft - 40, iconsLeft = trayLeft - 8 - 56 + 4;
const clockX = 608 - 56, batteryLeft = clockX - 16 - 46, trayLeft = batteryLeft - 40, iconsLeft = trayLeft - 8 - 56 + 4;
assert.deepEqual([status.x, status.y, status.image.width, status.image.height], [iconsLeft, 367, 608 - iconsLeft, 35]);
const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x];
// The clock's text runs 8 rows down the top bar's layout, which sits 5 rows into the row.
@@ -332,7 +332,7 @@ test('many windows scroll in what the notification icons leave them', () => {
const [row, status] = chrome.paintParts();
// Clock only (no batteries or widgets): notifications end 8px before its
// 8px lead-in, and stop where three window slots plus margins remain.
const trayLeft = 608 - 10 - 56 - 8, floor = 32 + 20 + 3 * 40 - 8 + 8;
const trayLeft = 608 - 56 - 8, floor = 32 + 20 + 3 * 40 - 8 + 8;
const max = Math.floor((trayLeft - 8 - floor + 4) / 28);
assert.equal(requested.at(-1), max);
const iconsLeft = trayLeft - 8 - max * 28 + 4;
+5 -5
View File
@@ -1,10 +1,10 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { layoutHubHeader } = require('../.test-build/app/apps/terminal/hub-header.js');
const { HUB_TITLE_X, layoutHubHeader } = require('../.test-build/app/apps/terminal/hub-header.js');
const font = size => ({ measureText: text => [...text].length * size, getGlyph: () => ({ dwidthX: size }) });
test('terminal short status stays inline; exact-fit status does not move the list', () => {
const f = font(7), title = 'Terminal', status = 'Connected.';
const width = 18 + f.measureText(title) + 16 + f.measureText(status) + 12;
const width = HUB_TITLE_X + f.measureText(title) + 16 + f.measureText(status) + 12;
const header = layoutHubHeader(f, title, status, width, 18);
assert.equal(header.y, 10); assert.equal(header.listTop, 34); assert.deepEqual(header.lines, [status]);
assert.equal(layoutHubHeader(f, title, status, width - 1, 18).y, 28);
@@ -14,16 +14,16 @@ test('terminal long error wraps in full-width block and moves menu below all lin
for (const size of [5, 7, 12, 20]) for (const width of [320, 576, 640]) {
const f = font(size), step = size * 2;
const header = layoutHubHeader(f, 'Terminal - Connections', status, width, step);
assert.equal(header.x, 18); assert.equal(header.y, 10 + step);
assert.equal(header.x, HUB_TITLE_X); assert.equal(header.y, 10 + step);
assert.equal(header.lines.join(' '), status);
assert.ok(header.lines.every(line => f.measureText(line) <= width - 30));
assert.ok(header.lines.every(line => f.measureText(line) <= width - HUB_TITLE_X - 12));
assert.ok(header.listTop >= header.y + header.lines.length * step);
assert.equal(header.listTop, 16 + step * (1 + header.lines.length));
}
});
test('terminal explicit newlines and long unbroken messages remain complete', () => {
const h = layoutHubHeader(font(7), 'Terminal', 'First\nSecond', 640, 18);
assert.equal(h.x, 18); assert.deepEqual(h.lines, ['First', 'Second']);
assert.equal(h.x, HUB_TITLE_X); assert.deepEqual(h.lines, ['First', 'Second']);
const word = 'x'.repeat(200);
const wrapped = layoutHubHeader(font(7), 'Terminal', word, 320, 18);
assert.equal(wrapped.lines.join(''), word);