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
feat(chat): polish assistant UI and empty state
rcourtman34ca21d677ba
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsxindex e24cf340a2..6e4e9783d0 100644--- a/frontend-modern/src/App.tsx+++ b/frontend-modern/src/App.tsx@@ -923,16 +923,16 @@ function App() {aria-label="Expand Pulse Assistant"><svg- class="h-4 w-4 flex-shrink-0"+ class="h-5 w-5 flex-shrink-0"fill="none"stroke="currentColor"viewBox="0 0 24 24"- stroke-width="2"+ stroke-width="1.5"><pathstroke-linecap="round"stroke-linejoin="round"- d="M11 19l-7-7 7-7M18 19l-7-7 7-7"+ d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"/></svg></button>diff --git a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsxindex fc099e3a3c..d5484acc5e 100644--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx@@ -1,5 +1,6 @@import { Component, Show, For, createEffect, createMemo } from 'solid-js';import { MessageItem } from './MessageItem';+import type { ChatSession } from '@/api/aiChat';import type { ChatMessage, PendingApproval, PendingQuestion } from './types';interface ChatMessagesProps {@@ -8,9 +9,12 @@ interface ChatMessagesProps {onSkip: (messageId: string, toolId: string) => void;onAnswerQuestion: (messageId: string, question: PendingQuestion, answers: Array<{ id: string; value: string }>) => void;onSkipQuestion: (messageId: string, questionId: string) => void;+ // Dashboard props+ recentSessions?: ChatSession[];+ onLoadSession?: (sessionId: string) => void;emptyState?: {title: string;- subtitle: string;+ subtitle?: string;suggestions?: string[];onSuggestionClick?: (suggestion: string) => void;};@@ -67,11 +71,11 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {>{/* Empty state */}<Show when={props.messages.length === 0 && props.emptyState}>- <div class="flex flex-col items-center justify-center h-full text-center py-12">+ <div class="flex flex-col items-center justify-center min-h-full text-center py-8">{/* AI Icon */}- <div class="w-16 h-16 mb-4 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center shadow-sm">+ <div class="w-14 h-14 mb-3 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center shadow-sm"><svg- class="w-8 h-8 text-blue-500 dark:text-blue-400"+ class="w-7 h-7 text-blue-500 dark:text-blue-400"fill="none"stroke="currentColor"viewBox="0 0 24 24"@@ -80,7 +84,7 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {stroke-linecap="round"stroke-linejoin="round"stroke-width="1.5"- d="M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611l-2.576.43a18.003 18.003 0 01-5.118 0l-2.576-.43c-1.717-.293-2.299-2.379-1.067-3.611L5 14.5"+ d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"/></svg></div>@@ -88,27 +92,66 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {<h3 class="text-base font-semibold text-slate-900 dark:text-slate-100 mb-1">{props.emptyState!.title}</h3>- <p class="text-sm text-slate-500 dark:text-slate-400 max-w-xs mb-6">- {props.emptyState!.subtitle}- </p>-- {/* Suggestions */}- <Show when={props.emptyState!.suggestions && props.emptyState!.suggestions!.length > 0}>- <div class="space-y-2 w-full max-w-xs">- <For each={props.emptyState!.suggestions}>- {(suggestion) => (- <button- type="button"- onClick={() => props.emptyState!.onSuggestionClick?.(suggestion)}- class="w-full text-left px-4 py-2.5 rounded-xl bg-slate-50 dark:bg-slate-800 text-slate-700 dark:text-slate-300 text-sm hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors border border-slate-200 dark:border-slate-700 hover:border-blue-300 dark:hover:border-blue-700"- >- <span class="text-blue-500 dark:text-blue-400 mr-2">→</span>- {suggestion}- </button>- )}- </For>- </div>+ <Show when={props.emptyState!.subtitle}>+ <p class="text-sm text-slate-500 dark:text-slate-400 max-w-xs mb-6">+ {props.emptyState!.subtitle}+ </p></Show>++ <div class="w-full max-w-xs space-y-6">+ {/* Recent Sessions */}+ <Show when={props.recentSessions && props.recentSessions.length > 0}>+ <div class="space-y-2">+ <div class="text-xs font-medium text-slate-400 dark:text-slate-500 text-left uppercase tracking-wider pl-1">+ Resume conversation+ </div>+ <For each={props.recentSessions}>+ {(session) => (+ <button+ type="button"+ onClick={() => props.onLoadSession?.(session.id)}+ class="w-full text-left px-4 py-3 rounded-xl bg-white dark:bg-slate-800/50 hover:bg-blue-50 dark:hover:bg-blue-900/10 border border-slate-200 dark:border-slate-700 hover:border-blue-200 dark:hover:border-blue-800 transition-all group flex items-center gap-3"+ >+ <div class="p-1.5 rounded-lg bg-slate-100 dark:bg-slate-700 text-slate-500 group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors">+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />+ </svg>+ </div>+ <div class="flex-1 min-w-0">+ <div class="text-sm font-medium text-slate-700 dark:text-slate-200 truncate group-hover:text-blue-700 dark:group-hover:text-blue-300">+ {session.title || 'Untitled Conversation'}+ </div>+ <div class="text-[11px] text-slate-400 dark:text-slate-500 truncate">+ {new Date(session.updated_at).toLocaleDateString()} · {session.message_count} messages+ </div>+ </div>+ </button>+ )}+ </For>+ </div>+ </Show>++ {/* Suggestions */}+ <Show when={props.emptyState!.suggestions && props.emptyState!.suggestions!.length > 0}>+ <div class="space-y-2">+ <div class="text-xs font-medium text-slate-400 dark:text-slate-500 text-left uppercase tracking-wider pl-1">+ Or try asking+ </div>+ <For each={props.emptyState!.suggestions}>+ {(suggestion) => (+ <button+ type="button"+ onClick={() => props.emptyState!.onSuggestionClick?.(suggestion)}+ class="w-full text-left px-4 py-2.5 rounded-xl bg-slate-50 dark:bg-slate-800/30 text-slate-600 dark:text-slate-400 text-sm hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors border border-transparent hover:border-slate-200 dark:hover:border-slate-700"+ >+ <span class="text-blue-500 dark:text-blue-400 mr-2 opacity-50">→</span>+ {suggestion}+ </button>+ )}+ </For>+ </div>+ </Show>+ </div></div></Show>diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsxindex 1622c5cfde..c5dfa2d866 100644--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx@@ -110,135 +110,141 @@ export const MessageItem: Component<MessageItemProps> = (props) => {</div></Show>- {/* Assistant message - full width, terminal-like */}+ {/* Assistant message - card style */}<Show when={!isUser()}>- <div class="w-full">- {/* Assistant indicator */}- <div class="flex items-center gap-2 mb-2 text-xs text-slate-500 dark:text-slate-400">- <div class="w-5 h-5 rounded-md bg-blue-600 flex items-center justify-center">- <svg class="w-3 h-3 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082" />- </svg>+ <div class="w-full pl-2 pr-2">+ <div class="group relative bg-slate-50/80 dark:bg-slate-800/40 rounded-2xl border border-slate-200/60 dark:border-slate-700/60 p-5 shadow-sm transition-all hover:border-slate-300 dark:hover:border-slate-600">+ {/* Assistant indicator */}+ <div class="flex items-center gap-2.5 mb-3">+ <div class="w-6 h-6 rounded-lg bg-white dark:bg-slate-700 border border-slate-100 dark:border-slate-600 shadow-sm flex items-center justify-center shrink-0">+ <svg class="w-3.5 h-3.5 text-blue-600 dark:text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z" />+ </svg>+ </div>+ <div class="flex items-baseline gap-2">+ <span class="text-xs font-semibold text-slate-700 dark:text-slate-200">Assistant</span>+ <Show when={props.message.model && !props.message.isStreaming}>+ <span class="text-[10px] text-slate-400 dark:text-slate-500 font-mono">+ {props.message.model}+ </span>+ </Show>+ </div></div>- <span class="font-medium">Assistant</span>- <Show when={props.message.model && !props.message.isStreaming}>- <span class="text-[10px] text-slate-400 dark:text-slate-500">- · {props.message.model}- </span>- </Show>- </div>- {/* Main content area */}- <div class="pl-7">- {/* Stream events - chronological display */}- <Show when={hasStreamEvents()}>- <For each={groupedEvents()}>- {(evt) => (- <Switch>- {/* Thinking block - collapsed by default */}- <Match when={evt.type === 'thinking' && evt.thinking}>- <ThinkingBlock- content={evt.thinking || ''}- isStreaming={props.message.isStreaming}- />- </Match>-- {/* Pending tool - hidden, we only show completed tools */}- <Match when={evt.type === 'pending_tool' && evt.pendingTool}>- <></>- </Match>-- {/* Completed tool execution block */}- <Match when={evt.type === 'tool' && evt.tool}>- <ToolExecutionBlock tool={{- name: evt.tool?.name || 'unknown',- input: evt.tool?.input || '{}',- output: evt.tool?.output || '',- success: evt.tool?.success ?? true,- }} />- </Match>-- {/* Content/text block */}- <Match when={evt.type === 'content' && evt.content}>- <div- class="text-sm prose prose-slate prose-sm dark:prose-invert max-w-none overflow-x-auto- prose-p:leading-relaxed prose-p:my-2- prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-pre:rounded-lg prose-pre:text-xs prose-pre:overflow-x-auto prose-pre:max-w-full- prose-code:text-blue-600 dark:prose-code:text-blue-400- prose-code:bg-blue-50 dark:prose-code:bg-blue-900/30- prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:break-all- prose-code:before:content-none prose-code:after:content-none- prose-headings:text-slate-900 dark:prose-headings:text-slate-100- prose-strong:text-slate-900 dark:prose-strong:text-slate-100- prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5"- // eslint-disable-next-line solid/no-innerhtml- innerHTML={renderMarkdown(evt.content || '')}- />- </Match>-- {/* Approval card - inline in stream */}- <Match when={evt.type === 'approval' && evt.approval}>- <div class="my-3">- <ApprovalCard- approval={evt.approval!}- onApprove={() => props.onApprove(evt.approval!)}- onSkip={() => props.onSkip(evt.approval!.toolId)}+ {/* Main content area */}+ <div class="pl-1">+ {/* Stream events - chronological display */}+ <Show when={hasStreamEvents()}>+ <For each={groupedEvents()}>+ {(evt) => (+ <Switch>+ {/* Thinking block */}+ <Match when={evt.type === 'thinking' && evt.thinking}>+ <ThinkingBlock+ content={evt.thinking || ''}+ isStreaming={props.message.isStreaming}/>- </div>- </Match>-- {/* Question card - inline in stream */}- <Match when={evt.type === 'question' && evt.question}>- <div class="my-3">- <QuestionCard- question={evt.question!}- onAnswer={(answers) => props.onAnswerQuestion(evt.question!, answers)}- onSkip={() => props.onSkipQuestion(evt.question!.questionId)}+ </Match>++ <Match when={evt.type === 'pending_tool' && evt.pendingTool}>+ <></>+ </Match>++ <Match when={evt.type === 'tool' && evt.tool}>+ <ToolExecutionBlock tool={{+ name: evt.tool?.name || 'unknown',+ input: evt.tool?.input || '{}',+ output: evt.tool?.output || '',+ success: evt.tool?.success ?? true,+ }} />+ </Match>++ {/* Content/text block */}+ <Match when={evt.type === 'content' && evt.content}>+ <div+ class="text-sm prose prose-slate prose-sm dark:prose-invert max-w-none+ prose-p:leading-relaxed prose-p:my-2+ prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-pre:rounded-xl prose-pre:text-xs prose-pre:border prose-pre:border-slate-800+ prose-code:text-blue-700 dark:prose-code:text-blue-300+ prose-code:bg-blue-50/50 dark:prose-code:bg-blue-900/20+ prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:font-mono prose-code:text-[0.9em] prose-code:border prose-code:border-blue-100 dark:prose-code:border-blue-800/30+ prose-code:before:content-none prose-code:after:content-none+ prose-headings:font-semibold prose-headings:tracking-tight+ prose-hr:border-slate-200 dark:prose-hr:border-slate-700+ prose-ul:my-2 prose-ol:my-2 prose-li:my-1"+ // eslint-disable-next-line solid/no-innerhtml+ innerHTML={renderMarkdown(evt.content || '')}/>- </div>- </Match>- </Switch>- )}- </For>- </Show>-- {/* Fallback: show content if no stream events */}- <Show when={props.message.content && !hasStreamEvents()}>- <div- class="text-sm prose prose-slate prose-sm dark:prose-invert max-w-none overflow-x-auto- prose-p:leading-relaxed prose-p:my-2- prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-pre:rounded-lg prose-pre:text-xs prose-pre:overflow-x-auto prose-pre:max-w-full- prose-code:text-blue-600 dark:prose-code:text-blue-400- prose-code:bg-blue-50 dark:prose-code:bg-blue-900/30- prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:break-all- prose-code:before:content-none prose-code:after:content-none- prose-headings:text-slate-900 dark:prose-headings:text-slate-100- prose-strong:text-slate-900 dark:prose-strong:text-slate-100- prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5"- // eslint-disable-next-line solid/no-innerhtml- innerHTML={renderMarkdown(props.message.content)}- />- </Show>-- {/* Streaming text indicator */}- <Show when={isStreamingText()}>- <span class="inline-block w-2 h-4 ml-0.5 bg-blue-500 dark:bg-blue-400 animate-pulse rounded-sm" />- </Show>-- <Show when={!props.message.isStreaming && contextTools().length > 0}>- <div class="mt-3 text-[10px] text-slate-400 dark:text-slate-500">- Context used: {contextTools().map((name) => formatToolName(name)).join(', ')}- </div>- </Show>-- {/* Token count footer */}- <Show when={props.message.tokens && !props.message.isStreaming}>- <div class="mt-3 pt-2 border-t border-slate-100 dark:border-slate-800 text-[10px] text-slate-400 dark:text-slate-500">- {props.message.tokens!.input + props.message.tokens!.output} tokens- <span class="mx-1">·</span>- {props.message.tokens!.input} in / {props.message.tokens!.output} out- </div>- </Show>+ </Match>++ <Match when={evt.type === 'approval' && evt.approval}>+ <div class="my-4">+ <ApprovalCard+ approval={evt.approval!}+ onApprove={() => props.onApprove(evt.approval!)}+ onSkip={() => props.onSkip(evt.approval!.toolId)}+ />+ </div>+ </Match>++ <Match when={evt.type === 'question' && evt.question}>+ <div class="my-4">+ <QuestionCard+ question={evt.question!}+ onAnswer={(answers) => props.onAnswerQuestion(evt.question!, answers)}+ onSkip={() => props.onSkipQuestion(evt.question!.questionId)}+ />+ </div>+ </Match>+ </Switch>+ )}+ </For>+ </Show>++ {/* Fallback */}+ <Show when={props.message.content && !hasStreamEvents()}>+ <div+ class="text-sm prose prose-slate prose-sm dark:prose-invert max-w-none+ prose-p:leading-relaxed prose-p:my-2+ prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-pre:rounded-xl prose-pre:text-xs prose-pre:border prose-pre:border-slate-800+ prose-code:text-blue-700 dark:prose-code:text-blue-300+ prose-code:bg-blue-50/50 dark:prose-code:bg-blue-900/20+ prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:font-mono prose-code:text-[0.9em] prose-code:border prose-code:border-blue-100 dark:prose-code:border-blue-800/30+ prose-code:before:content-none prose-code:after:content-none+ prose-headings:font-semibold prose-headings:tracking-tight+ prose-hr:border-slate-200 dark:prose-hr:border-slate-700+ prose-ul:my-2 prose-ol:my-2 prose-li:my-1"+ // eslint-disable-next-line solid/no-innerhtml+ innerHTML={renderMarkdown(props.message.content)}+ />+ </Show>++ {/* Streaming cursor */}+ <Show when={isStreamingText()}>+ <span class="inline-block w-1.5 h-4 ml-0.5 align-middle bg-blue-500 dark:bg-blue-400 animate-pulse rounded-full" />+ </Show>++ <Show when={!props.message.isStreaming && contextTools().length > 0}>+ <div class="mt-4 pt-3 border-t border-slate-100 dark:border-slate-700/50 flex flex-wrap gap-2">+ <span class="text-[10px] uppercase font-semibold text-slate-400 dark:text-slate-500 tracking-wider">Context used</span>+ <div class="flex flex-wrap gap-1.5">+ {contextTools().map((name) => (+ <span class="px-1.5 py-0.5 rounded text-[10px] bg-slate-100 dark:bg-slate-700 text-slate-500 dark:text-slate-300 border border-slate-200 dark:border-slate-600 font-medium">+ {formatToolName(name)}+ </span>+ ))}+ </div>+ </div>+ </Show>++ <Show when={props.message.tokens && !props.message.isStreaming}>+ <div class="mt-1 flex justify-end">+ <span class="text-[9px] text-slate-300 dark:text-slate-600 font-mono">+ {props.message.tokens!.input} in · {props.message.tokens!.output} out+ </span>+ </div>+ </Show>+ </div></div></div></Show>diff --git a/frontend-modern/src/components/AI/Chat/ModelSelector.tsx b/frontend-modern/src/components/AI/Chat/ModelSelector.tsxindex 07da4e890b..414bae0858 100644--- a/frontend-modern/src/components/AI/Chat/ModelSelector.tsx+++ b/frontend-modern/src/components/AI/Chat/ModelSelector.tsx@@ -1,4 +1,4 @@-import { Component, For, Show, createSignal, createMemo } from 'solid-js';+import { Component, For, Show, createSignal, createMemo, onMount, onCleanup } from 'solid-js';import { PROVIDER_DISPLAY_NAMES, getProviderFromModelId, groupModelsByProvider } from '../aiChatUtils';import type { ModelInfo } from './types';@@ -110,6 +110,25 @@ export const ModelSelector: Component<ModelSelectorProps> = (props) => {return selected;});+ // Click outside handler+ onMount(() => {+ const handleClickOutside = (e: MouseEvent) => {+ if (isOpen() && buttonRef && !buttonRef.closest('[data-dropdown]')?.contains(e.target as Node)) {+ // Check if we are clicking inside the dropdown content itself (which isn't buttonRef)+ // The dropdown content is rendered in a portal or just absolutely positioned?+ // In this file, it's absolutely positioned as a sibling to the button, wrapped in the same parent div.+ // The parent div has [data-dropdown].+ // So checking if e.target is inside the closest [data-dropdown] works for both button and content.+ const dropdownContainer = buttonRef.closest('[data-dropdown]');+ if (dropdownContainer && !dropdownContainer.contains(e.target as Node)) {+ setIsOpen(false);+ }+ }+ };+ document.addEventListener('click', handleClickOutside);+ onCleanup(() => document.removeEventListener('click', handleClickOutside));+ });+return (<div class="relative" data-dropdown><buttondiff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex 64f4deae32..83e8618514 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -43,6 +43,7 @@ export const AIChat: Component<AIChatProps> = (props) => {const [controlSaving, setControlSaving] = createSignal(false);const [discoveryEnabled, setDiscoveryEnabled] = createSignal<boolean | null>(null); // null = loadingconst [discoveryHintDismissed, setDiscoveryHintDismissed] = createSignal(false);+ const [isCluster, setIsCluster] = createSignal(false);// @ mention autocomplete stateconst [mentionActive, setMentionActive] = createSignal(false);@@ -328,6 +329,7 @@ export const AIChat: Component<AIChatProps> = (props) => {onMount(async () => {try {const state = await MonitoringAPI.getState();+ setIsCluster((state.nodes?.length || 0) > 1);const resources: MentionResource[] = [];// Add VMs@@ -588,16 +590,30 @@ export const AIChat: Component<AIChatProps> = (props) => {return (<div- class={`flex-shrink-0 h-full bg-white dark:bg-slate-900 border-l border-slate-200 dark:border-slate-700 flex flex-col transition-all duration-300 ${isOpen() ? 'w-full sm:w-[480px]' : 'w-0 border-l-0 overflow-hidden'+ class={`relative flex-shrink-0 h-full bg-white dark:bg-slate-900 border-l border-slate-200 dark:border-slate-700 flex flex-col transition-all duration-300 ${isOpen() ? 'w-full sm:w-[480px] overflow-visible' : 'w-0 border-l-0 overflow-hidden'}`}><Show when={isOpen()}>+ {/* Floating Close Handle (Desktop only) */}+ <button+ onClick={props.onClose}+ class="hidden sm:flex absolute left-0 top-1/2 -translate-x-full -translate-y-1/2 items-center justify-center w-8 py-3 rounded-l-xl bg-white dark:bg-slate-800 text-blue-600 dark:text-blue-400 shadow-md border border-r-0 border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-700 transition-colors z-50 cursor-pointer"+ title="Collapse Pulse Assistant"+ >+ <svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"+ />+ </svg>+ </button>{/* Header - wraps on mobile */}<div class="flex flex-wrap items-center justify-between gap-2 px-4 py-3 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50"><div class="flex items-center gap-3"><div class="p-2 bg-blue-600 rounded-xl shadow-sm"><svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611l-2.576.43a18.003 18.003 0 01-5.118 0l-2.576-.43c-1.717-.293-2.299-2.379-1.067-3.611L5 14.5" />+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z" /></svg></div><div>@@ -755,7 +771,7 @@ export const AIChat: Component<AIChatProps> = (props) => {</Show></div>- {/* Close button */}+ {/* Close button (Always visible as fallback) */}<buttononClick={(e) => {e.stopPropagation();@@ -765,7 +781,7 @@ export const AIChat: Component<AIChatProps> = (props) => {title="Close panel"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 5l7 7-7 7M6 5l7 7-7 7" />+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button></div>@@ -818,13 +834,20 @@ export const AIChat: Component<AIChatProps> = (props) => {onSkip={handleSkip}onAnswerQuestion={handleAnswerQuestion}onSkipQuestion={handleSkipQuestion}+ recentSessions={sessions()+ .filter(s => s.id !== chat.sessionId() && s.message_count > 0)+ .slice(0, 3)}+ onLoadSession={handleLoadSession}emptyState={{- title: 'Start a conversation',- subtitle: 'Ask about your infrastructure, diagnose issues, or get help.',- suggestions: [- 'What VMs are running?',- 'Show me resource usage',- 'Any issues to investigate?',+ title: 'Pulse Assistant ready',+ suggestions: isCluster() ? [+ 'Analyze overall cluster health',+ 'Check node load balancing',+ 'Find and fix failed services',+ ] : [+ 'Analyze system health',+ 'Check storage usage',+ 'Scan for security vulnerabilities',],onSuggestionClick: (s) => setInput(s),}}@@ -879,7 +902,7 @@ export const AIChat: Component<AIChatProps> = (props) => {value={input()}onInput={handleInputChange}onKeyDown={handleKeyDown}- placeholder="Ask about your infrastructure... (type @ to mention a resource)"+ placeholder="Ask about your infrastructure..."rows={2}class="w-full px-4 py-3 text-sm rounded-xl border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-900 dark:text-slate-100 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"/>@@ -895,6 +918,25 @@ export const AIChat: Component<AIChatProps> = (props) => {</div></div><div class="flex gap-1.5 self-end">+ <button+ type="button"+ onClick={() => {+ setInput(s => s + (s && !s.endsWith(' ') ? ' @' : '@'));+ textareaRef?.focus();+ // Trigger manual autocomplete activation logic if needed,+ // but input change handler should catch the '@' insertion+ // We simulate an input event to trigger the autocomplete logic:+ setTimeout(() => {+ const event = new Event('input', { bubbles: true });+ textareaRef?.dispatchEvent(event);+ }, 0);+ }}+ class="hidden sm:flex items-center justify-center w-10 h-10 rounded-xl border border-slate-200 dark:border-slate-700 hover:border-blue-400 dark:hover:border-blue-500 text-slate-500 hover:text-blue-600 dark:text-slate-400 dark:hover:text-blue-400 bg-slate-50 dark:bg-slate-800 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-all font-mono font-medium text-lg"+ title="Mention a resource (VM, Node, Docker...)"+ >+ @+ </button>+<Showwhen={!chat.isLoading()}fallback={@@ -923,11 +965,13 @@ export const AIChat: Component<AIChatProps> = (props) => {</Show></div></form>- <p class="text-[10px] text-slate-400 dark:text-slate-500 mt-2 text-center">- {chat.isLoading()- ? 'Generating... click Stop to interrupt'- : 'Press Enter to send · Shift+Enter for new line · Type @ to mention a resource'}- </p>+ <div class="flex items-center justify-center gap-4 mt-2 text-[10px] text-slate-400 dark:text-slate-500">+ <span>Press <kbd class="font-sans px-1 rounded bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700">Enter</kbd> to send</span>+ <span class="flex items-center gap-1.5">+ <span class="w-1 h-1 rounded-full bg-slate-300 dark:bg-slate-600"></span>+ <span>Type <span class="font-bold text-blue-600 dark:text-blue-400">@</span> to mention resources</span>+ </span>+ </div></div></Show></div>