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
Focus Assistant composer on chat entry
rcourtman86de23cc782f
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 5d1a3cc66e..9b020c6f0b 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -1206,6 +1206,11 @@ context, and browser session ID immediately, leave the model selection intact,and avoid adding empty conversations to the session list; the next submittedmessage materializes the durable session through the stream-owned cold-startcontract above.+The drawer must also stay composer-first: when Assistant opens, starts a blank+conversation, or loads an existing session, the textarea is registered with the+shared `aiChatStore` focus owner and focused without requiring an extra click.+Global shell shortcuts may use that store focus boundary, but drawer-local code+must not fork a second input-focus registry.The AI transport files are shared with `api-contracts`, not delegated away toit. `frontend-modern/src/api/ai.ts`,diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex 63c4e5a0e5..67e63c8e5b 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -129,6 +129,7 @@ const {const { findingId: _findingId, ...rest } = mockAiChatStore.context;mockAiChatStore.context = rest;}),+ registerInput: vi.fn(),clearRequestHandoffPayload: vi.fn(() => {const {handoffContext: _handoffContext,@@ -328,6 +329,16 @@ describe('AIChat', () => {expect(screen.getByPlaceholderText('Ask about your infrastructure...')).toBeInTheDocument();});+ it('registers and focuses the composer when opened', async () => {+ renderChat();+ const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');++ await waitFor(() => {+ expect(mockAiChatStore.registerInput).toHaveBeenCalledWith(textarea);+ expect(document.activeElement).toBe(textarea);+ });+ });+it('renders the ChatMessages child component', () => {renderChat();expect(screen.getByTestId('chat-messages')).toBeInTheDocument();@@ -797,6 +808,19 @@ describe('AIChat', () => {});});+ it('returns focus to the composer after starting a blank conversation', async () => {+ renderChat();+ const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');+ textarea.blur();++ fireEvent.click(screen.getByText('New'));++ await waitFor(() => {+ expect(mockChat.newSession).toHaveBeenCalledTimes(1);+ expect(document.activeElement).toBe(textarea);+ });+ });+it('keeps scoped handoff context when starting a new session fails', async () => {mockChat.newSession.mockResolvedValueOnce(null);mockAiChatStore.context = {@@ -891,6 +915,29 @@ describe('AIChat', () => {expect(mockChat.loadSession).toHaveBeenCalledWith('s1');});+ it('returns focus to the composer after loading a session', async () => {+ mockAIChatAPI.listSessions.mockResolvedValue([+ { id: 's1', title: 'Session One', created_at: '', updated_at: '', message_count: 5 },+ ]);+ renderChat();+ const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');++ await waitFor(() => {+ expect(mockAIChatAPI.listSessions).toHaveBeenCalled();+ });+ textarea.blur();+ fireEvent.click(screen.getByTitle('Pulse Assistant sessions'));+ await waitFor(() => {+ expect(screen.getByText('Session One')).toBeInTheDocument();+ });+ fireEvent.click(screen.getByText('Session One'));++ await waitFor(() => {+ expect(mockChat.loadSession).toHaveBeenCalledWith('s1');+ expect(document.activeElement).toBe(textarea);+ });+ });+it('restores safe Patrol handoff state from a loaded session summary', async () => {mockAIChatAPI.listSessions.mockResolvedValue([{diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex 3d5fa47f23..0e142df6c0 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -325,6 +325,12 @@ export const AIChat: Component<AIChatProps> = (props) => {const [accumulatedMentions, setAccumulatedMentions] = createSignal<MentionResource[]>([]);let textareaRef: HTMLTextAreaElement | undefined;+ const focusComposer = () => {+ queueMicrotask(() => {+ textareaRef?.focus();+ });+ };+const resizeTextarea = () => {if (!textareaRef) return;textareaRef.style.height = 'auto';@@ -627,6 +633,9 @@ export const AIChat: Component<AIChatProps> = (props) => {// Click outside handler to close all dropdownsonMount(() => {+ aiChatStore.registerInput?.(textareaRef ?? null);+ focusComposer();+const handleClickOutside = (e: MouseEvent) => {const target = e.target as HTMLElement;// Only close if click is outside dropdown containers@@ -640,7 +649,10 @@ export const AIChat: Component<AIChatProps> = (props) => {}};document.addEventListener('click', handleClickOutside);- onCleanup(() => document.removeEventListener('click', handleClickOutside));+ onCleanup(() => {+ document.removeEventListener('click', handleClickOutside);+ aiChatStore.registerInput?.(null);+ });});const mentionStatusRank = (status?: string) => {@@ -1061,6 +1073,7 @@ export const AIChat: Component<AIChatProps> = (props) => {if (!started) return;aiChatStore.clearContext?.();setShowSessions(false);+ focusComposer();};const handleToggleSessions = async () => {@@ -1101,6 +1114,7 @@ export const AIChat: Component<AIChatProps> = (props) => {aiChatStore.clearContext?.();}setShowSessions(false);+ focusComposer();};// Delete session