Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(web): translate backend case status to UI enum on /cases

Beenu Arorab61ab89f500f
diff --git a/apps/web/src/components/cases/CasesView.tsx b/apps/web/src/components/cases/CasesView.tsx
index 316b4efef..88adf9172 100644
--- a/apps/web/src/components/cases/CasesView.tsx
+++ b/apps/web/src/components/cases/CasesView.tsx
@@ -58,11 +58,15 @@ const STATUS_CONFIG: Record<
// ─── Case Card ────────────────────────────────────────────────────────────────
function CaseCard({ c }: { c: Case }) {
- const sev = SEVERITY_CONFIG[c.severity];
- const sts = STATUS_CONFIG[c.status];
+ const sev = SEVERITY_CONFIG[c.severity] ?? SEVERITY_CONFIG.medium;
+ // Defensive: if normalization missed an unexpected status string, fall back
+ // to "open" styling so the entire list never blanks the page.
+ const sts = STATUS_CONFIG[c.status] ?? STATUS_CONFIG.open;
+ const displayId = c.caseNumber ?? `${c.id ?? ''}`.slice(-6);
+ const detailHref = `/cases/${encodeURIComponent(c.caseNumber ?? c.id)}`;
return (
- <Link href={`/cases/${c.id}`} className="block">
+ <Link href={detailHref} className="block">
<div className="bg-gray-900/60 border border-gray-800/60 rounded-xl p-5 hover:border-gray-700 hover:bg-gray-900/80 transition-all group">
<div className="flex items-start justify-between gap-3">
<div className="flex-1 min-w-0">
@@ -77,9 +81,9 @@ function CaseCard({ c }: { c: Case }) {
</div>
<h3 className="text-sm font-medium text-gray-200 group-hover:text-white truncate">{c.title}</h3>
<div className="flex items-center gap-3 mt-2">
- <span className="text-xs text-gray-500">#{c.id.slice(-6)}</span>
+ <span className="text-xs text-gray-500">#{displayId}</span>
<span className="text-xs text-gray-500">·</span>
- <span className="text-xs text-gray-500">{c.alertCount} alerts</span>
+ <span className="text-xs text-gray-500">{c.alertCount ?? 0} alerts</span>
{c.assignee && (
<>
<span className="text-xs text-gray-500">·</span>
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index 99c6b0074..5a71636be 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -538,6 +538,11 @@ export interface CaseTask {
export interface Case {
id: string;
+ /**
+ * Short, human-friendly case identifier (e.g. ``INC-001``).
+ * Returned by the backend as ``case_number`` and used by demo deeplinks.
+ */
+ caseNumber?: string;
title: string;
description?: string;
status: CaseStatus;
@@ -561,6 +566,36 @@ export interface Case {
tasks?: CaseTask[];
}
+// The backend uses a 6-state lifecycle (`new | triaged | investigating |
+// contained | resolved | closed`) while the web console renders a simpler
+// 5-state model. Without translation, `STATUS_CONFIG[c.status]` returns
+// `undefined` and `<CaseCard>` throws a TypeError, which React surfaces as a
+// blank loading state on /cases. Keep these maps colocated with the Case type.
+const BACKEND_TO_UI_STATUS: Record<string, CaseStatus> = {
+ new: 'open',
+ open: 'open',
+ triaged: 'pending',
+ pending: 'pending',
+ investigating: 'in_progress',
+ in_progress: 'in_progress',
+ contained: 'in_progress',
+ resolved: 'resolved',
+ closed: 'closed',
+};
+
+const UI_TO_BACKEND_STATUS: Record<CaseStatus, string> = {
+ open: 'new',
+ pending: 'triaged',
+ in_progress: 'investigating',
+ resolved: 'resolved',
+ closed: 'closed',
+};
+
+function toUiStatus(raw: unknown): CaseStatus {
+ if (typeof raw !== 'string') return 'open';
+ return BACKEND_TO_UI_STATUS[raw] ?? 'open';
+}
+
export interface CasesResponse {
cases: Case[];
total: number;
@@ -626,11 +661,17 @@ function normalizeCase(raw: unknown): Case {
(r.updatedAt as string | undefined) ??
createdAt;
+ const caseNumber =
+ (r.case_number as string | undefined) ??
+ (r.caseNumber as string | undefined) ??
+ undefined;
+
return {
id: String(r.id ?? ''),
+ caseNumber,
title: String(r.title ?? ''),
description: (r.description as string | undefined) ?? undefined,
- status: (r.status as Case['status']) ?? 'open',
+ status: toUiStatus(r.status),
severity: (r.severity as Case['severity']) ?? 'medium',
priority: (r.priority as Case['severity'] | undefined) ?? (r.severity as Case['severity'] | undefined),
assignee: (r.assignee as string | null | undefined) ?? undefined,
@@ -693,9 +734,20 @@ function normalizeCasesResponse(raw: unknown, filters: CaseFilters = {}): CasesR
export const casesApi = {
list: async (filters: CaseFilters = {}) => {
- const raw = await request<unknown>('/api/v1/cases', {
- params: filters as Record<string, string>,
- });
+ // Translate UI status filter into the backend lifecycle vocabulary so
+ // querying "In Progress" in the console actually returns rows where the
+ // backend stored "investigating".
+ const params: Record<string, string> = {};
+ for (const [key, value] of Object.entries(filters)) {
+ if (value === undefined || value === null || value === '') continue;
+ if (key === 'status' && typeof value === 'string' && value !== 'all') {
+ params.status =
+ UI_TO_BACKEND_STATUS[value as CaseStatus] ?? value;
+ continue;
+ }
+ params[key] = String(value);
+ }
+ const raw = await request<unknown>('/api/v1/cases', { params });
return normalizeCasesResponse(raw, filters);
},