From 562ad901b121227c7d057e87639bbcd56f04da8b Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Tue, 17 Feb 2026 15:14:25 -0300 Subject: [PATCH] fix(settings): remove Compliance/Audit tab, optimize CLI tools status API - Remove ComplianceTab from settings page (tab definition, import, rendering) - Replace self-referential HTTP calls in /api/cli-tools/status with direct file reads via getCliPrimaryConfigPath, eliminating ~6 redundant HTTP roundtrips and ~6 duplicate process healthchecks per page load --- .../(dashboard)/dashboard/settings/page.tsx | 5 +- src/app/api/cli-tools/status/route.ts | 59 ++++++++++++++----- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/app/(dashboard)/dashboard/settings/page.tsx b/src/app/(dashboard)/dashboard/settings/page.tsx index a84e6dc28b..8497334560 100644 --- a/src/app/(dashboard)/dashboard/settings/page.tsx +++ b/src/app/(dashboard)/dashboard/settings/page.tsx @@ -11,7 +11,7 @@ import ProxyTab from "./components/ProxyTab"; import AppearanceTab from "./components/AppearanceTab"; import ThinkingBudgetTab from "./components/ThinkingBudgetTab"; import SystemPromptTab from "./components/SystemPromptTab"; -import ComplianceTab from "./components/ComplianceTab"; + import CacheStatsCard from "./components/CacheStatsCard"; import ResilienceTab from "./components/ResilienceTab"; @@ -22,7 +22,6 @@ const tabs = [ { id: "routing", label: "Routing", icon: "route" }, { id: "resilience", label: "Resilience", icon: "electrical_services" }, { id: "advanced", label: "Advanced", icon: "tune" }, - { id: "compliance", label: "Compliance", icon: "policy" }, ]; export default function SettingsPage() { @@ -90,8 +89,6 @@ export default function SettingsPage() { {activeTab === "resilience" && } {activeTab === "advanced" && } - - {activeTab === "compliance" && } {/* App Info */} diff --git a/src/app/api/cli-tools/status/route.ts b/src/app/api/cli-tools/status/route.ts index 1a535a8628..610ba837f5 100644 --- a/src/app/api/cli-tools/status/route.ts +++ b/src/app/api/cli-tools/status/route.ts @@ -1,9 +1,49 @@ "use server"; import { NextResponse } from "next/server"; -import { getCliRuntimeStatus, CLI_TOOL_IDS } from "@/shared/services/cliRuntime"; +import fs from "fs/promises"; +import { + getCliRuntimeStatus, + CLI_TOOL_IDS, + getCliPrimaryConfigPath, +} from "@/shared/services/cliRuntime"; import { getAllCliToolLastConfigured } from "@/lib/db/cliToolState"; +// Check if a tool has OmniRoute configured by reading its config file directly +// This replaces the expensive self-referential HTTP calls to /api/cli-tools/*-settings +async function checkToolConfigStatus(toolId: string): Promise { + try { + const configPath = getCliPrimaryConfigPath(toolId); + if (!configPath) return "unknown"; + + const content = await fs.readFile(configPath, "utf-8"); + const config = JSON.parse(content); + + // Each tool stores OmniRoute config differently + switch (toolId) { + case "claude": + return config?.env?.ANTHROPIC_BASE_URL ? "configured" : "not_configured"; + case "codex": + return config?.providers?.omniroute || config?.providers?.["openai-compatible"] + ? "configured" + : "not_configured"; + case "droid": + case "openclaw": + case "cline": + case "kilo": + // Generic check: look for any OmniRoute-related URL in the config + const configStr = JSON.stringify(config).toLowerCase(); + return configStr.includes("omniroute") || configStr.includes("20128") + ? "configured" + : "not_configured"; + default: + return "unknown"; + } + } catch { + return "not_configured"; + } +} + /** * GET /api/cli-tools/status * Returns runtime + config status for all CLI tools in one batch call. @@ -13,6 +53,7 @@ export async function GET() { try { const statuses = {}; + // Run all runtime checks in parallel await Promise.all( CLI_TOOL_IDS.map(async (toolId) => { try { @@ -34,7 +75,7 @@ export async function GET() { }) ); - // Now fetch configStatus for the 6 tools that have settings endpoints + // Check config status for installed+runnable tools via direct file reads const settingsTools = ["claude", "codex", "droid", "openclaw", "cline", "kilo"]; await Promise.all( @@ -43,19 +84,7 @@ export async function GET() { statuses[toolId].configStatus = "not_installed"; return; } - try { - const settingsRes = await fetch( - `${process.env.NEXT_PUBLIC_APP_URL || "http://localhost:20128"}/api/cli-tools/${toolId}-settings` - ); - if (settingsRes.ok) { - const data = await settingsRes.json(); - statuses[toolId].configStatus = data.hasOmniRoute ? "configured" : "not_configured"; - } else { - statuses[toolId].configStatus = "unknown"; - } - } catch { - statuses[toolId].configStatus = "unknown"; - } + statuses[toolId].configStatus = await checkToolConfigStatus(toolId); }) );