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): hydration-safe Framer Motion shells + clean tsc errors

Beenu Arora3cd0a4c25dce
diff --git a/apps/web/src/components/alerts/EntityRiskQueue.tsx b/apps/web/src/components/alerts/EntityRiskQueue.tsx
index 730e8c059..4d6216d58 100644
--- a/apps/web/src/components/alerts/EntityRiskQueue.tsx
+++ b/apps/web/src/components/alerts/EntityRiskQueue.tsx
@@ -96,10 +96,12 @@ const MOCK_ENTITIES: EntityRiskRecord[] = [
];
const MOCK_ENTITY_STATS: EntityRiskStats = {
+ tenant_id: 'demo',
total: 5,
promoted: 2,
alert_count: 26,
threshold: 80,
+ bands: { critical: 1, high: 1, medium: 2, low: 1 },
};
// ─── Helpers ─────────────────────────────────────────────────────────────────
@@ -465,7 +467,7 @@ export function EntityRiskQueue() {
const { data: queue, error: queueError, isLoading: queueLoading } = useSWR(
['entity-risk-queue', promotedOnly],
() => entityRiskApi.queue({ limit: 50, promotedOnly }),
- { refreshInterval: 30000, fallbackData: { entities: MOCK_ENTITIES, threshold: 80 } },
+ { refreshInterval: 30000, fallbackData: { tenant_id: 'demo', entities: MOCK_ENTITIES, threshold: 80 } },
);
const { data: stats } = useSWR<EntityRiskStats>(
'entity-risk-stats',
diff --git a/apps/web/src/components/audit/AuditLogView.tsx b/apps/web/src/components/audit/AuditLogView.tsx
index 175e20f43..87a14af18 100644
--- a/apps/web/src/components/audit/AuditLogView.tsx
+++ b/apps/web/src/components/audit/AuditLogView.tsx
@@ -76,7 +76,7 @@ export function AuditLogView() {
if (actionFilter) params.set('action', actionFilter);
if (resourceFilter) params.set('resource', resourceFilter);
- const { data: raw, error } = useSWR<AuditListResponse>(
+ const { data: raw, error, isLoading } = useSWR<AuditListResponse>(
`/api/v1/audit?${params}`,
fetcher,
{ refreshInterval: 30_000, fallbackData: MOCK_AUDIT, shouldRetryOnError: false, errorRetryCount: 0, revalidateOnFocus: false }
diff --git a/apps/web/src/components/cases/CaseWorkspace.tsx b/apps/web/src/components/cases/CaseWorkspace.tsx
index 631cd71b4..9e2f96b29 100644
--- a/apps/web/src/components/cases/CaseWorkspace.tsx
+++ b/apps/web/src/components/cases/CaseWorkspace.tsx
@@ -324,8 +324,12 @@ export function CaseWorkspace({ caseId }: { caseId: string }) {
return undefined;
}, [data, useFallback, caseId]);
- // Track demo mode for the header banner.
- if (useFallback && !demoMode) setDemoMode(true);
+ // Track demo mode for the header banner. Calling setState during render is
+ // a React anti-pattern that can interact badly with hydration; defer to an
+ // effect so the first paint matches between server and client.
+ useEffect(() => {
+ if (useFallback && !demoMode) setDemoMode(true);
+ }, [useFallback, demoMode]);
// ─── Investigation state ───────────────────────────────────────────────────
const [investigating, setInvestigating] = useState(false);
diff --git a/apps/web/src/components/connectors/ConnectorsView.tsx b/apps/web/src/components/connectors/ConnectorsView.tsx
index d3d3b5460..ac3fc650a 100644
--- a/apps/web/src/components/connectors/ConnectorsView.tsx
+++ b/apps/web/src/components/connectors/ConnectorsView.tsx
@@ -74,7 +74,7 @@ export function ConnectorsView() {
const { data, error, isLoading, mutate } = useSWR(
'connectors',
() => connectorsApi.list(),
- { revalidateOnFocus: false, fallbackData: { connectors: DEMO_CONNECTORS } },
+ { revalidateOnFocus: false, fallbackData: { connectors: DEMO_CONNECTORS, total: DEMO_CONNECTORS.length } },
);
// Health summary is a separate endpoint so the empty/error case is silent —
diff --git a/apps/web/src/components/layout/AppShell.tsx b/apps/web/src/components/layout/AppShell.tsx
index aa3b1fc00..cc4d75280 100644
--- a/apps/web/src/components/layout/AppShell.tsx
+++ b/apps/web/src/components/layout/AppShell.tsx
@@ -5,6 +5,7 @@ import { TopBar } from './TopBar';
import { CommandPalette } from './CommandPalette';
import { CopilotDock } from '@/components/copilot/CopilotDock';
import { DemoBanner } from '@/components/demo/DemoBanner';
+import { ClientOnly } from '@/components/util/ClientOnly';
import { isDemoMode } from '@/lib/demoMode';
interface AppShellProps {
@@ -27,10 +28,19 @@ export function AppShell({ children }: AppShellProps) {
<div className="p-6">{children}</div>
</main>
</div>
- {/* Floating Copilot launcher (hidden on /copilot itself) */}
- <CopilotDock />
- {/* Global command palette (⌘K) */}
- <CommandPalette />
+ {/*
+ Floating Copilot launcher and global command palette both rely on
+ Framer Motion, which serializes inline `transform` styles differently
+ on server vs client and triggers a hydration mismatch (React #418).
+ Wrapping them in ClientOnly defers their entire render to after mount
+ so SSR ships nothing for these subtrees.
+ */}
+ <ClientOnly>
+ <CopilotDock />
+ </ClientOnly>
+ <ClientOnly>
+ <CommandPalette />
+ </ClientOnly>
</div>
);
}
diff --git a/apps/web/src/components/settings/SettingsView.tsx b/apps/web/src/components/settings/SettingsView.tsx
index 6a6f6eea1..1349d0903 100644
--- a/apps/web/src/components/settings/SettingsView.tsx
+++ b/apps/web/src/components/settings/SettingsView.tsx
@@ -628,7 +628,7 @@ function WorkspacePanel() {
<InfoTile label="Tenant ID" value="tenant_demo_01H0XE4T2WJ9N6" mono />
<InfoTile label="Plan" value="Open-source (MIT)" />
<InfoTile label="Region" value="us-east-1 / Multi-AZ" />
- <InfoTile label="Created" value={format(NOW - 1000 * 60 * 60 * 24 * 96, 'PPP')} />
+ <InfoTile label="Created" value={format(Date.now() - 1000 * 60 * 60 * 24 * 96, 'PPP')} />
<InfoTile
label="Default locale"
value={`${Intl.DateTimeFormat().resolvedOptions().locale} • 24h`}