diff --git a/src/components/chat-view/Chat.tsx b/src/components/chat-view/Chat.tsx index 6e47337..9706bfc 100644 --- a/src/components/chat-view/Chat.tsx +++ b/src/components/chat-view/Chat.tsx @@ -41,9 +41,9 @@ import { openSettingsModalWithError } from '../../utils/open-settings-modal' import { PromptGenerator } from '../../utils/prompt-generator' import AssistantMessageActions from './AssistantMessageActions' -import ChatUserInput, { ChatUserInputRef } from './chat-input/ChatUserInput' +import PromptInputWithActions, { ChatUserInputRef } from './chat-input/PromptInputWithActions' import { editorStateToPlainText } from './chat-input/utils/editor-state-to-plain-text' -import { ChatListDropdown } from './ChatListDropdown' +import { ChatHistory } from './ChatHistory' import QueryProgress, { QueryProgressState } from './QueryProgress' import ReactMarkdown from './ReactMarkdown' import ShortcutInfo from './ShortcutInfo' @@ -557,7 +557,7 @@ const Chat = forwardRef((props, ref) => { > - { @@ -583,7 +583,7 @@ const Chat = forwardRef((props, ref) => { className="infio-chat-list-dropdown" > - +
@@ -604,21 +604,9 @@ const Chat = forwardRef((props, ref) => { {chatMessages.map((message, index) => message.role === 'user' ? (
- registerChatUserInputRef(message.id, ref)} initialSerializedEditorState={message.content} - onChange={(content) => { - setChatMessages((prevChatHistory) => - prevChatHistory.map((msg) => - msg.role === 'user' && msg.id === message.id - ? { - ...msg, - content, - } - : msg, - ), - ) - }} onSubmit={(content, useVaultSearch) => { if (editorStateToPlainText(content).trim() === '') return handleSubmit( @@ -674,16 +662,10 @@ const Chat = forwardRef((props, ref) => { )}
- registerChatUserInputRef(inputMessage.id, ref)} initialSerializedEditorState={inputMessage.content} - onChange={(content) => { - setInputMessage((prevInputMessage) => ({ - ...prevInputMessage, - content, - })) - }} onSubmit={(content, useVaultSearch) => { if (editorStateToPlainText(content).trim() === '') return handleSubmit( diff --git a/src/components/chat-view/ChatListDropdown.tsx b/src/components/chat-view/ChatHistory.tsx similarity index 99% rename from src/components/chat-view/ChatListDropdown.tsx rename to src/components/chat-view/ChatHistory.tsx index 1ecbda8..7ceb170 100644 --- a/src/components/chat-view/ChatListDropdown.tsx +++ b/src/components/chat-view/ChatHistory.tsx @@ -106,7 +106,7 @@ function ChatListItem({ ) } -export function ChatListDropdown({ +export function ChatHistory({ chatList, currentConversationId, onSelect, diff --git a/src/components/chat-view/chat-input/ChatUserInput.tsx b/src/components/chat-view/chat-input/PromptInputWithActions.tsx similarity index 96% rename from src/components/chat-view/chat-input/ChatUserInput.tsx rename to src/components/chat-view/chat-input/PromptInputWithActions.tsx index f8f9002..cdb0624 100644 --- a/src/components/chat-view/chat-input/ChatUserInput.tsx +++ b/src/components/chat-view/chat-input/PromptInputWithActions.tsx @@ -33,7 +33,6 @@ import { ModelSelect } from './ModelSelect' import { MentionNode } from './plugins/mention/MentionNode' import { NodeMutations } from './plugins/on-mutation/OnMutationPlugin' import { SubmitButton } from './SubmitButton' -import { VaultChatButton } from './VaultChatButton' export type ChatUserInputRef = { focus: () => void @@ -41,7 +40,7 @@ export type ChatUserInputRef = { export type ChatUserInputProps = { initialSerializedEditorState: SerializedEditorState | null - onChange: (content: SerializedEditorState) => void + onChange?: (content: SerializedEditorState) => void onSubmit: (content: SerializedEditorState, useVaultSearch?: boolean) => void onFocus: () => void mentionables: Mentionable[] @@ -50,7 +49,7 @@ export type ChatUserInputProps = { addedBlockKey?: string | null } -const ChatUserInput = forwardRef( +const PromptInputWithActions = forwardRef( ( { initialSerializedEditorState, @@ -279,11 +278,6 @@ const ChatUserInput = forwardRef(
handleSubmit()} /> - {/* { - handleSubmit({ useVaultSearch: true }) - }} - /> */}
@@ -369,6 +363,6 @@ function MentionableContentPreview({ ) : null } -ChatUserInput.displayName = 'ChatUserInput' +PromptInputWithActions.displayName = 'ChatUserInput' -export default ChatUserInput +export default PromptInputWithActions diff --git a/src/components/chat-view/chat-input/VaultChatButton.tsx b/src/components/chat-view/chat-input/VaultChatButton.tsx deleted file mode 100644 index b6cbb43..0000000 --- a/src/components/chat-view/chat-input/VaultChatButton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import * as Tooltip from '@radix-ui/react-tooltip' -import { - ArrowBigUp, - ChevronUp, - Command, - CornerDownLeftIcon, -} from 'lucide-react' -import { Platform } from 'obsidian' - -export function VaultChatButton({ onClick }: { onClick: () => void }) { - return ( - <> - - - - - - - - Chat with your entire vault - - - - - - ) -} diff --git a/src/components/chat-view/chat-input/plugins/template/TemplatePlugin.tsx b/src/components/chat-view/chat-input/plugins/template/TemplatePlugin.tsx index 11abcdd..69b4596 100644 --- a/src/components/chat-view/chat-input/plugins/template/TemplatePlugin.tsx +++ b/src/components/chat-view/chat-input/plugins/template/TemplatePlugin.tsx @@ -1,9 +1,9 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext' import clsx from 'clsx' import { - $parseSerializedNode, - COMMAND_PRIORITY_NORMAL, - TextNode, + $parseSerializedNode, + COMMAND_PRIORITY_NORMAL, + TextNode, } from 'lexical' import { Trash2 } from 'lucide-react' import { useCallback, useEffect, useMemo, useState } from 'react' @@ -13,8 +13,8 @@ import { useDatabase } from '../../../../../contexts/DatabaseContext' import { SelectTemplate } from '../../../../../database/schema' import { MenuOption } from '../shared/LexicalMenu' import { - LexicalTypeaheadMenuPlugin, - useBasicTypeaheadTriggerMatch, + LexicalTypeaheadMenuPlugin, + useBasicTypeaheadTriggerMatch, } from '../typeahead-menu/LexicalTypeaheadMenuPlugin' class TemplateTypeaheadOption extends MenuOption {