/* Copyright 2026 Marimo. All rights reserved. */
import { useAtomValue } from "jotai";
import { AlertTriangleIcon, XCircleIcon } from "lucide-react";
import type React from "react";
import { renderShortcut } from "@/components/shortcuts/renderShortcut";
import { Tooltip } from "@/components/ui/tooltip";
import { cellErrorCount } from "@/core/cells/cells";
import { isConnectingAtom } from "@/core/network/connection";
import { useHotkey } from "@/hooks/useHotkey";
import { ShowInKioskMode } from "../../kiosk-mode";
import { panelLayoutAtom, useChromeActions, useChromeState } from "../state";
import { FooterItem } from "./footer-item";
import { AIStatusIcon } from "./footer-items/ai-status";
import {
BackendConnectionStatus,
connectionStatusAtom,
} from "./footer-items/backend-status";
import { CopilotStatusIcon } from "./footer-items/copilot-status";
import { MachineStats } from "./footer-items/machine-stats";
import { RTCStatus } from "./footer-items/rtc-status";
import { RuntimeSettings } from "./footer-items/runtime-settings";
import { useSetDependencyPanelTab } from "./useDependencyPanelTab";
export const Footer: React.FC = () => {
const { isDeveloperPanelOpen } = useChromeState();
const { toggleDeveloperPanel, toggleApplication } = useChromeActions();
const setDependencyPanelTab = useSetDependencyPanelTab();
const errorCount = useAtomValue(cellErrorCount);
const connectionStatus = useAtomValue(connectionStatusAtom);
const panelLayout = useAtomValue(panelLayoutAtom);
// Show issue count: cell errors + connection issues
// Don't include error count if errors panel is in sidebar (it shows there instead)
const errorsInSidebar = panelLayout.sidebar.includes("errors");
const hasConnectionIssue =
connectionStatus === "unhealthy" || connectionStatus === "disconnected";
const issueCount =
(errorsInSidebar ? 0 : errorCount) + (hasConnectionIssue ? 1 : 0);
// TODO: Add warning count from diagnostics/linting
// This can signal warnings/errors with settings up AI / Copilot etc
const warningCount = 0;
useHotkey("global.toggleTerminal", () => {
toggleApplication("terminal");
});
useHotkey("global.togglePanel", () => {
toggleDeveloperPanel();
});
useHotkey("global.toggleMinimap", () => {
toggleApplication("dependencies");
setDependencyPanelTab("minimap");
});
return (
);
};
/**
* Only show the backend connection status if we are connecting to a kernel
*/
const ConnectingKernelIndicatorItem: React.FC = () => {
const isConnecting = useAtomValue(isConnectingAtom);
if (!isConnecting) {
return null;
}
return ;
};