/** * CliInstallWarningBanner — Global warning strip shown below the tab bar * when the configured runtime is unavailable. * * Hidden on Dashboard pages (which have their own detailed CliStatusBanner). * Only rendered in Electron mode. */ import { useAppTranslation } from '@features/localization/renderer'; import { isElectronMode } from '@renderer/api'; import { useStore } from '@renderer/store'; import { AlertTriangle } from 'lucide-react'; import { useShallow } from 'zustand/react/shallow'; export const CliInstallWarningBanner = (): React.JSX.Element | null => { const { t } = useAppTranslation('common'); const cliStatus = useStore(useShallow((s) => s.cliStatus)); const cliStatusLoading = useStore((s) => s.cliStatusLoading); const openDashboard = useStore((s) => s.openDashboard); // Returns a primitive boolean — minimizes re-renders const isDashboardFocused = useStore((s) => { const fp = s.paneLayout.panes.find((p) => p.id === s.paneLayout.focusedPaneId); if (!fp) return false; if (fp.tabs.length === 0) return true; // empty pane = default DashboardView return fp.tabs.find((t) => t.id === fp.activeTabId)?.type === 'dashboard'; }); // Hide when: not Electron, status not loaded yet, CLI installed, or dashboard is focused if ( !isElectronMode() || cliStatusLoading || !cliStatus || cliStatus.installed || isDashboardFocused ) { return null; } return (
{cliStatus.binaryPath && cliStatus.launchError ? `The configured ${cliStatus.displayName} runtime was found but failed to start. Open the Dashboard to repair or reinstall it.` : `The configured ${cliStatus.displayName} runtime is not installed. Install it from the Dashboard to enable all features.`}
); };