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
+5 -6
View File
@@ -5,21 +5,20 @@ import { useCallback, useMemo, useState } from "react"
import type { Dashboard } from "@/components/Dashboard/DashboardView"
import { PanelRail } from "@/components/Dashboard/PanelRail"
import { PanelSurface } from "@/components/Dashboard/PanelSurface"
import {
dashboardQueryOptions,
panelQueryOptions,
} from "@/components/Dashboard/queries"
import { dashboardQueryOptions } from "@/components/Dashboard/queries"
import {
LookProvider,
useCanvasRoot,
} from "@/components/Dashboard/ui/core/look"
import { deviceQueryOptions } from "@/components/Devices/queries"
import { useFlowSocket } from "@/components/Flow/useFlowSocket"
import { isLoggedIn } from "@/hooks/useAuth"
import { useIsMobile } from "@/hooks/useMobile"
import { cn } from "@/lib/utils"
/**
* What a paired device shows: the dashboards this panel was assigned.
* What a paired device shows: the dashboards it was assigned. The address
* stays `/panel/{id}`, which is what screens already hanging were pointed at.
*
* The same full-bleed surface as `/view/{name}`, with a rail down the left
* (along the bottom on a phone) when there is more than one to switch between — so a hallway tablet and a
@@ -50,7 +49,7 @@ function PanelRoute() {
const navigate = Route.useNavigate()
useFlowSocket()
const { data: panel } = useQuery(panelQueryOptions(id))
const { data: panel } = useQuery(deviceQueryOptions(id))
const dashboards = panel?.dashboards ?? []
// A name in the URL that this panel no longer carries falls back to the
// first, which is what a dashboard removed from under a running panel does.