"use client" import React, { useEffect, useState } from "react" import Link from "next/link" import { usePathname, useRouter, useSearchParams } from "next/navigation" import { Waveform, Handshake, Heart, Plus, X, Broadcast, } from "@phosphor-icons/react" import Image from "next/image" import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from "@/components/ui/sidebar" import { listRecentSessions, ensureStoreInitialized, removeRecentSession, type RecentSession, } from "@/lib/session-store" const PRODUCTS_ITEMS = [ { title: "Sales", url: "/sales", icon: Handshake, disabled: true }, { title: "Companionship", url: "/companionship", icon: Heart, disabled: true }, ] function formatDuration(s: number) { const m = Math.floor(s / 60) const sec = Math.floor(s % 60) return `${m}:${sec.toString().padStart(2, "0")}` } function stripExtension(name: string) { return name.replace(/\.[^/.]+$/, "") } export function AppSidebar() { const pathname = usePathname() const router = useRouter() const searchParams = useSearchParams() const currentSessionId = searchParams.get("s") const [recent, setRecent] = useState([]) // Load and refresh recent sessions whenever pathname changes useEffect(() => { ensureStoreInitialized() setRecent(listRecentSessions()) }, [pathname]) function handleDelete(id: string, e: React.MouseEvent) { e.preventDefault() e.stopPropagation() removeRecentSession(id) setRecent(listRecentSessions()) // Navigate home if we just deleted the active session if (currentSessionId === id) { router.push("/") } } return (
Ethos Studio Ethos | Studio
{/* Top-level nav */} Create Live Mode {/* Recent Sessions */} Recent {recent.length === 0 ? (
  • No sessions yet
  • ) : ( recent.map((session) => { const href = `/studio?s=${session.id}` return (
    {stripExtension(session.filename)} {formatDuration(session.duration)} ยท {session.speakerCount} speaker{session.speakerCount !== 1 ? "s" : ""}
    ) }) )}
    {/* Products */} Products {PRODUCTS_ITEMS.map((item) => ( {item.disabled ? (
    {item.title}
    ) : ( {item.title} )}
    ))}
    Developer Coming soon
    ) }