mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-14 19:22:32 +03:00
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
This commit is contained in:
@@ -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" && <ResilienceTab />}
|
||||
|
||||
{activeTab === "advanced" && <ProxyTab />}
|
||||
|
||||
{activeTab === "compliance" && <ComplianceTab />}
|
||||
</div>
|
||||
|
||||
{/* App Info */}
|
||||
|
||||
@@ -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<string> {
|
||||
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);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user