diff --git a/app/src/components/input.tsx b/app/src/components/input.tsx index c3c4e00..7198858 100644 --- a/app/src/components/input.tsx +++ b/app/src/components/input.tsx @@ -192,7 +192,7 @@ export default function MessageInput(props: MessageInputProps) { }, [initialMessage, transcript, recording, transcribing, useOpenAIWhisper, dispatch]); const onKeyDown = useCallback((e: React.KeyboardEvent) => { - if(e.key === 'Enter' && e.shiftKey === false && !props.disabled && isEnterToSend) { + if(e.key === 'Enter' && e.shiftKey === false && !props.disabled) { e.preventDefault(); onSubmit(); } @@ -276,9 +276,6 @@ export default function MessageInput(props: MessageInputProps) { rightSectionWidth={context.generating ? 100 : 55} onKeyDown={onKeyDown} />
-
- setIsEnterToSend(!v.currentTarget.checked)}/> -
)} +

+ +

; } diff --git a/app/src/components/settings/user.tsx b/app/src/components/settings/user.tsx index 474e3be..7532f43 100644 --- a/app/src/components/settings/user.tsx +++ b/app/src/components/settings/user.tsx @@ -1,12 +1,14 @@ import SettingsTab from "./tab"; import SettingsOption from "./option"; -import { Checkbox, TextInput } from "@mantine/core"; +import { Button, Checkbox, TextInput } from "@mantine/core"; import { useCallback, useMemo } from "react"; import { useAppDispatch, useAppSelector } from "../../store"; import { selectOpenAIApiKey, setOpenAIApiKeyFromEvent, selectUseOpenAIWhisper, setUseOpenAIWhisperFromEvent } from "../../store/api-keys"; import { selectSettingsOption } from "../../store/settings-ui"; import { FormattedMessage, useIntl } from "react-intl"; import { supportsSpeechRecognition } from "../../speech-recognition-types"; +import { useAppContext } from "../../context"; +import { serializeChat } from "../../types"; export default function UserOptionsTab(props: any) { const option = useAppSelector(selectSettingsOption); @@ -18,8 +20,35 @@ export default function UserOptionsTab(props: any) { const onOpenAIApiKeyChange = useCallback((event: React.ChangeEvent) => dispatch(setOpenAIApiKeyFromEvent(event)), [dispatch]); const onUseOpenAIWhisperChange = useCallback((event: React.ChangeEvent) => dispatch(setUseOpenAIWhisperFromEvent(event)), [dispatch]); + const context = useAppContext(); + const getData = useCallback(async () => { + const chats = Array.from(context.chat.chats.values()); + return chats.map(chat => ({ + ...chat, + messages: chat.messages.serialize(), + })); + }, [context.chat]); + + const handleExport = useCallback(async () => { + const data = await getData(); + const json = JSON.stringify(data); + const blob = new Blob([json], { type: "application/json" }); + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = "chat-with-gpt.json"; + link.click(); + }, [getData]); + const elem = useMemo(() => ( + +
+ +
+