SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(ai-assistant): polish composer UX and add Cmd+K entry (#11362)
Vishal Sharma727bb586b0b8
diff --git a/frontend/public/locales/en-GB/titles.json b/frontend/public/locales/en-GB/titles.jsonindex 35cc6dc0b5..ee8581ef13 100644--- a/frontend/public/locales/en-GB/titles.json+++ b/frontend/public/locales/en-GB/titles.json@@ -54,5 +54,12 @@"ROLES_SETTINGS": "SigNoz | Roles","MEMBERS_SETTINGS": "SigNoz | Members","SERVICE_ACCOUNTS_SETTINGS": "SigNoz | Service Accounts",- "MCP_SERVER": "SigNoz | MCP Server"+ "MCP_SERVER": "SigNoz | MCP Server",+ "AI_ASSISTANT": "SigNoz | AI Assistant",+ "TRACE_DETAIL_OLD": "SigNoz | Trace Detail",+ "SERVICE_TOP_LEVEL_OPERATIONS": "SigNoz | Service Operations",+ "ROLE_DETAILS": "SigNoz | Role Details",+ "TRACES_FUNNELS_DETAIL": "SigNoz | Funnel",+ "INTEGRATIONS_DETAIL": "SigNoz | Integration",+ "PUBLIC_DASHBOARD": "SigNoz | Dashboard"}diff --git a/frontend/public/locales/en/titles.json b/frontend/public/locales/en/titles.jsonindex 4e3d63010a..311b3742e0 100644--- a/frontend/public/locales/en/titles.json+++ b/frontend/public/locales/en/titles.json@@ -77,5 +77,12 @@"ROLES_SETTINGS": "SigNoz | Roles","MEMBERS_SETTINGS": "SigNoz | Members","SERVICE_ACCOUNTS_SETTINGS": "SigNoz | Service Accounts",- "MCP_SERVER": "SigNoz | MCP Server"+ "MCP_SERVER": "SigNoz | MCP Server",+ "AI_ASSISTANT": "SigNoz | AI Assistant",+ "TRACE_DETAIL_OLD": "SigNoz | Trace Detail",+ "SERVICE_TOP_LEVEL_OPERATIONS": "SigNoz | Service Operations",+ "ROLE_DETAILS": "SigNoz | Role Details",+ "TRACES_FUNNELS_DETAIL": "SigNoz | Funnel",+ "INTEGRATIONS_DETAIL": "SigNoz | Integration",+ "PUBLIC_DASHBOARD": "SigNoz | Dashboard"}diff --git a/frontend/src/components/cmdKPalette/cmdKPalette.tsx b/frontend/src/components/cmdKPalette/cmdKPalette.tsxindex 240d9db6e5..d2595e663a 100644--- a/frontend/src/components/cmdKPalette/cmdKPalette.tsx+++ b/frontend/src/components/cmdKPalette/cmdKPalette.tsx@@ -1,4 +1,5 @@import React, { useEffect } from 'react';+import { useLocation } from 'react-router-dom';import {CommandDialog,CommandEmpty,@@ -9,7 +10,17 @@ import {CommandShortcut,} from '@signozhq/ui/command';import logEvent from 'api/common/logEvent';+import {+ AIAssistantEvents,+ AIAssistantOpenSource,+} from 'container/AIAssistant/events';+import { normalizePage } from 'container/AIAssistant/hooks/useAIAssistantAnalyticsContext';+import {+ openAIAssistantModal,+ useAIAssistantStore,+} from 'container/AIAssistant/store/useAIAssistantStore';import { useThemeMode } from 'hooks/useDarkMode';+import { useIsAIAssistantEnabled } from 'hooks/useIsAIAssistantEnabled';import history from 'lib/history';import { ROLES as UserRole } from 'types/roles';@@ -37,6 +48,11 @@ export function CmdKPalette({const { open, setOpen } = useCmdK();const { setAutoSwitch, setTheme, theme } = useThemeMode();+ const location = useLocation();+ const isAIAssistantEnabled = useIsAIAssistantEnabled();+ const startNewConversation = useAIAssistantStore(+ (s) => s.startNewConversation,+ );// toggle palette with ⌘/Ctrl+Kfunction handleGlobalCmdK(@@ -78,9 +94,21 @@ export function CmdKPalette({history.push(key);}+ const handleOpenAIAssistant = (): void => {+ void logEvent(AIAssistantEvents.Opened, {+ source: AIAssistantOpenSource.Cmdk,+ currentPage: normalizePage(location.pathname),+ });+ startNewConversation();+ openAIAssistantModal();+ };+const actions = createShortcutActions({navigate: onClickHandler,handleThemeChange,+ aiAssistant: isAIAssistantEnabled+ ? { open: handleOpenAIAssistant }+ : undefined,});// RBAC filter: show action if no roles set OR current user role is includeddiff --git a/frontend/src/constants/shortcutActions.tsx b/frontend/src/constants/shortcutActions.tsxindex 96b3e8f32e..1cc1594ef8 100644--- a/frontend/src/constants/shortcutActions.tsx+++ b/frontend/src/constants/shortcutActions.tsx@@ -15,6 +15,7 @@ import {ListMinus,ScrollText,Settings,+ Sparkles,TowerControl,Workflow,} from '@signozhq/icons';@@ -34,12 +35,20 @@ export type CmdAction = {type ActionDeps = {navigate: (path: string) => void;handleThemeChange: (mode: string) => void;+ /**+ * Provided only when the AI Assistant feature is available for the current+ * tenant. When present, the palette surfaces an "Open AI Assistant" entry+ * at the top; when absent, the action is omitted entirely.+ */+ aiAssistant?: {+ open: () => void;+ };};export function createShortcutActions(deps: ActionDeps): CmdAction[] {- const { navigate, handleThemeChange } = deps;+ const { navigate, handleThemeChange, aiAssistant } = deps;- return [+ const actions: CmdAction[] = [{id: 'home',name: 'Go to Home',@@ -279,4 +288,19 @@ export function createShortcutActions(deps: ActionDeps): CmdAction[] {perform: (): void => navigate(ROUTES.MEMBERS_SETTINGS),},];++ if (aiAssistant) {+ actions.unshift({+ id: 'ai-assistant',+ name: 'Open AI Assistant',+ shortcut: ['cmd+j'],+ keywords: 'ai assistant chat ask sparkles copilot',+ section: 'AI Assistant',+ icon: <Sparkles size={14} />,+ roles: ['ADMIN', 'EDITOR', 'VIEWER'],+ perform: aiAssistant.open,+ });+ }++ return actions;}diff --git a/frontend/src/container/AIAssistant/AIAssistantModal/AIAssistantModal.tsx b/frontend/src/container/AIAssistant/AIAssistantModal/AIAssistantModal.tsxindex 6f90887849..a93446d73e 100644--- a/frontend/src/container/AIAssistant/AIAssistantModal/AIAssistantModal.tsx+++ b/frontend/src/container/AIAssistant/AIAssistantModal/AIAssistantModal.tsx@@ -10,7 +10,7 @@ import logEvent from 'api/common/logEvent';import HistorySidebar from '../components/ConversationsList';import ConversationView from '../ConversationView';-import { AIAssistantEvents } from '../events';+import { AIAssistantEvents, AIAssistantOpenSource } from '../events';import {normalizePage,useAIAssistantAnalyticsContext,@@ -65,7 +65,7 @@ export default function AIAssistantModal(): JSX.Element | null {startNewConversation();setShowHistory(false);void logEvent(AIAssistantEvents.Opened, {- source: 'shortcut',+ source: AIAssistantOpenSource.Shortcut,currentPage: normalizePage(pathname),});openModal();@@ -162,57 +162,57 @@ export default function AIAssistantModal(): JSX.Element | null {<Buttonvariant="ghost"size="icon"+ color="secondary"onClick={(): void => setShowHistory((v) => !v)}aria-label="Toggle conversations"className={showHistory ? styles.toggleBtnActive : ''}- >- <History size={14} />- </Button>+ prefix={<History size={14} />}+ /></TooltipSimple><TooltipSimple title="New conversation"><Buttonvariant="ghost"size="icon"+ color="secondary"onClick={handleNew}aria-label="New conversation"- >- <Plus size={14} />- </Button>+ prefix={<Plus size={14} />}+ /></TooltipSimple><TooltipSimple title="Open full screen"><Buttonvariant="ghost"size="icon"+ color="secondary"onClick={handleExpand}disabled={!activeConversationId}aria-label="Open full screen"- >- <Maximize2 size={14} />- </Button>+ prefix={<Maximize2 size={14} />}+ /></TooltipSimple><TooltipSimple title="Minimize to side panel"><Buttonvariant="ghost"size="icon"+ color="secondary"onClick={handleMinimize}aria-label="Minimize to side panel"- >- <Minus size={14} />- </Button>+ prefix={<Minus size={14} />}+ /></TooltipSimple><TooltipSimple title="Close"><Buttonvariant="ghost"size="icon"+ color="secondary"onClick={closeModal}aria-label="Close"- >- <X size={14} />- </Button>+ prefix={<X size={14} />}+ /></TooltipSimple></div></div>diff --git a/frontend/src/container/AIAssistant/AIAssistantPanel/AIAssistantPanel.tsx b/frontend/src/container/AIAssistant/AIAssistantPanel/AIAssistantPanel.tsxindex f9ab9ae838..3976102191 100644--- a/frontend/src/container/AIAssistant/AIAssistantPanel/AIAssistantPanel.tsx+++ b/frontend/src/container/AIAssistant/AIAssistantPanel/AIAssistantPanel.tsx@@ -150,9 +150,8 @@ export default function AIAssistantPanel(): JSX.Element | null {color="secondary"onClick={(): void => setShowHistory((v) => !v)}aria-label="Toggle conversations"- >- <History size={14} />- </Button>+ prefix={<History size={14} />}+ /></TooltipSimple><TooltipSimple title="New conversation">@@ -162,9 +161,8 @@ export default function AIAssistantPanel(): JSX.Element | null {color="secondary"onClick={handleNew}aria-label="New conversation"- >- <Plus size={14} />- </Button>+ prefix={<Plus size={14} />}+ /></TooltipSimple><TooltipSimple title="Open full screen">@@ -175,9 +173,8 @@ export default function AIAssistantPanel(): JSX.Element | null {onClick={handleExpand}disabled={!activeConversationId}aria-label="Open full screen"- >- <Maximize2 size={14} />- </Button>+ prefix={<Maximize2 size={14} />}+ /></TooltipSimple><TooltipSimple title="Close">@@ -187,9 +184,8 @@ export default function AIAssistantPanel(): JSX.Element | null {color="secondary"onClick={closeDrawer}aria-label="Close panel"- >- <X size={14} />- </Button>+ prefix={<X size={14} />}+ /></TooltipSimple></div></div>diff --git a/frontend/src/container/AIAssistant/AIAssistantTrigger/AIAssistantTrigger.tsx b/frontend/src/container/AIAssistant/AIAssistantTrigger/AIAssistantTrigger.tsxindex b647f0a5bc..73b000c389 100644--- a/frontend/src/container/AIAssistant/AIAssistantTrigger/AIAssistantTrigger.tsx+++ b/frontend/src/container/AIAssistant/AIAssistantTrigger/AIAssistantTrigger.tsx@@ -6,7 +6,7 @@ import logEvent from 'api/common/logEvent';import ROUTES from 'constants/routes';import { Bot } from '@signozhq/icons';-import { AIAssistantEvents } from '../events';+import { AIAssistantEvents, AIAssistantOpenSource } from '../events';import { normalizePage } from '../hooks/useAIAssistantAnalyticsContext';import {openAIAssistant,@@ -31,7 +31,7 @@ export default function AIAssistantTrigger(): JSX.Element | null {const handleOpen = useCallback((): void => {void logEvent(AIAssistantEvents.Opened, {- source: 'icon',+ source: AIAssistantOpenSource.Icon,currentPage: normalizePage(pathname),});openAIAssistant();diff --git a/frontend/src/container/AIAssistant/ConversationView/ConversationView.tsx b/frontend/src/container/AIAssistant/ConversationView/ConversationView.tsxindex 0518bd6247..d133558751 100644--- a/frontend/src/container/AIAssistant/ConversationView/ConversationView.tsx+++ b/frontend/src/container/AIAssistant/ConversationView/ConversationView.tsx@@ -159,6 +159,7 @@ export default function ConversationView({<ConversationSkeleton /><div className={inputWrapperClass}><ChatInput+ key={conversationId}onSend={handleSend}disabledautoContexts={autoContexts}@@ -172,6 +173,7 @@ export default function ConversationView({return (<div className={styles.conversation}><VirtualizedMessages+ key={conversationId}conversationId={conversationId}messages={messages}isStreaming={isStreamingHere}@@ -184,6 +186,7 @@ export default function ConversationView({)}<div className={inputWrapperClass}><ChatInput+ key={conversationId}onSend={handleSend}onCancel={handleCancel}disabled={inputDisabled}diff --git a/frontend/src/container/AIAssistant/components/ApprovalCard/ApprovalCard.tsx b/frontend/src/container/AIAssistant/components/ApprovalCard/ApprovalCard.tsxindex 6465c2d0bc..e922508e68 100644--- a/frontend/src/container/AIAssistant/components/ApprovalCard/ApprovalCard.tsx+++ b/frontend/src/container/AIAssistant/components/ApprovalCard/ApprovalCard.tsx@@ -11,6 +11,7 @@ import {DialogTitle,} from '@signozhq/ui/dialog';import { ToggleGroup, ToggleGroupItem } from '@signozhq/ui/toggle-group';+import { TooltipSimple } from '@signozhq/ui/tooltip';import type {ApprovalEventDTO,ApprovalEventDTODiff,@@ -100,16 +101,16 @@ export default function ApprovalCard({<div className={styles.diffSection}><div className={styles.diffHeader}><span className={styles.diffHeaderLabel}>Diff</span>- <Button- variant="link"- size="sm"- color="secondary"- onClick={(): void => setDiffExpanded(true)}- title="Expand diff"- aria-label="Expand diff"- >- <Maximize2 size={12} />- </Button>+ <TooltipSimple title="Expand diff">+ <Button+ variant="link"+ size="sm"+ color="secondary"+ onClick={(): void => setDiffExpanded(true)}+ aria-label="Expand diff"+ prefix={<Maximize2 size={12} />}+ />+ </TooltipSimple></div><DiffView diff={approval.diff} /></div>@@ -119,6 +120,8 @@ export default function ApprovalCard({<DialogContentclassName={styles.diffDialog}style={{ width: '80vw', maxWidth: '80vw', height: '70vh' }}+ // Skip auto-focus — otherwise the first Copy button opens its tooltip on dialog open.+ onOpenAutoFocus={(e): void => e.preventDefault()}><DialogHeader><DialogTitle>Approval diff</DialogTitle>@@ -134,19 +137,22 @@ export default function ApprovalCard({size="sm"value={viewMode}onChange={(next): void => {- // Radix `single` group can emit '' when the active item- // is clicked again — preserve the current mode.+ // Radix `single` group can emit '' when the active item is clicked again.if (next === 'split' || next === 'unified') {setViewMode(next);}}}>- <ToggleGroupItem value="split" aria-label="Split view">- <Columns2 size={12} />- </ToggleGroupItem>- <ToggleGroupItem value="unified" aria-label="Unified view">- <List size={12} />- </ToggleGroupItem>+ <TooltipSimple title="Split view">+ <ToggleGroupItem value="split" aria-label="Split view">+ <Columns2 size={12} />+ </ToggleGroupItem>+ </TooltipSimple>+ <TooltipSimple title="Unified view">+ <ToggleGroupItem value="unified" aria-label="Unified view">+ <List size={12} />+ </ToggleGroupItem>+ </TooltipSimple></ToggleGroup><ToggleGrouptype="multiple"@@ -154,12 +160,16 @@ export default function ApprovalCard({value={wrapText ? ['wrap'] : []}onChange={(next): void => setWrapText(next.includes('wrap'))}>- <ToggleGroupItem- value="wrap"- aria-label={wrapText ? 'Disable text wrap' : 'Wrap long lines'}+ <TooltipSimple+ title={wrapText ? 'Disable text wrap' : 'Wrap long lines'}>- <WrapText size={12} />- </ToggleGroupItem>+ <ToggleGroupItem+ value="wrap"+ aria-label={wrapText ? 'Disable text wrap' : 'Wrap long lines'}+ >+ <WrapText size={12} />+ </ToggleGroupItem>+ </TooltipSimple></ToggleGroup></div>{approval.diff && (@@ -457,15 +467,16 @@ function CopyButton({ text, label }: CopyButtonProps): JSX.Element {};return (- <Button- variant="ghost"- size="sm"- color="secondary"- onClick={handleCopy}- title={copied ? `Copied ${label}` : `Copy ${label}`}- aria-label={copied ? `Copied ${label}` : `Copy ${label}`}- >- {copied ? <Check size={12} /> : <Copy size={12} />}- </Button>+ <TooltipSimple title={copied ? `Copied ${label}` : `Copy ${label}`}>+ <Button+ variant="ghost"+ size="sm"+ color="secondary"+ onClick={handleCopy}+ aria-label={copied ? `Copied ${label}` : `Copy ${label}`}+ >+ {copied ? <Check size={12} /> : <Copy size={12} />}+ </Button>+ </TooltipSimple>);}diff --git a/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.module.scss b/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.module.scssindex eb15699000..d12605b349 100644--- a/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.module.scss+++ b/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.module.scss@@ -8,12 +8,7 @@border-radius: var(--radius-2);padding: 8px;border: 1px solid var(--l1-border);- transition: border-color 0.15s;position: relative;-- &:focus-within {- border-color: var(--l1-border);- }}.attachments {@@ -129,6 +124,18 @@border: 1px solid var(--l2-border);border-radius: var(--radius-2);padding: 4px;+ transition:+ border-color 0.15s,+ box-shadow 0.15s;++ // Scope the focus ring to the textarea row only — the surrounding+ // chrome (context chips, "Add Context", mic, send) sits outside this+ // element and stays unaffected when the cursor enters the textarea.+ &:focus-within {+ border-color: var(--accent-primary);+ box-shadow: 0 0 0 1px+ color-mix(in srgb, var(--accent-primary), transparent 70%);+ }}.footer {@@ -244,16 +251,24 @@}.contextPopoverCategoryItem {+ // Override DS Button's centered layout.+ --button-justify-content: flex-start;display: flex;align-items: center;+ justify-content: flex-start;gap: 8px;+ width: 100%;height: 32px;padding: 0 8px;- border: 1px solid color-mix(in srgb, var(--l1-foreground), transparent 96%);- border-radius: var(--radius-2);+ background: transparent;+ color: inherit;+ font: inherit;font-size: 12px;font-weight: 550;text-align: left;+ border: 1px solid color-mix(in srgb, var(--l1-foreground), transparent 96%);+ border-radius: var(--radius-2);+ appearance: none;cursor: pointer;transition:background 0.15s ease,@@ -309,17 +324,24 @@}.contextPopoverEntityItem {+ // Override DS Button's centered layout.+ --button-justify-content: flex-start;display: flex;align-items: center;+ justify-content: flex-start;gap: 10px;+ width: 100%;padding: 8px;- border: 1px solid color-mix(in srgb, var(--l1-foreground), transparent 96%);- border-radius: var(--radius-2);+ background: transparent;color: var(--l1-foreground);+ font: inherit;font-size: 12px;font-weight: 500;line-height: 1.35;text-align: left;+ border: 1px solid color-mix(in srgb, var(--l1-foreground), transparent 96%);+ border-radius: var(--radius-2);+ appearance: none;cursor: pointer;// Required for the inner span's `text-overflow: ellipsis` to engage —// flex items default to `min-width: auto` (intrinsic width) and would@@ -385,6 +407,11 @@border-radius: 50%;border: none;cursor: pointer;+ // Reset native <button> defaults so the 24px circle isn't inflated by+ // browser-default padding / font metrics.+ padding: 0;+ font: inherit;+ appearance: none;}.micDiscard {diff --git a/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.tsx b/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.tsxindex ec53d11651..f207b1dd9d 100644--- a/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.tsx+++ b/frontend/src/container/AIAssistant/components/ChatInput/ChatInput.tsx@@ -1,4 +1,10 @@-import { useCallback, useEffect, useRef, useState } from 'react';+import {+ useCallback,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+} from 'react';import { useQueryClient } from 'react-query';import cx from 'classnames';import { Badge } from '@signozhq/ui/badge';@@ -26,7 +32,11 @@ import { useSelector } from 'react-redux';import { AppState } from 'store/reducers';import { GlobalReducer } from 'types/reducer/globalTime';-import { AIAssistantEvents, getBrowserInfo } from '../../events';+import {+ AIAssistantEvents,+ VoiceInputSource,+ getBrowserInfo,+} from '../../events';import { useAIAssistantAnalyticsContext } from '../../hooks/useAIAssistantAnalyticsContext';import { useSpeechRecognition } from '../../hooks/useSpeechRecognition';import { MessageAttachment } from '../../types';@@ -142,6 +152,10 @@ function autoContextCategory(ctx: MessageContext): string {const MAX_INPUT_LENGTH = 20000;const WARNING_THRESHOLD = 15000;+// Cap for the auto-growing composer. Past this, the textarea stops growing+// and starts scrolling internally so the message list above doesn't get+// squeezed in tighter container variants (e.g. the floating panel).+const TEXTAREA_MAX_HEIGHT_PX = 200;const HOME_SERVICES_INTERVAL = 30 * 60 * 1000;/** sessionStorage key for the "voice input failed this tab" flag. */const VOICE_UNAVAILABLE_KEY = 'ai-assistant-voice-unavailable';@@ -224,6 +238,18 @@ export default function ChatInput({const [activeContextCategory, setActiveContextCategory] =useState<ContextCategory>('Dashboards');const [pickerSearchQuery, setPickerSearchQuery] = useState('');+ // Refs to each category tab so we can move DOM focus to the newly-active+ // tab on ArrowUp/ArrowDown. Without this the roving-tabindex pattern+ // stalls: focus stays on the original button (whose closure has the old+ // category), so subsequent arrow keys never advance past the second tab.+ const categoryTabRefs = useRef(+ new Map<ContextCategory, HTMLButtonElement | null>(),+ );+ // Refs to each entity row in the active tab panel, so we can cross from+ // the category tablist (ArrowRight) into the panel and step through+ // entities with ArrowUp/Down. Array is rewritten each render — there's+ // only ever one tab panel mounted so stale indices clear naturally.+ const entityRefs = useRef<(HTMLButtonElement | null)[]>([]);const queryClient = useQueryClient();// When the picker was opened by typing `@` in the textarea, this holds the@@ -303,11 +329,92 @@ export default function ChatInput({[mentionRange, selectedContexts, text],);+ const focusCategory = useCallback((category: ContextCategory) => {+ setActiveContextCategory(category);+ setPickerSearchQuery('');+ categoryTabRefs.current.get(category)?.focus();+ }, []);++ const handleCategoryKeyDown = useCallback(+ (+ e: React.KeyboardEvent<HTMLButtonElement>,+ category: ContextCategory,+ ): void => {+ const total = CONTEXT_CATEGORIES.length;+ const idx = CONTEXT_CATEGORIES.indexOf(category);+ if (e.key === 'ArrowDown') {+ e.preventDefault();+ focusCategory(CONTEXT_CATEGORIES[(idx + 1) % total]);+ } else if (e.key === 'ArrowUp') {+ e.preventDefault();+ focusCategory(CONTEXT_CATEGORIES[(idx - 1 + total) % total]);+ } else if (e.key === 'Home') {+ e.preventDefault();+ focusCategory(CONTEXT_CATEGORIES[0]);+ } else if (e.key === 'End') {+ e.preventDefault();+ focusCategory(CONTEXT_CATEGORIES[total - 1]);+ } else if (e.key === 'ArrowRight') {+ // Cross from tablist into entity panel.+ e.preventDefault();+ entityRefs.current[0]?.focus();+ }+ },+ [focusCategory],+ );++ const handleEntityKeyDown = useCallback(+ (e: React.KeyboardEvent<HTMLButtonElement>, index: number): void => {+ const count = entityRefs.current.length;+ if (count === 0) {+ return;+ }+ const focusAt = (i: number): void => {+ e.preventDefault();+ entityRefs.current[i]?.focus();+ };+ switch (e.key) {+ case 'ArrowDown':+ focusAt((index + 1) % count);+ break;+ case 'ArrowUp':+ focusAt((index - 1 + count) % count);+ break;+ case 'Home':+ focusAt(0);+ break;+ case 'End':+ focusAt(count - 1);+ break;+ case 'ArrowLeft':+ // Cross back to tablist.+ e.preventDefault();+ categoryTabRefs.current.get(activeContextCategory)?.focus();+ break;+ default:+ }+ },+ [activeContextCategory],+ );+// Focus the textarea when this component mounts (panel/modal open)useEffect(() => {textareaRef.current?.focus();}, []);+ // Auto-grow the textarea so long prompts aren't trapped in a 2-line+ // scrolling porthole. Reset to `auto` first to let the field shrink back+ // down when the user deletes content, then snap to scrollHeight capped at+ // TEXTAREA_MAX_HEIGHT_PX (overflow-y: auto in CSS handles the rest).+ useLayoutEffect(() => {+ const el = textareaRef.current;+ if (!el) {+ return;+ }+ el.style.height = 'auto';+ el.style.height = `${Math.min(el.scrollHeight, TEXTAREA_MAX_HEIGHT_PX)}px`;+ }, [text]);+const handleSend = useCallback(async () => {const trimmed = text.trim();if (!trimmed && pendingFiles.length === 0) {@@ -382,7 +489,7 @@ export default function ChatInput({// start time so we can attribute `durationMs` on the Voice input used// event regardless of which control ended the session.const voiceStartedAtRef = useRef<number | null>(null);- const voiceSourceRef = useRef<'button' | 'shortcut' | null>(null);+ const voiceSourceRef = useRef<VoiceInputSource | null>(null);// Set to true after a `network`, `not-allowed`, or `not-supported` failure// so we hide the mic button for the rest of the tab session — silent// retries don't help, and Chromium derivatives without the Google Speech@@ -459,7 +566,7 @@ export default function ChatInput({const showMic = isSupported && micPermission !== 'denied' && !voiceUnavailable;const startVoiceInput = useCallback(- (source: 'button' | 'shortcut') => {+ (source: VoiceInputSource) => {// Defense in depth: the button is hidden when `voiceUnavailable` is// true, but the PTT shortcut listener can still call us. Bailing here// keeps a single source of truth and prevents repeat `Voice input@@ -536,7 +643,7 @@ export default function ChatInput({return; // ignore auto-repeat}pttActiveRef.current = true;- startVoiceInput('shortcut');+ startVoiceInput(VoiceInputSource.Shortcut);};const handleKeyUp = (e: KeyboardEvent): void => {@@ -724,6 +831,12 @@ export default function ChatInput({entity.value.toLowerCase().includes(activeQuery),): contextEntitiesByCategory[activeContextCategory];+ // Truncate the ref array to match the current entity count so that+ // switching from a large category (e.g. 100 dashboards) to a smaller one+ // doesn't leave stale `null` slots from earlier renders. Keyboard nav math+ // already uses `filteredContextOptions.length` for the modulo, so stale+ // slots wouldn't be reached — this is purely housekeeping.+ entityRefs.current.length = filteredContextOptions.length;const { isLoading: isActiveContextLoading, isError: isActiveContextError } =contextCategoryStateByCategory[activeContextCategory];const currentLength = text.length;@@ -830,7 +943,7 @@ export default function ChatInput({onKeyDown={handleKeyDown}disabled={disabled}maxLength={MAX_INPUT_LENGTH}- rows={2}+ rows={3}/></div>{showTextWarning && (@@ -877,15 +990,37 @@ export default function ChatInput({sideOffset={8}><div className={styles.contextPopoverContent}>- <div className={styles.contextPopoverCategories}>+ <div+ className={styles.contextPopoverCategories}+ role="tablist"+ aria-orientation="vertical"+ aria-label="Context categories"+ >{CONTEXT_CATEGORIES.map((category) => {const CategoryIcon = CONTEXT_CATEGORY_ICONS[category];const isActive = activeContextCategory === category;return (- <div+ <Buttonkey={category}+ ref={(el): void => {+ categoryTabRefs.current.set(category, el);+ }}+ type="button"+ variant="ghost"+ color="secondary"+ size="sm"role="tab"- tabIndex={0}+ id={`ai-context-tab-${category}`}+ // Single stable panel id shared by every tab: only the+ // active category's tabpanel is rendered, so per-category+ // `aria-controls` ids would point at nonexistent nodes+ // for the two inactive tabs. APG allows a single+ // dynamic panel whose `aria-labelledby` swaps to the+ // active tab.+ aria-controls="ai-context-tabpanel"+ // Roving tabindex: only the active tab participates in+ // the Tab sequence; arrow keys move between tabs.+ tabIndex={isActive ? 0 : -1}aria-selected={isActive}className={cx(styles.contextPopoverCategoryItem, {[styles.active]: isActive,@@ -894,22 +1029,21 @@ export default function ChatInput({setActiveContextCategory(category);setPickerSearchQuery('');}}- onKeyDown={(e): void => {- if (e.key === 'Enter' || e.key === ' ') {- e.preventDefault();- setActiveContextCategory(category);- setPickerSearchQuery('');- }- }}+ onKeyDown={(e): void => handleCategoryKeyDown(e, category)}+ prefix={<CategoryIcon size={13} />}>- <CategoryIcon size={13} /><span>{category}</span>- </div>+ </Button>);})}</div>- <div className={styles.contextPopoverRight}>+ <div+ className={styles.contextPopoverRight}+ role="tabpanel"+ id="ai-context-tabpanel"+ aria-labelledby={`ai-context-tab-${activeContextCategory}`}+ ><div className={styles.contextPopoverSearch}><Inputtype="text"@@ -939,7 +1073,7 @@ export default function ChatInput({No matching entities</div>) : (- filteredContextOptions.map((option) => {+ filteredContextOptions.map((option, index) => {const isSelected = selectedContexts.some((item) =>item.category === activeContextCategory &&@@ -947,8 +1081,16 @@ export default function ChatInput({);return (- <div+ <Buttonkey={option.id}+ ref={(el): void => {+ entityRefs.current[index] = el;+ }}+ type="button"+ variant="ghost"+ color="secondary"+ size="sm"+ aria-pressed={isSelected}className={cx(styles.contextPopoverEntityItem, {[styles.selected]: isSelected,})}@@ -959,11 +1101,12 @@ export default function ChatInput({option.value,)}+ onKeyDown={(e): void => handleEntityKeyDown(e, index)}><span className={styles.contextPopoverEntityItemText}>{option.value}</span>- </div>+ </Button>);}))}@@ -977,14 +1120,24 @@ export default function ChatInput({<div className={styles.rightActions}>{showMic &&(isListening ? (- <div className={styles.micRecording}>- <div- className={cx(styles.micDiscard, styles.secondary)}- onClick={handleDiscard}- aria-label="Discard recording"- >- <X size={12} />- </div>+ <div+ className={styles.micRecording}+ role="status"+ aria-live="polite"+ aria-label="Recording voice input"+ >+ <TooltipSimple title="Discard recording">+ <Button+ type="button"+ variant="ghost"+ size="icon"+ color="secondary"+ className={cx(styles.micDiscard, styles.secondary)}+ onClick={handleDiscard}+ aria-label="Discard recording"+ prefix={<X size={12} />}+ />+ </TooltipSimple><span className={styles.micWaves} aria-hidden="true"><span /><span />@@ -995,26 +1148,30 @@ export default function ChatInput({<span /><span /></span>- <div- className={cx(styles.micStop, styles.destructive)}- onClick={handleStopAndSend}- aria-label="Stop and send"- >- <Square size={9} fill="currentColor" strokeWidth={0} />- </div>+ <TooltipSimple title="Stop and send">+ <Button+ type="button"+ variant="ghost"+ size="icon"+ color="destructive"+ className={cx(styles.micStop, styles.destructive)}+ onClick={handleStopAndSend}+ aria-label="Stop and send"+ prefix={<Square size={9} fill="currentColor" strokeWidth={0} />}+ />+ </TooltipSimple></div>) : (<TooltipSimple title="Voice input"><Buttonvariant="ghost"size="icon"- onClick={(): void => startVoiceInput('button')}+ onClick={(): void => startVoiceInput(VoiceInputSource.Button)}disabled={disabled}aria-label="Start voice input"className={styles.micBtn}- >- <Mic size={14} />- </Button>+ prefix={<Mic size={14} />}+ /></TooltipSimple>))}@@ -1026,21 +1183,21 @@ export default function ChatInput({color="destructive"onClick={onCancel}aria-label="Stop generating"- >- <Square size={10} fill="currentColor" strokeWidth={0} />- </Button>+ prefix={<Square size={10} fill="currentColor" strokeWidth={0} />}+ /></TooltipSimple>) : (- <Button- variant="solid"- size="icon"- color="primary"- onClick={isListening ? handleStopAndSend : handleSend}- disabled={disabled || (!text.trim() && pendingFiles.length === 0)}- aria-label="Send message"- >- <Send size={14} />- </Button>+ <TooltipSimple title="Send message">+ <Button+ variant="solid"+ size="icon"+ color="primary"+ onClick={isListening ? handleStopAndSend : handleSend}+ disabled={disabled || (!text.trim() && pendingFiles.length === 0)}+ aria-label="Send message"+ prefix={<Send size={14} />}+ />+ </TooltipSimple>)}</div></div>diff --git a/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.module.scss b/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.module.scssindex 060415007e..005e2f7df2 100644--- a/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.module.scss+++ b/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.module.scss@@ -64,6 +64,19 @@gap: 4px;}+// Mirrors `.field` for the multi_select group, but resets the browser's+// default `<fieldset>` border/padding/margin so the visual matches the+// `<div>`-based field rows.+.multiSelectFieldset {+ display: flex;+ flex-direction: column;+ gap: 4px;+ margin: 0;+ padding: 0;+ border: 0;+ min-width: 0;+}+.label {font-size: 12px;font-weight: 500;diff --git a/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.tsx b/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.tsxindex d726fb647f..76f3488aa2 100644--- a/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.tsx+++ b/frontend/src/container/AIAssistant/components/ClarificationForm/ClarificationForm.tsx@@ -63,7 +63,14 @@ export default function ClarificationForm({setAnswers((prev) => ({ ...prev, [id]: value }));};+ const isFormValid = fields.every(+ (f) => !f.required || isFieldFilled(f, answers[f.id]),+ );+const handleSubmit = async (): Promise<void> => {+ if (!isFormValid) {+ return;+ }setSubmitted(true);// Approximate queryLength as the JSON encoding of the form answers — the// clarification API doesn't render a single user-visible string, but the@@ -136,7 +143,7 @@ export default function ClarificationForm({variant="solid"color="primary"onClick={handleSubmit}- disabled={isStreaming}+ disabled={isStreaming || !isFormValid}prefix={<Send />}>Submit@@ -162,8 +169,9 @@ export default function ClarificationForm({/*** Per-type seed value. The DTO's `default` is `string | string[] | null`,- * which doesn't fit boolean fields cleanly — we coerce 'true'/'false' strings- * for them, fall back to `[]` for multi_select, and the raw string otherwise.+ * which doesn't fit boolean / number fields cleanly — we coerce 'true'/'false'+ * strings for booleans, parse number defaults out of the string form,+ * fall back to `[]` for multi_select, and the raw string otherwise.*/function initialAnswerFor(f: ClarificationFieldEventDTO): unknown {const raw = f.default;@@ -175,9 +183,41 @@ function initialAnswerFor(f: ClarificationFieldEventDTO): unknown {if (f.type === ClarificationFieldTypeDTO.multi_select) {return Array.isArray(raw) ? raw : [];}+ if (f.type === ClarificationFieldTypeDTO.number) {+ // Server sends number defaults as strings (e.g. `"5"`). Parse so the+ // stored value is a real `number` — otherwise `isFieldFilled` (which+ // requires `typeof === 'number'`) rejects a visibly-filled field and+ // Submit stays disabled.+ if (typeof raw !== 'string' || raw === '') {+ return null;+ }+ const parsed = Number(raw);+ return Number.isNaN(parsed) ? null : parsed;+ }return raw ?? '';}+// Whether a required field has been answered. Booleans are always considered+// filled (they're initialised to a concrete true/false). For other types we+// reject empty strings, empty arrays, NaN numbers, and `null` (which the+// number input emits when its raw value is `''` — `Number('')` would+// otherwise silently coerce to `0` and read as a valid answer).+function isFieldFilled(+ field: ClarificationFieldEventDTO,+ value: unknown,+): boolean {+ switch (field.type) {+ case ClarificationFieldTypeDTO.multi_select:+ return Array.isArray(value) && value.length > 0;+ case ClarificationFieldTypeDTO.boolean:+ return true;+ case ClarificationFieldTypeDTO.number:+ return typeof value === 'number' && !Number.isNaN(value);+ default:+ return typeof value === 'string' && value.trim().length > 0;+ }+}+interface FieldInputProps {field: ClarificationFieldEventDTO;value: unknown;@@ -216,13 +256,21 @@ function FieldInput({ field, value, onChange }: FieldInputProps): JSX.Element {<div className={styles.field}><label className={styles.label} htmlFor={id}>{label}- {required && <span className={styles.required}>*</span>}+ {required && (+ <span className={styles.required} aria-hidden="true">+ *+ </span>+ )}</label><Selectvalue={isCustom ? CUSTOM_OPTION_SENTINEL : String(value ?? '')}onChange={handleSelectChange}>- <SelectTrigger id={id} placeholder="Select…" />+ <SelectTrigger+ id={id}+ placeholder="Select…"+ aria-required={required || undefined}+ />{/* Pin the dropdown width to the trigger via Radix's`--radix-select-trigger-width`; otherwise the popoversizes to its widest item and looks misaligned. */}@@ -267,7 +315,11 @@ function FieldInput({ field, value, onChange }: FieldInputProps): JSX.Element {onChange={(): void => onChange(!checked)}>{label}- {required && <span className={styles.required}>*</span>}+ {required && (+ <span className={styles.required} aria-hidden="true">+ *+ </span>+ )}</Checkbox></div>);@@ -312,11 +364,21 @@ function FieldInput({ field, value, onChange }: FieldInputProps): JSX.Element {};return (- <div className={styles.field}>- <span className={styles.label}>+ // `fieldset` + `legend` is the WCAG-recommended grouping for+ // related checkboxes (1.3.1). SRs announce the legend before each+ // option, so users hear the group label as context.+ <fieldset+ className={styles.multiSelectFieldset}+ aria-required={required || undefined}+ >+ <legend className={styles.label}>{label}- {required && <span className={styles.required}>*</span>}- </span>+ {required && (+ <span className={styles.required} aria-hidden="true">+ *+ </span>+ )}+ </legend><div className={styles.checkboxGroup}>{options?.map((opt) => (<Checkbox@@ -347,7 +409,7 @@ function FieldInput({ field, value, onChange }: FieldInputProps): JSX.Element {onChange={(e): void => updateCustomValue(e.target.value)}/>)}- </div>+ </fieldset>);}@@ -356,16 +418,29 @@ function FieldInput({ field, value, onChange }: FieldInputProps): JSX.Element {<div className={styles.field}><label className={styles.label} htmlFor={id}>{label}- {required && <span className={styles.required}>*</span>}+ {required && (+ <span className={styles.required} aria-hidden="true">+ *+ </span>+ )}</label><Inputid={id}type={type === 'number' ? 'number' : 'text'}className={styles.input}value={String(value ?? '')}- onChange={(e): void =>- onChange(type === 'number' ? Number(e.target.value) : e.target.value)- }+ aria-required={required || undefined}+ onChange={(e): void => {+ if (type === 'number') {+ const raw = e.target.value;+ // Map empty input to `null` instead of `Number('') === 0`+ // so a required numeric field cleared after typing doesn't+ // silently read as a valid `0` in `isFieldFilled`.+ onChange(raw === '' ? null : Number(raw));+ } else {+ onChange(e.target.value);+ }+ }}placeholder={label}/></div>diff --git a/frontend/src/container/AIAssistant/components/MessageFeedback/MessageFeedback.tsx b/frontend/src/container/AIAssistant/components/MessageFeedback/MessageFeedback.tsxindex 637d1e75ec..ca0ad35ef2 100644--- a/frontend/src/container/AIAssistant/components/MessageFeedback/MessageFeedback.tsx+++ b/frontend/src/container/AIAssistant/components/MessageFeedback/MessageFeedback.tsx@@ -10,6 +10,7 @@ import { useTimezone } from 'providers/Timezone';import logEvent from 'api/common/logEvent';+import { FeedbackRatingDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';import { AIAssistantEvents } from '../../events';import { useAIAssistantAnalyticsContext } from '../../hooks/useAIAssistantAnalyticsContext';import { useAIAssistantStore } from '../../store/useAIAssistantStore';@@ -17,6 +18,22 @@ import { FeedbackRating, Message } from '../../types';import styles from './MessageFeedback.module.scss';+const FEEDBACK_ANALYTICS_RATING = {+ [FeedbackRatingDTO.positive]: 'up',+ [FeedbackRatingDTO.negative]: 'down',+} as const;++const VOTE_LABEL = {+ [FeedbackRatingDTO.positive]: {+ tooltip: 'Good response',+ ariaLabel: 'Good response',+ },+ [FeedbackRatingDTO.negative]: {+ tooltip: 'Bad response',+ ariaLabel: 'Bad response',+ },+} as const;+interface MessageFeedbackProps {message: Message;onRegenerate?: () => void;@@ -117,7 +134,7 @@ export default function MessageFeedback({if (vote === rating) {return;}- if (rating === 'negative') {+ if (rating === FeedbackRatingDTO.negative) {setNegativeComment('');setIsNegativeDialogOpen(true);return;@@ -126,7 +143,7 @@ export default function MessageFeedback({void logEvent(AIAssistantEvents.FeedbackSubmitted, {messageId: message.id,threadId,- rating: 'up',+ rating: FEEDBACK_ANALYTICS_RATING[rating],hasComment: false,commentLength: 0,});@@ -136,17 +153,21 @@ export default function MessageFeedback({);const handleSubmitNegative = useCallback((): void => {- setVote('negative');+ setVote(FeedbackRatingDTO.negative);setIsNegativeDialogOpen(false);const trimmed = negativeComment.trim();void logEvent(AIAssistantEvents.FeedbackSubmitted, {messageId: message.id,threadId,- rating: 'down',+ rating: FEEDBACK_ANALYTICS_RATING[FeedbackRatingDTO.negative],hasComment: trimmed.length > 0,commentLength: trimmed.length,});- submitMessageFeedback(message.id, 'negative', trimmed || undefined);+ submitMessageFeedback(+ message.id,+ FeedbackRatingDTO.negative,+ trimmed || undefined,+ );}, [message.id, negativeComment, submitMessageFeedback, threadId]);return (@@ -160,32 +181,39 @@ export default function MessageFeedback({variant="ghost"onClick={handleCopy}color="secondary"+ aria-label={copied ? 'Copied' : 'Copy message'}>{copied ? <Check size={12} /> : <Copy size={12} />}</Button></TooltipSimple>- <TooltipSimple title="Good response">+ <TooltipSimple title={VOTE_LABEL[FeedbackRatingDTO.positive].tooltip}><Button- className={cx(styles.btn, { [styles.votedUp]: vote === 'positive' })}+ className={cx(styles.btn, {+ [styles.votedUp]: vote === FeedbackRatingDTO.positive,+ })}size="icon"variant="ghost"color="secondary"- onClick={(): void => handleVote('positive')}+ onClick={(): void => handleVote(FeedbackRatingDTO.positive)}+ aria-label={VOTE_LABEL[FeedbackRatingDTO.positive].ariaLabel}+ aria-pressed={vote === FeedbackRatingDTO.positive}><ThumbsUp size={12} /></Button></TooltipSimple>- <TooltipSimple title="Bad response">+ <TooltipSimple title={VOTE_LABEL[FeedbackRatingDTO.negative].tooltip}><ButtonclassName={cx(styles.btn, {- [styles.votedDown]: vote === 'negative',+ [styles.votedDown]: vote === FeedbackRatingDTO.negative,})}size="icon"variant="ghost"color="secondary"- onClick={(): void => handleVote('negative')}+ onClick={(): void => handleVote(FeedbackRatingDTO.negative)}+ aria-label={VOTE_LABEL[FeedbackRatingDTO.negative].ariaLabel}+ aria-pressed={vote === FeedbackRatingDTO.negative}><ThumbsDown size={12} /></Button>@@ -199,6 +227,7 @@ export default function MessageFeedback({variant="ghost"color="secondary"onClick={onRegenerate}+ aria-label="Regenerate response"><RefreshCw size={12} /></Button>diff --git a/frontend/src/container/AIAssistant/components/UserMessageActions/UserMessageActions.tsx b/frontend/src/container/AIAssistant/components/UserMessageActions/UserMessageActions.tsxindex 0b2bbc7c0a..c0a29b71dc 100644--- a/frontend/src/container/AIAssistant/components/UserMessageActions/UserMessageActions.tsx+++ b/frontend/src/container/AIAssistant/components/UserMessageActions/UserMessageActions.tsx@@ -47,6 +47,7 @@ export default function UserMessageActions({variant="ghost"color="secondary"onClick={handleCopy}+ aria-label={copied ? 'Copied' : 'Copy message'}>{copied ? <Check size={12} /> : <Copy size={12} />}</Button>diff --git a/frontend/src/container/AIAssistant/components/VirtualizedMessages/VirtualizedMessages.tsx b/frontend/src/container/AIAssistant/components/VirtualizedMessages/VirtualizedMessages.tsxindex 635888ded0..872a0f7ad2 100644--- a/frontend/src/container/AIAssistant/components/VirtualizedMessages/VirtualizedMessages.tsx+++ b/frontend/src/container/AIAssistant/components/VirtualizedMessages/VirtualizedMessages.tsx@@ -90,6 +90,16 @@ export default function VirtualizedMessages({const virtuosoRef = useRef<VirtuosoHandle>(null);const scrollerRef = useRef<HTMLElement | Window | null>(null);+ // Tracks whether the scroller is pinned to (or near) the bottom. Updated+ // via Virtuoso's `atBottomStateChange` so we can stop force-scrolling the+ // user back down when they've intentionally scrolled up to read earlier+ // content.+ const atBottomRef = useRef(true);+ // Id of the latest user message we've already anchored to. Used to detect+ // a fresh user send so we can re-anchor to the bottom regardless of where+ // the user was scrolled — sending a message and not seeing it is worse+ // than the anti-yank guarantee.+ const lastSeenUserMessageIdRef = useRef<string | null>(null);const handleRegenerate = useCallback((messageId: string): void => {@@ -111,8 +121,25 @@ export default function VirtualizedMessages({// align: 'end')` would only reach the last item's bottom and leave the// padding hidden below the fold. Use `auto` while streaming so the bottom// stays glued as text deltas arrive; `smooth` lags when triggered every- // few ms.+ // few ms. Bail out if the user has scrolled away from the bottom — that's+ // an explicit signal they want to read earlier content without being+ // yanked back.useEffect(() => {+ const lastMessage = messages[messages.length - 1];+ const isFreshUserSend =+ lastMessage?.role === 'user' &&+ lastMessage.id !== lastSeenUserMessageIdRef.current;+ if (isFreshUserSend) {+ lastSeenUserMessageIdRef.current = lastMessage.id;+ // Re-anchor so the user sees their own send (and the assistant's+ // follow-up streaming) even if they were reading history when they+ // hit Enter.+ atBottomRef.current = true;+ }++ if (!atBottomRef.current) {+ return;+ }const scroller = scrollerRef.current;if (!(scroller instanceof HTMLElement)) {return;@@ -122,7 +149,7 @@ export default function VirtualizedMessages({behavior: isStreaming ? 'auto' : 'smooth',});}, [- messages.length,+ messages,streamingEvents.length,streamingContentLength,isStreaming,@@ -132,14 +159,18 @@ export default function VirtualizedMessages({const followOutput = useCallback((atBottom: boolean): false | 'auto' | 'smooth' => {- if (isStreaming) {- return 'auto';+ if (!atBottom) {+ return false;}- return atBottom ? 'smooth' : false;+ return isStreaming ? 'auto' : 'smooth';},[isStreaming],);+ const handleAtBottomStateChange = useCallback((atBottom: boolean): void => {+ atBottomRef.current = atBottom;+ }, []);+const showStreamingSlot =isStreaming || Boolean(pendingApproval) || Boolean(pendingClarification);@@ -188,6 +219,8 @@ export default function VirtualizedMessages({className={styles.messages}totalCount={totalCount}followOutput={followOutput}+ atBottomStateChange={handleAtBottomStateChange}+ atBottomThreshold={64}initialTopMostItemIndex={Math.max(0, totalCount - 1)}itemContent={(index): JSX.Element => {if (index < messages.length) {diff --git a/frontend/src/container/AIAssistant/components/blocks/RichCodeBlock/RichCodeBlock.tsx b/frontend/src/container/AIAssistant/components/blocks/RichCodeBlock/RichCodeBlock.tsxindex 314b371707..7aea690ce7 100644--- a/frontend/src/container/AIAssistant/components/blocks/RichCodeBlock/RichCodeBlock.tsx+++ b/frontend/src/container/AIAssistant/components/blocks/RichCodeBlock/RichCodeBlock.tsx@@ -1,6 +1,7 @@import React, { useEffect, useRef, useState } from 'react';import { useCopyToClipboard } from 'react-use';import { Button } from '@signozhq/ui/button';+import { TooltipSimple } from '@signozhq/ui/tooltip';import { Check, Copy } from '@signozhq/icons';import SyntaxHighlighter, {a11yDark,@@ -126,16 +127,17 @@ function CopyButton({ text }: { text: string }): JSX.Element {};return (- <Button- variant="ghost"- size="sm"- color="secondary"- className={styles.copyBtn}- onClick={handleCopy}- title={copied ? 'Copied' : 'Copy code'}- aria-label={copied ? 'Copied' : 'Copy code'}- >- {copied ? <Check size={12} /> : <Copy size={12} />}- </Button>+ <TooltipSimple title={copied ? 'Copied' : 'Copy code'}>+ <Button+ variant="ghost"+ size="sm"+ color="secondary"+ className={styles.copyBtn}+ onClick={handleCopy}+ aria-label={copied ? 'Copied' : 'Copy code'}+ >+ {copied ? <Check size={12} /> : <Copy size={12} />}+ </Button>+ </TooltipSimple>);}diff --git a/frontend/src/container/AIAssistant/events.ts b/frontend/src/container/AIAssistant/events.tsindex e2231e104f..d18a6c4ff6 100644--- a/frontend/src/container/AIAssistant/events.ts+++ b/frontend/src/container/AIAssistant/events.ts@@ -63,6 +63,26 @@ export const SuggestedPromptCategory = {export type SuggestedPromptCategory =(typeof SuggestedPromptCategory)[keyof typeof SuggestedPromptCategory];+// `source` attribute on the AI Assistant `Opened` event — describes which+// surface triggered the open. Keep values stable: dashboards downstream+// depend on the literal strings.+export const AIAssistantOpenSource = {+ Icon: 'icon',+ Shortcut: 'shortcut',+ Cmdk: 'cmdk',+} as const;+export type AIAssistantOpenSource =+ (typeof AIAssistantOpenSource)[keyof typeof AIAssistantOpenSource];++// `source` attribute on the `VoiceInputUsed` event — which surface initiated+// the recording.+export const VoiceInputSource = {+ Button: 'button',+ Shortcut: 'shortcut',+} as const;+export type VoiceInputSource =+ (typeof VoiceInputSource)[keyof typeof VoiceInputSource];+export enum AIAssistantEvents {Opened = 'AI Assistant: Opened',MessageSent = 'AI Assistant: Message sent',diff --git a/frontend/src/container/AppLayout/utils.ts b/frontend/src/container/AppLayout/utils.tsindex 649dcc46fc..bf2e79cc89 100644--- a/frontend/src/container/AppLayout/utils.ts+++ b/frontend/src/container/AppLayout/utils.ts@@ -1,9 +1,32 @@import ROUTES from 'constants/routes';+const PARAM_SEGMENT = /:[^/]+/g;+const REGEX_SPECIALS = /[.+*?^$()[\]{}|\\]/g;++function templateToRegex(template: string): RegExp {+ const pattern = template+ .replace(REGEX_SPECIALS, '\\$&')+ .replace(PARAM_SEGMENT, '[^/]+');+ return new RegExp(`^${pattern}$`);+}+export function getRouteKey(pathname: string): string {- const [routeKey] = Object.entries(ROUTES).find(- ([, value]) => value === pathname,- ) || ['DEFAULT'];+ const entries = Object.entries(ROUTES);++ const exact = entries.find(([, value]) => value === pathname);+ if (exact) {+ return exact[0];+ }++ // First template that matches wins, so declaration order in `ROUTES`+ // matters when templates can overlap. Today's set is unambiguous because+ // `[^/]+` is segment-bounded, but if you ever add a sibling like+ // `/services/list` next to `SERVICE_METRICS: '/services/:servicename'`,+ // list the more-specific (more-static-segments) entry first in `ROUTES`+ // — otherwise the param template will swallow the static path.+ const dynamic = entries.find(+ ([, value]) => value.includes(':') && templateToRegex(value).test(pathname),+ );- return routeKey;+ return dynamic?.[0] ?? 'DEFAULT';}