eythaann/Seelen-UI · error · Error
Current monitor not found
Error message
Current monitor not found
What it means
The fancy-toolbar widget derives its current monitor by finding, in the `monitors` signal, the entry whose id matches `currentMonitorId`. If no monitor matches, `$derived.by` throws `Current monitor not found`. Since this runs inside a reactive derivation, the whole toolbar render fails until the monitor id resolves.
Source
Thrown at src/ui/svelte/fancy-toolbar/state/system.svelte.ts:9
import { FancyToolbarSide } from "@seelen-ui/lib/types";
import { currentMonitorId, monitors, mousePos, virtualDesktop } from "./getters.svelte.ts";
export { virtualDesktop };
const _currentMonitor = $derived.by(() => {
const monitor = monitors.value.find((m) => m.id === currentMonitorId);
if (!monitor) {
throw new Error("Current monitor not found");
}
return monitor;
});
const _mouseAtEdge = $derived.by((): FancyToolbarSide | null => {
const box = _currentMonitor.rect;
const x = mousePos.value[0];
const y = mousePos.value[1];
if (x < box.left || x > box.right || y < box.top || y > box.bottom) {
return null;
}
if (y === box.top) {
return FancyToolbarSide.Top;
}
if (y === box.bottom - 1) {View on GitHub (pinned to dee4aaa940)
Solutions
- Guard the lookup: fall back to the first monitor or skip the derivation when not found instead of throwing.
- Ensure `monitors` and `currentMonitorId` signals are initialized (LazySignal `.init()` awaited) before reactive UI consumes them.
- Subscribe to monitor-change events and re-evaluate; verify the toolbar webview restarts/re-syncs on `MonitorsChanged`.
Example fix
// before
const monitor = monitors.value.find((m) => m.id === currentMonitorId);
if (!monitor) throw new Error("Current monitor not found");
// after
const monitor = monitors.value.find((m) => m.id === currentMonitorId)
?? monitors.value[0];
if (!monitor) return null; Defensive patterns
Strategy: fallback
Validate before calling
const monitor = monitors.value.find((m) => m.id === currentMonitorId); const isMonitorReady = Boolean(monitor); // check before consuming the derived monitor
Type guard
function monitorExists(id: string): boolean {
return monitors.value.some((m) => m.id === id);
} Try / catch
// wrap consumers of the derived monitor
try {
renderToolbar(_currentMonitor);
} catch (e) {
if ((e as Error).message === "Current monitor not found") renderSkeleton();
else throw e;
} Prevention
- Await LazySignal init for `monitors` before mounting UI that derives from it.
- Handle monitor hot-plug events and re-resolve currentMonitorId.
- Design derivations to return null/safe defaults for transient states instead of throwing.
When it happens
Trigger: `monitors.value` has not been populated yet (initial load before the backend sends the monitor list) or `currentMonitorId` refers to a monitor that was unplugged/changed id (display hot-plug, monitor re-enumeration, sleep/resume).
Common situations: Toolbar starting up before the first `MonitorsChanged` event arrives; user unplugs an external display the toolbar was attached to; Windows display reconfiguration changing monitor ids.
Related errors
- Current monitor not found
- Current monitor not found
- LazyRune was not initialized
- no key provided to $t()
- Monitor settings not initialized ${device.id}
AI-assisted analysis of eythaann/Seelen-UI@dee4aaa940 (2026-09-03).
Data as JSON: /api/errors/711b59b6fca7b4c3.
Report an issue: GitHub.