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
Keep Patrol background sessions out of the Assistant quick-resume list
rcourtman32f0fd42447d
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 32a3c20dba..831bfcc201 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -2474,6 +2474,17 @@ query...`, and `Reading storage...` before streamed tool arguments are(missing, corrupt, or stale entries only cost a re-parse, never a wrongsummary, and dotfiles are never listed as sessions). `writeSession` and`Delete` keep the cache and index coherent on every mutation.+ Pulse-owned background sessions are not resumable chats. The session store+ owns the well-known background session IDs (`patrol-main`, `patrol-eval`,+ `investigation-*`) through `chat.IsSystemSessionID` and marks their+ summaries `system: true` in every `Session` projection. The Assistant+ empty-state quick-resume list (`selectQuickResumeSessions` in+ `frontend-modern/src/components/AI/Chat/recentSessionsModel.ts`) must+ exclude system sessions — a Patrol detection log titled with the raw triage+ seed is forensic material, not a conversation to resume — while the+ drawer-owned session picker and the Settings sessions panel keep listing+ them for inspection. The canonical Patrol forensic surface remains the+ `PatrolRunRecord` history at `/api/ai/patrol/runs`.Assistant session navigation must provide a searchable history path in thedrawer-owned picker, using the canonical `/api/ai/sessions` contract ratherthan a separate recent-chat store. Search is applied before result limitingdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 6808d11d95..085c3a41fa 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1288,7 +1288,14 @@ payload shape change when the portal presents compact client rows.state. `GET /api/ai/sessions` and other `ChatSession` projections mayexpose only the boolean `can_redo` hint alongside safe title/timestamp,count, and handoff-summary fields so the drawer can re-enable redo after a- reload without reading the redo stack itself. Browser clients must use the+ reload without reading the redo stack itself. The projection also carries+ a boolean `system` flag for Pulse-owned background sessions (Patrol+ detection `patrol-main`, `patrol-eval`, and `investigation-*` runs),+ derived server-side from the well-known session IDs via+ `chat.IsSystemSessionID`; browser clients must not re-derive that+ ownership from ID string patterns, and must keep system sessions out of+ resumable-chat offers (quick-resume) while leaving them listable for+ inspection. Browser clients must use theshared `AIChatAPI.undoLastTurn(sessionId)` and`AIChatAPI.redoLastTurn(sessionId)` helpers so path encoding and responseshape stay canonical.diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex 4d033fc75d..eaea5e991a 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -1322,6 +1322,23 @@ describe('AIChatAPI', () => {expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/ai/sessions');});+ it('preserves the system flag on Pulse-owned background sessions', async () => {+ // patrol-main / investigation-* sessions arrive with system: true so the+ // Assistant quick-resume list can keep forensic Patrol logs out of the+ // resumable-chat offers.+ const patrolSession = {+ id: 'patrol-main',+ title: '# Deterministic Triage Results Scanned 70 resources',+ created_at: '2026-07-11T06:00:00Z',+ updated_at: '2026-07-11T06:05:00Z',+ message_count: 200,+ system: true,+ };+ apiFetchJSONMock.mockResolvedValueOnce([patrolSession]);++ await expect(AIChatAPI.listSessions()).resolves.toEqual([patrolSession]);+ });+it('passes session search and limit as query parameters', async () => {apiFetchJSONMock.mockResolvedValueOnce([]);diff --git a/frontend-modern/src/api/aiChat.ts b/frontend-modern/src/api/aiChat.tsindex 0e1787a203..dfb898f463 100644--- a/frontend-modern/src/api/aiChat.ts+++ b/frontend-modern/src/api/aiChat.ts@@ -15,6 +15,8 @@ export interface ChatSession {updated_at: string;message_count: number;can_redo?: boolean;+ /** Pulse-owned background run (Patrol detection/eval/investigation), not a resumable user chat. */+ system?: boolean;handoff_summary?: ChatSessionHandoffSummary;}diff --git a/frontend-modern/src/components/AI/Chat/__tests__/recentSessionsModel.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/recentSessionsModel.test.tsnew file mode 100644index 0000000000..fc516be336--- /dev/null+++ b/frontend-modern/src/components/AI/Chat/__tests__/recentSessionsModel.test.ts@@ -0,0 +1,47 @@+import { describe, expect, it } from 'vitest';+import type { ChatSession } from '@/api/aiChat';+import {+ QUICK_RESUME_SESSION_LIMIT,+ selectQuickResumeSessions,+} from '../recentSessionsModel';++const session = (overrides: Partial<ChatSession> & { id: string }): ChatSession => ({+ title: overrides.id,+ created_at: '2026-07-11T06:00:00Z',+ updated_at: '2026-07-11T06:00:00Z',+ message_count: 5,+ ...overrides,+});++describe('selectQuickResumeSessions', () => {+ it('excludes Pulse-owned background sessions from the quick-resume list', () => {+ const sessions = [+ session({ id: 'patrol-main', title: '# Deterministic Triage Results Scanned 70', system: true, message_count: 200 }),+ session({ id: 'user-chat-1' }),+ ];++ const result = selectQuickResumeSessions(sessions, null);++ expect(result.map((s) => s.id)).toEqual(['user-chat-1']);+ });++ it('excludes the active session and empty sessions', () => {+ const sessions = [+ session({ id: 'active-chat' }),+ session({ id: 'empty-chat', message_count: 0 }),+ session({ id: 'resumable-chat' }),+ ];++ const result = selectQuickResumeSessions(sessions, 'active-chat');++ expect(result.map((s) => s.id)).toEqual(['resumable-chat']);+ });++ it('caps the list at the quick-resume limit', () => {+ const sessions = Array.from({ length: QUICK_RESUME_SESSION_LIMIT + 2 }, (_, index) =>+ session({ id: `chat-${index}` }),+ );++ expect(selectQuickResumeSessions(sessions, null)).toHaveLength(QUICK_RESUME_SESSION_LIMIT);+ });+});diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex 6dbc6a1405..2286051261 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -165,6 +165,7 @@ import { ModelSelector } from './ModelSelector';import { MentionAutocomplete, type MentionResource } from './MentionAutocomplete';import { SlashCommandAutocomplete } from './SlashCommandAutocomplete';import { getAssistantActiveTurnStatus } from './activeTurnStatus';+import { selectQuickResumeSessions } from './recentSessionsModel';import {createPacedWorkflowStatus,replaceLatestWorkflowStatusEventForDisplay,@@ -4844,9 +4845,7 @@ export const AIChat: Component<AIChatProps> = (props) => {chat.cancelQueuedFollowUp(id);focusComposer();}}- recentSessions={sessions()- .filter((s) => s.id !== chat.sessionId() && s.message_count > 0)- .slice(0, 3)}+ recentSessions={selectQuickResumeSessions(sessions(), chat.sessionId())}onLoadSession={handleLoadSession}/>diff --git a/frontend-modern/src/components/AI/Chat/recentSessionsModel.ts b/frontend-modern/src/components/AI/Chat/recentSessionsModel.tsnew file mode 100644index 0000000000..77586a1361--- /dev/null+++ b/frontend-modern/src/components/AI/Chat/recentSessionsModel.ts@@ -0,0 +1,21 @@+import type { ChatSession } from '@/api/aiChat';++export const QUICK_RESUME_SESSION_LIMIT = 3;++/**+ * Sessions offered as resumable chats in the Assistant empty state.+ *+ * Pulse-owned background runs (Patrol detection/eval, investigations) arrive+ * with `system: true`; they are forensic logs, not conversations, so the+ * quick-resume list offers user chats only. The full session picker and the+ * Settings sessions panel still list system sessions for inspection.+ */+export const selectQuickResumeSessions = (+ sessions: ChatSession[],+ activeSessionId: string | null,+): ChatSession[] =>+ sessions+ .filter(+ (session) => !session.system && session.id !== activeSessionId && session.message_count > 0,+ )+ .slice(0, QUICK_RESUME_SESSION_LIMIT);diff --git a/internal/ai/chat/session.go b/internal/ai/chat/session.goindex 1fb106832a..63c6f3f63d 100644--- a/internal/ai/chat/session.go+++ b/internal/ai/chat/session.go@@ -424,6 +424,7 @@ func sessionSummaryFromData(data sessionData) Session {UpdatedAt: data.UpdatedAt,MessageCount: len(data.Messages),CanRedo: len(data.TurnRedoStack) > 0,+ System: IsSystemSessionID(data.ID),HandoffSummary: modelContextHandoffSummary(data.ModelContext),}}@@ -449,6 +450,7 @@ func sessionSummaryFromListData(data sessionListData) Session {UpdatedAt: data.UpdatedAt,MessageCount: len(data.Messages),CanRedo: len(data.TurnRedoStack) > 0,+ System: IsSystemSessionID(data.ID),HandoffSummary: modelContextHandoffSummary(data.ModelContext),}}diff --git a/internal/ai/chat/session_test.go b/internal/ai/chat/session_test.goindex 7a63514335..4c0f7b609c 100644--- a/internal/ai/chat/session_test.go+++ b/internal/ai/chat/session_test.go@@ -662,3 +662,33 @@ func TestGenerateTitle(t *testing.T) {assert.Equal(t, tt.expected, generateTitle(tt.input))}}++func TestSessionListMarksSystemSessions(t *testing.T) {+ store, err := NewSessionStore(t.TempDir())+ require.NoError(t, err)++ _, err = store.EnsureSession("patrol-main")+ require.NoError(t, err)+ userSession, err := store.Create()+ require.NoError(t, err)++ sessions, err := store.List()+ require.NoError(t, err)+ require.Len(t, sessions, 2)++ byID := make(map[string]Session, len(sessions))+ for _, s := range sessions {+ byID[s.ID] = s+ }+ assert.True(t, byID["patrol-main"].System, "patrol-main must be marked system so clients keep it out of resumable chat lists")+ assert.False(t, byID[userSession.ID].System, "user sessions must not be marked system")+}++func TestIsSystemSessionID(t *testing.T) {+ assert.True(t, IsSystemSessionID("patrol-main"))+ assert.True(t, IsSystemSessionID("patrol-eval"))+ assert.True(t, IsSystemSessionID("investigation-abc123"))+ assert.False(t, IsSystemSessionID("patrol-adjacent-user-session"))+ assert.False(t, IsSystemSessionID(""))+ assert.False(t, IsSystemSessionID("my-chat"))+}diff --git a/internal/ai/chat/types.go b/internal/ai/chat/types.goindex f260d45ccf..c02e88c2ae 100644--- a/internal/ai/chat/types.go+++ b/internal/ai/chat/types.go@@ -20,9 +20,20 @@ type Session struct {UpdatedAt time.Time `json:"updated_at"`MessageCount int `json:"message_count,omitempty"`CanRedo bool `json:"can_redo,omitempty"`+ System bool `json:"system,omitempty"`HandoffSummary *SessionHandoffSummary `json:"handoff_summary,omitempty"`}+// IsSystemSessionID reports whether a session ID belongs to a Pulse-owned+// background run (Patrol detection, Patrol eval, or a Patrol investigation)+// rather than a user conversation. These sessions are forensic logs: they+// stay listable and inspectable, but clients should not offer them as+// resumable chats.+func IsSystemSessionID(id string) bool {+ id = strings.TrimSpace(id)+ return id == "patrol-main" || id == "patrol-eval" || strings.HasPrefix(id, "investigation-")+}+// SessionTurnUndoResult is returned when the chat runtime removes the latest// user turn and makes that prompt available for editing.type SessionTurnUndoResult struct {