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
Refresh Assistant sessions before picker opens
rcourtman3a6282047480
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex c709832589..04bd92adbc 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -292,6 +292,9 @@ runtime cost control, and shared AI transport surfaces.an operator decision surface, so it must not leave stale pending/approvallabels in the drawer after the governed action moved on, and it must stillomit raw commands, preflight bodies, and execution output.+ The Assistant drawer must also fetch that current session list before+ opening the session picker instead of presenting mount-time cached+ summaries as the operator's decision surface.Proposed-fix command text must stay out of both the persisted chat messageand the model-only handoff context, and command payloads remainapproval-context data, not conversational copy.diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex 352e121561..3944e1f527 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -557,16 +557,39 @@ describe('AIChat', () => {});});- it('opens session picker on click', () => {+ it('opens session picker on click', async () => {renderChat();fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('New session')).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('New session')).toBeInTheDocument();+ });});- it('shows "No previous assistant sessions" when empty', () => {+ it('shows "No previous assistant sessions" when empty', async () => {renderChat();fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('No previous assistant sessions')).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('No previous assistant sessions')).toBeInTheDocument();+ });+ });++ it('refreshes sessions before opening the picker', async () => {+ mockAIChatAPI.listSessions+ .mockResolvedValueOnce([])+ .mockResolvedValueOnce([+ { id: 's-fresh', title: 'Fresh session', created_at: '', updated_at: '', message_count: 1 },+ ]);++ renderChat();+ await waitFor(() => {+ expect(mockAIChatAPI.listSessions).toHaveBeenCalledTimes(1);+ });+ fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));++ await waitFor(() => {+ expect(mockAIChatAPI.listSessions).toHaveBeenCalledTimes(2);+ expect(screen.getByText('Fresh session')).toBeInTheDocument();+ });});it('lists sessions in the dropdown', async () => {@@ -579,10 +602,12 @@ describe('AIChat', () => {expect(mockAIChatAPI.listSessions).toHaveBeenCalled();});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('Session One')).toBeInTheDocument();- expect(screen.getByText('Session Two')).toBeInTheDocument();- expect(screen.getByText('5 messages')).toBeInTheDocument();- expect(screen.getByText('3 messages')).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('Session One')).toBeInTheDocument();+ expect(screen.getByText('Session Two')).toBeInTheDocument();+ expect(screen.getByText('5 messages')).toBeInTheDocument();+ expect(screen.getByText('3 messages')).toBeInTheDocument();+ });});it('loads a session when clicked in the dropdown', async () => {@@ -594,6 +619,9 @@ describe('AIChat', () => {expect(mockAIChatAPI.listSessions).toHaveBeenCalled();});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));+ await waitFor(() => {+ expect(screen.getByText('Session One')).toBeInTheDocument();+ });fireEvent.click(screen.getByText('Session One'));expect(mockChat.loadSession).toHaveBeenCalledWith('s1');});@@ -632,9 +660,11 @@ describe('AIChat', () => {});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('Pulse Patrol')).toBeInTheDocument();- expect(screen.getByText('Approval required')).toBeInTheDocument();- expect(screen.getByText(/approval pending/)).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('Pulse Patrol')).toBeInTheDocument();+ expect(screen.getByText('Approval required')).toBeInTheDocument();+ expect(screen.getByText(/approval pending/)).toBeInTheDocument();+ });fireEvent.click(screen.getByText('High CPU follow-up'));@@ -696,8 +726,10 @@ describe('AIChat', () => {});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('Pulse Patrol')).toBeInTheDocument();- expect(screen.getByText('Context attached')).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('Pulse Patrol')).toBeInTheDocument();+ expect(screen.getByText('Context attached')).toBeInTheDocument();+ });fireEvent.click(screen.getByText('Context-only Patrol follow-up'));@@ -750,6 +782,9 @@ describe('AIChat', () => {expect(mockAIChatAPI.listSessions).toHaveBeenCalled();});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));+ await waitFor(() => {+ expect(screen.getByText('Session One')).toBeInTheDocument();+ });fireEvent.click(screen.getByText('Session One'));await waitFor(() => {@@ -1482,7 +1517,9 @@ describe('AIChat', () => {expect(mockAIChatAPI.listSessions).toHaveBeenCalled();});fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));- expect(screen.getByText('Session One')).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByText('Session One')).toBeInTheDocument();+ });// Find the delete button inside the session rowconst sessionRow = screen.getByText('Session One').closest('[class*="group"]')!;diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex ca03779528..7523d290f8 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -910,6 +910,32 @@ export const AIChat: Component<AIChatProps> = (props) => {setShowSessions(false);};+ const handleToggleSessions = async () => {+ const next = !showSessions();+ if (!next) {+ setShowSessions(false);+ return;+ }++ if (sessionButtonRef) {+ const rect = sessionButtonRef.getBoundingClientRect();+ setSessionDropdownPosition({+ top: rect.bottom + 4,+ right: window.innerWidth - rect.right,+ });+ }++ try {+ await refreshSessions();+ } catch (error) {+ logger.error('[AIChat] Failed to refresh sessions before opening picker:', error);+ notificationStore.error('Failed to refresh assistant sessions');+ return;+ }++ setShowSessions(true);+ };+// Load sessionconst handleLoadSession = async (sessionId: string) => {const session = sessions().find((candidate) => candidate.id === sessionId);@@ -1146,15 +1172,7 @@ export const AIChat: Component<AIChatProps> = (props) => {<buttonref={sessionButtonRef}onClick={() => {- const next = !showSessions();- if (next && sessionButtonRef) {- const rect = sessionButtonRef.getBoundingClientRect();- setSessionDropdownPosition({- top: rect.bottom + 4,- right: window.innerWidth - rect.right,- });- }- setShowSessions(next);+ void handleToggleSessions();}}class="p-2 hover:text-base-content rounded-md hover:bg-surface-hover transition-colors"title={AI_CHAT_SESSION_MENU_TITLE}