Commit Graph

5 Commits

Author SHA1 Message Date
OG T
7db42ffdac fix(web): Y按鈕簽核回應解析錯誤 - result.status → result.approval.status
根因: API 回傳 {approval: {status: 'approved'}} 但前端誤檢查 result.status

修復:
- dual-state-incident-card.tsx: 正確解析 result.approval.status
- api-client.ts: 更新回傳型別與後端對齊

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-23 21:20:41 +08:00
OG T
4c41a6728f fix(web): Fix API contract mismatch for sign/reject endpoints
- signApproval: send signer_id, signer_name, comment (not signer, reason)
- rejectApproval: send rejector_id, rejector_name, reason

Fixes 422 Unprocessable Entity on Y/n button click

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-23 21:04:44 +08:00
OG T
0aaf6a276b feat(api,web): Phase 6.5 DecisionManager with dual-engine fallback
Backend:
- Add DecisionManager with state machine (INIT→ANALYZING→READY→EXECUTING)
- Implement Expert System rules engine (100% local, never fails)
- Dual-engine: LLM (primary) + Expert System (fallback)
- Auto-generate decision_token for each incident
- 30-second timeout guarantee

Frontend:
- Use decision.state to unlock [Y/n] buttons
- Display AI action suggestion in card
- Show source indicator [AI] or [EXP]
- Generate proposal on-demand if needed

Fixes: UI locked with hourglass when LLM times out

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-23 13:19:55 +08:00
OG T
28fa8e6af4 feat(web): Phase 6.5c implement [Y/n] execution wiring
DualStateIncidentCard:
- Add proposalId prop for approval actions
- Add onApprovalChange callback for status updates
- Implement handleApprove() calling POST /api/v1/approvals/{id}/sign
- Implement handleReject() calling POST /api/v1/approvals/{id}/reject
- Add ButtonState management (idle/loading/approved/rejected/error)
- Loading spinner during API call
- Success state: green "已授權" / red "已拒絕"
- Error state: orange "錯誤" with auto-recovery

API Client:
- Fix endpoint mismatch: rename approveApproval to signApproval
- Use correct endpoint /sign instead of /approve
- Add signer parameter for multi-sig support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-23 12:37:56 +08:00
OG T
196d269b92 feat: add all application source code
- apps/api: FastAPI backend with Dockerfile
- apps/web: Next.js frontend with Dockerfile
- apps/sensor: Signal collection agent
- packages: shared packages

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-22 18:57:44 +08:00