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.
This commit is contained in:
Rankin Zheng 2023-08-03 16:47:26 +08:00
parent efd3bc0e14
commit b900fe0b8b
3 changed files with 23 additions and 23 deletions

View File

@ -25,7 +25,7 @@ import {
startSystemMessage, startSystemMessage,
} from './chatSlice'; } from './chatSlice';
import InputMessage from './InputMessage'; import InputMessage from '@/views/components/InputMessage';
import MessageContainer from './MessageContainer'; import MessageContainer from './MessageContainer';
import { clearContexts, setValue } from './inputSlice'; import { clearContexts, setValue } from './inputSlice';

View File

@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from '@/views/hooks';
import { import {
selectContexts, selectContexts,
removeContext, removeContext,
} from './inputSlice'; } from '@/views/inputSlice';
const InputContexts = () => { const InputContexts = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();

View File

@ -2,10 +2,10 @@ import { useMantineTheme, Flex, Stack, Accordion, Box, ActionIcon, ScrollArea, C
import { useListState, useResizeObserver } from "@mantine/hooks"; import { useListState, useResizeObserver } from "@mantine/hooks";
import { IconGitBranch, IconBook, IconX, IconSquareRoundedPlus, IconSend } from "@tabler/icons-react"; import { IconGitBranch, IconBook, IconX, IconSquareRoundedPlus, IconSend } from "@tabler/icons-react";
import React, { useState, useEffect } from "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 messageUtil from '@/util/MessageUtil';
import { useAppDispatch, useAppSelector } from '@/views/hooks'; import { useAppDispatch, useAppSelector } from '@/views/hooks';
import InputContexts from '@/views/InputContexts'; import InputContexts from './InputContexts';
import { import {
setValue, setValue,
@ -23,12 +23,12 @@ import {
closeMenu, closeMenu,
fetchContextMenus, fetchContextMenus,
fetchCommandMenus, fetchCommandMenus,
} from './inputSlice'; } from '@/views/inputSlice';
import { import {
selectGenerating, selectGenerating,
newMessage, newMessage,
startGenerating, startGenerating,
} from './chatSlice'; } from '@/views/chatSlice';
const InputMessage = (props: any) => { const InputMessage = (props: any) => {
const { width } = props; const { width } = props;
@ -64,23 +64,23 @@ const InputMessage = (props: any) => {
dispatch(setValue(value)); dispatch(setValue(value));
}; };
const handleSendClick = (event: React.MouseEvent<HTMLButtonElement>) => { const handleSendClick = (event: React.MouseEvent<HTMLButtonElement>) => {
if (input) { if (input) {
// Process and send the message to the extension // Process and send the message to the extension
const contextInfo = contexts.map((item: any, index: number) => { const contextInfo = contexts.map((item: any, index: number) => {
const { file, context } = item; const { file, context } = item;
return { file, context }; return { file, context };
}); });
const text = input; const text = input;
// Add the user's message to the chat UI // Add the user's message to the chat UI
dispatch(newMessage({ type: 'user', message: input, contexts: contexts ? [...contexts].map((item) => ({ ...item })) : undefined })); dispatch(newMessage({ type: 'user', message: input, contexts: contexts ? [...contexts].map((item) => ({ ...item })) : undefined }));
// start generating // start generating
dispatch(startGenerating({ text, contextInfo })); dispatch(startGenerating({ text, contextInfo }));
// Clear the input field // Clear the input field
dispatch(setValue('')); dispatch(setValue(''));
dispatch(clearContexts()); dispatch(clearContexts());
} }
}; };
const handleContextClick = (contextName: string) => { const handleContextClick = (contextName: string) => {
// Process and send the message to the extension // Process and send the message to the extension