Remove recordings feature, replay sessions directly, bump to 0.6.0
CI / Build and push image (push) Successful in 1m41s
CI / Static checks (push) Successful in 2m12s

Recordings were just a thin named pointer over an already-captured
session's events, so the whole separate feature (recordings table, API
routes, pages, UI) is gone: any completed session can now be named and
replayed directly. Replaying no longer creates a session or duplicates
events of its own - it just bumps the source session's playCount/lastPlayedAt.

Also renames play_sessions/playSession(s) to sessions/session(s) throughout
the schema, queries, API routes, and UI for consistency, and updates the
README to match the new flow.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 21:38:51 +02:00
co-authored by Claude Sonnet 5
parent 2a3c4ff1f2
commit 401b9b5033
46 changed files with 1710 additions and 1018 deletions
+33 -41
View File
@@ -14,23 +14,23 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Trash2 } from "lucide-react";
import { Play, Trash2 } from "lucide-react";
import { toast } from "sonner";
interface BlockingRecording {
id: number;
name: string;
}
export interface SessionRow {
id: number;
name: string | null;
kind: "live" | "replay";
status: "active" | "completed" | "aborted";
startedAt: number;
durationMs: number | null;
}
const STATUS_VARIANT = {
active: "default",
completed: "secondary",
aborted: "destructive",
} as const;
function formatDuration(ms: number | null): string {
if (ms === null) return "-";
const totalSeconds = Math.round(ms / 1000);
@@ -41,30 +41,17 @@ function formatDuration(ms: number | null): string {
export function SessionsTable({ sessions }: { sessions: SessionRow[] }) {
const router = useRouter();
const [conflict, setConflict] = useState<{ id: number; recordings: BlockingRecording[] } | null>(null);
const [pendingDelete, setPendingDelete] = useState<SessionRow | null>(null);
const [deleting, setDeleting] = useState(false);
async function handleDelete(id: number) {
const res = await fetch(`/api/play-sessions/${id}`, { method: "DELETE" });
if (res.ok) {
toast.success("Session deleted");
router.refresh();
} else if (res.status === 409) {
const body: { recordings?: BlockingRecording[] } = await res.json().catch(() => ({}));
setConflict({ id, recordings: body.recordings ?? [] });
} else {
toast.error("Could not delete session");
}
}
async function handleCascadeDelete() {
if (!conflict) return;
async function handleDelete() {
if (!pendingDelete) return;
setDeleting(true);
const res = await fetch(`/api/play-sessions/${conflict.id}?cascade=true`, { method: "DELETE" });
const res = await fetch(`/api/sessions/${pendingDelete.id}`, { method: "DELETE" });
setDeleting(false);
if (res.ok) {
toast.success("Session and recording deleted");
setConflict(null);
toast.success("Session deleted");
setPendingDelete(null);
router.refresh();
} else {
toast.error("Could not delete session");
@@ -81,7 +68,6 @@ export function SessionsTable({ sessions }: { sessions: SessionRow[] }) {
<TableHeader>
<TableRow>
<TableHead>Session</TableHead>
<TableHead>Kind</TableHead>
<TableHead>Status</TableHead>
<TableHead>Started</TableHead>
<TableHead>Duration</TableHead>
@@ -97,15 +83,21 @@ export function SessionsTable({ sessions }: { sessions: SessionRow[] }) {
</Link>
</TableCell>
<TableCell>
<Badge variant={s.kind === "live" ? "default" : "secondary"}>{s.kind}</Badge>
<Badge variant={STATUS_VARIANT[s.status]}>{s.status}</Badge>
</TableCell>
<TableCell className="text-muted-foreground">{s.status}</TableCell>
<TableCell className="bp-readout text-muted-foreground">
{new Date(s.startedAt).toLocaleString()}
</TableCell>
<TableCell className="bp-readout">{formatDuration(s.durationMs)}</TableCell>
<TableCell className="text-right">
<Button variant="ghost" size="icon-sm" onClick={() => void handleDelete(s.id)} aria-label="Delete">
<TableCell className="flex justify-end gap-1">
{s.status === "completed" && s.durationMs !== null && (
<Button asChild variant="ghost" size="icon-sm">
<Link href={`/sessions/${s.id}/replay`} aria-label="Replay">
<Play className="size-3.5" />
</Link>
</Button>
)}
<Button variant="ghost" size="icon-sm" onClick={() => setPendingDelete(s)} aria-label="Delete">
<Trash2 className="size-3.5" />
</Button>
</TableCell>
@@ -114,24 +106,24 @@ export function SessionsTable({ sessions }: { sessions: SessionRow[] }) {
</TableBody>
</Table>
<Dialog open={conflict !== null} onOpenChange={(open) => !open && setConflict(null)}>
<Dialog open={pendingDelete !== null} onOpenChange={(open) => !open && setPendingDelete(null)}>
<DialogContent>
<DialogHeader>
<DialogTitle>Delete session and recording?</DialogTitle>
<DialogTitle>Delete session?</DialogTitle>
<DialogDescription>
This session has a saved recording
{conflict && conflict.recordings.length > 0
? ` (${conflict.recordings.map((r) => r.name).join(", ")})`
: ""}{" "}
that still points to it. Deleting the session will also delete that recording.
This permanently deletes{" "}
<span className="font-medium text-foreground">
{pendingDelete?.name ?? `Session #${pendingDelete?.id}`}
</span>{" "}
and all of its recorded events. This can&apos;t be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="ghost" onClick={() => setConflict(null)}>
<Button variant="ghost" onClick={() => setPendingDelete(null)}>
Cancel
</Button>
<Button variant="destructive" onClick={() => void handleCascadeDelete()} disabled={deleting}>
{deleting ? "Deleting..." : "Delete both"}
<Button variant="destructive" onClick={() => void handleDelete()} disabled={deleting}>
{deleting ? "Deleting..." : "Delete"}
</Button>
</DialogFooter>
</DialogContent>