import { useEffect } from "react"; import Sidebar from "./components/Sidebar"; import Topbar from "./components/Topbar"; import Overview from "./tabs/Overview"; import Sessions from "./tabs/Sessions"; import Agents from "./tabs/Agents"; import Activity from "./tabs/Activity"; import Cost from "./tabs/Cost"; import Plans from "./tabs/Plans"; import Settings from "./tabs/Settings"; import AgentLog from "./components/AgentLog"; import ConfirmModal from "./components/ConfirmModal"; import Toast from "./components/Toast"; import { useHive } from "./store"; import { selectProject, setActiveTab } from "./store/raw"; import { connect } from "./store/wiring"; import { relTime, sessionSlug } from "./lib/format"; // Scope subtitle. Isolated into its own leaf so the 1s `now` tick (needed only // for the "updated Xs ago" clause at session scope) re-renders this line alone, // not the whole tab tree. function ScopeSubtitle() { const scope = useHive((s) => s.scope); const scopeTitle = useHive((s) => s.scopeTitle); const scopedStats = useHive((s) => s.scopedStats); const now = useHive((s) => s.now); const s = scope; const st = scopedStats; let text: string; if (s.level === "fleet") text = `${st.sessions} sessions across all projects · ${st.live} live · ${st.running} agents running`; else if (s.level === "project") text = `${st.sessions} session${st.sessions === 1 ? "" : "s"} · ${st.live} live · ${st.running} agents running`; else { const sess = scopeTitle.session; text = sess ? `Session ${sessionSlug(sess.session_id)} · ${sess.live ? `${sess.running} agents running` : "idle"} · updated ${relTime(sess.last_ts, now || Date.now())}` : "session"; } return
{text}
; } export default function App() { const activeTab = useHive((s) => s.activeTab); const scope = useHive((s) => s.scope); const scopeTitle = useHive((s) => s.scopeTitle); useEffect(() => { connect(); }, []); // Settings is project-scoped: if the user drops to fleet scope while on the // Settings tab, send them back to Overview so they aren't on a hidden tab. useEffect(() => { if (activeTab === "settings" && scope.level === "fleet") setActiveTab("overview"); }, [activeTab, scope.level]); return (

{scopeTitle.title}

{scope.level === "session" && ( )}
{activeTab === "sessions" ? : activeTab === "agents" ? : activeTab === "plans" ? : activeTab === "activity" ? : activeTab === "cost" ? : activeTab === "settings" ? (scope.level !== "fleet" ? : ) : }
); }