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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-10-16 15:48:36 +02:00
co-authored by Claude Opus 5.5
parent 01495aed25
commit ed06bdec6b
56 changed files with 3539 additions and 2404 deletions
@@ -51,7 +51,7 @@ const GROUPS: {
{ category: "output", label: "Outputs", icon: LogOut },
{ category: "dashboard", label: "Dashboards", icon: LayoutDashboard },
{ category: "widget", label: "Widgets", icon: LayoutGrid },
{ category: "panel", label: "Panels", icon: MonitorSmartphone },
{ category: "device", label: "Devices", icon: MonitorSmartphone },
{ category: "secret", label: "Secrets", icon: KeyRound },
{ category: "module", label: "Modules", icon: Package },
{ category: "worker", label: "Workers", icon: Server },
@@ -179,13 +179,8 @@ export function GlobalSearch({
to: "/dashboards/$name",
params: { name: entry.parent ?? "" },
})
// Panels are managed in a dialog on the dashboards screen, which opens
// itself when the address says so.
case "panel":
return navigate({
to: "/dashboards",
search: { panels: true, panel: entry.name },
})
case "device":
return navigate({ to: "/devices/$id", params: { id: entry.name } })
case "secret":
return navigate({ to: "/secrets" })
case "module":
@@ -47,7 +47,7 @@ export function useSelection(names: string[]) {
}
/**
* One entry of the flows or dashboards overview.
* One entry of the flows, dashboards or devices overview.
*
* Stays a link in both modes rather than swapping element: while selecting it
* carries `role="checkbox"` instead, which is what it now behaves as. Ctrl or
@@ -60,6 +60,7 @@ export function OverviewCard({
title,
detail,
draft,
online,
selecting,
selected,
onToggle,
@@ -71,6 +72,8 @@ export function OverviewCard({
detail: ReactNode
/** Has unpublished changes. */
draft?: boolean
/** Connected right now, for a device. */
online?: boolean
selecting: boolean
selected: boolean
onToggle: () => void
@@ -137,6 +140,11 @@ export function OverviewCard({
<span className="sr-only">Unpublished changes</span>
</span>
) : null}
{online ? (
<span className="size-1.5 shrink-0 rounded-full bg-status-success">
<span className="sr-only">Online</span>
</span>
) : null}
</span>
<span className="truncate text-sm text-muted-foreground">{detail}</span>
@@ -43,8 +43,8 @@ export function OverviewToolbar({
searchTestId,
createLabel,
createTestId,
draftCount,
publishing,
draftCount = 0,
publishing = false,
onPublishAll,
selectedCount = 0,
onDeleteSelected,
@@ -59,9 +59,10 @@ export function OverviewToolbar({
createLabel: string
createTestId: string
/** How many of the listed documents have unpublished changes. */
draftCount: number
publishing: boolean
onPublishAll: () => void
draftCount?: number
publishing?: boolean
/** Left out for a list of things that have no drafts, such as devices. */
onPublishAll?: () => void
/** How many entries are picked; above zero the list is in selection mode. */
selectedCount?: number
onDeleteSelected?: () => void
@@ -125,7 +126,7 @@ export function OverviewToolbar({
</Tooltip>
)}
{selectedCount > 0 ? (
{selectedCount > 0 && onDuplicateSelected ? (
<Tooltip>
<TooltipTrigger asChild>
<Button
@@ -176,30 +177,32 @@ export function OverviewToolbar({
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
{/* A disabled button gets no pointer events, so the tooltip that
{onPublishAll ? (
<Tooltip>
<TooltipTrigger asChild>
{/* A disabled button gets no pointer events, so the tooltip that
explains why it is disabled needs a wrapper to hang on. */}
<span>
<Button
variant="ghost"
size="icon-touch"
className="text-muted-foreground"
disabled={draftCount === 0 || publishing}
onClick={onPublishAll}
aria-label="Publish all changes"
data-testid="publish-all"
>
{publishing ? <FluksioLoader /> : <Check />}
</Button>
</span>
</TooltipTrigger>
<TooltipContent>
{draftCount === 0
? "Nothing unpublished"
: `Publish ${draftCount} unpublished change${draftCount === 1 ? "" : "s"}`}
</TooltipContent>
</Tooltip>
<span>
<Button
variant="ghost"
size="icon-touch"
className="text-muted-foreground"
disabled={draftCount === 0 || publishing}
onClick={onPublishAll}
aria-label="Publish all changes"
data-testid="publish-all"
>
{publishing ? <FluksioLoader /> : <Check />}
</Button>
</span>
</TooltipTrigger>
<TooltipContent>
{draftCount === 0
? "Nothing unpublished"
: `Publish ${draftCount} unpublished change${draftCount === 1 ? "" : "s"}`}
</TooltipContent>
</Tooltip>
) : null}
</div>
)
}