forked from Blendman974/faceclaw
Enhancements to Nightscout and Terminal apps
Nightscout app: Alert thresholds for canula age, cartridge volume, pump battery, time since last loop, shown in top bar. Option to always show in top bar when window is closed. Terminal app: Activity indicators in the app-switcher sidebar. </details>
This commit is contained in:
1 parent
9b70880a5b
commit
070c891577
13 files changed
+566
-71
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { normalizeNightscoutThreshold, type NightscoutThresholds } from "../apps/nightscout/nightscout-alerts";
|
||||
import { GESTURE_DOUBLE_CLICK, InputEvent } from "./gestures";
|
||||
import {
|
||||
getBooleanSetting,
|
||||
@@ -755,6 +756,48 @@ export const nightscoutApiTokenSetting = new ConfigSettingString({
|
||||
description: "Access token for the Nightscout site's API.",
|
||||
});
|
||||
|
||||
function nightscoutThresholdSetting(id: string, label: string, unit: string, description: string): ConfigSettingString {
|
||||
return new ConfigSettingString({
|
||||
id: `nightscout-${id}`,
|
||||
label,
|
||||
storageKey: `integrations.nightscout.${id}`,
|
||||
defaultValue: "0",
|
||||
editorTitle: `${label} (${unit}; 0 = off)`,
|
||||
normalize: normalizeNightscoutThreshold,
|
||||
formatValue: (value) => Number(value) > 0 ? `${value} ${unit}` : "Off",
|
||||
description: `${description} Enter 0 to disable.`,
|
||||
});
|
||||
}
|
||||
|
||||
export const nightscoutMaxCannulaAgeSetting = nightscoutThresholdSetting(
|
||||
"max-cannula-age-hours", "Max cannula age", "h", "Warn when time since the last site change exceeds this many hours.",
|
||||
);
|
||||
export const nightscoutCartridgeLowSetting = nightscoutThresholdSetting(
|
||||
"cartridge-low-units", "Cartridge low threshold", "U", "Warn when the pump reservoir falls below this many units.",
|
||||
);
|
||||
export const nightscoutBatteryLowSetting = nightscoutThresholdSetting(
|
||||
"battery-low-voltage", "Battery voltage threshold", "V", "Warn when pump battery voltage falls below this value.",
|
||||
);
|
||||
export const nightscoutMaxLoopAgeSetting = nightscoutThresholdSetting(
|
||||
"max-loop-age-minutes", "Max time since last loop", "min", "Warn when time since the last loop exceeds this many minutes.",
|
||||
);
|
||||
export const nightscoutAlwaysShowInTopBarSetting = new ConfigSettingBoolean({
|
||||
id: "nightscout-always-show-in-top-bar",
|
||||
label: "Always show in top bar",
|
||||
storageKey: "integrations.nightscout.alwaysShowInTopBar",
|
||||
defaultValue: false,
|
||||
description: "Keep the Nightscout glucose graph and warnings in the top bar even when all Nightscout windows are closed.",
|
||||
});
|
||||
|
||||
export function loadNightscoutThresholds(): NightscoutThresholds {
|
||||
return {
|
||||
maxCannulaAgeHours: Number(nightscoutMaxCannulaAgeSetting.get()),
|
||||
cartridgeLowUnits: Number(nightscoutCartridgeLowSetting.get()),
|
||||
batteryLowVoltage: Number(nightscoutBatteryLowSetting.get()),
|
||||
maxLoopAgeMinutes: Number(nightscoutMaxLoopAgeSetting.get()),
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Navigate app: saved and recent destinations.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BATTERY_ICON_WIDTH, drawBattery } from "../../graphics/battery";
|
||||
import { readActiveNotificationIcons } from "../../native/notification-icons";
|
||||
import { readPhoneBatteryState } from "../../native/phone-battery";
|
||||
import { noteStaleDataUsed, renderPassAllowsStaleData } from "../../util/render-freshness";
|
||||
import { renderIcon, renderIconWithGlyph, type IconName } from "../../graphics/icons";
|
||||
import { renderIcon, renderIconWithGlyph, type IconActivity, type IconName } from "../../graphics/icons";
|
||||
import { batteryDisplayModeSetting, timeFormatSetting } from "../dashboard-settings";
|
||||
import { Layer } from "../layers";
|
||||
import { scrollToKeepSelectionVisible } from "../menu";
|
||||
@@ -144,9 +144,9 @@ function invertedIcon(icon: GrayImage): GrayImage {
|
||||
}
|
||||
|
||||
/** Window icon rendered from an SVG (Lucide), rendered once per size and cached. */
|
||||
export function makeSvgWindowIcon(name: IconName, glyph?: string): ShellChromeWindow["drawIcon"] {
|
||||
export function makeSvgWindowIcon(name: IconName, glyph?: string, activity?: () => IconActivity): ShellChromeWindow["drawIcon"] {
|
||||
return (image, x, y, size, inverted) => {
|
||||
const icon = glyph ? renderIconWithGlyph(name, glyph, size) : renderIcon(name, size);
|
||||
const icon = glyph || activity ? renderIconWithGlyph(name, glyph ?? "", size, activity?.() ?? "idle") : renderIcon(name, size);
|
||||
if (!icon) return;
|
||||
const dx = x + Math.max(0, ((size - icon.width) / 2) | 0);
|
||||
const dy = y + Math.max(0, ((size - icon.height) / 2) | 0);
|
||||
@@ -155,8 +155,8 @@ export function makeSvgWindowIcon(name: IconName, glyph?: string): ShellChromeWi
|
||||
}
|
||||
|
||||
/** SVG icon when a name is given, else the letter placeholder. */
|
||||
export function windowIcon(icon: IconName | undefined, letter: string, glyph?: string): ShellChromeWindow["drawIcon"] {
|
||||
return icon ? makeSvgWindowIcon(icon, glyph) : makeLetterWindowIcon(letter);
|
||||
export function windowIcon(icon: IconName | undefined, letter: string, glyph?: string, activity?: () => IconActivity): ShellChromeWindow["drawIcon"] {
|
||||
return icon ? makeSvgWindowIcon(icon, glyph, activity) : makeLetterWindowIcon(letter);
|
||||
}
|
||||
|
||||
/** Window icon backed by an arbitrary cached grayscale image renderer. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
import { type IconName } from "../../graphics/icons";
|
||||
import { type IconActivity, type IconName } from "../../graphics/icons";
|
||||
import { toolRegistry, type ToolResult, type ToolSpec } from "../../assistant/tool-registry";
|
||||
import { appViewportSize, type WindowHeightMode } from "./geometry";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
@@ -62,6 +62,8 @@ export type WorkerAppReply =
|
||||
}
|
||||
| { type: "set-title"; windowId: string; title: string }
|
||||
| { type: "set-attention"; windowId: string; attention: boolean }
|
||||
/** App-driven animation phase for sidebar icons that support an activity cursor. */
|
||||
| { type: "set-icon-activity"; windowId: string; activity: IconActivity }
|
||||
| {
|
||||
/** Open the shell's voice dialog aimed at this window (a menu pick). */
|
||||
type: "start-voice-input";
|
||||
@@ -194,6 +196,7 @@ const TOOL_CALL_HOST_TIMEOUT_MS = 15_000;
|
||||
|
||||
export class WorkerAppHost {
|
||||
private readonly openWindows = new Set<string>();
|
||||
private readonly windowIconActivity = new Map<string, IconActivity>();
|
||||
/** Per-window gesture bindings, as last reported (see set-window-gestures). */
|
||||
private readonly windowGestures = new Map<string, { hasAppMenu: boolean; claimsLongPress: boolean }>();
|
||||
private readonly pendingToolCalls = new Map<string, PendingToolCall>();
|
||||
@@ -270,6 +273,12 @@ export class WorkerAppHost {
|
||||
shell.openSystemMenu(message.windowId);
|
||||
}
|
||||
break;
|
||||
case "set-icon-activity":
|
||||
if (this.openWindows.has(message.windowId) && this.windowIconActivity.get(message.windowId) !== message.activity) {
|
||||
this.windowIconActivity.set(message.windowId, message.activity);
|
||||
this.options.requestShellRender();
|
||||
}
|
||||
break;
|
||||
case "set-window-gestures":
|
||||
this.windowGestures.set(message.windowId, {
|
||||
hasAppMenu: message.hasAppMenu,
|
||||
@@ -358,13 +367,14 @@ export class WorkerAppHost {
|
||||
close: () => {
|
||||
this.openWindows.delete(spec.windowId);
|
||||
this.windowGestures.delete(spec.windowId);
|
||||
this.windowIconActivity.delete(spec.windowId);
|
||||
// Withdraw this window's tools and fail any in-flight calls to it.
|
||||
toolRegistry.removeAppTools(spec.windowId);
|
||||
this.failPendingToolCallsFor(spec.windowId);
|
||||
this.post({ type: "close-window", windowId: spec.windowId });
|
||||
this.options.removeSurface(surfaceId);
|
||||
},
|
||||
drawIcon: windowIcon(spec.icon, spec.iconLetter, spec.iconGlyph),
|
||||
drawIcon: windowIcon(spec.icon, spec.iconLetter, spec.iconGlyph, () => this.windowIconActivity.get(spec.windowId) ?? "idle"),
|
||||
handleInput: (event, frameId) => {
|
||||
frameTimings.logFrame(frameId, `input posted to the ${this.options.appId} worker`);
|
||||
this.post({
|
||||
|
||||
Reference in new issue
Block a user