import { LogOut, PanelRight } from "lucide-react"; import type { ReactNode } from "react"; import type { GuestSnapshot } from "../../lib/client"; import { fmtPercent, shortenPath } from "../../lib/format"; import { ThemeToggle } from "./ThemeToggle"; export interface HeaderBarProps { snapshot: GuestSnapshot; subCount: number; railOpen: boolean; onToggleRail(): void; onLeave(): void; } export function HeaderBar({ snapshot, subCount, railOpen, onToggleRail, onLeave }: HeaderBarProps): ReactNode { const { header, state, phase, readOnly } = snapshot; const title = header?.title ?? state?.sessionName ?? "session"; const usage = state?.contextUsage; let pct: number | null = null; if (usage) { pct = usage.percent ?? (usage.tokens != null && usage.contextWindow !== null && usage.contextWindow > 0 ? (usage.tokens / usage.contextWindow) * 100 : null); } return (
{title} {state?.cwd && ( {shortenPath(state.cwd)} )}
{readOnly && ( read-only )} {state?.model && {state.model.name}} {state?.thinkingLevel && {state.thinkingLevel}} {pct != null && ( 80 ? "sh-gauge sh-gauge-warn" : "sh-gauge"} title={`context · ${fmtPercent(pct)}`} > {fmtPercent(pct)} )} {state && state.participants.length > 0 && ( {state.participants.map((p, i) => ( {(p.name[0] ?? "?").toUpperCase()} ))} )}
); }