eythaann/Seelen-UI · error · Error
Current monitor not found
Error message
Current monitor not found
What it means
Same family as the fancy-toolbar error: the SeelenWeg (dock) widget derives the current monitor from `monitors.value.find((m) => m.id === currentMonitorId)` and throws `Current monitor not found` when absent. The dock's geometry (`_mouseAtEdge`, positioning) depends on this monitor rect, so the derivation failure breaks the whole widget state.
Source
Thrown at src/ui/svelte/weg/state/system.svelte.ts:7
import { SeelenWegSide } from "@seelen-ui/lib/types";
import { currentMonitorId, monitors, mousePos } from "./getters.svelte.ts";
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((): SeelenWegSide | null => {
const box = _currentMonitor.rect;
const x = mousePos.value.x;
const y = mousePos.value.y;
if (x < box.left || x > box.right || y < box.top || y > box.bottom) {
return null;
}
if (y === box.top) return SeelenWegSide.Top;
if (x === box.left) return SeelenWegSide.Left;
if (y === box.bottom - 1) return SeelenWegSide.Bottom;
if (x === box.right - 1) return SeelenWegSide.Right;
View on GitHub (pinned to dee4aaa940)
Solutions
- Add a fallback to the primary/first monitor or return a safe default instead of throwing inside the derivation.
- Await signal initialization (`await monitors.init()`) before mounting the dock UI.
- Handle monitor hot-plug events so `currentMonitorId` is re-resolved (or the widget re-created) when the old id disappears.
Example fix
// before
if (!monitor) throw new Error("Current monitor not found");
// after
if (!monitor) return monitors.value[0] ?? null; Defensive patterns
Strategy: fallback
Validate before calling
const current = monitors.value.find((m) => m.id === currentMonitorId) ?? monitors.value[0]; if (!current) return; // no monitors yet — skip dock geometry
Type guard
function getMonitor(id: string) {
return monitors.value.find((m) => m.id === id) ?? monitors.value[0] ?? null;
} Try / catch
try {
layoutDock(_currentMonitor.rect);
} catch (e) {
if ((e as Error).message === "Current monitor not found") hideDock();
else throw e;
} Prevention
- Initialize monitor signals before the dock's first reactive evaluation.
- React to MonitorsChanged to refresh currentMonitorId after hot-plug/resume.
- Prefer returning a fallback monitor over throwing inside $derived.by.
When it happens
Trigger: Initial load before `monitors` is populated; `currentMonitorId` stale after unplugging the monitor the dock lives on; monitor id changed after sleep/resume or graphics-driver reset.
Common situations: Dock webview launching at startup racing the first monitor list event; docking/undocking a laptop; changing primary display in Windows settings while SeelenWeg is attached to it.
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/b2901d1e1be553da.
Report an issue: GitHub.