feat: /api/v1/auto-repair/history endpoint + neural-command 接真實 API (Sprint 3)
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 8m50s
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 8m50s
- 新增 RepairHistoryItem/RepairHistoryResponse Pydantic models - GET /api/v1/auto-repair/history?limit=N 從 incidents working memory 推導修復歷史 - 前端 fetchData() 同時拉 history + approvals/pending,移除硬編碼 pendingApprovals=0 - try/except 包覆確保任何錯誤都回傳空列表不中斷前端 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -61,12 +61,15 @@ export default function NeuralCommandPage({ params }: { params: { locale: string
|
||||
const [history, setHistory] = useState<RepairHistoryItem[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [lastRefresh, setLastRefresh] = useState<Date>(new Date())
|
||||
const [pendingApprovals, setPendingApprovals] = useState(0)
|
||||
|
||||
const fetchData = useCallback(async () => {
|
||||
try {
|
||||
const [statsRes, pbRes] = await Promise.all([
|
||||
const [statsRes, pbRes, histRes, approvalsRes] = await Promise.all([
|
||||
fetch('/api/v1/auto-repair/stats'),
|
||||
fetch('/api/v1/playbooks/'),
|
||||
fetch('/api/v1/auto-repair/history?limit=20'),
|
||||
fetch('/api/v1/approvals/pending'),
|
||||
])
|
||||
|
||||
if (statsRes.ok) {
|
||||
@@ -77,6 +80,14 @@ export default function NeuralCommandPage({ params }: { params: { locale: string
|
||||
const data = await pbRes.json()
|
||||
setPlaybooks(data.items?.map((i: { playbook: PlaybookItem }) => i.playbook) ?? [])
|
||||
}
|
||||
if (histRes.ok) {
|
||||
const data = await histRes.json()
|
||||
setHistory(data.items ?? [])
|
||||
}
|
||||
if (approvalsRes.ok) {
|
||||
const data = await approvalsRes.json()
|
||||
setPendingApprovals(data.count ?? 0)
|
||||
}
|
||||
|
||||
setLastRefresh(new Date())
|
||||
} catch {
|
||||
@@ -93,7 +104,6 @@ export default function NeuralCommandPage({ params }: { params: { locale: string
|
||||
}, [fetchData])
|
||||
|
||||
const approvedPlaybooks = playbooks.filter(p => p.status === 'approved')
|
||||
const pendingApprovals = 0 // TODO: fetch from /api/v1/approvals
|
||||
|
||||
return (
|
||||
<AppLayout locale={params.locale}>
|
||||
|
||||
Reference in New Issue
Block a user