mirror of https://github.com/buster-so/buster.git
Update BusterChatInputButtons.tsx
This commit is contained in:
parent
d0db81d359
commit
77847ed4b7
|
@ -4,7 +4,11 @@ import { Button } from '@/components/ui/buttons';
|
||||||
import { ArrowUp, Magnifier, Sparkle2 } from '@/components/ui/icons';
|
import { ArrowUp, Magnifier, Sparkle2 } from '@/components/ui/icons';
|
||||||
import Atom from '@/components/ui/icons/NucleoIconOutlined/atom';
|
import Atom from '@/components/ui/icons/NucleoIconOutlined/atom';
|
||||||
import Microphone from '@/components/ui/icons/NucleoIconOutlined/microphone';
|
import Microphone from '@/components/ui/icons/NucleoIconOutlined/microphone';
|
||||||
import { useMentionInputHasValue } from '@/components/ui/inputs/MentionInputSuggestions';
|
import {
|
||||||
|
useMentionInputHasValue,
|
||||||
|
useMentionInputSuggestionsGetValue,
|
||||||
|
useMentionInputSuggestionsOnChangeValue,
|
||||||
|
} from '@/components/ui/inputs/MentionInputSuggestions';
|
||||||
import { Popover } from '@/components/ui/popover';
|
import { Popover } from '@/components/ui/popover';
|
||||||
import { AppSegmented, type AppSegmentedProps } from '@/components/ui/segmented';
|
import { AppSegmented, type AppSegmentedProps } from '@/components/ui/segmented';
|
||||||
import { AppTooltip } from '@/components/ui/tooltip';
|
import { AppTooltip } from '@/components/ui/tooltip';
|
||||||
|
@ -14,13 +18,13 @@ import { cn } from '@/lib/utils';
|
||||||
export type BusterChatInputMode = 'auto' | 'research' | 'deep-research';
|
export type BusterChatInputMode = 'auto' | 'research' | 'deep-research';
|
||||||
|
|
||||||
type BusterChatInputButtons = {
|
type BusterChatInputButtons = {
|
||||||
onSubmit: () => void;
|
onSubmit: (value: string) => void;
|
||||||
onStop: () => void;
|
onStop: () => void;
|
||||||
submitting: boolean;
|
submitting: boolean;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
mode: BusterChatInputMode;
|
mode: BusterChatInputMode;
|
||||||
onModeChange: (mode: BusterChatInputMode) => void;
|
onModeChange: (mode: BusterChatInputMode) => void;
|
||||||
onDictate: (transcript: string) => void;
|
onDictate?: (transcript: string) => void;
|
||||||
onDictateListeningChange?: (listening: boolean) => void;
|
onDictateListeningChange?: (listening: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +41,8 @@ export const BusterChatInputButtons = React.memo(
|
||||||
}: BusterChatInputButtons) => {
|
}: BusterChatInputButtons) => {
|
||||||
const { transcript, listening, browserSupportsSpeechRecognition } = useSpeechRecognition();
|
const { transcript, listening, browserSupportsSpeechRecognition } = useSpeechRecognition();
|
||||||
const hasValue = useMentionInputHasValue();
|
const hasValue = useMentionInputHasValue();
|
||||||
|
const onChangeValue = useMentionInputSuggestionsOnChangeValue();
|
||||||
|
const getValue = useMentionInputSuggestionsGetValue();
|
||||||
|
|
||||||
const disableSubmit = !hasValue;
|
const disableSubmit = !hasValue;
|
||||||
|
|
||||||
|
@ -50,9 +56,10 @@ export const BusterChatInputButtons = React.memo(
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (listening && transcript) {
|
if (listening && transcript) {
|
||||||
onDictate(transcript);
|
onDictate?.(transcript);
|
||||||
|
onChangeValue(transcript);
|
||||||
}
|
}
|
||||||
}, [listening, transcript, onDictate]);
|
}, [listening, transcript, onDictate, onChangeValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onDictateListeningChange?.(listening);
|
onDictateListeningChange?.(listening);
|
||||||
|
@ -88,7 +95,7 @@ export const BusterChatInputButtons = React.memo(
|
||||||
rounding={'large'}
|
rounding={'large'}
|
||||||
variant={'default'}
|
variant={'default'}
|
||||||
prefix={<ArrowUp />}
|
prefix={<ArrowUp />}
|
||||||
onClick={submitting ? onStop : onSubmit}
|
onClick={submitting ? onStop : () => onSubmit(getValue?.()?.transformedValue ?? '')}
|
||||||
loading={submitting}
|
loading={submitting}
|
||||||
disabled={disabled || disableSubmit}
|
disabled={disabled || disableSubmit}
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|
Loading…
Reference in New Issue