@@ -3,8 +3,9 @@ import dynamic from 'next/dynamic';
33import { parseAsJson , parseAsStringEnum , useQueryState } from 'nuqs' ;
44import { useForm } from 'react-hook-form' ;
55import { useHotkeys } from 'react-hotkeys-hook' ;
6- import { SavedChartConfig } from '@hyperdx/common-utils/dist/types' ;
6+ import { SavedChartConfig , SourceKind } from '@hyperdx/common-utils/dist/types' ;
77import {
8+ Alert ,
89 Box ,
910 Button ,
1011 Collapse ,
@@ -16,6 +17,7 @@ import {
1617} from '@mantine/core' ;
1718import { notifications } from '@mantine/notifications' ;
1819
20+ import api from '@/api' ;
1921import { DEFAULT_CHART_CONFIG , Granularity } from '@/ChartUtils' ;
2022import EditTimeChartForm from '@/components/DBEditTimeChartForm' ;
2123import { InputControlled } from '@/components/InputControlled' ;
@@ -24,6 +26,7 @@ import { useChartAssistant } from '@/hooks/ai';
2426import { withAppNav } from '@/layout' ;
2527import { useSources } from '@/source' ;
2628import { parseTimeQuery , useNewTimeQuery } from '@/timeQuery' ;
29+ import { useLocalStorage } from '@/utils' ;
2730
2831// Autocomplete can focus on column/map keys
2932
@@ -36,12 +39,18 @@ function AIAssistant({
3639 setConfig,
3740 onTimeRangeSelect,
3841 submitRef,
42+ aiAssistantEnabled,
3943} : {
4044 setConfig : ( config : SavedChartConfig ) => void ;
4145 onTimeRangeSelect : ( start : Date , end : Date ) => void ;
4246 submitRef : React . RefObject < ( ( ) => void ) | undefined > ;
47+ aiAssistantEnabled : boolean ;
4348} ) {
4449 const [ opened , setOpened ] = useState ( false ) ;
50+ const [ alertDismissed , setAlertDismissed ] = useLocalStorage (
51+ 'ai-assistant-alert-dismissed' ,
52+ false ,
53+ ) ;
4554 const { control, watch, setValue, handleSubmit } = useForm < {
4655 text : string ;
4756 source : string ;
@@ -105,6 +114,30 @@ function AIAssistant({
105114 } ,
106115 ) ;
107116
117+ if ( ! aiAssistantEnabled && ! alertDismissed ) {
118+ return (
119+ < Box mb = "sm" >
120+ < Alert
121+ color = "dark.3"
122+ icon = { < i className = "bi bi-info-circle" /> }
123+ variant = "outline"
124+ withCloseButton
125+ onClose = { ( ) => setAlertDismissed ( true ) }
126+ p = "xxs"
127+ >
128+ < Text size = "xs" c = "dark.2" pt = "2px" >
129+ New AI Assistant available, enable with configuring the{ ' ' }
130+ < code > ANTHROPIC_API_KEY</ code > environment variable on the HyperDX
131+ server.
132+ </ Text >
133+ </ Alert >
134+ < Divider mt = "sm" />
135+ </ Box >
136+ ) ;
137+ } else if ( ! aiAssistantEnabled ) {
138+ return null ;
139+ }
140+
108141 return (
109142 < Box mb = "sm" >
110143 < Group gap = "md" align = "center" mb = "sm" >
@@ -123,7 +156,7 @@ function AIAssistant({
123156 < Text size = "xxs" > AI Assistant [A]</ Text >
124157 </ Group >
125158 </ Button >
126- < Pill size = "xs" > Super Experimental</ Pill >
159+ < Pill size = "xs" > Experimental</ Pill >
127160 </ Group >
128161 < Collapse in = { opened } >
129162 { opened && (
@@ -135,6 +168,7 @@ function AIAssistant({
135168 control = { control }
136169 name = "source"
137170 data-testid = "source-selector"
171+ allowedSourceKinds = { [ SourceKind . Log , SourceKind . Trace ] }
138172 />
139173 < Box style = { { flexGrow : 1 , minWidth : 100 } } >
140174 < InputControlled
@@ -177,6 +211,7 @@ function DBChartExplorerPage() {
177211
178212 const submitRef = useRef < ( ) => void > ( ) ;
179213 const { data : sources } = useSources ( ) ;
214+ const { data : me } = api . useMe ( ) ;
180215
181216 const [ chartConfig , setChartConfig ] = useQueryState (
182217 'config' ,
@@ -192,6 +227,7 @@ function DBChartExplorerPage() {
192227 setConfig = { setChartConfig }
193228 onTimeRangeSelect = { onTimeRangeSelect }
194229 submitRef = { submitRef }
230+ aiAssistantEnabled = { me ?. aiAssistantEnabled ?? false }
195231 />
196232 < EditTimeChartForm
197233 data-testid = "chart-explorer-form"
0 commit comments