- Fix device rename input collapsing on mobile (fixed width vs w-full inside an auto-layout table column). - Add cascade-delete confirmation for sessions with a saved recording. - Fix header connection LED: derive state from scanning/device-count/ recording instead of the Buttplug client's raw connected flag; drop the label text and hide the indicator entirely when idle. - Add a per-device disconnect button (stop + remove from store, the closest equivalent Buttplug's protocol allows per device). - Fix replay ending early: duration now comes from the recording's actual durationMs, not the last event's timestamp. - Replay robustness: show which devices are being replayed to, reset actuators to zero on start/play/pause, fully disconnect devices and the whole client on stop/unmount, surface command failures via toast. - Stop flagging the header LED red during replay - recording is only for live sessions. - Add page-number pagination to recordings/sessions/devices lists. - Wordmark SEXY -> Sexy; add proper per-page <title>s including dynamic titles for recording/session detail and replay pages. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import type { Metadata } from "next";
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { SessionTimelineChart } from "@/components/sessions/SessionTimelineChart";
|
|
import { getPlaySessionDetail, getPlaySessionName } from "@/lib/db/queries/play-sessions";
|
|
import { getSessionTimeline } from "@/lib/db/queries/stats";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> {
|
|
const { id } = await params;
|
|
const name = await getPlaySessionName(Number(id));
|
|
return { title: name ?? `Session #${id}` };
|
|
}
|
|
|
|
function formatDuration(ms: number | null): string {
|
|
if (ms === null) return "-";
|
|
const totalSeconds = Math.round(ms / 1000);
|
|
return `${Math.floor(totalSeconds / 60)}:${(totalSeconds % 60).toString().padStart(2, "0")}`;
|
|
}
|
|
|
|
export default async function SessionDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
const sessionId = Number(id);
|
|
const [detail, timeline] = await Promise.all([getPlaySessionDetail(sessionId), getSessionTimeline(sessionId)]);
|
|
if (!detail) notFound();
|
|
|
|
return (
|
|
<div className="flex flex-col gap-6">
|
|
<div>
|
|
<h1 className="font-heading text-2xl font-semibold">{detail.session.name ?? `Session #${detail.session.id}`}</h1>
|
|
<p className="text-sm text-muted-foreground">
|
|
{detail.session.kind} · {detail.session.status} · {formatDuration(detail.session.durationMs)}
|
|
</p>
|
|
</div>
|
|
|
|
<Card className="bp-glass">
|
|
<CardHeader>
|
|
<CardTitle className="text-base">Intensity timeline</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<SessionTimelineChart timeline={timeline} />
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card className="bp-glass">
|
|
<CardHeader>
|
|
<CardTitle className="text-base">Devices</CardTitle>
|
|
</CardHeader>
|
|
<CardContent className="flex flex-col gap-1">
|
|
{detail.devices.map((d) => (
|
|
<div key={d.id} className="text-sm">
|
|
{d.slotLabel} <span className="text-muted-foreground">({d.deviceDisplayName ?? d.deviceBleName})</span>
|
|
</div>
|
|
))}
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|