Introduce oxlint, and fix lint warnings

This commit is contained in:
James Babcock committed 2026-09-29 11:54:22 -07:00
1 parent cb6dddd120
commit 06146c2b08
89 files changed
+818 -469

No files matched your search

+4 -3
View File
@@ -108,6 +108,7 @@ class AiChatLayer implements Layer {
return;
case "long-press-release": this.draft.release(); return;
case "double-click": this.draft.cancel(); shell.yieldFocusToSidebar(); return;
default: return;
}
}
menuItems(): MenuItem[] {
@@ -123,20 +124,20 @@ class AiChatLayer implements Layer {
{ label: "Switch session", disabled: () => external || busy(), onSelect: (ctx) => submenu(ctx, "Sessions",
[...this.conversations.list()].reverse().map((item) => ({
label: `${item.id === record.id ? "✓ " : ""}${this.conversations.title(item)}`,
onSelect: (ctx) => { if (this.conversations.select(item.id)) ctx.stack.clearToBase(); },
onSelect: (pickCtx) => { if (this.conversations.select(item.id)) pickCtx.stack.clearToBase(); },
}))) },
{ label: `Model: ${assistantModelLabel(record.model)}`, disabled: () => external || busy(), onSelect: (ctx) => submenu(ctx, "Model",
ASSISTANT_MODEL_CHOICES.map((model) => ({
label: `${model === record.model ? "✓ " : ""}${assistantModelLabel(model)}`,
disabled: () => !this.conversations.available(model, record.reasoning),
onSelect: (ctx) => { if (this.conversations.configure(model, record.reasoning)) ctx.stack.clearToBase(); },
onSelect: (pickCtx) => { if (this.conversations.configure(model, record.reasoning)) pickCtx.stack.clearToBase(); },
}))) },
{ label: `Reasoning: ${record.reasoning}`, disabled: () => {
const llm = resolveAssistantModel(record.model, { anthropic: anthropicApiKeySetting.get(), openai: openAiApiKeySetting.get() });
return external || busy() || !llm?.effort;
}, onSelect: (ctx) => submenu(ctx, "Reasoning", (["default", "low", "medium", "high"] as ReasoningLevel[]).map((reasoning) => ({
label: `${reasoning === record.reasoning ? "✓ " : ""}${reasoning === "default" ? "Model default" : reasoning}`,
onSelect: (ctx) => { if (this.conversations.configure(record.model, reasoning)) ctx.stack.clearToBase(); },
onSelect: (pickCtx) => { if (this.conversations.configure(record.model, reasoning)) pickCtx.stack.clearToBase(); },
}))) },
...(record.session?.isTurnActive() ? [{ label: "Cancel response", onSelect: (ctx: LayerContext) => {
record.session?.cancel(); ctx.stack.clearToBase();
+8 -3
View File
@@ -284,6 +284,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
updateTickTimer(window);
}
break;
case "navigation-sensors":
case "resize-window":
case "text-input":
case "tool-call":
break;
}
};
@@ -349,7 +354,7 @@ function handleInput(window: BlocksWindow, event: InputEvent, frameId: number):
// An open window menu owns all input (it closes itself via pop); menus are
// list UIs, so watch swipes take their standard fallback meanings there.
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(directionalFallback(event))
.catch((error) => console.error(`blocks menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
@@ -605,7 +610,7 @@ function paintContent(window: BlocksWindow): GrayImage {
drawCenteredIn(image, smallFont, BOARD_X, COLS * CELL, BOARD_Y + 150, `${GESTURE_DOUBLE_CLICK} leave`, 150);
} else {
paintBoard(image, window);
if (window.phase === "game-over") paintGameOver(image, window);
if (window.phase === "game-over") paintGameOver(image);
}
paintPanel(image, window);
return image;
@@ -637,7 +642,7 @@ function drawCell(image: GrayImage, x: number, y: number, shade: number): void {
image.fillRect(BOARD_X + x * CELL, BOARD_Y + y * CELL, CELL - 1, CELL - 1, shade);
}
function paintGameOver(image: GrayImage, window: BlocksWindow): void {
function paintGameOver(image: GrayImage): void {
const boxY = BOARD_Y + 70;
image.fillRect(BOARD_X, boxY, COLS * CELL, 100, 0);
image.drawRect(BOARD_X + 4, boxY + 4, COLS * CELL - 8, 92, 150);
+1 -2
View File
@@ -96,8 +96,7 @@ export function createCalculatorAppWindow(options: InProcessAppOptions): InProce
},
];
let app: InProcessWindow;
app = createInProcessWindow({
const app = createInProcessWindow({
appId: "calculator",
windowId: CALCULATOR_WINDOW_ID,
title: "Calculator",
+1 -1
View File
@@ -24,7 +24,7 @@ import {
findDigits,
highlightedMatch,
} from "./digit-search";
import { type MathWorkload, longRunOffer as makeLongRunOffer, type LongRunOffer } from "./workload";
import { type MathWorkload } from "./workload";
import {
binomial,
factorizationText,
+1 -1
View File
@@ -322,7 +322,7 @@ export function digitalRoot(value: number): number {
export function isPalindrome(value: number): boolean {
const text = String(Math.abs(value));
return text === [...text].reverse().join("");
return text === text.split("").reverse().join("");
}
export function isPerfect(value: number): boolean {
+2 -2
View File
@@ -123,7 +123,7 @@ export class Polynomial {
*/
dividingByRoot(root: MathNumber): Polynomial {
if (this.degree < 1) return this;
const quotient: MathNumber[] = new Array(this.degree).fill(integer(0));
const quotient: MathNumber[] = Array.from({ length: this.degree }, () => integer(0));
let carry: MathNumber = integer(0);
for (let power = this.degree; power >= 1; power--) {
const coefficient = add(this.at(power), carry);
@@ -235,7 +235,7 @@ function addAt(value: MathNumber, power: number, coefficients: MathNumber[]): vo
function convolve(lhs: MathNumber[], rhs: MathNumber[]): MathNumber[] {
if (lhs.length === 0 || rhs.length === 0) return [integer(0)];
const result: MathNumber[] = new Array(lhs.length + rhs.length - 1).fill(integer(0));
const result: MathNumber[] = Array.from({ length: lhs.length + rhs.length - 1 }, () => integer(0));
for (let i = 0; i < lhs.length; i++) {
if (isZero(lhs[i]!)) continue;
for (let j = 0; j < rhs.length; j++) {
-1
View File
@@ -19,7 +19,6 @@ import {
multiplyExpr,
negate,
num,
numberValue,
relation as relationExpr,
spokenRelation,
subtractExpr,
@@ -29,12 +29,12 @@ import {
numberEquals,
rational,
reciprocal,
isZero,
} from "./math-number";
import { simplify } from "./simplifier";
import { differentiate, integrateNumeric } from "./derivative";
import { evaluateValue } from "./evaluator";
import { Polynomial } from "./polynomial";
import { isZero } from "./math-number";
/** Indefinite integral with respect to `variable`, without the constant. */
export function integrate(expression: MathExpression, variable: string): MathExpression | null {
+2 -7
View File
@@ -103,8 +103,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
return wrap(`1/${inner}`, parentPrecedence > PRECEDENCE.product);
}
const body =
`${render(expression.base, PRECEDENCE.power + 1)}` +
`^${render(expression.exponent, PRECEDENCE.power + 1)}`;
`${render(expression.base, PRECEDENCE.power + 1)}^${render(expression.exponent, PRECEDENCE.power + 1)}`;
return wrap(body, parentPrecedence > PRECEDENCE.power);
}
@@ -116,11 +115,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
}
case "relation":
return (
`${render(expression.lhs, PRECEDENCE.relation)} ` +
`${expression.relation} ` +
`${render(expression.rhs, PRECEDENCE.relation)}`
);
return `${render(expression.lhs, PRECEDENCE.relation)} ${expression.relation} ${render(expression.rhs, PRECEDENCE.relation)}`;
}
}
+10 -10
View File
@@ -26,14 +26,14 @@ export type SolutionFamily = {
baseExpression: MathExpression | null;
};
export function familyValues(family: SolutionFamily, lower: number, upper: number): number[] {
if (family.period <= 0) {
return family.base >= lower && family.base <= upper ? [family.base] : [];
export function familyValues(solutionFamily: SolutionFamily, lower: number, upper: number): number[] {
if (solutionFamily.period <= 0) {
return solutionFamily.base >= lower && solutionFamily.base <= upper ? [solutionFamily.base] : [];
}
const results: number[] = [];
let n = Math.floor((lower - family.base) / family.period);
let n = Math.floor((lower - solutionFamily.base) / solutionFamily.period);
for (;;) {
const value = family.base + n * family.period;
const value = solutionFamily.base + n * solutionFamily.period;
if (value > upper) break;
if (value >= lower) results.push(value);
n += 1;
@@ -42,14 +42,14 @@ export function familyValues(family: SolutionFamily, lower: number, upper: numbe
return results;
}
export function familyText(family: SolutionFamily): string {
const baseText = family.baseExpression
? plain(family.baseExpression)
: describeNumber(fromDecimal(family.base));
export function familyText(solutionFamily: SolutionFamily): string {
const baseText = solutionFamily.baseExpression
? plain(solutionFamily.baseExpression)
: describeNumber(fromDecimal(solutionFamily.base));
// The separator is load-bearing: "2*pi" run straight into the index reads
// as "2*pin", a different and nonsensical expression to anyone scanning it
// on the lens.
const periodText = describePi(family.period);
const periodText = describePi(solutionFamily.period);
return `${baseText} + ${periodText}·n`;
}
+1 -2
View File
@@ -21,7 +21,6 @@ export const CALENDAR_SURFACE_ID = "window:calendar";
*/
export function createCalendarAppWindow(options: InProcessAppOptions): InProcessWindow {
let requesting = false;
let app: InProcessWindow;
let unsubscribe = () => {};
let tick: ReturnType<typeof setInterval> | null = null;
@@ -37,7 +36,7 @@ export function createCalendarAppWindow(options: InProcessAppOptions): InProcess
.finally(() => { requesting = false; });
};
app = createInProcessWindow({
const app = createInProcessWindow({
appId: "calendar",
windowId: CALENDAR_WINDOW_ID,
title: "Calendar",
+1 -2
View File
@@ -211,10 +211,9 @@ class CompassLayer implements Layer {
}
export function createCompassAppWindow(options: InProcessAppOptions): InProcessWindow {
let app: InProcessWindow;
let requestRender = () => {};
const layer = new CompassLayer(() => requestRender());
app = createInProcessWindow({
const app = createInProcessWindow({
appId: "compass",
windowId: COMPASS_WINDOW_ID,
title: "Compass",
+1 -1
View File
@@ -2,7 +2,7 @@ import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fon
import { GrayImage } from "../../graphics/image";
import { clamp } from "../../util/numeric-util";
import { addImuListener, imuSourceLabel, setImuReportEnabled, type ImuReading } from "../../native/imu";
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "../../ui/gestures";
import { type InputEvent } from "../../ui/gestures";
import { Layer, type LayerContext } from "../../ui/layers";
import { shell } from "../../ui/shell/shell";
+1 -1
View File
@@ -1,7 +1,7 @@
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { GrayImage } from "../../graphics/image";
import { Layer, type LayerActions, type LayerContext } from "../../ui/layers";
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL, type InputEvent } from "../../ui/gestures";
import { GESTURE_CLICK, type InputEvent } from "../../ui/gestures";
import { Menu, type MenuDrawArgs } from "../../ui/menu-core";
import { centeredTextY, tightRowHeight } from "../../ui/metrics";
import {
+2
View File
@@ -64,6 +64,8 @@ export class ScreenTestLayer implements Layer {
case "double-click":
ctx.stack.pop();
return;
default:
return;
}
}
}
+2
View File
@@ -236,6 +236,8 @@ export class UnicodeSampleLayer implements Layer {
case "double-click":
ctx.stack.pop();
return;
default:
return;
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { Application } from "@nativescript/core";
import { Utils } from "@nativescript/core";
export function hmacSha256Base64(secret: string, message: string): string {
const charset = java.nio.charset.StandardCharsets.UTF_8;
@@ -10,7 +10,7 @@ export function hmacSha256Base64(secret: string, message: string): string {
}
export function getPhoneOpenUdid(): string {
const resolver = Application.android.context?.getContentResolver();
const resolver = Utils.android.getApplicationContext()?.getContentResolver();
const id = resolver ? String(android.provider.Settings.Secure.getString(resolver, android.provider.Settings.Secure.ANDROID_ID) ?? "") : "";
if (!id) throw new Error("Android did not provide a device ID for EvenHub authentication.");
return id;
+1 -1
View File
@@ -22,7 +22,7 @@ export type EvenHubPermissionName =
| "album"
| "camera"
| "fs"
| string;
| (string & {});
export type EvenHubPermission = {
name: EvenHubPermissionName;
+1 -1
View File
@@ -1177,7 +1177,7 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
}
return out;
};
if (requested.length === 0 || requested.every((id) => this.grantedApiKeys.has(id))) {
if (requested.every((id) => this.grantedApiKeys.has(id))) {
return Promise.resolve(buildGrant());
}
if (!this.windowHooks) return Promise.resolve({});
+1 -1
View File
@@ -73,7 +73,7 @@ export async function checkForEvenHubUpdates(
onProgress?: (done: number, total: number) => void,
): Promise<EvenHubAppUpdate[]> {
const installed = getInstalledEvenHubApps();
const results: EvenHubAppUpdate[] = new Array(installed.length);
const results: EvenHubAppUpdate[] = [];
let next = 0;
let done = 0;
const worker = async () => {
-1
View File
@@ -1,4 +1,3 @@
import { type BdfFont } from "../../graphics/bdffont";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { truncateText } from "../../graphics/textwrap";
import { GrayImage } from "../../graphics/image";
+8 -1
View File
@@ -287,6 +287,10 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
syncTickTimer(window);
}
break;
case "navigation-sensors":
case "text-input":
case "tool-call":
break;
}
};
@@ -383,7 +387,7 @@ function handleInput(window: FlappyWindow, event: InputEvent, frameId: number):
// An open window menu owns all input (it closes itself via pop); menus are
// list UIs, so watch swipes take their standard fallback meanings there.
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(directionalFallback(event))
.catch((error) => console.error(`flappy menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
@@ -728,6 +732,9 @@ function paintHud(image: GrayImage, window: FlappyWindow): void {
`${GESTURE_CLICK} new game ${GESTURE_DOUBLE_CLICK} leave`,
]);
break;
case "playing":
case "dying":
break;
}
}
+8 -5
View File
@@ -58,9 +58,6 @@ function rankOf(card: number): number {
function isRed(card: number): boolean {
return (card & 1) === 1;
}
function cardLabel(card: number): string {
return RANK_CHARS[rankOf(card)]! + SUIT_CHARS[suitOf(card)]!;
}
const CARD_W = 60;
const CARD_H = 36;
@@ -208,6 +205,13 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
if (window.foreground) renderAndSubmit(window, 0);
break;
}
case "input-focus":
case "navigation-sensors":
case "resize-window":
case "screen":
case "text-input":
case "tool-call":
break;
}
};
@@ -285,7 +289,7 @@ function handleInput(window: FreecellWindow, event: InputEvent, frameId: number)
// An open window menu owns all input (it closes itself via pop); menus are
// list UIs, so watch swipes take their standard fallback meanings there.
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(directionalFallback(event))
.catch((error) => console.error(`freecell menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
@@ -792,7 +796,6 @@ function paintCard(
if (selected) image.drawRoundedRect(x + 1, y + 1, CARD_W - 2, CARD_H - 2, 255, 3);
const rankText: string = RANK_CHARS[rankOf(card)]!
const suitText: string = SUIT_CHARS[suitOf(card)]!;
const labelText = rankText + suitText;
image.drawText(labelFont, x + 5, y, rankText, 255);
image.drawText(suitFont, x + 5 + labelFont.measureText(rankText), y + 3, suitText, 150);
if (isRed(card)) {
+2 -3
View File
@@ -344,7 +344,6 @@ class GlancePreviewLayer implements Layer {
export function createGlanceboardAppWindow(options: InProcessAppOptions): InProcessWindow {
let previewVisible = false;
const heightMode = () => previewVisible && glanceLayoutSetting.get() === "2x3" ? "max" as const : "medium" as const;
let unsubscribeSettings: (() => void) | undefined;
const app = createInProcessWindow({
appId: "glanceboard",
windowId: GLANCEBOARD_WINDOW_ID,
@@ -367,10 +366,10 @@ export function createGlanceboardAppWindow(options: InProcessAppOptions): InProc
removeSurface: options.removeSurface,
reconfigureSurface: options.reconfigureSurface,
onClosed: () => {
unsubscribeSettings?.();
unsubscribeSettings();
options.onClosed();
},
});
unsubscribeSettings = onAnySettingChanged(() => app.setHeightMode(heightMode()));
const unsubscribeSettings = onAnySettingChanged(() => app.setHeightMode(heightMode()));
return app;
}
+1 -1
View File
@@ -16,7 +16,7 @@ export const GLANCE_WIDGETS: readonly GlanceWidgetDefinition[] = [
{ id: "music", label: "Music", create: () => new MusicWidget() },
];
export function findGlanceWidget(id: GlanceWidgetId | string): GlanceWidgetDefinition | null {
export function findGlanceWidget(id: GlanceWidgetId | (string & {})): GlanceWidgetDefinition | null {
return GLANCE_WIDGETS.find((widget) => widget.id === id) ?? null;
}
@@ -26,7 +26,7 @@ const BOTTOM_MARGIN = 2;
* once the snapshot is in.
*/
export class TerminalWidget implements GlanceWidget {
private snapshot: TerminalSessionsSnapshot | undefined = readWorkerState(TERMINAL_SESSIONS_STATE_KEY);
private snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY) as TerminalSessionsSnapshot | undefined;
private unsubscribe: (() => void) | null = null;
private requestRender: (() => void) | null = null;
private phase = 0;
@@ -34,9 +34,9 @@ export class TerminalWidget implements GlanceWidget {
start(requestRender: () => void): void {
this.requestRender = requestRender;
this.snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY);
this.unsubscribe = onWorkerStateChanged<TerminalSessionsSnapshot>(TERMINAL_SESSIONS_STATE_KEY, (snapshot) => {
this.snapshot = snapshot;
this.snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY) as TerminalSessionsSnapshot | undefined;
this.unsubscribe = onWorkerStateChanged(TERMINAL_SESSIONS_STATE_KEY, (snapshot) => {
this.snapshot = snapshot as TerminalSessionsSnapshot;
this.syncAnimation();
requestRender();
});
-1
View File
@@ -1,4 +1,3 @@
import { type BdfFont } from "../../graphics/bdffont";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { truncateText } from "../../graphics/textwrap";
import { GrayImage } from "../../graphics/image";
+3 -3
View File
@@ -57,7 +57,7 @@ export function loadMicConfig(): MicConfig {
return {
...defaults,
...parsed,
hostMics: { ...defaults.hostMics, ...(parsed.hostMics ?? {}) },
hostMics: { ...defaults.hostMics, ...parsed.hostMics },
};
} catch {
return defaultMicConfig();
@@ -72,8 +72,8 @@ class MicArrayController {
private readonly statusListeners = new Set<(statuses: MicArrayStatuses) => void>();
private statuses: MicArrayStatuses = { left: null, right: null };
// The Java listener proxy must stay referenced or it gets GC'd.
private statusProxy: any | null = null;
private proxyCommunicator: any | null = null;
private statusProxy: any = null;
private proxyCommunicator: any = null;
private leaseTimer: ReturnType<typeof setInterval> | null = null;
private armed = false;
+6 -6
View File
@@ -16,7 +16,6 @@ import {
type HeadOrientation,
} from "./dsp";
import { micArrayController, micControlSupported, loadMicConfig, saveMicConfig } from "./mic-control";
import type { MicConfig } from "./mic-protocol";
import { micModelPath } from "./mic-models";
import {
MIC_CHANNEL_KEYS,
@@ -27,6 +26,7 @@ import {
splitConcatenatedPcm16,
templeActive,
type MicChannelKey,
type MicConfig,
type MicSide,
} from "./mic-protocol";
import {
@@ -158,8 +158,8 @@ class MicSession {
// Captions state.
private captionLines: CaptionLine[] = [];
private captionEngine: any | null = null;
private captionListenerProxy: any | null = null;
private captionEngine: any = null;
private captionListenerProxy: any = null;
private captionsActive = false;
private engineStartWallMs = 0;
private sessionRowId = -1;
@@ -168,7 +168,7 @@ class MicSession {
private conversationLang = "und";
// Recording state.
private recorder: any | null = null;
private recorder: any = null;
private recordingPath = "";
// Stock path subscriptions.
@@ -177,7 +177,7 @@ class MicSession {
private offCompass: (() => void) | null = null;
// Extended path.
private forwardingProxy: any | null = null;
private forwardingProxy: any = null;
private temples = new Map<MicSide, TempleAudioPipeline>();
private templeAngles: { left: number | null; right: number | null } = { left: null, right: null };
private templeSsr: { left: number; right: number } = { left: 0, right: 0 };
@@ -193,7 +193,7 @@ class MicSession {
private offVoiceActivity: (() => void) | null = null;
// Phone-side spectral noise suppressor (FaceclawNoiseSuppressor).
private suppressor: any | null = null;
private suppressor: any = null;
private suppressorEngine = "";
// True between the caption engine's speech-start event and the utterance
+2 -2
View File
@@ -8,7 +8,7 @@ declare const java: any;
* translation to the phone's default language beneath it.
*/
let languageIdentifier: any | null = null;
let languageIdentifier: any = null;
// Translators are expensive to build (model download on first use); cache by
// "src>dst" and keep the proxies referenced so they aren't GC'd mid-flight.
const translators = new Map<string, any>();
@@ -59,7 +59,7 @@ export function identifyLanguage(text: string): Promise<string> {
});
}
function translatorFor(sourceLang: string, targetLang: string): any | null {
function translatorFor(sourceLang: string, targetLang: string): any {
const key = `${sourceLang}>${targetLang}`;
const cached = translators.get(key);
if (cached) return cached;
@@ -250,6 +250,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
syncClock(window);
}
break;
case "navigation-sensors":
case "resize-window":
case "text-input":
case "tool-call":
break;
}
};
@@ -350,7 +355,7 @@ function handleInput(window: MinesweeperWindow, event: InputEvent, frameId: numb
// An open window menu owns all input (it closes itself via pop); menus are
// list UIs, so watch swipes take their standard fallback meanings there.
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(directionalFallback(event))
.catch((error) => console.error(`minesweeper menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
+32 -24
View File
@@ -63,7 +63,16 @@ import {
GESTURE_SHORT_THEN_LONG_PRESS,
type InputEvent,
} from "../../ui/gestures";
import { LocationTracker, type TrackedLocation } from "./navigation-sensors";
import {
addCompassListener,
COMPASS_CHANGED,
handleNavigationSensorEvent,
LocationTracker,
magneticDeclinationDegrees,
setCompassEnabled,
type CompassEvent,
type TrackedLocation,
} from "./navigation-sensors";
import {
fetchRoute,
fetchStaticMapGray,
@@ -75,14 +84,11 @@ import {
type RouteProfile,
type StaticMapCamera,
} from "../../native/mapbox";
import { addCompassListener, COMPASS_CHANGED, setCompassEnabled, type CompassEvent } from "./navigation-sensors";
import { magneticDeclinationDegrees, handleNavigationSensorEvent } from "./navigation-sensors";
import { calibrateHeading, normalizeHeading } from "../compass/calibration";
import { bearingDegrees, haversineMeters, RouteFollower, type RouteProgress } from "./route-follower";
import { drawManeuverGlyph } from "./maneuver-icons";
declare const global: any;
declare const com: any;
const MAP_SIZE = 260;
const PANEL_X = MAP_SIZE + 10;
@@ -376,6 +382,8 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
);
break;
}
case "input-focus":
break;
}
};
@@ -914,7 +922,7 @@ function describeRouteStatus(): string {
* display and saved-destination settings (Home, Work, custom named places), and the
* recent-destinations preference.
*/
function windowMenuItems(win: NavWindow): MenuItem[] {
function windowMenuItems(): MenuItem[] {
const items: MenuItem[] = [];
if (phase !== "idle") {
items.push({
@@ -993,15 +1001,15 @@ function savedDestinationMenuItems(): MenuItem[] {
const work = saved.find((d) => d.id === WORK_DESTINATION_ID);
items.push(addressMenuItem("Home", HOME_DESTINATION_ID, home?.address ?? ""));
items.push(addressMenuItem("Work", WORK_DESTINATION_ID, work?.address ?? ""));
for (const destination of saved) {
if (destination.builtin) continue;
for (const dest of saved) {
if (dest.builtin) continue;
items.push({
label: destination.name,
label: dest.name,
onSelect: (ctx) => {
ctx.stack.push(new WindowMenuLayer(destination.name, customDestinationMenuItems(destination)));
ctx.stack.push(new WindowMenuLayer(dest.name, customDestinationMenuItems(dest)));
},
render: ({ image, x, y, width, height }) => {
drawAddressRow(image, x, y, width, destination.name, destination.address, true);
drawAddressRow(image, x, y, width, dest.name, dest.address, true);
drawSubmenuIndicator(image, smallFont, x - 10, y, width + 20, height, 150);
},
});
@@ -1028,14 +1036,14 @@ function addressMenuItem(label: string, id: string, address: string): MenuItem {
};
}
function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
function customDestinationMenuItems(dest: SavedDestination): MenuItem[] {
return [
{
label: "Navigate there",
disabled: !destination.address,
disabled: !dest.address,
onSelect: (ctx) => {
closeMenusAnd(ctx, () => {
void startNavigationTo({ kind: "query", query: destination.address, label: destination.name }, profile).catch(
void startNavigationTo({ kind: "query", query: dest.address, label: dest.name }, profile).catch(
() => {},
);
});
@@ -1044,16 +1052,16 @@ function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
{
label: "Set address",
onSelect: (ctx) => {
closeMenusAnd(ctx, () => beginAddressEdit(destination.id, destination.name, destination.address));
closeMenusAnd(ctx, () => beginAddressEdit(dest.id, dest.name, dest.address));
},
},
{
label: "Rename",
onSelect: (ctx) => {
closeMenusAnd(ctx, () => {
navigateDestinationNameDraftSetting.set(destination.name);
beginEdit(navigateDestinationNameDraftSetting, `Rename ${destination.name}`, (name) => {
if (name) updateCustomDestination(destination.id, { name });
navigateDestinationNameDraftSetting.set(dest.name);
beginEdit(navigateDestinationNameDraftSetting, `Rename ${dest.name}`, (name) => {
if (name) updateCustomDestination(dest.id, { name });
});
});
},
@@ -1062,7 +1070,7 @@ function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
label: "Remove",
onSelect: (ctx) => {
closeMenusAnd(ctx, () => {
removeCustomDestination(destination.id);
removeCustomDestination(dest.id);
syncIdleList();
});
},
@@ -1195,10 +1203,10 @@ function idleEntries(): IdleEntry[] {
run: () => { void startMap(); },
}];
entries.push(...loadSavedDestinations()
.filter((destination) => destination.address)
.map((destination): IdleEntry => ({ kind: "saved", destination })));
for (const destination of loadRecentDestinations()) {
entries.push({ kind: "recent", destination });
.filter((dest) => dest.address)
.map((dest): IdleEntry => ({ kind: "saved", destination: dest })));
for (const dest of loadRecentDestinations()) {
entries.push({ kind: "recent", destination: dest });
}
return entries;
}
@@ -1250,7 +1258,7 @@ function windowMenu(win: NavWindow): WindowMenu {
windowId: win.windowId,
post,
title: () => win.title,
items: () => windowMenuItems(win),
items: () => windowMenuItems(),
size: { width: win.viewportWidth, height: win.viewportHeight },
paintBase: () => paintContent(win),
isFocused: () => win.focused,
@@ -1261,7 +1269,7 @@ function windowMenu(win: NavWindow): WindowMenu {
function handleInput(win: NavWindow, event: InputEvent, frameId: number): void {
if (win.menu?.isOpen()) {
win.menu
void win.menu
.handleInput(event)
.catch((error) => console.error(`navigate menu input failed: ${error}`))
.then(() => renderAndSubmit(win, frameId));
+2 -2
View File
@@ -46,7 +46,7 @@ export class RouteFollower {
constructor(route: Route) {
this.route = route;
this.vertexMeters = new Array(route.coordinates.length);
this.vertexMeters = Array.from({ length: route.coordinates.length }, () => 0);
let along = 0;
this.vertexMeters[0] = 0;
for (let i = 1; i < route.coordinates.length; i++) {
@@ -58,7 +58,7 @@ export class RouteFollower {
// Each step's maneuver happens where the previous step's travel ends, so
// the maneuver point of step k sits at the sum of steps 0..k-1 distances.
// (Slight drift vs the geometry is fine at guidance granularity.)
this.stepStartMeters = new Array(route.steps.length);
this.stepStartMeters = Array.from({ length: route.steps.length }, () => 0);
let stepAlong = 0;
for (let i = 0; i < route.steps.length; i++) {
this.stepStartMeters[i] = Math.min(stepAlong, this.totalMeters);
+8 -1
View File
@@ -405,6 +405,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
syncTickTimer(window);
}
break;
case "navigation-sensors":
case "resize-window":
case "text-input":
case "tool-call":
break;
}
};
@@ -500,7 +505,7 @@ function handleInput(window: PinballWindow, event: InputEvent, frameId: number):
// An open window menu owns all input (it closes itself via pop); menus are
// list UIs, so watch swipes take their standard fallback meanings there.
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(directionalFallback(event))
.catch((error) => console.error(`pinball menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
@@ -744,6 +749,8 @@ function stepFlippers(window: PinballWindow, dt: number): void {
flipper.state = "rest";
}
break;
case "rest":
break;
}
}
}
+1 -1
View File
@@ -121,7 +121,7 @@ async function roamPost(endpoint: "q" | "pull" | "write", body: object): Promise
base = API_BASE;
continue;
}
throw new Error(`Roam API request failed: ${(error as Error)?.message ?? error}`);
throw new Error(`Roam API request failed: ${(error as Error)?.message ?? error}`, { cause: error });
}
if (response.status >= 300 && response.status < 400) {
const location = response.headers?.get?.("Location") ?? response.headers?.get?.("location");
+7 -4
View File
@@ -52,7 +52,6 @@ import {
} from "./roam-doc";
declare const global: any;
declare const com: any;
const HEADER_HEIGHT = 30;
const BOTTOM_MARGIN = 6;
@@ -252,6 +251,10 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
);
break;
}
case "input-focus":
case "navigation-sensors":
case "resize-window":
break;
}
};
@@ -339,7 +342,7 @@ function windowMenu(win: RoamWindow): WindowMenu {
windowId: win.windowId,
post,
title: () => win.title,
items: () => menuItems(win),
items: () => menuItems(),
size: { width: win.viewportWidth, height: win.viewportHeight },
paintBase: () => paintContent(win),
isFocused: () => win.focused,
@@ -348,7 +351,7 @@ function windowMenu(win: RoamWindow): WindowMenu {
return win.menu;
}
function menuItems(win: RoamWindow): MenuItem[] {
function menuItems(): MenuItem[] {
const items: MenuItem[] = [];
const today = todayRef();
if (currentRef?.uid !== today.uid) {
@@ -415,7 +418,7 @@ function endSettingEdit(): void {
function handleInput(win: RoamWindow, event: InputEvent, frameId: number): void {
if (win.menu?.isOpen()) {
win.menu
void win.menu
.handleInput(event)
.catch((error) => console.error(`roam menu input failed: ${error}`))
.then(() => renderAndSubmit(win, frameId));
+4 -3
View File
@@ -39,7 +39,6 @@ import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../gra
import { prepareFrameDraws } from "../../graphics/glyph-wire";
import { getDefaultSmallFont, getTerminalFontConfig } from "../../graphics/ui-fonts";
import { layoutHubHeader } from "./hub-header";
import { truncateText } from "../../graphics/textwrap";
import { TERMINAL_ICON_GLYPHS, type IconActivity } from "../../graphics/icons";
import {
drawSessionRow,
@@ -64,7 +63,6 @@ import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-win
import type { ToolResult, ToolSpec } from "../../assistant/tool-registry";
declare const global: any;
declare const com: any;
// Cell geometry comes from the terminal font setting (Settings > Terminal >
// Font; the default is Terminus-12's 6x12). Each window derives its grid from
@@ -429,6 +427,9 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
);
break;
}
case "input-focus":
case "navigation-sensors":
break;
}
};
@@ -1092,7 +1093,7 @@ function handleInput(window: TerminalWindow, event: InputEvent, frameId: number)
if (window.kind === "view") activeViewId = window.windowId;
// An open window menu owns all input (it closes itself via pop).
if (window.menu?.isOpen()) {
window.menu
void window.menu
.handleInput(event)
.catch((error) => console.error(`terminal menu input failed: ${error}`))
.then(() => renderAndSubmit(window, frameId));
+1
View File
@@ -368,6 +368,7 @@ export class TimersLayer implements Layer {
else timerEngine.restartTimer(timer.id);
return;
}
return;
}
case "new-timer":
this.openDial("");
+1 -1
View File
@@ -43,7 +43,7 @@ export class TranscribeLayer implements Layer {
const { width, height } = ctx.stack.getBaseSize();
const image = new GrayImage(width, height, 0);
const text = this.transcript.text || (this.listening ? "Listening..." : this.detail);
const wrapped = wrapTranscribeText((text) => font.measureText(text), text, width - 64);
const wrapped = wrapTranscribeText((line) => font.measureText(line), text, width - 64);
image.drawText(font, 24, 20, "Transcribe", 200);
image.drawText(font, 24, 40, this.saveNotice || this.status, 110);
+1 -2
View File
@@ -16,7 +16,6 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
let closed = false;
let requestingPermission = false;
let unsubscribe: (() => void) | null = null;
let app: InProcessWindow;
const requestUpdate = () => {
if (closed || requestingPermission) return;
@@ -33,7 +32,7 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
}).catch((error) => { requestingPermission = false; console.warn(`Weather permission: ${error}`); });
};
app = createInProcessWindow({
const app = createInProcessWindow({
appId: "weather",
windowId: WEATHER_WINDOW_ID,
title: "Weather",