forked from Blendman974/faceclaw
<details>
<summary>Prompts Used</summary> Act as a code reviewer for https://github.com/jimrandomh/faceclaw/pull/14 (checked out in this working directory). > * The review finished — 42 raw candidates were verified down to 10 confirmed findings. Reporting them now. > > * Code review(review · 10 findings) > ⎿ app/phone-ui/main-view-model.ts > ● 766 [correctness] mirrorFraction subtracts view.getLocationOnScreen() from tap coordinates that NativeScript already delivers > view-local, so every phone-mirror tap is shifted up/left and misroutes > ● 84 [resource-leak] MainViewModel's constructor registers onAnySettingChanged and discards the unsubscriber; a new view model is > built on every page navigation, leaking listeners and retained preview bitmaps > wear/app/src/main/kotlin/com/faceclaw/wear/MainActivity.kt > ● 52 [correctness] onStop abandons an in-progress stem-button hold without sending LONG_PRESS_RELEASE, so the glasses shell > escape menu opens by itself > wear/app/src/main/kotlin/com/faceclaw/wear/ui/TouchpadGestures.kt > ● 62 [correctness] Breaking out of the touchpad gesture loop on a consumed pointer event (or coroutine cancellation mid-hold) > skips onLongPressEnd, leaving a stuck long-press > wear/app/src/main/kotlin/com/faceclaw/wear/PhoneLink.kt > ● 270 [correctness] loadStateItem queries the Data Layer with a hostless Uri (`wear:/faceclaw/state`), which matches no stored > items, so the cached phone state is never read > app/ui/shell/modal-layer.ts > ● 14 [correctness] MODAL_INTERIOR is a module-level constant frozen at import time from the (now runtime-dynamic) display mode, > while modalRect() is computed live, so modals render corrupted after a display-mode switch > app/g2/dashboard-controller.ts > ● 1404 [correctness] handleMirrorTouch wakes the glasses display unconditionally, bypassing the watchWakesDisplaySetting gate > that the parallel injectSyntheticRingInput path honors > ● 1440 [correctness] A mirror tap while any second layer is stacked (e.g. an in-window long-press menu) degrades to a blind > synthetic click that activates whatever is highlighted, not what was tapped > App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawWearBridge.java > ● 147 [correctness] Watch gestures/commands queued while the JS listener is down are replayed up to 30 seconds later on listener > registration, executing stale non-idempotent input the watch already reported as failed > wear/app/src/main/kotlin/com/faceclaw/wear/ui/RemoteScreen.kt > ● 232 [efficiency] WristTwistDetector (gyroscope, default-on) samples at 100 Hz via DisposableEffect and is not stopped when > the activity stops, draining the watch battery while the process is cached > > * Review of PR #14 (Wear OS companion app + remote controls, 85 files, +5813/−102) is done — 10 confirmed findings reported above, ranked by > severity. The headline items are the phone-mirror tap coordinate double-correction (which misroutes every mirror tap in the default > configuration) and two independent paths on the watch that can drop LONG_PRESS_RELEASE, each of which makes the shell escape menu open on the > glasses by itself. > > A few things beyond the reported list, for context: > > Refuted during verification (looked like bugs, aren't): the watch ack-timeout-during-render theory (input injection never blocks on BLE > transmit), mirror swipes stealing page scroll (no enclosing ScrollView), and a suspected raw-settings-key notification gap (the store-level > broadcast covers raw keys). > > Confirmed but below the 10-finding cap — worth folding in if you're touching those areas anyway: > - shell.closeAssistant() no-ops via popIfTop when another layer sits above the assistant, yet still acks ok to the watch. > - Landscape preview sizing still assumes the old 260-wide panel after the XML moved to 360 (overlap under ~568 dip). > - The shell escape menu and tool-debug dialogs hardcode SIDEBAR_WIDTH + 8, wrong in the new full-panel mode. > - A CapabilityClient IPC fires every 250 ms during streamed assistant replies even on watchless phones; backgrounded preview updates bypass > their 150 ms floor. > - Cleanups: the sidebarWidth() > 0 || focus === "sidebar" predicate appears three times, sidebar slot math is duplicated in chrome-layer.ts, > dead protocol-version plumbing, dead padPointers field, and display-mode is missing from wear/PROTOCOL.md. > > If you'd like, I can apply fixes for any subset of these, or post the findings as inline PR comments (/code-review 14 --comment). <hr> Thanks, let's go ahead and write fixes for all of the issues you described. > Everything builds and tests pass. All 16 issues from the review are fixed — the 10 reported findings plus the six below-cap items. Here's what changed, by fix: > > **Watch app (Kotlin)** > - **Stuck long-press via onStop** — `MainActivity.onStop` now sends `LONG_PRESS_RELEASE` when a stem hold is in progress before dropping the link, so the phone's escape-menu countdown can't run to completion on its own. > - **Stuck long-press via the gesture loop** — `detectTouchpadGestures` wraps the loop in try/finally that pairs every `onLongPressStart` with an `onLongPressEnd`, covering both the consumed-event `break` and coroutine cancellation mid-hold. > - **Cached state never loading** — `PhoneLink.loadStateItem` now queries `wear://*/faceclaw/state` (wildcard host) instead of a hostless Uri that matched nothing, so the watch shows the cached dashboard state when the phone is unreachable. > - **Sensors draining battery while stopped** — the gyroscope/accelerometer/off-body detectors are now driven by a `WhileStartedEffect` helper tied to the activity lifecycle: they stop on `ON_STOP` (palmed screen, back to watch face) and restart on `ON_START`, instead of running at 100 Hz for as long as the process is cached. > - **Dead protocol plumbing** — removed the unused `Protocol.PROTOCOL_VERSION` const and the never-read `PhoneState.protocol` field; the wire field stays and PROTOCOL.md now documents it as reserved. > > **Phone Java** > - **Stale input replay** — `FaceclawWearBridge` now queues only idempotent `/faceclaw/state/request` messages for replay after the JS listener registers; gestures and commands that arrived while the dashboard was down are acked as failed and dropped, never executed up to 30 seconds later. > > **Phone TypeScript** > - **Mirror taps misrouting (the top finding)** — `mirrorFraction` no longer subtracts `getLocationOnScreen()`; NativeScript's `getX`/`getY` are view-local DIPs (I verified this in the installed `@nativescript/core` gesture source), so every mirror tap was being shifted up-left by the status bar + action bar. Taps now land where you touch. > - **Mirror touch ignoring the wake setting** — `handleMirrorTouch` now honours `watchWakesDisplaySetting`: with it off, only a double-tap reaches a dark display, matching the rest of the watch scheme. > - **Blind click through open menus** — `LayerStack.hitTest` now consumes a mirror tap when any layer is stacked (menu, dialog) instead of reporting a miss, so a tap on visible app content can no longer activate whatever menu row happened to be highlighted (e.g. "Close window"). > - **Modal corruption after display-mode switch** — `MODAL_INTERIOR` is now a live `modalInterior()` function, and `ShellModalLayer.paint` re-syncs the inner stack's size each paint, so notification modals render correctly after switching Band ↔ Full panel. > - **View-model leak** — `MainViewModel` keeps its controller/settings unsubscribers and exposes `attach()`/`dispose()`; `main-page.ts` disposes on unload and re-attaches on load (re-attach is needed because suspend/resume fires unloaded/loaded without a navigation, and `subscribe` delivers a fresh snapshot so nothing is missed). > - **`closeAssistant` no-op** — new `LayerStack.popThrough` closes the assistant overlay plus anything stacked above it (follow-up voice dialog, alert); the watch ack now says "The assistant was not open." when there was nothing to close. > - **Watchless-phone IPC churn** — assistant stream events and alerts are skipped when no watch is reachable, so a streaming reply no longer triggers a CapabilityClient lookup every 250 ms. > - **Backgrounded preview floor bypass** — the 150 ms floor check (and timestamp) in `updateCompositePreview` now runs before the foreground-activity check, so backgrounded per-frame refreshes actually throttle. > - **Full-panel hardcodes** — the shell escape menu and tool-debug dialogs position at `sidebarWidth() + 8` (0 in full-panel mode) instead of the fixed 64 px strip. > - **Cleanups** — the strip-visible predicate is now one `sidebarStripVisible()` helper in geometry.ts (used in three places); sidebar slot math is a single `slotPosition()` shared by drawing and hit-testing; dead `padPointers` removed; landscape preview sizing updated to the XML's 360 dp panel; `wear/PROTOCOL.md` documents the `display-mode` command and `displayMode` state field. > > Verification: `./build.sh` (webpack + Gradle) succeeds, `npx tsc --noEmit` is clean, the wear `:app:assembleDebug` builds, and all 59 tests pass. The behavioral fixes — especially mirror-tap coordinates, the two long-press-release paths, and the watch state cache — still need a hardware pass to confirm on device. </details>
This commit is contained in:
1 parent
646335cb64
commit
eef7aa2679
17 files changed
+306
-158
No files matched your search
+23
-2
@@ -238,6 +238,21 @@ export class LayerStack {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop layers down to and including the given one, wherever it sits in the
|
||||
* stack (e.g. dismissing the assistant while a follow-up voice dialog is
|
||||
* open above it). Returns false if the layer isn't stacked (the base layer
|
||||
* can never be popped). Removal callbacks fire top-down.
|
||||
*/
|
||||
popThrough(layer: Layer): boolean {
|
||||
const index = this.layers.indexOf(layer);
|
||||
if (index <= 0) return false;
|
||||
for (const removed of this.layers.splice(index).reverse()) {
|
||||
notifyRemoved(removed);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
isAtBase(): boolean {
|
||||
return this.layers.length === 1;
|
||||
}
|
||||
@@ -271,9 +286,15 @@ export class LayerStack {
|
||||
await top.handleInput(delivered, this.ctx);
|
||||
}
|
||||
|
||||
/** Pass a mirror touch to the base layer when nothing is stacked on it. */
|
||||
/**
|
||||
* Pass a mirror touch to the base layer when nothing is stacked on it.
|
||||
* With a layer stacked (a menu, a dialog) the touch is consumed without
|
||||
* acting: positions mean nothing to the overlay, and falling back to a
|
||||
* blind synthetic click would activate whatever happens to be highlighted
|
||||
* rather than what was tapped.
|
||||
*/
|
||||
async hitTest(x: number, y: number): Promise<boolean> {
|
||||
if (this.layers.length !== 1) return false;
|
||||
if (this.layers.length !== 1) return true;
|
||||
const base = this.layers[0]!;
|
||||
if (!base.hitTest) return false;
|
||||
return await base.hitTest(x, y, this.ctx);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
minWindowTop,
|
||||
SHELL_OPAQUE_BLACK,
|
||||
SIDEBAR_WIDTH,
|
||||
sidebarWidth,
|
||||
sidebarStripVisible,
|
||||
TOP_BAR_HEIGHT,
|
||||
windowTop,
|
||||
type WindowHeightMode,
|
||||
@@ -51,6 +51,25 @@ function columnLeft(variant: SidebarVariant, column: number): number {
|
||||
return SIDEBAR_WIDTH - (variant.columns - column) * variant.columnWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Column and top y of a visible sidebar slot; `position` counts from the
|
||||
* first visible (scrolled-to) icon. Slots fill the rightmost column top to
|
||||
* bottom, then overflow leftward. The single source of slot geometry for
|
||||
* both drawing and hit testing.
|
||||
*/
|
||||
function slotPosition(variant: SidebarVariant, listTop: number, position: number): { column: number; y: number } {
|
||||
const rows = rowsPerColumn(variant);
|
||||
return {
|
||||
column: variant.columns - 1 - ((position / rows) | 0),
|
||||
y: listTop + (position % rows) * (variant.iconSize + ICON_SPACING),
|
||||
};
|
||||
}
|
||||
|
||||
/** Top y of the sidebar's icon list (below the band's top bar). */
|
||||
function sidebarListTop(): number {
|
||||
return minWindowTop() + TOP_BAR_HEIGHT + LIST_MARGIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Left edge of the sidebar region that actually holds icons: the one-column
|
||||
* variant leaves a dead strip left of its single right-aligned column.
|
||||
@@ -169,7 +188,7 @@ export class ShellChromeLayer implements Layer {
|
||||
const state = this.getState();
|
||||
// Full-panel mode: the strip is an overlay, present only while the user
|
||||
// is in it (the window underneath keeps its full width the rest of the time).
|
||||
if (sidebarWidth() > 0 || state.focus === "sidebar") {
|
||||
if (sidebarStripVisible(state.focus)) {
|
||||
this.drawSidebar(image, state);
|
||||
}
|
||||
this.drawTopBar(image, state);
|
||||
@@ -189,14 +208,10 @@ export class ShellChromeLayer implements Layer {
|
||||
windowIndexAt(x: number, y: number, windowCount: number): number | null {
|
||||
if (x < 0 || x >= SIDEBAR_WIDTH || windowCount === 0) return null;
|
||||
const variant = sidebarVariant(windowCount);
|
||||
const rows = rowsPerColumn(variant);
|
||||
const listTop = minWindowTop() + TOP_BAR_HEIGHT + LIST_MARGIN;
|
||||
const itemStride = variant.iconSize + ICON_SPACING;
|
||||
const lastVisible = Math.min(windowCount, this.scrollRow + rows * variant.columns);
|
||||
const listTop = sidebarListTop();
|
||||
const lastVisible = Math.min(windowCount, this.scrollRow + rowsPerColumn(variant) * variant.columns);
|
||||
for (let index = this.scrollRow; index < lastVisible; index++) {
|
||||
const position = index - this.scrollRow;
|
||||
const column = variant.columns - 1 - ((position / rows) | 0);
|
||||
const slotY = listTop + (position % rows) * itemStride;
|
||||
const { column, y: slotY } = slotPosition(variant, listTop, index - this.scrollRow);
|
||||
const left = columnLeft(variant, column);
|
||||
if (x >= left && x < left + variant.columnWidth && y >= slotY - 2 && y < slotY + variant.iconSize + 2) {
|
||||
return index;
|
||||
@@ -223,20 +238,11 @@ export class ShellChromeLayer implements Layer {
|
||||
const iconMarginX = ((variant.columnWidth - iconSize) / 2) | 0;
|
||||
// Column index of the rightmost column (the one that fills first).
|
||||
const firstColumn = variant.columns - 1;
|
||||
const listTop = bandTop + TOP_BAR_HEIGHT + LIST_MARGIN;
|
||||
const itemStride = iconSize + ICON_SPACING;
|
||||
const rows = rowsPerColumn(variant);
|
||||
const visibleCount = rows * variant.columns;
|
||||
const listTop = sidebarListTop();
|
||||
const visibleCount = rowsPerColumn(variant) * variant.columns;
|
||||
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 / rows) | 0;
|
||||
return {
|
||||
column: firstColumn - columnsFromRight,
|
||||
y: listTop + (position % rows) * itemStride,
|
||||
};
|
||||
};
|
||||
const slotOf = (index: number) => slotPosition(variant, listTop, index - this.scrollRow);
|
||||
|
||||
// The selection is a "diversion" of the sidebar/main separator line: the
|
||||
// line bulges right around the selected icon (rounded on the left, open
|
||||
@@ -297,7 +303,7 @@ export class ShellChromeLayer implements Layer {
|
||||
const barTop = windowTop(state.foregroundHeightMode);
|
||||
// The bar spans the app viewport; with the sidebar overlaid (full-panel
|
||||
// mode, sidebar focused) it still starts past the strip.
|
||||
const barLeft = sidebarWidth() > 0 || state.focus === "sidebar" ? SIDEBAR_WIDTH : 0;
|
||||
const barLeft = sidebarStripVisible(state.focus) ? SIDEBAR_WIDTH : 0;
|
||||
image.fillRect(barLeft, barTop, G2_LENS_WIDTH - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
||||
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, G2_LENS_WIDTH - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
|
||||
|
||||
|
||||
@@ -26,6 +26,14 @@ export function sidebarWidth(): number {
|
||||
return displayMode() === "640x480" ? 0 : SIDEBAR_WIDTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the sidebar strip is on screen: always when it reserves width; in
|
||||
* the full-panel mode (where it overlays the window) only while it has focus.
|
||||
*/
|
||||
export function sidebarStripVisible(focus: "sidebar" | "window"): boolean {
|
||||
return sidebarWidth() > 0 || focus === "sidebar";
|
||||
}
|
||||
|
||||
/**
|
||||
* The height an app's requested mode actually gets: the band mode honours
|
||||
* it, the taller modes give every window the whole screen.
|
||||
|
||||
+19
-14
@@ -4,16 +4,20 @@ import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, Pai
|
||||
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
|
||||
// The modal covers most of the min-height app viewport, leaving a little of
|
||||
// the foreground app visible around the edges. Its size is fixed (min-height
|
||||
// windows have a fixed viewport size); its position follows the vertical
|
||||
// position setting, so it is computed per paint.
|
||||
// the foreground app visible around the edges. Both its size and position are
|
||||
// computed per paint: the display-mode setting changes the viewport size at
|
||||
// runtime, and the vertical position setting moves the band.
|
||||
const MODAL_MARGIN = 14;
|
||||
const MODAL_PADDING = 4;
|
||||
|
||||
export const MODAL_INTERIOR = {
|
||||
width: appViewportSize("min").width - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
height: appViewportSize("min").height - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
} as const;
|
||||
/** Content (inner layer stack) size of the modal box. */
|
||||
function modalInterior(): { width: number; height: number } {
|
||||
const viewport = appViewportSize("min");
|
||||
return {
|
||||
width: viewport.width - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
height: viewport.height - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
};
|
||||
}
|
||||
|
||||
/** Screen rect of the modal box, aligned to the min-height window band. */
|
||||
export function modalRect(): { x: number; y: number; width: number; height: number } {
|
||||
@@ -36,17 +40,18 @@ export class ShellModalLayer implements Layer {
|
||||
private readonly stack: LayerStack;
|
||||
|
||||
constructor(baseLayer: Layer, actions: LayerActions) {
|
||||
this.stack = new LayerStack(baseLayer, actions, {
|
||||
width: MODAL_INTERIOR.width,
|
||||
height: MODAL_INTERIOR.height,
|
||||
});
|
||||
this.stack = new LayerStack(baseLayer, actions, modalInterior());
|
||||
}
|
||||
|
||||
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
paint(_ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
const image = paintBelow();
|
||||
// Track a display-mode switch while the modal is up, so the inner stack
|
||||
// paints at the same size the box below is drawn with.
|
||||
const interior = modalInterior();
|
||||
this.stack.setBaseSize(interior);
|
||||
// Flattening bakes the inner stack's planes (glyphs included) so the blit
|
||||
// below transplants the finished modal content into this layer's plane.
|
||||
const inner = flattenPlanes(this.stack.paint(), MODAL_INTERIOR);
|
||||
const inner = flattenPlanes(this.stack.paint(), interior);
|
||||
const rect = modalRect();
|
||||
image.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, SHELL_OPAQUE_BLACK, 8);
|
||||
image.drawRoundedRect(rect.x, rect.y, rect.width, rect.height, 110, 8);
|
||||
@@ -54,7 +59,7 @@ export class ShellModalLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
async handleInput(event: DashboardInputEvent, _ctx: LayerContext): Promise<void> {
|
||||
await this.stack.handleInput(event);
|
||||
}
|
||||
}
|
||||
+16
-9
@@ -43,7 +43,7 @@ import { ToolDebugMenuLayer } from "./tool-debug-layer";
|
||||
import { toolRegistry } from "../../assistant/tool-registry";
|
||||
import {
|
||||
minWindowTop,
|
||||
SIDEBAR_WIDTH,
|
||||
sidebarWidth,
|
||||
TOP_BAR_HEIGHT,
|
||||
windowBandHeight,
|
||||
windowTop,
|
||||
@@ -157,9 +157,10 @@ const LONG_PRESS_ESCAPE_MENU_MS = 4000;
|
||||
class ShellOverlayMenuLayer extends MenuLayer {
|
||||
constructor(items: MenuItem[], private readonly onClosed: () => void) {
|
||||
// Aligned to the min-height window band (like the sidebar), wherever the
|
||||
// vertical position setting currently puts it.
|
||||
// vertical position setting currently puts it; past the sidebar strip
|
||||
// where one reserves width (none in the full-panel mode).
|
||||
super(null, items, {
|
||||
x: SIDEBAR_WIDTH + 8,
|
||||
x: sidebarWidth() + 8,
|
||||
y: minWindowTop() + TOP_BAR_HEIGHT + 8,
|
||||
width: 272,
|
||||
minHeight: 0,
|
||||
@@ -858,9 +859,12 @@ class Shell {
|
||||
}
|
||||
}
|
||||
|
||||
/** Dismiss the assistant overlay (cancelling any in-flight turn), as Done would. */
|
||||
closeAssistant(): void {
|
||||
this.closeAssistantLayer();
|
||||
/**
|
||||
* Dismiss the assistant overlay (cancelling any in-flight turn), as Done
|
||||
* would. Returns whether an overlay was actually open to close.
|
||||
*/
|
||||
closeAssistant(): boolean {
|
||||
return this.closeAssistantLayer();
|
||||
}
|
||||
|
||||
private ensureAssistantSession(): AssistantSession | null {
|
||||
@@ -998,13 +1002,16 @@ class Shell {
|
||||
this.config.requestShellRender();
|
||||
}
|
||||
|
||||
private closeAssistantLayer(): void {
|
||||
private closeAssistantLayer(): boolean {
|
||||
// Popping fires the layer's onRemoved, which cancels the turn and clears
|
||||
// this.assistantLayer.
|
||||
// this.assistantLayer. popThrough also closes anything stacked above the
|
||||
// overlay (a follow-up voice dialog, an alert), so a close command works
|
||||
// no matter what the conversation is showing.
|
||||
const layer = this.assistantLayer;
|
||||
if (layer) this.stack.popIfTop((top) => top === layer);
|
||||
const closed = layer ? this.stack.popThrough(layer) : false;
|
||||
this.noteUserActivity();
|
||||
this.config.requestShellRender();
|
||||
return closed;
|
||||
}
|
||||
|
||||
/** Show a brief text popup on the lenses (assistant show_alert / notices). */
|
||||
|
||||
@@ -5,7 +5,7 @@ import { clamp } from "../../util/numeric-util";
|
||||
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 { MIN_WINDOW_HEIGHT, minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { lineStep } from "../metrics";
|
||||
|
||||
/**
|
||||
@@ -15,13 +15,20 @@ import { lineStep } from "../metrics";
|
||||
* page with its full name, gating state, and description.
|
||||
*/
|
||||
|
||||
const DIALOG_X = SIDEBAR_WIDTH + 8;
|
||||
const DIALOG_WIDTH = 420;
|
||||
const DETAIL_WIDTH = G2_LENS_WIDTH - DIALOG_X - 8;
|
||||
// Shell overlays align to the min-height window band; the detail box fills
|
||||
// the band below the top bar with an 8px margin on each side.
|
||||
const DETAIL_HEIGHT = MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT - 16;
|
||||
|
||||
/** Dialog left edge: past the sidebar strip where one reserves width. */
|
||||
function dialogX(): number {
|
||||
return sidebarWidth() + 8;
|
||||
}
|
||||
|
||||
function detailWidth(): number {
|
||||
return G2_LENS_WIDTH - dialogX() - 8;
|
||||
}
|
||||
|
||||
/** Dialog top edge, aligned to the min-height band's content area. */
|
||||
function dialogY(): number {
|
||||
return minWindowTop() + TOP_BAR_HEIGHT + 8;
|
||||
@@ -31,7 +38,7 @@ const DETAIL_PADDING = 14;
|
||||
export class ToolDebugMenuLayer extends MenuLayer {
|
||||
constructor(appId: string | null, entries: ToolDebugEntry[], private readonly onClosed: () => void) {
|
||||
super(appId ? `Assistant tools: ${appId}` : "Assistant tools", buildItems(appId, entries), {
|
||||
x: DIALOG_X,
|
||||
x: dialogX(),
|
||||
y: dialogY(),
|
||||
width: DIALOG_WIDTH,
|
||||
minHeight: 0,
|
||||
@@ -78,12 +85,14 @@ class ToolDetailLayer implements Layer {
|
||||
paint(_ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
const image = paintBelow();
|
||||
const font = getDefaultSmallFont();
|
||||
const left = dialogX();
|
||||
const width = detailWidth();
|
||||
const top = dialogY();
|
||||
image.fillRoundedRect(DIALOG_X, top, DETAIL_WIDTH, DETAIL_HEIGHT, 1, 10);
|
||||
image.drawRoundedRect(DIALOG_X, top, DETAIL_WIDTH, DETAIL_HEIGHT, 72, 10);
|
||||
image.fillRoundedRect(left, top, width, DETAIL_HEIGHT, 1, 10);
|
||||
image.drawRoundedRect(left, top, width, DETAIL_HEIGHT, 72, 10);
|
||||
|
||||
const textX = DIALOG_X + DETAIL_PADDING;
|
||||
const textWidth = DETAIL_WIDTH - 2 * DETAIL_PADDING - 8;
|
||||
const textX = left + DETAIL_PADDING;
|
||||
const textWidth = width - 2 * DETAIL_PADDING - 8;
|
||||
const lines = this.buildLines(textWidth);
|
||||
const detailLineH = lineStep(font);
|
||||
const visibleRowCount = Math.max(1, ((DETAIL_HEIGHT - 2 * DETAIL_PADDING) / detailLineH) | 0);
|
||||
@@ -98,7 +107,7 @@ class ToolDetailLayer implements Layer {
|
||||
if (lines.length > visibleRowCount) {
|
||||
drawListScrollbar(
|
||||
image,
|
||||
DIALOG_X + DETAIL_WIDTH - 7,
|
||||
left + width - 7,
|
||||
top + DETAIL_PADDING,
|
||||
DETAIL_HEIGHT - 2 * DETAIL_PADDING,
|
||||
this.scrollRow,
|
||||
|
||||
Reference in new issue
Block a user