// frontend/src/shell/NavSessions.tsx
import type { ReactNode } from "react";
import type { SessionSummary } from "../api/types";
interface Props {
sessions: SessionSummary[];
activeSessionId: string | null;
onOpenPanel: (id: string) => void;
menuFor: (session: SessionSummary) => ReactNode;
}
export function NavSessions({ sessions, activeSessionId, onOpenPanel, menuFor }: Props) {
if (sessions.length === 0) {
return (
No sessions yet. Start with New session.
);
}
return (
{sessions.map((s) => {
const active = s.id === activeSessionId;
const label = s.name || s.question || s.id;
return (
-
onOpenPanel(s.id)}
role="button"
tabIndex={0}
aria-label={label}
title={`${label} ยท ${s.status}`}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
onOpenPanel(s.id);
}
}}
className={[
"group flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-left transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
active ? "bg-[oklch(var(--primary)/0.12)]" : "hover:bg-accent",
].join(" ")}
>
{label}
{menuFor(s)}
);
})}
);
}