Panels become devices: per-device documents in the flow repo, a Devices tab

- flow/devices.py: DeviceDef in FLOWS_DIR/_devices/<id>.json, committed under
  the flow store's write lock, 409 on a stale version; nonces in DEVICES_FILE
  outside git; in-memory presence announced as device_status
- api/routes/devices.py: CRUD, pairing with an optional {name, board,
  firmware}, a pending list adopted without a code from the LAN only, unpair;
  /panels/pair, /panels/pair/{code} and GET /panels/{id} kept as aliases,
  PUT /panels/ gone
- _device_may replaces _panel_may, JWT claims unchanged
- panels.json moves into devices once at startup, then .migrated
- MCP list_devices, get_device; search category device
- Devices tab (list, detail with presence, pairing, ordered dashboards,
  touch, I/O), PanelsDialog removed, serialised optimistic saves
This commit is contained in:
Melvin Strobl
2026-10-16 15:48:36 +02:00
parent 3c0912a3fe
commit 28a565e501
56 changed files with 3539 additions and 2404 deletions
@@ -31,6 +31,7 @@ import {
DockSeparator,
PublishButton,
} from "@/components/Common/Dock"
import { devicesQueryOptions } from "@/components/Devices/queries"
import { CanvasTitle } from "@/components/Flow/CanvasTitle"
import { Button } from "@/components/ui/button"
import {
@@ -68,7 +69,6 @@ import { LockNotice } from "./PanelSurface"
import { DashboardPanel, WidgetPanel } from "./panels"
import {
dashboardKeys,
panelsQueryOptions,
useDiscardDashboardDraft,
usePublishDashboard,
useSaveDashboard,
@@ -580,16 +580,16 @@ export function DashboardEditor({
),
)
// A dashboard hanging on a panel beside others is drawn with a rail on it,
// A dashboard hanging on a device beside others is drawn with a rail on it,
// which takes room off the canvas. Show that here rather than letting someone
// arrange against a width the wall does not have.
// ponytail: the first such panel wins — the others differ only in scale.
const { data: panels } = useQuery(panelsQueryOptions())
// ponytail: the first such device wins — the others differ only in scale.
const { data: devices } = useQuery(devicesQueryOptions())
const railDashboards =
(panels?.panels ?? []).find(
(panel) =>
(panel.dashboards ?? []).length > 1 &&
(panel.dashboards ?? []).includes(draft.name),
(devices?.data ?? []).find(
(device) =>
(device.dashboards ?? []).length > 1 &&
(device.dashboards ?? []).includes(draft.name),
)?.dashboards ?? null
// A round face has no room for one: a panel swipes between those instead.
const hasRail = Boolean(railDashboards) && !stacked && !round