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
Distinguish unread investigation history from absent history
pulse-triage[bot]99738e5e08b1
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 33ee69cdf3..7494cd52c2 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -15,6 +15,25 @@## Purpose+### Unread investigation history is not absent history++Investigation detail and thread reads distinguish a genuine 404/empty response+from an unavailable or denied read. Failed reads show an accessible warning and+a read-only Retry, never a false empty state. Re-investigate is withheld while+the detail read has failed, including when its last answer is retained: that+answer may miss a newer run or queued fix. Retry only reads existing history;+it does not start a run or change Patrol's existing refresh intervals.++Previously loaded same-finding/session evidence remains readable after a+transient failure, labelled as potentially out of date or incomplete. Source+changes do not borrow another finding/session's evidence; HTTP 401/403 still+withdraw the query cache and show the existing access guidance without raw+error payloads. A successful read clears the warning and restores normal+empty/data/action presentation. The registered InvestigationSection and+InvestigationMessages suites cover these transitions and retained row identity.+This consumer contract requires truthful producer statuses; it does not prove+private persistence admission, original installed recovery or release delivery.+### Attention selection retains visible evidence in its name (24 October 2026)Attention list buttons use their visible contents as the accessible name insteaddiff --git a/frontend-modern/src/components/patrol/InvestigationMessages.tsx b/frontend-modern/src/components/patrol/InvestigationMessages.tsxindex 310f2527ee..04cc0fc3a0 100644--- a/frontend-modern/src/components/patrol/InvestigationMessages.tsx+++ b/frontend-modern/src/components/patrol/InvestigationMessages.tsx@@ -9,9 +9,12 @@ import { Component, createEffect, createMemo, on, Show, For } from 'solid-js';import { getInvestigationMessages, formatTimestamp, type ChatMessage } from '@/api/patrol';import { withAPIErrorStatusNull } from '@/api/responseUtils';import { LoadingSpinner } from '@/components/shared/LoadingSpinner';+import { Button } from '@/components/shared/Button';+import { InlineNotice } from '@/components/shared/InlineNotice';import { createNonSuspendingQuery } from '@/hooks/createNonSuspendingQuery';import { useRelativeTimeNow } from '@/utils/relativeTimeClock';import { getInvestigationMessagesState } from '@/utils/patrolEmptyStatePresentation';+import { getAPIReadAccessErrorMessage } from '@/utils/apiAccessError';import { renderMarkdown } from '@/components/AI/aiChatUtils';import { ToolExecutionBlock } from './ToolExecutionBlock';@@ -101,14 +104,40 @@ export const InvestigationMessages: Component<InvestigationMessagesProps> = (proreturn (<div class="mt-2">- <Show when={!messagesState().empty && messagesState().text}>+ <Show when={messagesQuery.error()}>+ <InlineNotice+ role="alert"+ tone="warning"+ aria-label="Investigation thread read failed"+ class="mb-2"+ >+ <p class="font-medium">Could not load investigation messages.</p>+ <p>+ {getAPIReadAccessErrorMessage(messagesQuery.error()) ??+ (messages().length > 0+ ? 'Showing previously loaded messages. Newer messages may be missing.'+ : 'The saved thread could not be read. This does not mean it is empty.')}+ </p>+ <Button+ size="sm"+ disabled={messagesQuery.loading()}+ onClick={(e) => {+ e.stopPropagation();+ void messagesQuery.refetch();+ }}+ >+ {messagesQuery.loading() ? 'Retrying messages...' : 'Retry messages'}+ </Button>+ </InlineNotice>+ </Show>+ <Show when={!messagesQuery.error() && !messagesState().empty && messagesState().text}><div class="flex items-center gap-2 text-xs text-muted py-2"><LoadingSpinner size="sm" />{messagesState().text}</div></Show>- <Show when={messagesState().empty}>+ <Show when={!messagesQuery.error() && messagesState().empty}><p class="text-xs text-muted py-1">{messagesState().text}</p></Show>diff --git a/frontend-modern/src/components/patrol/InvestigationSection.tsx b/frontend-modern/src/components/patrol/InvestigationSection.tsxindex e2ec7e6bed..0dda3459b5 100644--- a/frontend-modern/src/components/patrol/InvestigationSection.tsx+++ b/frontend-modern/src/components/patrol/InvestigationSection.tsx@@ -26,7 +26,10 @@ import {import { getInvestigationSectionState } from '@/utils/patrolEmptyStatePresentation';import { buildPatrolInvestigationRecordPresentation } from '@/features/patrol/patrolInvestigationContextModel';import { LoadingSpinner } from '@/components/shared/LoadingSpinner';+import { Button } from '@/components/shared/Button';+import { InlineNotice } from '@/components/shared/InlineNotice';import { MetadataBadge } from '@/components/shared/MetadataBadge';+import { getAPIReadAccessErrorMessage } from '@/utils/apiAccessError';import { InvestigationMessages } from './InvestigationMessages';import { renderMarkdown } from '@/components/AI/aiChatUtils';import { notificationStore } from '@/stores/notifications';@@ -117,7 +120,10 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (propsconst canReinvestigate = () => {// Until the first read answers, a running investigation or a queued fix// looks like no investigation at all, which would offer another run.- if (!investigationQuery.resolvedOnce()) return false;+ // A failed read says nothing about whether a run already exists. Even a+ // retained answer may miss a newer run or queued fix. Retry the read, not+ // the investigation, until its current state is known.+ if (!investigationQuery.resolvedOnce() || investigationQuery.error()) return false;if (Date.now() < cooldownUntil()) return false;const inv = investigation();if (!inv) return true; // No investigation yet@@ -202,8 +208,41 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props</Show></div>- {/* Loading */}- <Show when={!investigationSectionState().empty && investigationSectionState().text}>+ <Show when={investigationQuery.error()}>+ <InlineNotice+ role="alert"+ tone="warning"+ aria-label="Investigation read failed"+ class="mb-2"+ >+ <p class="font-medium">Could not load investigation history.</p>+ <p>+ {getAPIReadAccessErrorMessage(investigationQuery.error()) ??+ (hasInvestigationContext()+ ? 'Showing previously loaded investigation evidence. It may be out of date.'+ : 'The saved investigation could not be read. This does not mean no investigation exists.')}+ </p>+ <Button+ size="sm"+ disabled={investigationQuery.loading()}+ onClick={(e) => {+ e.stopPropagation();+ void investigationQuery.refetch();+ }}+ >+ {investigationQuery.loading() ? 'Retrying history...' : 'Retry history'}+ </Button>+ </InlineNotice>+ </Show>++ {/* A failed read is neither loading nor an empty investigation. */}+ <Show+ when={+ !investigationQuery.error() &&+ !investigationSectionState().empty &&+ investigationSectionState().text+ }+ ><div class="flex items-center gap-2 text-xs text-muted py-2"><LoadingSpinner size="sm" />{investigationSectionState().text}@@ -211,7 +250,7 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props</Show>{/* No investigation data */}- <Show when={investigationSectionState().empty}>+ <Show when={!investigationQuery.error() && investigationSectionState().empty}><p class="text-xs text-muted py-1">{investigationSectionState().text}</p></Show>diff --git a/frontend-modern/src/components/patrol/__tests__/InvestigationMessages.test.tsx b/frontend-modern/src/components/patrol/__tests__/InvestigationMessages.test.tsxindex bd11ee1dd0..828deed2f7 100644--- a/frontend-modern/src/components/patrol/__tests__/InvestigationMessages.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/InvestigationMessages.test.tsx@@ -90,7 +90,10 @@ describe('InvestigationMessages', () => {messages: [{ id: 'r-1', role: 'assistant', content: 'Read on retry.', timestamp: '1' }],});render(() => <InvestigationMessages findingId="finding-7" sessionId="session-retry" />);- expect(await screen.findByText('No investigation messages available.')).toBeInTheDocument();+ expect(+ await screen.findByRole('alert', { name: 'Investigation thread read failed' }),+ ).toHaveTextContent('This does not mean it is empty.');+ expect(screen.queryByText('No investigation messages available.')).not.toBeInTheDocument();vi.advanceTimersByTime(30_000);expect(await screen.findByText('Read on retry.')).toBeInTheDocument();@@ -99,6 +102,121 @@ describe('InvestigationMessages', () => {}});+ it('lets a read-only retry recover an unavailable thread without exposing its error payload', async () => {+ getMessages.mockRejectedValueOnce(Object.assign(new Error('private path'), { status: 503 }));+ let finishRead: (value: unknown) => void = () => {};+ getMessages.mockReturnValueOnce(+ new Promise((resolve) => {+ finishRead = resolve;+ }),+ );+ render(() => <InvestigationMessages findingId="unavailable" sessionId="unavailable" />);+ await screen.findByRole('alert', { name: 'Investigation thread read failed' });+ expect(screen.queryByText('private path')).not.toBeInTheDocument();+ expect(screen.queryByText('No investigation messages available.')).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Retry messages' }));+ expect(screen.getByRole('button', { name: 'Retrying messages...' })).toBeDisabled();+ finishRead({+ messages: [+ {+ id: 'recovered',+ role: 'assistant',+ content: 'Recovered thread evidence.',+ timestamp: '1',+ },+ ],+ });+ expect(await screen.findByText('Recovered thread evidence.')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it.each([404, 200])(+ 'shows genuine empty messages for HTTP %s, not a read failure',+ async (status) => {+ if (status === 404)+ getMessages.mockRejectedValueOnce(Object.assign(new Error('not found'), { status }));+ else getMessages.mockResolvedValueOnce({ messages: [] });+ render(() => <InvestigationMessages findingId="absent" sessionId="absent" />);+ expect(await screen.findByText('No investigation messages available.')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ },+ );++ it('labels retained messages after failure and keeps the same rows through successful recovery', async () => {+ vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });+ try {+ const message = {+ id: 'retained',+ role: 'assistant',+ content: 'Retained message evidence.',+ timestamp: '1',+ };+ getMessages.mockResolvedValueOnce({ messages: [message] });+ getMessages.mockRejectedValueOnce(Object.assign(new Error('unavailable'), { status: 503 }));+ getMessages.mockResolvedValueOnce({+ messages: [+ message,+ { id: 'new', role: 'assistant', content: 'New evidence after recovery.', timestamp: '2' },+ ],+ });+ render(() => <InvestigationMessages findingId="retained" sessionId="retained" live />);+ const row = await screen.findByText('Retained message evidence.');+ vi.advanceTimersByTime(5_000);+ expect(+ await screen.findByRole('alert', { name: 'Investigation thread read failed' }),+ ).toHaveTextContent('Newer messages may be missing.');+ expect(screen.getByText('Retained message evidence.')).toBe(row);+ fireEvent.click(screen.getByRole('button', { name: 'Retry messages' }));+ expect(await screen.findByText('New evidence after recovery.')).toBeInTheDocument();+ expect(screen.getByText('Retained message evidence.')).toBe(row);+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ } finally {+ vi.useRealTimers();+ }+ });++ it.each([401, 403])('withdraws retained thread messages after HTTP %s', async (status) => {+ vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });+ try {+ getMessages.mockResolvedValueOnce({+ messages: [+ {+ id: 'private',+ role: 'assistant',+ content: 'Previously authorised message.',+ timestamp: '1',+ },+ ],+ });+ getMessages.mockRejectedValueOnce(Object.assign(new Error('secret payload'), { status }));+ render(() => <InvestigationMessages findingId="private" sessionId="private" live />);+ await screen.findByText('Previously authorised message.');+ vi.advanceTimersByTime(5_000);+ const alert = await screen.findByRole('alert', { name: 'Investigation thread read failed' });+ expect(alert).toHaveTextContent(status === 401 ? 'Sign in again' : 'Access denied');+ expect(alert).not.toHaveTextContent('secret payload');+ expect(screen.queryByText('Previously authorised message.')).not.toBeInTheDocument();+ } finally {+ vi.useRealTimers();+ }+ });++ it('does not borrow the previous session messages when the new session is unavailable', async () => {+ getMessages.mockResolvedValueOnce({+ messages: [+ { id: 'old', role: 'assistant', content: 'Old session evidence.', timestamp: '1' },+ ],+ });+ getMessages.mockRejectedValueOnce(Object.assign(new Error('unavailable'), { status: 503 }));+ const [sessionId, setSessionId] = createSignal('old');+ render(() => <InvestigationMessages findingId="same-finding" sessionId={sessionId()} />);+ await screen.findByText('Old session evidence.');+ setSessionId('new');+ await screen.findByRole('alert', { name: 'Investigation thread read failed' });+ expect(screen.queryByText('Old session evidence.')).not.toBeInTheDocument();+ expect(screen.queryByText('No investigation messages available.')).not.toBeInTheDocument();+ });+it('does not read a finished thread again while it stays open', async () => {vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });try {diff --git a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsxindex 8e58ce620a..f6a7162d9c 100644--- a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx@@ -1,5 +1,5 @@import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';-import { Suspense } from 'solid-js';+import { createSignal, Suspense } from 'solid-js';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { InvestigationRecord } from '@/api/ai';import type { Investigation } from '@/api/patrol';@@ -109,9 +109,113 @@ describe('InvestigationSection', () => {await new Promise((resolve) => setTimeout(resolve, 0));expect(screen.getByText('The service restarted twice.')).toBeInTheDocument();+ expect(screen.getByRole('alert', { name: 'Investigation read failed' })).toHaveTextContent(+ 'Showing previously loaded investigation evidence. It may be out of date.',+ );+ expect(screen.queryByRole('button', { name: 'Re-investigate' })).not.toBeInTheDocument();+ expect(screen.queryByText(/No investigation yet/)).not.toBeInTheDocument();+ });++ it('retries an unavailable cold read without offering or starting another investigation', async () => {+ getInvestigationMock.mockRejectedValueOnce(+ Object.assign(new Error('private path'), { status: 503 }),+ );+ let finishRead: (value: Investigation) => void = () => {};+ getInvestigationMock.mockReturnValueOnce(+ new Promise<Investigation>((resolve) => {+ finishRead = resolve;+ }),+ );+ render(() => <InvestigationSection findingId="unavailable" />);++ const alert = await screen.findByRole('alert', { name: 'Investigation read failed' });+ expect(alert).toHaveTextContent('This does not mean no investigation exists.');+ expect(alert).not.toHaveTextContent('private path');expect(screen.queryByText(/No investigation yet/)).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'Re-investigate' })).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Retry history' }));+ expect(screen.getByRole('button', { name: 'Retrying history...' })).toBeDisabled();+ expect(alert).toBeInTheDocument();+ finishRead({+ id: 'recovered',+ finding_id: 'unavailable',+ session_id: 'session-recovered',+ status: 'failed',+ outcome: 'fix_queued',+ started_at: '2026-10-29T08:00:00Z',+ turn_count: 1,+ summary: 'A fix is already waiting.',+ });+ expect(await screen.findByText('A fix is already waiting.')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'Re-investigate' })).not.toBeInTheDocument();+ expect(reinvestigateFindingMock).not.toHaveBeenCalled();+ });++ it('keeps a genuine 404 distinct from an unread investigation', async () => {+ getInvestigationMock.mockRejectedValueOnce(+ Object.assign(new Error('not found'), { status: 404 }),+ );+ render(() => <InvestigationSection findingId="absent" />);+ expect(await screen.findByText(/No investigation yet/)).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Re-investigate' })).toBeEnabled();+ });++ it('never shows one finding as the history of a different unavailable finding', async () => {+ getInvestigationMock.mockResolvedValueOnce({+ id: 'first',+ finding_id: 'first',+ session_id: 'first',+ status: 'completed',+ started_at: '2026-10-29T08:00:00Z',+ turn_count: 1,+ summary: 'Evidence for the first finding.',+ });+ getInvestigationMock.mockRejectedValueOnce(+ Object.assign(new Error('unavailable'), { status: 503 }),+ );+ const [findingId, setFindingId] = createSignal('first');+ render(() => <InvestigationSection findingId={findingId()} />);+ expect(await screen.findByText('Evidence for the first finding.')).toBeInTheDocument();+ setFindingId('second');+ await screen.findByRole('alert', { name: 'Investigation read failed' });+ expect(screen.queryByText('Evidence for the first finding.')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'Re-investigate' })).not.toBeInTheDocument();});+ it.each([401, 403])(+ 'withdraws retained history after HTTP %s without exposing the error payload',+ async (status) => {+ vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });+ try {+ getInvestigationMock.mockResolvedValueOnce({+ id: 'private',+ finding_id: 'private',+ session_id: 'private',+ status: 'completed',+ outcome: 'unclassified',+ started_at: '2026-10-29T08:00:00Z',+ turn_count: 1,+ summary: 'Previously authorised evidence.',+ });+ getInvestigationMock.mockRejectedValue(+ Object.assign(new Error('secret error payload'), { status }),+ );+ render(() => <InvestigationSection findingId="private" />);+ expect(await screen.findByText('Previously authorised evidence.')).toBeInTheDocument();+ vi.advanceTimersByTime(30_000);+ const alert = await screen.findByRole('alert', { name: 'Investigation read failed' });+ expect(alert).toHaveTextContent(status === 401 ? 'Sign in again' : 'Access denied');+ expect(alert).not.toHaveTextContent('secret error payload');+ expect(screen.queryByText('Previously authorised evidence.')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'Re-investigate' })).not.toBeInTheDocument();+ } finally {+ vi.useRealTimers();+ }+ },+ );+it('reads again on its own after a failed first read', async () => {// Findings refreshes no longer remount the review, so it retries itself.vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });