Some checks failed
Test / frontend-tests (pull_request) Successful in 1m26s
Test / frontend-typecheck (pull_request) Successful in 1m35s
PR Review Automation / review (pull_request) Successful in 5m6s
Test / rust-fmt-check (pull_request) Failing after 11m23s
Test / rust-clippy (pull_request) Successful in 13m2s
Test / rust-tests (pull_request) Successful in 14m47s
Blockers: - Replace serde_yaml::from_str with serde_json::from_str in all 6 parse_*_json functions (parse_namespaces, parse_pods, parse_services, parse_deployments, parse_statefulsets, parse_daemonsets). Update .as_sequence() → .as_array(), .as_mapping() → .as_object(), and mapping iterator patterns throughout. Explicitly type serde_yaml::Value in extract_context/extract_server_url which legitimately parse YAML. Warnings: - Add containers: Vec<String> to PodInfo struct; parse from spec.containers[].name in parse_pods_json - Fix PodList.tsx to use selectedPod.containers instead of [selectedPod.name] - Fix exec_pod: add optional shell param with allowlist validation (sh/bash/ash/dash); correct arg ordering — -c container now placed before -- separator - Handle empty namespace with --all-namespaces in all 5 list commands - Fix dialog overflow: overflow-hidden → overflow-y-auto on inner div - Memoize namespace options with useMemo in ResourceBrowser Lint cleanup (all pre-existing, surfaced by eslint config fix): - Deduplicate eslint.config.js (was doubled to 272 lines); move ignores to standalone global object; allow console.log in cli section - Remove stale .eslintignore (migrated to eslint.config.js) - Remove unused Card/CardTitle imports from Kubernetes list components - Rename unused props to _clusterId/_namespace in DaemonSetList, ServiceList, StatefulSetList - Fix useEffect/useCallback missing deps in Triage and LogUpload - Remove debug console.log from App.tsx provider auto-test - Rename unused hover prop to _hover in TableRow (ui/index.tsx) - Add #[allow(unused_variables)] to Phase 3 stub Tauri commands - Restore get_pod_logs, scale_deployment, restart_deployment, delete_resource, exec_pod to lib.rs handler registration (were accidentally dropped in Phase 3 expansion) All checks pass: cargo clippy -D warnings, tsc --noEmit, eslint --max-warnings 0, 331 Rust tests, 98 frontend tests.
211 lines
8.0 KiB
TypeScript
211 lines
8.0 KiB
TypeScript
import React, { useState, useEffect, useRef } from "react";
|
|
import { Routes, Route, NavLink, useLocation } from "react-router-dom";
|
|
import {
|
|
Home,
|
|
Plus,
|
|
Clock,
|
|
Cpu,
|
|
Bot,
|
|
Shield,
|
|
Link,
|
|
Plug,
|
|
ChevronLeft,
|
|
ChevronRight,
|
|
Sun,
|
|
Moon,
|
|
Terminal,
|
|
FileCode,
|
|
Server,
|
|
} from "lucide-react";
|
|
import { useSettingsStore } from "@/stores/settingsStore";
|
|
import { getAppVersionCmd, loadAiProvidersCmd, testProviderConnectionCmd, shutdownPortForwardsCmd } from "@/lib/tauriCommands";
|
|
|
|
import Dashboard from "@/pages/Dashboard";
|
|
import NewIssue from "@/pages/NewIssue";
|
|
import LogUpload from "@/pages/LogUpload";
|
|
import Triage from "@/pages/Triage";
|
|
import Resolution from "@/pages/Resolution";
|
|
import RCA from "@/pages/RCA";
|
|
import Postmortem from "@/pages/Postmortem";
|
|
import History from "@/pages/History";
|
|
import AIProviders from "@/pages/Settings/AIProviders";
|
|
import Ollama from "@/pages/Settings/Ollama";
|
|
import Integrations from "@/pages/Settings/Integrations";
|
|
import MCPServers from "@/pages/Settings/MCPServers";
|
|
import Security from "@/pages/Settings/Security";
|
|
import ShellExecution from "@/pages/Settings/ShellExecution";
|
|
import KubeconfigManager from "@/pages/Settings/KubeconfigManager";
|
|
import { KubernetesPage } from "@/pages/Kubernetes/KubernetesPage";
|
|
import { ShellApprovalModal } from "@/components/ShellApprovalModal";
|
|
|
|
const navItems = [
|
|
{ to: "/", icon: Home, label: "Dashboard" },
|
|
{ to: "/new-issue", icon: Plus, label: "New Issue" },
|
|
{ to: "/kubernetes", icon: Server, label: "Kubernetes" },
|
|
{ to: "/history", icon: Clock, label: "History" },
|
|
];
|
|
|
|
const settingsItems = [
|
|
{ to: "/settings/providers", icon: Cpu, label: "AI Providers" },
|
|
{ to: "/settings/ollama", icon: Bot, label: "Ollama" },
|
|
{ to: "/settings/shell", icon: Terminal, label: "Shell Execution" },
|
|
{ to: "/settings/kubeconfig", icon: FileCode, label: "Kubeconfig" },
|
|
{ to: "/settings/integrations", icon: Link, label: "Integrations" },
|
|
{ to: "/settings/mcp", icon: Plug, label: "MCP Servers" },
|
|
{ to: "/settings/security", icon: Shield, label: "Security" },
|
|
];
|
|
|
|
export default function App() {
|
|
const [collapsed, setCollapsed] = useState(false);
|
|
const [appVersion, setAppVersion] = useState("");
|
|
const { theme, setTheme, setProviders, getActiveProvider } = useSettingsStore();
|
|
const cleanupDone = useRef(false);
|
|
void useLocation();
|
|
|
|
useEffect(() => {
|
|
getAppVersionCmd().then(setAppVersion).catch(() => {});
|
|
}, []);
|
|
|
|
// Cleanup port forwards on app unmount
|
|
useEffect(() => {
|
|
return () => {
|
|
if (!cleanupDone.current) {
|
|
cleanupDone.current = true;
|
|
void shutdownPortForwardsCmd().catch((err) => {
|
|
console.error("Failed to shutdown port forwards:", err);
|
|
});
|
|
}
|
|
};
|
|
}, []);
|
|
|
|
// Load providers and auto-test active provider on startup
|
|
useEffect(() => {
|
|
const initializeProviders = async () => {
|
|
try {
|
|
const providers = await loadAiProvidersCmd();
|
|
setProviders(providers);
|
|
|
|
// Auto-test the active provider
|
|
const activeProvider = getActiveProvider();
|
|
if (activeProvider) {
|
|
try {
|
|
await testProviderConnectionCmd(activeProvider);
|
|
} catch (err) {
|
|
console.warn("⚠ Active provider connection test failed:", activeProvider.name, err);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error("Failed to initialize AI providers:", err);
|
|
}
|
|
};
|
|
initializeProviders();
|
|
}, [setProviders, getActiveProvider]);
|
|
|
|
return (
|
|
<div className={theme === "dark" ? "dark" : ""}>
|
|
<ShellApprovalModal />
|
|
<div className="grid h-screen" style={{ gridTemplateColumns: collapsed ? "64px 1fr" : "240px 1fr" }}>
|
|
{/* Sidebar */}
|
|
<aside className="bg-card border-r flex flex-col h-screen overflow-y-auto">
|
|
{/* Logo */}
|
|
<div className="flex items-center justify-between px-4 py-4 border-b">
|
|
{!collapsed && (
|
|
<span className="text-lg font-bold text-foreground tracking-tight">
|
|
Troubleshooting and RCA Assistant
|
|
</span>
|
|
)}
|
|
<button
|
|
onClick={() => setCollapsed((c) => !c)}
|
|
className="p-1 rounded hover:bg-accent text-muted-foreground"
|
|
>
|
|
{collapsed ? <ChevronRight className="w-4 h-4" /> : <ChevronLeft className="w-4 h-4" />}
|
|
</button>
|
|
</div>
|
|
|
|
{/* Main nav */}
|
|
<nav className="flex-1 px-2 py-3 space-y-1">
|
|
{navItems.map((item) => (
|
|
<NavLink
|
|
key={item.to}
|
|
to={item.to}
|
|
end={item.to === "/"}
|
|
className={({ isActive }) =>
|
|
`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors ${
|
|
isActive
|
|
? "bg-primary text-primary-foreground"
|
|
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
}`
|
|
}
|
|
>
|
|
<item.icon className="w-4 h-4 shrink-0" />
|
|
{!collapsed && <span>{item.label}</span>}
|
|
</NavLink>
|
|
))}
|
|
|
|
{/* Settings section */}
|
|
<div className="pt-4">
|
|
{!collapsed && (
|
|
<p className="px-3 text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2">
|
|
Settings
|
|
</p>
|
|
)}
|
|
{settingsItems.map((item) => (
|
|
<NavLink
|
|
key={item.to}
|
|
to={item.to}
|
|
className={({ isActive }) =>
|
|
`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors ${
|
|
isActive
|
|
? "bg-primary text-primary-foreground"
|
|
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
}`
|
|
}
|
|
>
|
|
<item.icon className="w-4 h-4 shrink-0" />
|
|
{!collapsed && <span>{item.label}</span>}
|
|
</NavLink>
|
|
))}
|
|
</div>
|
|
</nav>
|
|
|
|
{/* Version + Theme toggle */}
|
|
<div className="px-4 py-3 border-t flex items-center justify-between">
|
|
<span className="text-xs text-muted-foreground">
|
|
{appVersion ? `v${appVersion}` : ""}
|
|
</span>
|
|
<button
|
|
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
|
|
className="p-1 rounded hover:bg-accent text-muted-foreground"
|
|
title={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
|
|
>
|
|
{theme === "dark" ? <Sun className="w-4 h-4" /> : <Moon className="w-4 h-4" />}
|
|
</button>
|
|
</div>
|
|
</aside>
|
|
|
|
{/* Main content */}
|
|
<main className="overflow-y-auto bg-background">
|
|
<Routes>
|
|
<Route path="/" element={<Dashboard />} />
|
|
<Route path="/new-issue" element={<NewIssue />} />
|
|
<Route path="/issue/:id/logs" element={<LogUpload />} />
|
|
<Route path="/issue/:id/triage" element={<Triage />} />
|
|
<Route path="/issue/:id/resolution" element={<Resolution />} />
|
|
<Route path="/issue/:id/rca" element={<RCA />} />
|
|
<Route path="/issue/:id/postmortem" element={<Postmortem />} />
|
|
<Route path="/history" element={<History />} />
|
|
<Route path="/settings/providers" element={<AIProviders />} />
|
|
<Route path="/settings/ollama" element={<Ollama />} />
|
|
<Route path="/settings/shell" element={<ShellExecution />} />
|
|
<Route path="/settings/kubeconfig" element={<KubeconfigManager />} />
|
|
<Route path="/kubernetes" element={<KubernetesPage />} />
|
|
<Route path="/settings/integrations" element={<Integrations />} />
|
|
<Route path="/settings/mcp" element={<MCPServers />} />
|
|
<Route path="/settings/security" element={<Security />} />
|
|
</Routes>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|