From d5ce17c72d5bec51d0bbb804fdd2adaafc8f1b52 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 5 Jun 2026 01:28:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E6=A8=99=E7=A4=BA=20AIOps=20?= =?UTF-8?q?=E7=AF=84=E4=BE=8B=E8=B3=87=E6=96=99=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/messages/en.json | 2 +- apps/web/messages/zh-TW.json | 2 +- .../src/app/[locale]/aiops/timeline/page.tsx | 2 +- .../components/ai/openclaw-state-machine.tsx | 2 +- .../aiops/timeline/AiopsTimelinePanel.tsx | 19 ++++++++++--------- .../src/components/aiops/timeline/index.ts | 2 +- .../{mock-data.ts => sample-incidents.ts} | 4 ++-- .../genui/__tests__/registry.test.ts | 4 ++-- .../neural-command/NeuralApprovalPanel.tsx | 2 +- .../components/neural-command/NeuralStats.tsx | 2 +- 10 files changed, 21 insertions(+), 20 deletions(-) rename apps/web/src/components/aiops/timeline/{mock-data.ts => sample-incidents.ts} (99%) diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json index 234d2231..233dde61 100644 --- a/apps/web/messages/en.json +++ b/apps/web/messages/en.json @@ -2239,7 +2239,7 @@ "aiopsTimeline": { "title": "AIOps 全景時序", "subtitle": "告警→感官調查→AI決策→自動執行→驗證→學習 完整鏈路", - "mockBadge": "MOCK 模式", + "sampleBadge": "範例資料", "stages": { "alert": "告警觸發", "diagnose": "感官調查", diff --git a/apps/web/messages/zh-TW.json b/apps/web/messages/zh-TW.json index 234d2231..233dde61 100644 --- a/apps/web/messages/zh-TW.json +++ b/apps/web/messages/zh-TW.json @@ -2239,7 +2239,7 @@ "aiopsTimeline": { "title": "AIOps 全景時序", "subtitle": "告警→感官調查→AI決策→自動執行→驗證→學習 完整鏈路", - "mockBadge": "MOCK 模式", + "sampleBadge": "範例資料", "stages": { "alert": "告警觸發", "diagnose": "感官調查", diff --git a/apps/web/src/app/[locale]/aiops/timeline/page.tsx b/apps/web/src/app/[locale]/aiops/timeline/page.tsx index 27c68d4e..3784acb0 100644 --- a/apps/web/src/app/[locale]/aiops/timeline/page.tsx +++ b/apps/web/src/app/[locale]/aiops/timeline/page.tsx @@ -5,7 +5,7 @@ // AIOps 全景時序頁面 // 告警→感官調查→AI決策→自動執行→驗證→學習 完整鏈路視覺化 // -// Mock 模式:NEXT_PUBLIC_AIOPS_TIMELINE_MOCK=true +// 範例資料模式:NEXT_PUBLIC_AIOPS_TIMELINE_MOCK=true // 真實 API: GET /api/v1/aiops/timeline?incident_id=&limit=20 // ============================================================ diff --git a/apps/web/src/components/ai/openclaw-state-machine.tsx b/apps/web/src/components/ai/openclaw-state-machine.tsx index 2c6a9ebf..9aff1a00 100644 --- a/apps/web/src/components/ai/openclaw-state-machine.tsx +++ b/apps/web/src/components/ai/openclaw-state-machine.tsx @@ -12,7 +12,7 @@ * - ApprovalCard 滑入動畫 * - 記憶體安全清理 * - * 真實性條款: 禁止任何 Mock Data + * 真實性條款:禁止以範例資料掩蓋 API 狀態 * i18n: 100% next-intl */ diff --git a/apps/web/src/components/aiops/timeline/AiopsTimelinePanel.tsx b/apps/web/src/components/aiops/timeline/AiopsTimelinePanel.tsx index 1573887f..e3a02f3b 100644 --- a/apps/web/src/components/aiops/timeline/AiopsTimelinePanel.tsx +++ b/apps/web/src/components/aiops/timeline/AiopsTimelinePanel.tsx @@ -20,7 +20,7 @@ import { import { cn } from '@/lib/utils' import { TimelineFilter } from './TimelineFilter' import { TimelineStage } from './TimelineStage' -import { MOCK_INCIDENTS } from './mock-data' +import { SAMPLE_TIMELINE_INCIDENTS } from './sample-incidents' import type { TimelineIncident, TimelineFilterState, @@ -31,7 +31,8 @@ import type { // Constants // ============================================================ -const IS_MOCK = process.env.NEXT_PUBLIC_AIOPS_TIMELINE_MOCK === 'true' +// 保留既有環境變數相容;UI 以「範例資料」呈現,避免誤讀為正式證據。 +const USE_SAMPLE_TIMELINE = process.env.NEXT_PUBLIC_AIOPS_TIMELINE_MOCK === 'true' const API_BASE = process.env.NEXT_PUBLIC_API_URL ?? '' const STAGE_ORDER: StageType[] = ['alert', 'diagnose', 'decide', 'execute', 'verify', 'learn'] @@ -280,14 +281,14 @@ export default function AiopsTimelinePanel() { } = useQuery({ queryKey: ['aiops-timeline', filter.incident_id, filter.time_range], queryFn: () => fetchTimeline(filter.incident_id), - enabled: !IS_MOCK, + enabled: !USE_SAMPLE_TIMELINE, staleTime: 30_000, refetchInterval: 60_000, }) // 客戶端篩選 — rawIncidents 內聯進 useMemo 避免 conditional 依賴警告 const incidents = useMemo(() => { - const rawIncidents: TimelineIncident[] = IS_MOCK ? MOCK_INCIDENTS : (apiData ?? []) + const rawIncidents: TimelineIncident[] = USE_SAMPLE_TIMELINE ? SAMPLE_TIMELINE_INCIDENTS : (apiData ?? []) let list = rawIncidents if (filter.incident_id.trim()) { @@ -325,9 +326,9 @@ export default function AiopsTimelinePanel() {

@@ -337,7 +338,7 @@ export default function AiopsTimelinePanel() { {/* Refresh button (僅真實模式顯示) */} - {!IS_MOCK && ( + {!USE_SAMPLE_TIMELINE && (