Remove recordings feature, replay sessions directly, bump to 0.6.0
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:
@@ -1,15 +1,18 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import type { Metadata } from "next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
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 { getSessionDetail, getSessionName } from "@/lib/db/queries/sessions";
|
||||
import { getSessionTimeline } from "@/lib/db/queries/stats";
|
||||
import { Play } from "lucide-react";
|
||||
|
||||
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));
|
||||
const name = await getSessionName(Number(id));
|
||||
return { title: name ?? `Session #${id}` };
|
||||
}
|
||||
|
||||
@@ -22,16 +25,40 @@ function formatDuration(ms: number | null): string {
|
||||
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)]);
|
||||
const [detail, timeline] = await Promise.all([getSessionDetail(sessionId), getSessionTimeline(sessionId)]);
|
||||
if (!detail) notFound();
|
||||
|
||||
const canReplay = detail.session.status === "completed" && detail.session.durationMs !== null;
|
||||
|
||||
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 className="flex items-center justify-between gap-4">
|
||||
<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.status} · {formatDuration(detail.session.durationMs)}
|
||||
{detail.session.kind === "replay" && detail.replayedFromName !== undefined && (
|
||||
<> · replayed from {detail.replayedFromName ?? `session #${detail.session.replayedSessionId}`}</>
|
||||
)}
|
||||
{detail.session.playCount > 0 && (
|
||||
<>
|
||||
{" "}
|
||||
· replayed {detail.session.playCount}×
|
||||
{detail.session.lastPlayedAt && ` (last ${new Date(detail.session.lastPlayedAt).toLocaleString()})`}
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
{detail.session.description && (
|
||||
<p className="mt-1 text-sm text-muted-foreground">{detail.session.description}</p>
|
||||
)}
|
||||
</div>
|
||||
{canReplay && (
|
||||
<Button asChild>
|
||||
<Link href={`/sessions/${detail.session.id}/replay`}>
|
||||
<Play className="size-4" /> Replay
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Card className="bp-glass">
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Metadata } from "next";
|
||||
import { ReplayPlayerLoader } from "@/components/sessions/ReplayPlayerLoader";
|
||||
import { getSessionName } from "@/lib/db/queries/sessions";
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
const name = await getSessionName(Number(id));
|
||||
return { title: name ? `Replay ${name}` : "Replay" };
|
||||
}
|
||||
|
||||
export default async function ReplayPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<h1 className="font-heading text-2xl font-semibold">Replay</h1>
|
||||
<ReplayPlayerLoader sessionId={Number(id)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import type { Metadata } from "next";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { SessionsTable } from "@/components/sessions/SessionsTable";
|
||||
import { PageNav } from "@/components/shared/PageNav";
|
||||
import { listPlaySessionsPage } from "@/lib/db/queries/play-sessions";
|
||||
import { listSessionsPage } from "@/lib/db/queries/sessions";
|
||||
import { parsePage } from "@/lib/pagination";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -14,7 +14,7 @@ export default async function SessionsPage({
|
||||
searchParams: Promise<{ page?: string }>;
|
||||
}) {
|
||||
const page = parsePage((await searchParams).page);
|
||||
const { items: sessions, pageSize, total } = await listPlaySessionsPage(page);
|
||||
const { items: sessions, pageSize, total } = await listSessionsPage(page);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
Reference in New Issue
Block a user