Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Converge loading spinners on shared primitive

rcourtman3e05c537f84f
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 0cf263470d..0a8e25aa73 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1107,6 +1107,9 @@ the canonical monitored-system blocked payload.
state and count badges route through frontend-primitives-owned
`StatusIndicatorBadge` and `MetadataBadge` instead of page-local class
strings in the Patrol section owners
+ and Patrol loading indicator state remains API data only while the visible
+ header and finding loading spinners route through frontend-primitives-owned
+ `LoadingSpinner` instead of encoding API state in page-local spinner shells
and the Patrol verification summary derived from run history, so the page also states whether recent Patrol evidence came from a successful full patrol or only from scoped/erroring runs instead of leaving verification scope implicit
and the same-day activity-mix explanation derived from that governed run history, so when a recent full patrol is followed by alert-triggered or anomaly-triggered scoped work the verification surface can explain the mix directly instead of reconstructing it from page-local timing heuristics
and the Patrol status recency split, so `last_patrol_at` remains reserved for completed full Patrol sweeps while scoped runs and verification checks advance `last_activity_at` without claiming a fresh full-estate verification pass
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 8525729d0e..8b45386b57 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2552,6 +2552,11 @@ semantics. Storage linked-disk health rows must derive a `StatusDot` variant
through `getLinkedDiskHealthDotVariant` and must not recreate local rounded
green/yellow span classes in storage components or storage-backup presentation
helpers.
+Loading indicators are registry-backed too. `LoadingSpinner` owns the shared
+border-based spinner shell, size catalog, tone catalog, decorative status, and
+accessible status label behavior. Patrol and AI finding surfaces must compose
+that primitive for loading and action-pending spinners; icon-specific refresh
+rotation remains local icon state, not a loading-spinner shell.
Native select controls are registry-backed too. `FormSelect` owns label/id
wiring, helper-text description merging, value synchronization, default select
chrome, dynamic-option value synchronization, and compact styling hooks for
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 5567bd7889..86702dab86 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -62,9 +62,12 @@ Patrol-specific presentation helpers.
visible run-history, status-bar, and runtime-summary state badges must
compose the shared `StatusIndicatorBadge`, and
resource/outcome/snapshot/scoped-run/status-bar/workspace-tab metadata chips
- must compose the shared `MetadataBadge`. If Patrol needs a new badge shape
- or tone, extend the shared primitive and registry guard instead of adding
- page-local rounded pill spans.
+ must compose the shared `MetadataBadge`. Patrol and AI finding loading
+ indicators must compose the shared `LoadingSpinner` for border-based spinner
+ shell, size, tone, and accessibility behavior; icon-specific refresh
+ rotation remains local icon state. If Patrol needs a new badge shape, tone,
+ or loading indicator variant, extend the shared primitive and registry guard
+ instead of adding page-local rounded pill spans or spinner spans.
3. Keep remediation execution badge copy and severity styling aligned through `frontend-modern/src/components/patrol/RemediationStatus.tsx` and `frontend-modern/src/utils/remediationPresentation.ts`
4. Add or change Patrol header, summary, status runtime-state presentation, or runtime provider action presentation through `frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`, `frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx`, `frontend-modern/src/components/patrol/PatrolStatusBar.tsx`, `frontend-modern/src/utils/patrolRuntimePresentation.ts`, and `frontend-modern/src/utils/patrolRuntimeActions.ts`
Patrol summary presentation may show recent activity mix and trigger mode as
@@ -83,6 +86,7 @@ Patrol-specific presentation helpers.
2. Duplicating Patrol finding severity, lifecycle, alert-identity, or approval-risk derivation outside the governed Patrol presentation helpers
3. Letting the Patrol page, local store, and findings UI drift into separate shadow truths for the same Patrol status or finding lifecycle state
4. Recreating Patrol run-history, status-bar, runtime-summary, or workspace-tab status/metadata badge shells locally instead of composing `StatusIndicatorBadge` and `MetadataBadge`
+5. Recreating border-based Patrol or AI finding loading spinner shells locally instead of composing `LoadingSpinner`
## Completion Obligations
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index b4f177cf4b..233b07d749 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -275,6 +275,67 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "loading-spinner-shell",
+ "category": "loading-indicator",
+ "summary": "Patrol, AI, and shared loading indicators must compose LoadingSpinner for shared size, tone, and accessibility behavior instead of recreating border-based animate-spin spans.",
+ "canonical": {
+ "path": "src/components/shared/LoadingSpinner.tsx",
+ "export": "LoadingSpinner"
+ },
+ "requiredConsumers": [
+ { "path": "src/components/AI/FindingsPanel.tsx" },
+ { "path": "src/components/patrol/ApprovalBanner.tsx" },
+ { "path": "src/components/patrol/ApprovalSection.tsx" },
+ { "path": "src/components/patrol/InvestigationMessages.tsx" },
+ { "path": "src/components/patrol/InvestigationSection.tsx" },
+ { "path": "src/components/patrol/RunToolCallTrace.tsx" },
+ { "path": "src/features/patrol/PatrolIntelligenceHeader.tsx" }
+ ],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/AI/FindingsPanel.tsx",
+ "patterns": [
+ "border border-current border-t-transparent animate-spin",
+ "h-4 w-4 border-2 border-current border-t-transparent rounded-full animate-spin"
+ ]
+ },
+ {
+ "path": "src/components/patrol/ApprovalBanner.tsx",
+ "patterns": ["h-3 w-3 border-2 border-white border-t-transparent rounded-full animate-spin"]
+ },
+ {
+ "path": "src/components/patrol/ApprovalSection.tsx",
+ "patterns": ["h-3 w-3 border-2 border-white border-t-transparent rounded-full animate-spin"]
+ },
+ {
+ "path": "src/components/patrol/InvestigationMessages.tsx",
+ "patterns": ["h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin"]
+ },
+ {
+ "path": "src/components/patrol/InvestigationSection.tsx",
+ "patterns": ["h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin"]
+ },
+ {
+ "path": "src/components/patrol/RunToolCallTrace.tsx",
+ "patterns": ["h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin"]
+ },
+ {
+ "path": "src/features/patrol/PatrolIntelligenceHeader.tsx",
+ "patterns": ["animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"]
+ }
+ ],
+ "proof": [
+ "src/components/shared/LoadingSpinner.test.tsx",
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/AI/__tests__/FindingsPanel.test.ts",
+ "src/components/patrol/__tests__/ApprovalBanner.test.tsx",
+ "src/components/patrol/__tests__/ApprovalSection.test.tsx",
+ "src/components/patrol/__tests__/InvestigationSection.test.tsx",
+ "src/components/patrol/__tests__/RunToolCallTrace.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "button-command-shell",
"category": "action-button",
@@ -1067,6 +1128,30 @@
}
],
"patternGuards": [
+ {
+ "id": "patrol-ai-local-loading-spinner-shell",
+ "category": "loading-indicator",
+ "summary": "Patrol and AI finding surfaces must not recreate border-based loading spinners locally; compose LoadingSpinner so size, tone, and accessibility behavior stay shared.",
+ "canonical": {
+ "path": "src/components/shared/LoadingSpinner.tsx",
+ "export": "LoadingSpinner"
+ },
+ "scopes": [
+ "src/components/patrol",
+ "src/features/patrol",
+ "src/components/AI/FindingsPanel.tsx"
+ ],
+ "extensions": [".tsx"],
+ "allPatterns": ["border-t-transparent", "animate-spin"],
+ "legacyReason": "Retired migration debt. Patrol action-pending, investigation-loading, header-saving, and AI finding-loading spinners compose LoadingSpinner for shared shell, sizing, tone, and accessible status behavior.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/LoadingSpinner.test.tsx",
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-shell-local-frame",
"category": "platform-table-shell",
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index 29f7718db5..15b36af7ec 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -14,6 +14,7 @@ import { Component, createSignal, createEffect, Show, For, createMemo } from 'so
import { useLocation } from '@solidjs/router';
import { Card } from '@/components/shared/Card';
import { FormSelect } from '@/components/shared/FormSelect';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { aiIntelligenceStore, type UnifiedFinding } from '@/stores/aiIntelligence';
import { notificationStore } from '@/stores/notifications';
@@ -909,9 +910,12 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
finding.investigationStatus === 'pending'
}
>
- <span
- class={`h-2 w-2 rounded-full ${finding.investigationStatus === 'running' ? 'border border-current border-t-transparent animate-spin' : 'bg-current animate-pulse'}`}
- />
+ <Show
+ when={finding.investigationStatus === 'running'}
+ fallback={<span class="h-2 w-2 rounded-full bg-current animate-pulse" />}
+ >
+ <LoadingSpinner size="xs" />
+ </Show>
</Show>
{getInvestigationStatusLabel(finding.investigationStatus!)}
</MetadataBadge>
@@ -1661,7 +1665,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{/* Loading/Error states */}
<Show when={shouldShowLoadingState()}>
<div class="p-4 text-sm text-muted flex items-center gap-2">
- <span class="h-4 w-4 border-2 border-current border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="md" />
Loading findings...
</div>
</Show>
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 3a8fea385d..4e5a6064ad 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -53,6 +53,12 @@ const patrolWorkspaceSource = readFileSync(
);
describe('FindingsPanel assistant handoff', () => {
+ it('routes finding loading indicators through the shared LoadingSpinner primitive', () => {
+ expect(findingsPanelSource).toContain("from '@/components/shared/LoadingSpinner'");
+ expect(findingsPanelSource).toContain('<LoadingSpinner size="xs" />');
+ expect(findingsPanelSource).toContain('<LoadingSpinner size="md" />');
+ });
+
it('routes Patrol investigation records into the Assistant briefing context', () => {
expect(findingsPanelSource).toContain('buildPatrolAssistantFindingHandoff');
expect(findingsPanelSource).toContain('buildPatrolAssistantApprovalBriefingInput');
diff --git a/frontend-modern/src/components/patrol/ApprovalBanner.tsx b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
index 82e1396ed8..a0d8b9cf75 100644
--- a/frontend-modern/src/components/patrol/ApprovalBanner.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
@@ -16,6 +16,7 @@ import {
getApprovalExpiryStatusLabel,
getApprovalRiskPresentation,
} from '@/utils/approvalRiskPresentation';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
import CheckIcon from 'lucide-solid/icons/check';
@@ -134,7 +135,7 @@ export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
class="flex items-center gap-1.5 px-3 py-1.5 bg-green-600 hover:bg-green-700 disabled:bg-green-400 text-white text-xs font-medium rounded-md transition-colors"
>
<Show when={actionLoading() === firstApproval()!.id}>
- <span class="h-3 w-3 border-2 border-white border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" tone="inverse" />
</Show>
<Show when={actionLoading() !== firstApproval()!.id}>
<CheckIcon class="w-3.5 h-3.5" />
diff --git a/frontend-modern/src/components/patrol/ApprovalSection.tsx b/frontend-modern/src/components/patrol/ApprovalSection.tsx
index 60651d26ce..4a4661b9fd 100644
--- a/frontend-modern/src/components/patrol/ApprovalSection.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalSection.tsx
@@ -11,6 +11,7 @@ import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
import { hasFeature } from '@/stores/license';
import { AIAPI, type ApprovalRequest, type ApprovalExecutionResult } from '@/api/ai';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import {
@@ -240,7 +241,7 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
class="flex-1 px-3 py-1.5 bg-amber-600 hover:bg-amber-700 disabled:bg-amber-400 text-white text-xs font-medium rounded flex items-center justify-center gap-1.5"
>
<Show when={actionLoading() === 'reapprove'}>
- <span class="h-3 w-3 border-2 border-white border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" tone="inverse" />
</Show>
<Show when={actionLoading() !== 'reapprove'}>
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -322,7 +323,7 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
class="flex-1 px-3 py-1.5 bg-green-600 hover:bg-green-700 disabled:bg-green-400 text-white text-xs font-medium rounded flex items-center justify-center gap-1.5"
>
<Show when={actionLoading() === approval.id}>
- <span class="h-3 w-3 border-2 border-white border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" tone="inverse" />
</Show>
<Show when={actionLoading() !== approval.id}>
<svg
diff --git a/frontend-modern/src/components/patrol/InvestigationMessages.tsx b/frontend-modern/src/components/patrol/InvestigationMessages.tsx
index f4ecc5792a..2252dcbcda 100644
--- a/frontend-modern/src/components/patrol/InvestigationMessages.tsx
+++ b/frontend-modern/src/components/patrol/InvestigationMessages.tsx
@@ -7,6 +7,7 @@
import { Component, createResource, Show, For } from 'solid-js';
import { getInvestigationMessages, formatTimestamp, type ChatMessage } from '@/api/patrol';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { getInvestigationMessagesState } from '@/utils/patrolEmptyStatePresentation';
interface InvestigationMessagesProps {
@@ -35,7 +36,7 @@ export const InvestigationMessages: Component<InvestigationMessagesProps> = (pro
<div class="mt-2">
<Show when={!getInvestigationMessagesState(messages.loading, !!messages()?.length).empty && getInvestigationMessagesState(messages.loading, !!messages()?.length).text}>
<div class="flex items-center gap-2 text-xs text-muted py-2">
- <span class="h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" />
{getInvestigationMessagesState(messages.loading, !!messages()?.length).text}
</div>
</Show>
diff --git a/frontend-modern/src/components/patrol/InvestigationSection.tsx b/frontend-modern/src/components/patrol/InvestigationSection.tsx
index 0b8902b463..03bd3bc97e 100644
--- a/frontend-modern/src/components/patrol/InvestigationSection.tsx
+++ b/frontend-modern/src/components/patrol/InvestigationSection.tsx
@@ -26,6 +26,7 @@ import {
} from '@/utils/aiFindingPresentation';
import { getInvestigationSectionState } from '@/utils/patrolEmptyStatePresentation';
import { buildPatrolInvestigationRecordPresentation } from '@/features/patrol/patrolInvestigationContextModel';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { InvestigationMessages } from './InvestigationMessages';
import { notificationStore } from '@/stores/notifications';
@@ -167,7 +168,7 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props
{/* Loading */}
<Show when={!investigationSectionState().empty && investigationSectionState().text}>
<div class="flex items-center gap-2 text-xs text-muted py-2">
- <span class="h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" />
{investigationSectionState().text}
</div>
</Show>
diff --git a/frontend-modern/src/components/patrol/RunToolCallTrace.tsx b/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
index e91c7ae22d..2d7e6f63e4 100644
--- a/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
+++ b/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
@@ -12,6 +12,7 @@ import {
type ToolCallVerification,
type ToolCallVerificationStatus,
} from '@/api/patrol';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import {
getToolCallResultBadgeTone,
@@ -141,7 +142,7 @@ export const RunToolCallTrace: Component<RunToolCallTraceProps> = (props) => {
<Show when={expanded()}>
<Show when={toolCalls.loading}>
<div class="flex items-center gap-2 text-xs text-muted py-2 mt-2">
- <span class="h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin" />
+ <LoadingSpinner size="sm" />
{getToolCallsLoadingState()}
</div>
</Show>
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
index 50126d3713..28a29d9824 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
@@ -48,6 +48,7 @@ describe('ApprovalBanner', () => {
it('keeps approval risk chips on the shared MetadataBadge primitive', () => {
expect(approvalBannerSource).toContain('MetadataBadge');
+ expect(approvalBannerSource).toContain('LoadingSpinner');
expect(approvalBannerSource).toContain('APPROVAL_BANNER_BADGE_PROPS');
expect(approvalBannerSource).toContain('firstApprovalRisk()!.badgeTone');
expect(approvalBannerSource).not.toContain('firstApprovalRisk()!.badgeClass');
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
index a6b1d0ee0e..e5acd8827e 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
@@ -88,6 +88,10 @@ describe('ApprovalSection', () => {
openMock.mockReset();
});
+ it('keeps approval action loading indicators on the shared LoadingSpinner primitive', () => {
+ expect(approvalSectionSource).toContain('LoadingSpinner');
+ });
+
afterEach(() => {
cleanup();
});
diff --git a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
index 8d7b9800fe..b0a9ac023f 100644
--- a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
@@ -7,6 +7,7 @@ import {
getInvestigationOutcomeLabel,
getInvestigationStatusBadgeTone,
} from '@/utils/aiFindingPresentation';
+import investigationSectionSource from '../InvestigationSection.tsx?raw';
import InvestigationSection from '../InvestigationSection';
const getInvestigationMock = vi.hoisted(() => vi.fn<() => Promise<Investigation>>());
@@ -47,6 +48,10 @@ describe('InvestigationSection', () => {
cleanup();
});
+ it('keeps investigation loading indicators on the shared LoadingSpinner primitive', () => {
+ expect(investigationSectionSource).toContain('LoadingSpinner');
+ });
+
it('renders investigation status badges from the shared finding presentation contract', async () => {
getInvestigationMock.mockResolvedValue({
id: 'inv-1',
diff --git a/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
index 2efc107a46..acb505923b 100644
--- a/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
@@ -20,6 +20,7 @@ describe('RunToolCallTrace', () => {
it('keeps tool-call result chips on the shared MetadataBadge primitive', () => {
expect(runToolCallTraceSource).toContain('MetadataBadge');
+ expect(runToolCallTraceSource).toContain('LoadingSpinner');
expect(runToolCallTraceSource).toContain('RUN_TOOL_CALL_BADGE_PROPS');
expect(runToolCallTraceSource).toContain('getToolCallResultBadgeTone');
expect(runToolCallTraceSource).not.toContain('getToolCallResultBadgeClass');
diff --git a/frontend-modern/src/components/shared/LoadingSpinner.test.tsx b/frontend-modern/src/components/shared/LoadingSpinner.test.tsx
new file mode 100644
index 0000000000..dee3f3a864
--- /dev/null
+++ b/frontend-modern/src/components/shared/LoadingSpinner.test.tsx
@@ -0,0 +1,61 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it } from 'vitest';
+import { LoadingSpinner, getLoadingSpinnerClass } from '@/components/shared/LoadingSpinner';
+
+afterEach(cleanup);
+
+describe('LoadingSpinner', () => {
+ it('renders the canonical decorative spinner shell by default', () => {
+ render(() => <LoadingSpinner />);
+
+ const spinner = document.querySelector('span');
+
+ expect(spinner).toHaveClass('inline-block');
+ expect(spinner).toHaveClass('shrink-0');
+ expect(spinner).toHaveClass('animate-spin');
+ expect(spinner).toHaveClass('rounded-full');
+ expect(spinner).toHaveClass('border-t-transparent');
+ expect(spinner).toHaveClass('h-3');
+ expect(spinner).toHaveClass('w-3');
+ expect(spinner).toHaveClass('border-2');
+ expect(spinner).toHaveClass('border-current');
+ expect(spinner).toHaveAttribute('aria-hidden', 'true');
+ expect(spinner).not.toHaveAttribute('role');
+ });
+
+ it('supports accessible status labels without leaking local props to the DOM', () => {
+ render(() => (
+ <LoadingSpinner
+ data-testid="spinner"
+ size="lg"
+ tone="info"
+ label="Loading findings"
+ class="mx-1"
+ />
+ ));
+
+ const spinner = screen.getByRole('status', { name: 'Loading findings' });
+
+ expect(spinner).toHaveClass('h-12');
+ expect(spinner).toHaveClass('w-12');
+ expect(spinner).toHaveClass('border-4');
+ expect(spinner).toHaveClass('border-blue-500');
+ expect(spinner).toHaveClass('mx-1');
+ expect(spinner).not.toHaveAttribute('aria-hidden');
+ expect(spinner).not.toHaveAttribute('size');
+ expect(spinner).not.toHaveAttribute('tone');
+ expect(spinner).not.toHaveAttribute('label');
+ });
+
+ it('keeps size and tone class composition in the shared primitive model', () => {
+ expect(getLoadingSpinnerClass({ size: 'xs', tone: 'muted', class: 'align-middle' })).toContain(
+ 'h-2',
+ );
+ expect(getLoadingSpinnerClass({ size: 'xs', tone: 'muted', class: 'align-middle' })).toContain(
+ 'border-slate-400',
+ );
+ expect(getLoadingSpinnerClass({ size: 'xs', tone: 'muted', class: 'align-middle' })).toContain(
+ 'align-middle',
+ );
+ });
+});
diff --git a/frontend-modern/src/components/shared/LoadingSpinner.tsx b/frontend-modern/src/components/shared/LoadingSpinner.tsx
new file mode 100644
index 0000000000..6c3d42aa8d
--- /dev/null
+++ b/frontend-modern/src/components/shared/LoadingSpinner.tsx
@@ -0,0 +1,64 @@
+import { splitProps, type JSX } from 'solid-js';
+
+export type LoadingSpinnerSize = 'xs' | 'sm' | 'md' | 'lg';
+export type LoadingSpinnerTone = 'current' | 'inverse' | 'info' | 'muted';
+
+export interface LoadingSpinnerProps extends Omit<JSX.HTMLAttributes<HTMLSpanElement>, 'class'> {
+ size?: LoadingSpinnerSize;
+ tone?: LoadingSpinnerTone;
+ label?: string;
+ class?: string;
+}
+
+const LOADING_SPINNER_SIZE_CLASSES: Record<LoadingSpinnerSize, string> = {
+ xs: 'h-2 w-2 border',
+ sm: 'h-3 w-3 border-2',
+ md: 'h-4 w-4 border-2',
+ lg: 'h-12 w-12 border-4',
+};
+
+const LOADING_SPINNER_TONE_CLASSES: Record<LoadingSpinnerTone, string> = {
+ current: 'border-current',
+ inverse: 'border-white',
+ info: 'border-blue-500',
+ muted: 'border-slate-400',
+};
+
+export function getLoadingSpinnerClass(props: {
+ size?: LoadingSpinnerSize;
+ tone?: LoadingSpinnerTone;
+ class?: string;
+}): string {
+ const size = props.size ?? 'sm';
+ const tone = props.tone ?? 'current';
+
+ return [
+ 'inline-block shrink-0 animate-spin rounded-full border-t-transparent',
+ LOADING_SPINNER_SIZE_CLASSES[size],
+ LOADING_SPINNER_TONE_CLASSES[tone],
+ props.class ?? '',
+ ]
+ .filter(Boolean)
+ .join(' ');
+}
+
+export function LoadingSpinner(props: LoadingSpinnerProps): JSX.Element {
+ const [local, rest] = splitProps(props, ['size', 'tone', 'label', 'class']);
+ const ariaHidden = () => (local.label ? undefined : 'true');
+
+ return (
+ <span
+ {...rest}
+ class={getLoadingSpinnerClass({
+ size: local.size,
+ tone: local.tone,
+ class: local.class,
+ })}
+ role={local.label ? 'status' : undefined}
+ aria-label={local.label}
+ aria-hidden={ariaHidden()}
+ />
+ );
+}
+
+export default LoadingSpinner;
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 5920369ff5..beeb26a6e8 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -47,6 +47,7 @@ import searchInputEnhancementsSource from '@/components/shared/SearchInputEnhanc
import searchInputEnhancementsModelSource from '@/components/shared/searchInputEnhancementsModel.ts?raw';
import searchInputModelSource from '@/components/shared/searchInputModel.ts?raw';
import statusDotSource from '@/components/shared/StatusDot.tsx?raw';
+import loadingSpinnerSource from '@/components/shared/LoadingSpinner.tsx?raw';
import statusBadgeSource from '@/components/shared/StatusBadge.tsx?raw';
import statusBadgeModelSource from '@/components/shared/statusBadgeModel.ts?raw';
import statusIndicatorBadgeSource from '@/components/shared/StatusIndicatorBadge.tsx?raw';
@@ -215,6 +216,7 @@ import patrolIntelligenceSummarySource from '@/features/patrol/PatrolIntelligenc
import patrolIntelligenceWorkspaceSource from '@/features/patrol/PatrolIntelligenceWorkspace.tsx?raw';
import approvalBannerSource from '@/components/patrol/ApprovalBanner.tsx?raw';
import approvalSectionSource from '@/components/patrol/ApprovalSection.tsx?raw';
+import investigationMessagesSource from '@/components/patrol/InvestigationMessages.tsx?raw';
import investigationSectionSource from '@/components/patrol/InvestigationSection.tsx?raw';
import runHistoryEntrySource from '@/components/patrol/RunHistoryEntry.tsx?raw';
import runToolCallTraceSource from '@/components/patrol/RunToolCallTrace.tsx?raw';
@@ -1859,6 +1861,65 @@ describe('shared primitive guardrails', () => {
}
});
+ it('keeps Patrol and AI loading spinners on the shared LoadingSpinner primitive', () => {
+ const registry = JSON.parse(sharedTemplateRegistrySource) as {
+ rules?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ requiredConsumers?: Array<{ path?: string }>;
+ }>;
+ patternGuards?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ allPatterns?: string[];
+ scopes?: string[];
+ allowedPaths?: string[];
+ ignoredPaths?: string[];
+ }>;
+ };
+ const registeredRule = registry.rules?.find((rule) => rule.id === 'loading-spinner-shell');
+ const registeredGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'patrol-ai-local-loading-spinner-shell',
+ );
+
+ expect(registeredRule?.canonical?.path).toBe('src/components/shared/LoadingSpinner.tsx');
+ expect(registeredRule?.canonical?.export).toBe('LoadingSpinner');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
+ 'src/components/AI/FindingsPanel.tsx',
+ 'src/components/patrol/ApprovalBanner.tsx',
+ 'src/components/patrol/ApprovalSection.tsx',
+ 'src/components/patrol/InvestigationMessages.tsx',
+ 'src/components/patrol/InvestigationSection.tsx',
+ 'src/components/patrol/RunToolCallTrace.tsx',
+ 'src/features/patrol/PatrolIntelligenceHeader.tsx',
+ ]);
+ expect(registeredGuard?.canonical?.path).toBe('src/components/shared/LoadingSpinner.tsx');
+ expect(registeredGuard?.canonical?.export).toBe('LoadingSpinner');
+ expect(registeredGuard?.allPatterns).toEqual(['border-t-transparent', 'animate-spin']);
+ expect(registeredGuard?.scopes).toEqual([
+ 'src/components/patrol',
+ 'src/features/patrol',
+ 'src/components/AI/FindingsPanel.tsx',
+ ]);
+ expect(registeredGuard?.allowedPaths ?? []).toHaveLength(0);
+
+ expect(loadingSpinnerSource).toContain('getLoadingSpinnerClass');
+ expect(loadingSpinnerSource).toContain('aria-hidden={ariaHidden()}');
+
+ for (const source of [
+ findingsPanelSource,
+ approvalBannerSource,
+ approvalSectionSource,
+ investigationMessagesSource,
+ investigationSectionSource,
+ runToolCallTraceSource,
+ patrolIntelligenceHeaderSource,
+ ]) {
+ expect(source).toContain('LoadingSpinner');
+ expect(source).not.toMatch(/border(?:-\d)?[^\n]*border-t-transparent[^\n]*animate-spin/);
+ }
+ });
+
it('keeps standard command buttons on the shared Button primitive', () => {
const registry = JSON.parse(sharedTemplateRegistrySource) as {
rules?: Array<{
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
index 71fe625338..9382cd44a4 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
@@ -11,6 +11,7 @@ import { Toggle, TogglePrimitive } from '@/components/shared/Toggle';
import { CountdownTimer } from '@/components/patrol';
import { FormSelect } from '@/components/shared/FormSelect';
import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
+import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import type { PatrolAutonomyLevel } from '@/api/patrol';
import { presentationPolicyHidesUpgradePrompts } from '@/stores/sessionPresentationPolicy';
import { formatRelativeTime } from '@/utils/format';
@@ -527,7 +528,7 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState
class="w-full py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md shadow-sm transition-all focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-blue-300 disabled:hover:bg-blue-300 dark:disabled:bg-blue-900 flex items-center justify-center gap-2"
>
<Show when={state.isSavingAdvanced()}>
- <div class="animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"></div>
+ <LoadingSpinner size="md" />
</Show>
<Show when={!state.isSavingAdvanced()}>Apply Configuration</Show>
</button>
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 47fb658e07..e8dff68116 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -4,6 +4,7 @@ import { Suspense, createSignal } from 'solid-js';
import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
import { resetAIRuntimeState } from '@/stores/aiRuntimeState';
import { getPublicPricingUrl } from '@/utils/pricingHandoff';
+import patrolIntelligenceHeaderSource from '@/features/patrol/PatrolIntelligenceHeader.tsx?raw';
import patrolIntelligenceStateSource from '@/features/patrol/usePatrolIntelligenceState.ts?raw';
import { AIIntelligence } from '../AIIntelligence';
@@ -344,6 +345,10 @@ describe('AIIntelligence entitlement gating', () => {
expect(patrolIntelligenceStateSource).toContain('requestId === refreshRequestId');
});
+ it('keeps Patrol header loading indicators on the shared LoadingSpinner primitive', () => {
+ expect(patrolIntelligenceHeaderSource).toContain('LoadingSpinner');
+ });
+
beforeEach(() => {
resetCreateNonSuspendingQueryCacheForTest();
resetAIRuntimeState();