import { Brain, RotateCcw, Save } from "lucide-react"; import React, { useEffect, useState } from "react"; import { Button } from "../../../ui/button"; import { SettingCard, SettingsSection } from "../../settings-ui"; import { DEFAULT_PHASE1_SYSTEM, DEFAULT_PHASE2_SYSTEM, } from "../../../../infrastructure/ai/rcaAgent/rcaRunner"; const STORAGE_KEY = "netcatty_rca_prompts_v1"; interface RcaPromptsConfig { phase1?: string; phase2?: string; } function loadConfig(): RcaPromptsConfig { try { const raw = localStorage.getItem(STORAGE_KEY); if (raw) return JSON.parse(raw); } catch (_) {} return {}; } function saveConfig(cfg: RcaPromptsConfig) { localStorage.setItem(STORAGE_KEY, JSON.stringify(cfg)); } export const RcaPromptSettings: React.FC = () => { const defaults = { phase1: DEFAULT_PHASE1_SYSTEM, phase2: DEFAULT_PHASE2_SYSTEM, }; const [phase1, setPhase1] = useState(""); const [phase2, setPhase2] = useState(""); const [savedVersion, setSavedVersion] = useState<{ p1: string; p2: string }>({ p1: "", p2: "" }); // 加载 localStorage 中的自定义值(无则空字符串,表示"使用默认") useEffect(() => { const cfg = loadConfig(); const p1 = cfg.phase1 ?? ""; const p2 = cfg.phase2 ?? ""; setPhase1(p1); setPhase2(p2); setSavedVersion({ p1, p2 }); }, []); const dirty = phase1 !== savedVersion.p1 || phase2 !== savedVersion.p2; const phase1IsDefault = !phase1.trim(); const phase2IsDefault = !phase2.trim(); const handleSave = () => { const cfg: RcaPromptsConfig = { phase1: phase1.trim() ? phase1 : undefined, phase2: phase2.trim() ? phase2 : undefined, }; saveConfig(cfg); setSavedVersion({ p1: phase1, p2: phase2 }); }; const handleResetAll = () => { setPhase1(""); setPhase2(""); }; return (

自定义 AI 根因分析(RCA)的系统提示词。留空表示使用内置默认值。 Phase 1 是诊断命令规划,Phase 2 是根因综合分析。

自定义提示词会覆盖内置默认值,点击"恢复默认"可清空编辑内容。
{/* Phase 1 */}
{phase1IsDefault ? ( 使用默认 ) : ( 已自定义 )} {!phase1IsDefault && ( )}