import { auth } from '@/auth' import { db } from '@/lib/db' import { sessions } from '@/lib/db/schema' import { eq, desc } from 'drizzle-orm' import { Card, CardContent } from '@/components/ui/card' import { History, Clock, Monitor, CheckCircle2, Circle, Link2 } from 'lucide-react' import { format, formatDistanceToNow } from 'date-fns' function formatDuration(seconds: number | null) { if (!seconds) return '-' const h = Math.floor(seconds / 3600) const m = Math.floor((seconds % 3600) / 60) const s = seconds % 60 if (h > 0) return `${h}h ${m}m` if (m > 0) return `${m}m ${s}s` return `${s}s` } export default async function SessionsPage() { const session = await auth() const sessionList = await db .select() .from(sessions) .where(eq(sessions.viewerUserId, session!.user.id)) .orderBy(desc(sessions.startedAt)) .limit(50) return (
View your remote connection history
{s.machineName || 'Unknown Machine'}
{s.endedAt ?Started
{format(new Date(s.startedAt), 'MMM d, h:mm a')}
Duration
Status
{s.endedAt ? 'Completed' : 'Active'}
{s.notes}
Your remote session history will appear here once you start connecting to machines.