From b900fe0b8b87699e71cb02b5d356279f9642960b Mon Sep 17 00:00:00 2001 From: Rankin Zheng Date: Thu, 3 Aug 2023 16:47:26 +0800 Subject: [PATCH] Move InputMessage and related files to components folder - Moved InputMessage and InputContexts from views to components folder. - Updated import paths for InputMessage in ChatPanel.tsx. - Adjusted import paths for inputSlice and chatSlice in InputMessage and InputContexts. - Improved code formatting in InputMessage.tsx. --- src/views/ChatPanel.tsx | 2 +- .../InputMessage}/InputContexts.tsx | 2 +- .../InputMessage/index.tsx} | 42 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) rename src/views/{ => components/InputMessage}/InputContexts.tsx (99%) rename src/views/{InputMessage.tsx => components/InputMessage/index.tsx} (94%) diff --git a/src/views/ChatPanel.tsx b/src/views/ChatPanel.tsx index 1ea37a8..e11822f 100644 --- a/src/views/ChatPanel.tsx +++ b/src/views/ChatPanel.tsx @@ -25,7 +25,7 @@ import { startSystemMessage, } from './chatSlice'; -import InputMessage from './InputMessage'; +import InputMessage from '@/views/components/InputMessage'; import MessageContainer from './MessageContainer'; import { clearContexts, setValue } from './inputSlice'; diff --git a/src/views/InputContexts.tsx b/src/views/components/InputMessage/InputContexts.tsx similarity index 99% rename from src/views/InputContexts.tsx rename to src/views/components/InputMessage/InputContexts.tsx index a9de484..28e3a9a 100644 --- a/src/views/InputContexts.tsx +++ b/src/views/components/InputMessage/InputContexts.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from '@/views/hooks'; import { selectContexts, removeContext, -} from './inputSlice'; +} from '@/views/inputSlice'; const InputContexts = () => { const dispatch = useAppDispatch(); diff --git a/src/views/InputMessage.tsx b/src/views/components/InputMessage/index.tsx similarity index 94% rename from src/views/InputMessage.tsx rename to src/views/components/InputMessage/index.tsx index 338741d..a0fe510 100644 --- a/src/views/InputMessage.tsx +++ b/src/views/components/InputMessage/index.tsx @@ -2,10 +2,10 @@ import { useMantineTheme, Flex, Stack, Accordion, Box, ActionIcon, ScrollArea, C import { useListState, useResizeObserver } from "@mantine/hooks"; import { IconGitBranch, IconBook, IconX, IconSquareRoundedPlus, IconSend } from "@tabler/icons-react"; import React, { useState, useEffect } from "react"; -import { IconGitBranchChecked, IconShellCommand, IconMouseRightClick } from "./Icons"; +import { IconGitBranchChecked, IconShellCommand, IconMouseRightClick } from "../../Icons"; import messageUtil from '@/util/MessageUtil'; import { useAppDispatch, useAppSelector } from '@/views/hooks'; -import InputContexts from '@/views/InputContexts'; +import InputContexts from './InputContexts'; import { setValue, @@ -23,12 +23,12 @@ import { closeMenu, fetchContextMenus, fetchCommandMenus, -} from './inputSlice'; +} from '@/views/inputSlice'; import { selectGenerating, newMessage, startGenerating, -} from './chatSlice'; +} from '@/views/chatSlice'; const InputMessage = (props: any) => { const { width } = props; @@ -64,23 +64,23 @@ const InputMessage = (props: any) => { dispatch(setValue(value)); }; -const handleSendClick = (event: React.MouseEvent) => { - if (input) { - // Process and send the message to the extension - const contextInfo = contexts.map((item: any, index: number) => { - const { file, context } = item; - return { file, context }; - }); - const text = input; - // Add the user's message to the chat UI - dispatch(newMessage({ type: 'user', message: input, contexts: contexts ? [...contexts].map((item) => ({ ...item })) : undefined })); - // start generating - dispatch(startGenerating({ text, contextInfo })); - // Clear the input field - dispatch(setValue('')); - dispatch(clearContexts()); - } -}; + const handleSendClick = (event: React.MouseEvent) => { + if (input) { + // Process and send the message to the extension + const contextInfo = contexts.map((item: any, index: number) => { + const { file, context } = item; + return { file, context }; + }); + const text = input; + // Add the user's message to the chat UI + dispatch(newMessage({ type: 'user', message: input, contexts: contexts ? [...contexts].map((item) => ({ ...item })) : undefined })); + // start generating + dispatch(startGenerating({ text, contextInfo })); + // Clear the input field + dispatch(setValue('')); + dispatch(clearContexts()); + } + }; const handleContextClick = (contextName: string) => { // Process and send the message to the extension