diff --git a/apps/web/src/components/features/input/BusterChatInput/BusterChatInputBase.tsx b/apps/web/src/components/features/input/BusterChatInput/BusterChatInputBase.tsx index 61e841c4f..ce5374086 100644 --- a/apps/web/src/components/features/input/BusterChatInput/BusterChatInputBase.tsx +++ b/apps/web/src/components/features/input/BusterChatInput/BusterChatInputBase.tsx @@ -1,29 +1,24 @@ import type { ListShortcutsResponse } from '@buster/server-shared/shortcuts'; import type { GetSuggestedPromptsResponse } from '@buster/server-shared/user'; -import omit from 'lodash/omit'; -import sampleSize from 'lodash/sampleSize'; import React, { useMemo, useRef, useState } from 'react'; import { useCreateShortcutsMentionsSuggestions, useShortcutsSuggestions, } from '@/components/features/input/Mentions/ShortcutsSuggestions/ShortcutsSuggestions'; -import CircleQuestion from '@/components/ui/icons/NucleoIconOutlined/circle-question'; -import FileSparkle from '@/components/ui/icons/NucleoIconOutlined/file-sparkle'; import type { MentionArrayItem, MentionSuggestionExtension, } from '@/components/ui/inputs/MentionInput'; import type { - MentionInputSuggestionsDropdownItem, MentionInputSuggestionsProps, MentionInputSuggestionsRef, } from '@/components/ui/inputs/MentionInputSuggestions'; import { MentionInputSuggestions } from '@/components/ui/inputs/MentionInputSuggestions'; import { useMemoizedFn } from '@/hooks/useMemoizedFn'; import { useMount } from '@/hooks/useMount'; -import { ASSET_ICONS } from '../../icons/assetIcons'; import { NewShortcutModal } from '../../modals/NewShortcutModal'; import { BusterChatInputButtons, type BusterChatInputMode } from './BusterChatInputButtons'; +import { useUniqueSuggestions } from './useUniqueSuggestions'; export type BusterChatInputProps = { defaultValue: string; @@ -131,7 +126,8 @@ export const BusterChatInputBase: React.FC = React.memo( placeholder="Ask a question or type ‘/’ for shortcuts..." ref={mentionInputSuggestionsRef} inputContainerClassName="px-5 pt-4" - inputClassName="text-lg" + inputClassName="text-md" + behavior="open-on-focus" > = React.memo( ); BusterChatInputBase.displayName = 'BusterChatInputBase'; - -const iconRecord: Record = { - report: , - dashboard: , - visualization: , - help: , -}; - -const useUniqueSuggestions = ( - suggestedPrompts: GetSuggestedPromptsResponse['suggestedPrompts'] -): MentionInputSuggestionsProps['suggestionItems'] => { - return useMemo(() => { - const filteredSuggestedPrompts = omit(suggestedPrompts, ['help']); - const allSuggestions: { type: keyof typeof suggestedPrompts; value: string }[] = Object.entries( - filteredSuggestedPrompts - ).flatMap(([key, value]) => { - return value.map((prompt) => { - return { - type: key as keyof typeof suggestedPrompts, - value: prompt, - }; - }); - }); - - // Ensure we have at least 4 suggestions - if (allSuggestions.length < 4) { - throw new Error('Not enough suggestions available - need at least 4'); - } - - const fourUniqueSuggestions = sampleSize(allSuggestions, 4); - - const items: MentionInputSuggestionsDropdownItem[] = fourUniqueSuggestions.map((suggestion) => { - const icon = iconRecord[suggestion.type] || ; - return { - type: 'item', - value: suggestion.type + suggestion.value, - label: suggestion.value, - icon, - }; - }); - - return [ - { - type: 'group', - label: 'Shortcuts', - suggestionItems: items, - addValueToInput: true, - closeOnSelect: true, - }, - ] satisfies MentionInputSuggestionsProps['suggestionItems']; - }, [suggestedPrompts]); -}; diff --git a/apps/web/src/components/features/input/BusterChatInput/BusterChatInputButtons.tsx b/apps/web/src/components/features/input/BusterChatInput/BusterChatInputButtons.tsx index 5d1fc6f33..332ad6c06 100644 --- a/apps/web/src/components/features/input/BusterChatInput/BusterChatInputButtons.tsx +++ b/apps/web/src/components/features/input/BusterChatInput/BusterChatInputButtons.tsx @@ -67,7 +67,12 @@ export const BusterChatInputButtons = React.memo( return (
- onModeChange(v.value)} /> + onModeChange(v.value)} + />
{browserSupportsSpeechRecognition && ( @@ -85,8 +90,8 @@ export const BusterChatInputButtons = React.memo( variant={'ghost'} prefix={} onClick={listening ? onStopListening : onStartListening} - loading={false} disabled={disabled} + size={'tall'} className={cn( 'origin-center transform-gpu transition-all duration-300 ease-out will-change-transform text-text-secondary', !disabled && 'hover:scale-110 active:scale-95', @@ -109,7 +114,8 @@ export const BusterChatInputButtons = React.memo( >