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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
render Overdue commitments filter in FindingsPanel
rcourtmane84afb140e3a
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsxindex bf8be0dfa6..7302995b75 100644--- a/frontend-modern/src/components/AI/FindingsPanel.tsx+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx@@ -82,7 +82,7 @@ interface FindingsPanelProps {showResolved?: boolean;maxItems?: number;onFindingClick?: (finding: UnifiedFinding) => void;- filterOverride?: 'all' | 'active' | 'resolved' | 'approvals' | 'attention';+ filterOverride?: 'all' | 'active' | 'resolved' | 'approvals' | 'attention' | 'overdue';filterFindingIds?: string[];showControls?: boolean;scopeResourceIds?: string[];@@ -146,7 +146,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {const location = useLocation();const { get: getResource } = useResources();const [filter, setFilter] = createSignal<- 'all' | 'active' | 'resolved' | 'approvals' | 'attention'+ 'all' | 'active' | 'resolved' | 'approvals' | 'attention' | 'overdue'>(props.filterOverride ?? 'active');const [sortBy, setSortBy] = createSignal<'severity' | 'time'>('severity');const [expandedId, setExpandedId] = createSignal<string | null>(null);@@ -314,6 +314,23 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {} else if (filter() === 'approvals') {const approvalFindingIds = new Set(sourceFindingsWithPendingApprovals().map((f) => f.id));findings = findings.filter((f) => approvalFindingIds.has(f.id));+ } else if (filter() === 'overdue') {+ // Overdue surfaces will_fix_later commitments whose RemindAt+ // deadline has already passed. The Go store's proactive sweep+ // (SweepWillFixLaterReminders) wakes these on a 1h timer, but+ // this filter lets the operator see them on demand — including+ // any that the sweep has not yet promoted on this cycle.+ const nowMs = Date.now();+ findings = findings.filter((f) => {+ if (f.dismissedReason !== 'will_fix_later') {+ return false;+ }+ if (!f.remindAt) {+ return false;+ }+ const due = Date.parse(f.remindAt);+ return Number.isFinite(due) && due <= nowMs;+ });}// Filter by specific finding IDs if provided@@ -401,6 +418,17 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {? scopedPendingApprovalCount(): sourceFindingsWithPendingApprovals().length,}));+ // Count of will_fix_later commitments whose RemindAt deadline has+ // already passed. Drives the Overdue commitments chip below.+ const overdueCount = createMemo(() => {+ const nowMs = Date.now();+ return sourceFindings().filter((f) => {+ if (f.dismissedReason !== 'will_fix_later') return false;+ if (!f.remindAt) return false;+ const due = Date.parse(f.remindAt);+ return Number.isFinite(due) && due <= nowMs;+ }).length;+ });const patrolFindings = createMemo(() => {if (isPatrolFindingsSource()) {return filteredFindings();@@ -410,15 +438,22 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {);});const filterOptions = createMemo(() => buildFindingFilterOptions(filterCounts()));- const emptyStateCopy = createMemo(() =>- getPatrolFindingsEmptyState({- filter: filter(),+ const emptyStateCopy = createMemo(() => {+ // 'overdue' is a FindingsPanel-local extension to the shared+ // FindingsFilter union. The empty state for that case is rendered+ // inline below (the <Show when={filter() === 'overdue'}> branch),+ // so the value passed here is intentionally a no-op fallback that+ // keeps the helper inside its FindingsFilter contract.+ const currentFilter = filter();+ const emptyFilter = currentFilter === 'overdue' ? 'all' : currentFilter;+ return getPatrolFindingsEmptyState({+ filter: emptyFilter,overallHealth: props.overallHealth,runtimeState: props.runtimeState,blockedReason: props.blockedReason,runSnapshot: props.runSnapshot,- }),- );+ });+ });const emptyStateTone = createMemo(() => getSemanticTonePresentation(emptyStateCopy().tone));// Auto-reset filter when the conditional filter buttons disappearcreateEffect(() => {@@ -428,6 +463,9 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {if (filter() === 'approvals' && filterCounts().pendingApprovalCount === 0) {setFilter('active');}+ if (filter() === 'overdue' && overdueCount() === 0) {+ setFilter('active');+ }});const showFilterControls = createMemo(() =>@@ -435,10 +473,12 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {(useRunSnapshotScopedControls()? runSnapshotScopedPatrolFindings().length > 0 ||filterCounts().needsAttentionCount > 0 ||- filterCounts().pendingApprovalCount > 0+ filterCounts().pendingApprovalCount > 0 ||+ overdueCount() > 0: allPatrolFindings().length > 0 ||filterCounts().needsAttentionCount > 0 ||- filterCounts().pendingApprovalCount > 0),+ filterCounts().pendingApprovalCount > 0 ||+ overdueCount() > 0),);const isOutOfScope = (finding: UnifiedFinding): boolean => {@@ -1937,7 +1977,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {<For each={filterOptions()}>{(option, index) => {const isFirst = () => index() === 0;- const isLast = () => index() === filterOptions().length - 1;+ const isLast = () => index() === filterOptions().length - 1 && overdueCount() === 0;return (<buttontype="button"@@ -1952,6 +1992,17 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {);}}</For>+ <Show when={overdueCount() > 0}>+ <button+ type="button"+ data-testid="findings-panel-filter-overdue"+ onClick={() => setFilter('overdue')}+ class={`px-2 py-1 border rounded-r ${segmentedButtonClass(filter() === 'overdue', false, 'warning')}`}+ title="Will-fix-later commitments past their remind deadline"+ >+ Overdue commitments ({overdueCount()})+ </button>+ </Show></div><Show when={patrolFindings().length > 1}><FormSelect@@ -2027,9 +2078,13 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {</Show><Show when={filter() === 'attention'}>{emptyStateCopy().title}</Show><Show when={filter() === 'approvals'}>{emptyStateCopy().title}</Show>+ <Show when={filter() === 'overdue'}>No overdue will-fix-later commitments.</Show><Showwhen={- filter() !== 'active' && filter() !== 'attention' && filter() !== 'approvals'+ filter() !== 'active' &&+ filter() !== 'attention' &&+ filter() !== 'approvals' &&+ filter() !== 'overdue'}>{emptyStateCopy().title}diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsxnew file mode 100644index 0000000000..b649cf3e92--- /dev/null+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx@@ -0,0 +1,226 @@+import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import type { JSX } from 'solid-js';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { FindingsPanel } from '../FindingsPanel';++function makeFinding(overrides: Record<string, unknown>) {+ return {+ id: 'finding-1',+ source: 'ai-patrol',+ resourceId: 'node-a/storage/tank',+ resourceName: 'tank',+ resourceType: 'storage',+ category: 'capacity',+ severity: 'warning',+ title: 'Storage pool tank approaching threshold',+ description: 'Pool tank is filling up.',+ detectedAt: '2026-04-01T10:00:00Z',+ lastSeenAt: '2026-04-01T10:05:00Z',+ status: 'active',+ ...overrides,+ };+}++const mockState = vi.hoisted(() => {+ const loadFindings = vi.fn();+ const loadPatrolFindings = vi.fn();+ const loadRemediationPlans = vi.fn();+ return {+ findings: [] as unknown[],+ remediationPlans: [] as unknown[],+ loadFindings,+ loadPatrolFindings,+ loadRemediationPlans,+ };+});++vi.mock('@solidjs/router', () => ({+ A: (props: { href: string; children?: JSX.Element; [key: string]: unknown }) => (+ <a href={props.href} aria-label={props['aria-label'] as string} onClick={props.onClick as any}>+ {props.children}+ </a>+ ),+ useLocation: () => ({ hash: '' }),+}));++vi.mock('@/components/shared/Card', () => ({+ Card: (props: { children?: JSX.Element }) => <div>{props.children}</div>,+}));++vi.mock('@/components/patrol', () => ({+ InvestigationSection: () => null,+ ApprovalSection: () => null,+}));++vi.mock('@/stores/notifications', () => ({+ notificationStore: {+ success: vi.fn(),+ error: vi.fn(),+ },+}));++vi.mock('@/stores/aiChat', () => ({+ aiChatStore: {+ openWithPrompt: vi.fn(),+ },+}));++vi.mock('@/api/ai', () => ({+ AIAPI: {+ approveRemediationPlan: vi.fn(),+ },+}));++vi.mock('@/hooks/useResources', () => ({+ useResources: () => ({+ get: () => undefined,+ }),+}));++vi.mock('@/stores/aiIntelligence', () => ({+ aiIntelligenceStore: {+ get findings() {+ return mockState.findings;+ },+ get findingsLoading() {+ return false;+ },+ get findingsError() {+ return null;+ },+ get patrolFindings() {+ return mockState.findings;+ },+ get patrolFindingsLoading() {+ return false;+ },+ get patrolFindingsError() {+ return null;+ },+ get findingsNeedingAttention() {+ return [];+ },+ get patrolFindingsNeedingAttention() {+ return [];+ },+ get findingsWithPendingApprovals() {+ return [];+ },+ get patrolFindingsWithPendingApprovals() {+ return [];+ },+ get remediationPlans() {+ return mockState.remediationPlans;+ },+ findingsSignal: () => mockState.findings,+ patrolFindingsSignal: () => mockState.findings,+ loadFindings: mockState.loadFindings,+ loadPatrolFindings: mockState.loadPatrolFindings,+ loadRemediationPlans: mockState.loadRemediationPlans,+ },+}));++beforeEach(() => {+ mockState.findings = [];+ mockState.remediationPlans = [];+ mockState.loadFindings.mockClear();+ mockState.loadPatrolFindings.mockClear();+ mockState.loadRemediationPlans.mockClear();+ if (typeof window.requestAnimationFrame !== 'function') {+ window.requestAnimationFrame = ((callback: FrameRequestCallback) =>+ window.setTimeout(() => callback(performance.now()), 0)) as typeof window.requestAnimationFrame;+ }+});++afterEach(() => {+ vi.clearAllMocks();+});++describe('FindingsPanel overdue commitments filter', () => {+ // The Overdue chip lets operators see will_fix_later commitments whose+ // RemindAt deadline has passed without waiting for the hourly sweep+ // (SweepWillFixLaterReminders) to re-surface them. The filter must+ // include only past-deadline will_fix_later findings and exclude+ // future-dated commitments and unrelated active findings.+ it('renders only past-deadline will_fix_later findings when Overdue chip is clicked', async () => {+ const past = '2026-01-01T00:00:00Z';+ const future = '2099-01-01T00:00:00Z';++ const overdue = makeFinding({+ id: 'overdue-1',+ title: 'Storage pool past remind deadline',+ status: 'dismissed',+ dismissedReason: 'will_fix_later',+ remindAt: past,+ });+ const pending = makeFinding({+ id: 'pending-1',+ title: 'CPU growth still within commitment window',+ status: 'dismissed',+ dismissedReason: 'will_fix_later',+ remindAt: future,+ });+ const active = makeFinding({+ id: 'active-1',+ title: 'Active finding with no dismissal',+ });++ mockState.findings = [overdue, pending, active];++ render(() => <FindingsPanel findingsSource="patrol" />);++ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());++ // The Overdue chip appears in the filter bar.+ const overdueChip = screen.getByTestId('findings-panel-filter-overdue');+ expect(overdueChip).toHaveTextContent(/Overdue commitments \(1\)/);+ fireEvent.click(overdueChip);++ await waitFor(() => {+ expect(screen.getByText('Storage pool past remind deadline')).toBeInTheDocument();+ });+ expect(screen.queryByText('CPU growth still within commitment window')).not.toBeInTheDocument();+ expect(screen.queryByText('Active finding with no dismissal')).not.toBeInTheDocument();+ });++ it('hides the Overdue chip when no will_fix_later commitment is past its deadline', async () => {+ const future = '2099-01-01T00:00:00Z';+ mockState.findings = [+ makeFinding({+ id: 'pending-1',+ title: 'Future commitment',+ status: 'dismissed',+ dismissedReason: 'will_fix_later',+ remindAt: future,+ }),+ makeFinding({ id: 'active-1', title: 'Active finding' }),+ ];++ render(() => <FindingsPanel findingsSource="patrol" />);++ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());+ expect(screen.queryByTestId('findings-panel-filter-overdue')).not.toBeInTheDocument();+ });++ it('honors filterOverride="overdue" so callers can land directly on the filter', async () => {+ const past = '2026-01-01T00:00:00Z';+ mockState.findings = [+ makeFinding({+ id: 'overdue-1',+ title: 'Only overdue should render',+ status: 'dismissed',+ dismissedReason: 'will_fix_later',+ remindAt: past,+ }),+ makeFinding({ id: 'active-1', title: 'Active finding with no dismissal' }),+ ];++ render(() => <FindingsPanel findingsSource="patrol" filterOverride="overdue" />);++ await waitFor(() => {+ expect(screen.getByText('Only overdue should render')).toBeInTheDocument();+ });+ expect(screen.queryByText('Active finding with no dismissal')).not.toBeInTheDocument();+ });+});