diff --git a/app/ui/apps/assistant.ts b/app/ui/apps/assistant.ts index 8a88e5fb..54f73004 100644 --- a/app/ui/apps/assistant.ts +++ b/app/ui/apps/assistant.ts @@ -1,18 +1,26 @@ -import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; +import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont"; import { GESTURE_DOUBLE_CLICK } from "../gestures"; import { drawSelectionHighlight } from "../menu"; import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers"; import { wrapText, truncateText } from "../../graphics/textwrap"; +import { MIN_WINDOW_HEIGHT, minWindowTop } from "../shell/geometry"; const DIALOG_X = 40; -const DIALOG_Y = 40; const DIALOG_W = G2_LENS_WIDTH - 80; -const DIALOG_H = G2_LENS_HEIGHT - 80; +// The dialog fits inside the min-height window band (like the other shell +// overlays), wherever the vertical position setting puts it. +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. */ +function dialogY(): number { + return minWindowTop() + DIALOG_MARGIN_Y; +} + /** thinking: turn running; done/error: finished, showing the Follow-up/Done menu. */ type AssistantPhase = "thinking" | "done" | "error"; @@ -81,22 +89,23 @@ export class AssistantLayer implements Layer { paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { const font = getDefaultSmallFont(); const image = paintBelow(); + const top = dialogY(); // Solid dialog box (fill 1, matching the voice dialog: opaque after 4bpp // quantization, but not the color-key transparent 0). - image.fillRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 1, 10); - image.drawRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 90, 10); + image.fillRoundedRect(DIALOG_X, top, DIALOG_W, DIALOG_H, 1, 10); + image.drawRoundedRect(DIALOG_X, top, DIALOG_W, DIALOG_H, 90, 10); const left = DIALOG_X + 16; - image.drawText(font, left, DIALOG_Y + 12, this.phase === "thinking" ? "Assistant ●" : "Assistant", 220); + image.drawText(font, left, top + 12, this.phase === "thinking" ? "Assistant ●" : "Assistant", 220); if (this.status) { const statusValue = this.phase === "error" ? 200 : 130; - image.drawText(font, left, DIALOG_Y + 30, truncateText(font, this.status, TEXT_MAX_WIDTH), statusValue); + image.drawText(font, left, top + 30, truncateText(font, this.status, TEXT_MAX_WIDTH), statusValue); } const inMenu = this.phase !== "thinking"; - const textBottom = inMenu ? DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 8 : DIALOG_Y + DIALOG_H - 8; - const textTop = DIALOG_Y + 56; + const textBottom = inMenu ? top + DIALOG_H - MENU_ROWS * MENU_ROW_H - 8 : top + DIALOG_H - 8; + const textTop = top + 56; const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0); const wrapped = wrapText(font, this.replyText, TEXT_MAX_WIDTH); @@ -108,7 +117,7 @@ export class AssistantLayer implements Layer { if (inMenu) { const rows = ["Follow-up", "Done"]; - const menuTop = DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 2; + const menuTop = top + DIALOG_H - MENU_ROWS * MENU_ROW_H - 2; for (let i = 0; i < rows.length; i++) { const rowY = menuTop + i * MENU_ROW_H; const selected = i === this.menuIndex; @@ -118,7 +127,7 @@ export class AssistantLayer implements Layer { image.drawText(font, left + 4, rowY + 2, rows[i]!, selected ? 255 : 200); } } else { - image.drawText(font, left, DIALOG_Y + DIALOG_H - 14, `${GESTURE_DOUBLE_CLICK} cancel`, 110); + image.drawText(font, left, top + DIALOG_H - 14, `${GESTURE_DOUBLE_CLICK} cancel`, 110); } return image; } diff --git a/app/ui/apps/voice-input.ts b/app/ui/apps/voice-input.ts index 46b50210..2274c9e5 100644 --- a/app/ui/apps/voice-input.ts +++ b/app/ui/apps/voice-input.ts @@ -1,4 +1,4 @@ -import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; +import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; import { wrapText, truncateText } from "../../graphics/textwrap"; import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont"; import { voiceControlBridge, type VoiceTranscriptEvent } from "../../native/voice-control"; @@ -7,12 +7,20 @@ import { anthropicApiKeySetting } from "../dashboard-settings"; import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, gestureHints } from "../gestures"; import { drawSelectionHighlight } from "../menu"; import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers"; +import { MIN_WINDOW_HEIGHT, minWindowTop } from "../shell/geometry"; const DIALOG_X = 40; -const DIALOG_Y = 40; const DIALOG_W = G2_LENS_WIDTH - 80; -const DIALOG_H = G2_LENS_HEIGHT - 80; +// The dialog fits inside the min-height window band (like the other shell +// overlays), wherever the vertical position setting puts it. +const DIALOG_MARGIN_Y = 24; +const DIALOG_H = MIN_WINDOW_HEIGHT - 2 * DIALOG_MARGIN_Y; const TEXT_MAX_WIDTH = DIALOG_W - 32; + +/** Dialog top edge; band-relative, so computed per paint. */ +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. @@ -221,21 +229,22 @@ export class VoiceInputLayer implements Layer { paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { const font = getDefaultSmallFont(); const image = paintBelow(); + const top = dialogY(); // Solid dialog box over the underlying UI. Fill 1, not 0: identical after // 4bpp quantization, but 0 is transparent on the color-key shell surface. - image.fillRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 1, 10); - image.drawRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 90, 10); + image.fillRoundedRect(DIALOG_X, top, DIALOG_W, DIALOG_H, 1, 10); + image.drawRoundedRect(DIALOG_X, top, DIALOG_W, DIALOG_H, 90, 10); const left = DIALOG_X + 16; - image.drawText(font, left, DIALOG_Y + 12, this.capturing ? "Voice ●" : "Voice", 220); - image.drawText(font, left, DIALOG_Y + 30, truncateText(font, this.status, TEXT_MAX_WIDTH), 130); + image.drawText(font, left, top + 12, this.capturing ? "Voice ●" : "Voice", 220); + image.drawText(font, left, top + 30, truncateText(font, this.status, TEXT_MAX_WIDTH), 130); const inMenu = this.phase === "menu"; const rows = inMenu ? this.menuRows() : []; // Reserve space for the actual number of rows this menu has. - const textBottom = inMenu ? DIALOG_Y + DIALOG_H - rows.length * MENU_ROW_H - 8 : DIALOG_Y + DIALOG_H - 8; - const textTop = DIALOG_Y + 56; + const textBottom = inMenu ? top + DIALOG_H - rows.length * MENU_ROW_H - 8 : top + DIALOG_H - 8; + const textTop = top + 56; const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0); const text = this.displayText() || this.placeholderText(); @@ -246,7 +255,7 @@ export class VoiceInputLayer implements Layer { } if (inMenu) { - const menuTop = DIALOG_Y + DIALOG_H - rows.length * MENU_ROW_H - 2; + const menuTop = top + DIALOG_H - rows.length * MENU_ROW_H - 2; for (let i = 0; i < rows.length; i++) { const rowY = menuTop + i * MENU_ROW_H; const selected = i === this.menuIndex; @@ -257,7 +266,7 @@ export class VoiceInputLayer implements Layer { image.drawText(font, left + 4, rowY + 2, row.label, row.dim ? 90 : selected ? 255 : 200); } } else { - image.drawText(font, left, DIALOG_Y + DIALOG_H - 14, this.hintText(), 110); + image.drawText(font, left, top + DIALOG_H - 14, this.hintText(), 110); } return image; } diff --git a/app/ui/shell/chrome-layer.ts b/app/ui/shell/chrome-layer.ts index 75d65de5..a4d21b60 100644 --- a/app/ui/shell/chrome-layer.ts +++ b/app/ui/shell/chrome-layer.ts @@ -12,6 +12,8 @@ import { MIN_WINDOW_HEIGHT, minWindowTop, SHELL_OPAQUE_BLACK, + SIDEBAR_COLUMN_WIDTH, + SIDEBAR_COLUMNS, SIDEBAR_WIDTH, TOP_BAR_HEIGHT, windowTop, @@ -19,7 +21,9 @@ import { } from "./geometry"; const ICON_SIZE = 32; -const ICON_MARGIN_X = ((SIDEBAR_WIDTH - ICON_SIZE) / 2) | 0; +const ICON_MARGIN_X = ((SIDEBAR_COLUMN_WIDTH - ICON_SIZE) / 2) | 0; +/** Column index of the rightmost sidebar column (the one that fills first). */ +const FIRST_COLUMN = SIDEBAR_COLUMNS - 1; const ICON_SPACING = 8; const NOTIFICATION_ICON_SIZE = 24; const BORDER_VALUE = 40; @@ -121,43 +125,61 @@ export class ShellChromeLayer implements Layer { image.fillRect(0, bandTop, SIDEBAR_WIDTH, MIN_WINDOW_HEIGHT, SHELL_OPAQUE_BLACK); // Scroll the icon list to keep the selection visible; chevrons mark - // windows off-screen above/below. + // windows off-screen above/below. Icons fill the right column top to + // bottom, then overflow into the left one, so a visible slot's column is + // decided by its position within the scrolled window. const listTop = bandTop + TOP_BAR_HEIGHT + 10; const itemStride = ICON_SIZE + ICON_SPACING; const listHeight = bandBottom - listTop - 10; - const visibleCount = Math.max(1, ((listHeight + ICON_SPACING) / itemStride) | 0); + const rowsPerColumn = Math.max(1, ((listHeight + ICON_SPACING) / itemStride) | 0); + const visibleCount = rowsPerColumn * SIDEBAR_COLUMNS; const count = state.windows.length; this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, visibleCount, count); const lastVisible = Math.min(count, this.scrollRow + visibleCount); + const slotOf = (index: number) => { + const position = index - this.scrollRow; + const columnsFromRight = (position / rowsPerColumn) | 0; + return { + column: FIRST_COLUMN - columnsFromRight, + y: listTop + (position % rowsPerColumn) * itemStride, + }; + }; // The selection is a "diversion" of the sidebar/main separator line: the // line bulges right around the selected icon (rounded on the left, open // to the main area on the right), so the separator is drawn with a gap // there. When the sidebar has focus, the diversion is filled white and - // the icon drawn inverted. + // the icon drawn inverted. Only the right column touches the separator; + // a selected overflow icon gets a self-contained box instead. const sep = SIDEBAR_WIDTH - 1; const selVisible = state.selectedIndex >= this.scrollRow && state.selectedIndex < lastVisible; - const selTabTop = selVisible ? listTop + (state.selectedIndex - this.scrollRow) * itemStride - 2 : 0; - const selTabBottom = selTabTop + ICON_SIZE + 4; - if (selVisible) { + const selSlot = selVisible ? slotOf(state.selectedIndex) : null; + const selTabTop = selSlot && selSlot.column === FIRST_COLUMN ? selSlot.y - 2 : null; + if (selTabTop !== null) { image.drawLine(sep, bandTop, sep, selTabTop, BORDER_VALUE); - image.drawLine(sep, selTabBottom, sep, bandBottom - 1, BORDER_VALUE); + image.drawLine(sep, selTabTop + ICON_SIZE + 4, sep, bandBottom - 1, BORDER_VALUE); } else { image.drawLine(sep, bandTop, sep, bandBottom - 1, BORDER_VALUE); } for (let index = this.scrollRow; index < lastVisible; index++) { const window = state.windows[index]!; - const y = listTop + (index - this.scrollRow) * itemStride; + const { column, y } = slotOf(index); + const columnLeft = column * SIDEBAR_COLUMN_WIDTH; + const x = columnLeft + ICON_MARGIN_X; const selected = index === state.selectedIndex; const focused = selected && state.focus === "sidebar"; - if (selected) { - drawSelectionTab(image, y - 2, y + ICON_SIZE + 2, focused); + if (selected && column === FIRST_COLUMN) { + drawSelectionTab(image, columnLeft, y - 2, y + ICON_SIZE + 2, focused); + } else if (selected) { + // Spans the full column: only 2px of margin flanks a 32px icon in a + // 36px column, so anything wider would clip at the screen edge. + drawSelectionBox(image, columnLeft, y - 2, SIDEBAR_COLUMN_WIDTH, ICON_SIZE + 4, focused); } - window.drawIcon(image, ICON_MARGIN_X, y, ICON_SIZE, focused); + window.drawIcon(image, x, y, ICON_SIZE, focused); if (window.attention) { // Black dot on the white focused tab, white dot otherwise. - image.fillRoundedRect(ICON_MARGIN_X + ICON_SIZE - 7, y - 1, 8, 8, focused ? SHELL_OPAQUE_BLACK : 255, 4); + image.fillRoundedRect(x + ICON_SIZE - 7, y - 1, 8, 8, focused ? SHELL_OPAQUE_BLACK : 255, 4); } } @@ -277,26 +299,40 @@ const TAB_EXTEND = 1; const TAB_STROKE = 150; /** - * Draw the selection "diversion" of the separator line around a sidebar icon: - * rounded on the left, square and open on the right, extending a few px past - * the separator into the main area. Focused = filled white; otherwise an - * outline. + * Draw the selection "diversion" of the separator line around a sidebar icon + * in the rightmost column: rounded on the left, square and open on the right, + * extending a few px past the separator into the main area. Focused = filled + * white; otherwise an outline. `left` is the column's left edge, which the + * rounded corners curve in from. */ -function drawSelectionTab(image: GrayImage, top: number, bottom: number, focused: boolean): void { +function drawSelectionTab(image: GrayImage, left: number, top: number, bottom: number, focused: boolean): void { const right = SIDEBAR_WIDTH - 1 + TAB_EXTEND; if (focused) { for (let yy = top; yy < bottom; yy++) { - const inset = tabLeftInset(yy, top, bottom, TAB_RADIUS); - image.fillRect(inset, yy, right - inset + 1, 1, 255); + const x = left + tabLeftInset(yy, top, bottom, TAB_RADIUS); + image.fillRect(x, yy, right - x + 1, 1, 255); } return; } // Outline: curved left edge (per-row) plus straight top and bottom edges. for (let yy = top; yy < bottom; yy++) { - image.setPixel(tabLeftInset(yy, top, bottom, TAB_RADIUS), yy, TAB_STROKE); + image.setPixel(left + tabLeftInset(yy, top, bottom, TAB_RADIUS), yy, TAB_STROKE); + } + image.drawLine(left + tabLeftInset(top, top, bottom-1, TAB_RADIUS), top, right, top, TAB_STROKE); + image.drawLine(left + tabLeftInset(bottom-1, top, bottom-1, TAB_RADIUS), bottom-1, right, bottom-1, TAB_STROKE); +} + +/** + * Selection marker for an overflow-column icon, which has no separator to + * divert: a self-contained rounded box, filled white when the sidebar has + * focus and outlined otherwise (matching the tab's two states). + */ +function drawSelectionBox(image: GrayImage, x: number, y: number, width: number, height: number, focused: boolean): void { + if (focused) { + image.fillRoundedRect(x, y, width, height, 255, TAB_RADIUS); + } else { + image.drawRoundedRect(x, y, width, height, TAB_STROKE, TAB_RADIUS); } - image.drawLine(tabLeftInset(top, top, bottom-1, TAB_RADIUS), top, right, top, TAB_STROKE); - image.drawLine(tabLeftInset(bottom-1, top, bottom-1, TAB_RADIUS), bottom-1, right, bottom-1, TAB_STROKE); } /** Left boundary x of the tab at row yy: 0 in the middle, curving to the rounded left corners. */ diff --git a/app/ui/shell/geometry.ts b/app/ui/shell/geometry.ts index 2b3580de..a869d477 100644 --- a/app/ui/shell/geometry.ts +++ b/app/ui/shell/geometry.ts @@ -3,8 +3,15 @@ import { verticalPositionSetting } from "../dashboard-settings"; /** Top bar: 24px notification icons plus a little padding. */ export const TOP_BAR_HEIGHT = 28; -/** Left sidebar: 32px window icons plus a little padding. */ -export const SIDEBAR_WIDTH = 36; +/** One sidebar column: 32px window icons plus a little padding. */ +export const SIDEBAR_COLUMN_WIDTH = 36; +/** + * Sidebar icon columns. The right column (against the app area) fills first; + * windows past that overflow into the left column, so the common few-window + * case keeps every icon next to the content it belongs to. + */ +export const SIDEBAR_COLUMNS = 2; +export const SIDEBAR_WIDTH = SIDEBAR_COLUMN_WIDTH * SIDEBAR_COLUMNS; /** * On the color-key shell surface, pixel value 0 is transparent; 1 is the