Adjust UI to account for user-configured variable font size

This commit is contained in:
James Babcock committed 2026-08-19 20:48:18 -07:00
1 parent 96842ceb23
commit eef9fbaab4
25 files changed
+350 -222

No files matched your search

+6 -5
View File
@@ -3,6 +3,7 @@ import { type BdfFont } from "../../graphics/bdffont";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { GESTURE_DOUBLE_CLICK } from "../gestures";
import { drawSelectionHighlight } from "../menu";
import { listRowHeight } from "../metrics";
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
import { wrapText, truncateText } from "../../graphics/textwrap";
import { MIN_WINDOW_HEIGHT, minWindowTop } from "./geometry";
@@ -14,7 +15,6 @@ const DIALOG_W = G2_LENS_WIDTH - 80;
const DIALOG_MARGIN_Y = 24;
const DIALOG_H = MIN_WINDOW_HEIGHT - 2 * DIALOG_MARGIN_Y;
const TEXT_MAX_WIDTH = DIALOG_W - 32;
const MENU_ROW_H = 20;
const MENU_ROWS = 2;
/** Dialog top edge; band-relative, so computed per paint. */
@@ -89,6 +89,7 @@ export class AssistantLayer implements Layer {
paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage {
const font = getDefaultSmallFont();
const menuRowH = listRowHeight(font);
const image = paintBelow();
const top = dialogY();
@@ -105,7 +106,7 @@ export class AssistantLayer implements Layer {
}
const inMenu = this.phase !== "thinking";
const textBottom = inMenu ? top + DIALOG_H - MENU_ROWS * MENU_ROW_H - 8 : top + DIALOG_H - 8;
const textBottom = inMenu ? top + DIALOG_H - MENU_ROWS * menuRowH - 8 : top + DIALOG_H - 8;
const textTop = top + 56;
const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0);
@@ -118,12 +119,12 @@ export class AssistantLayer implements Layer {
if (inMenu) {
const rows = ["Follow-up", "Done"];
const menuTop = top + DIALOG_H - MENU_ROWS * MENU_ROW_H - 2;
const menuTop = top + DIALOG_H - MENU_ROWS * menuRowH - 2;
for (let i = 0; i < rows.length; i++) {
const rowY = menuTop + i * MENU_ROW_H;
const rowY = menuTop + i * menuRowH;
const selected = i === this.menuIndex;
if (selected) {
drawSelectionHighlight(image, left - 4, rowY - 2, DIALOG_W - 24, MENU_ROW_H - 2, true, 6);
drawSelectionHighlight(image, left - 4, rowY - 2, DIALOG_W - 24, menuRowH - 2, true, 6);
}
image.drawText(font, left + 4, rowY + 2, rows[i]!, selected ? 255 : 200);
}
+1 -1
View File
@@ -166,7 +166,7 @@ class ShellAlertLayer implements Layer {
image.drawTextWrapped({
font,
x: ALERT_X + 16,
y: alertY + 34,
y: alertY + 18 + font.lineHeight + 4,
width: ALERT_W - 32,
text: this.text,
value: 235,
+4 -3
View File
@@ -6,6 +6,7 @@ import type { ToolDebugEntry } from "../../assistant/tool-registry";
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "../layers";
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
import { MIN_WINDOW_HEIGHT, minWindowTop, SIDEBAR_WIDTH, TOP_BAR_HEIGHT } from "./geometry";
import { lineStep } from "../metrics";
/**
* Shell-overlay debug dialog (escape menu > Debug): lists the voice assistant
@@ -26,7 +27,6 @@ function dialogY(): number {
return minWindowTop() + TOP_BAR_HEIGHT + 8;
}
const DETAIL_PADDING = 14;
const DETAIL_LINE_HEIGHT = 14;
export class ToolDebugMenuLayer extends MenuLayer {
constructor(appId: string | null, entries: ToolDebugEntry[], private readonly onClosed: () => void) {
@@ -85,13 +85,14 @@ class ToolDetailLayer implements Layer {
const textX = DIALOG_X + DETAIL_PADDING;
const textWidth = DETAIL_WIDTH - 2 * DETAIL_PADDING - 8;
const lines = this.buildLines(textWidth);
const visibleRowCount = Math.max(1, ((DETAIL_HEIGHT - 2 * DETAIL_PADDING) / DETAIL_LINE_HEIGHT) | 0);
const detailLineH = lineStep(font);
const visibleRowCount = Math.max(1, ((DETAIL_HEIGHT - 2 * DETAIL_PADDING) / detailLineH) | 0);
this.scrollRow = clamp(this.scrollRow, 0, Math.max(0, lines.length - visibleRowCount));
const lastVisibleRow = Math.min(lines.length, this.scrollRow + visibleRowCount);
for (let index = this.scrollRow; index < lastVisibleRow; index++) {
const line = lines[index]!;
const y = top + DETAIL_PADDING + (index - this.scrollRow) * DETAIL_LINE_HEIGHT;
const y = top + DETAIL_PADDING + (index - this.scrollRow) * detailLineH;
image.drawText(font, textX, y, line.text, line.value);
}
if (lines.length > visibleRowCount) {
+6 -5
View File
@@ -7,6 +7,7 @@ import { refineDictation, type AnthropicStreamHandle } from "../../native/anthro
import { anthropicApiKeySetting } from "../dashboard-settings";
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, gestureHints } from "../gestures";
import { drawSelectionHighlight } from "../menu";
import { listRowHeight } from "../metrics";
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
import { MIN_WINDOW_HEIGHT, minWindowTop } from "./geometry";
@@ -22,7 +23,6 @@ const TEXT_MAX_WIDTH = DIALOG_W - 32;
function dialogY(): number {
return minWindowTop() + DIALOG_MARGIN_Y;
}
const MENU_ROW_H = 20;
// After the mic stops, the provider's final transcript can trail in (cloud
// commit round-trip); wait this long for it before refining with what we have.
const FOLLOWUP_FINALIZE_TIMEOUT_MS = 1200;
@@ -229,6 +229,7 @@ export class VoiceInputLayer implements Layer {
paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage {
const font = getDefaultSmallFont();
const menuRowH = listRowHeight(font);
const image = paintBelow();
const top = dialogY();
@@ -244,7 +245,7 @@ export class VoiceInputLayer implements Layer {
const inMenu = this.phase === "menu";
const rows = inMenu ? this.menuRows() : [];
// Reserve space for the actual number of rows this menu has.
const textBottom = inMenu ? top + DIALOG_H - rows.length * MENU_ROW_H - 8 : top + DIALOG_H - 8;
const textBottom = inMenu ? top + DIALOG_H - rows.length * menuRowH - 8 : top + DIALOG_H - 8;
const textTop = top + 56;
const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0);
@@ -256,12 +257,12 @@ export class VoiceInputLayer implements Layer {
}
if (inMenu) {
const menuTop = top + DIALOG_H - rows.length * MENU_ROW_H - 2;
const menuTop = top + DIALOG_H - rows.length * menuRowH - 2;
for (let i = 0; i < rows.length; i++) {
const rowY = menuTop + i * MENU_ROW_H;
const rowY = menuTop + i * menuRowH;
const selected = i === this.menuIndex;
if (selected) {
drawSelectionHighlight(image, left - 4, rowY - 2, DIALOG_W - 24, MENU_ROW_H - 2, true, 6);
drawSelectionHighlight(image, left - 4, rowY - 2, DIALOG_W - 24, menuRowH - 2, true, 6);
}
const row = rows[i]!;
image.drawText(font, left + 4, rowY + 2, row.label, row.dim ? 90 : selected ? 255 : 200);