diff --git a/src/views/components/InputMessage/index.tsx b/src/views/components/InputMessage/index.tsx index f8e22f7..5a73717 100644 --- a/src/views/components/InputMessage/index.tsx +++ b/src/views/components/InputMessage/index.tsx @@ -33,7 +33,6 @@ const useStyles = createStyles((theme) => ({ const InputMessage = observer((props: any) => { const {classes} = useStyles(); - const { chatPanelWidth } = props; const { input, chat } = useMst(); const { contexts, menuOpend, menuType, currentMenuIndex, contextMenus, commandMenus,modelMenus } = input; const { generating } = chat; @@ -320,7 +319,7 @@ const InputMessage = observer((props: any) => { }} > { { input.closeMenu(); diff --git a/src/views/components/MessageBody/index.tsx b/src/views/components/MessageBody/index.tsx index 10bc9a8..6be4b12 100644 --- a/src/views/components/MessageBody/index.tsx +++ b/src/views/components/MessageBody/index.tsx @@ -1,22 +1,35 @@ -import { Container } from "@mantine/core"; +import { Container, createStyles } from "@mantine/core"; import React from "react"; import { observer } from "mobx-react-lite"; import MessageMarkdown from "@/views/components/MessageMarkdown"; +import { useMst } from "@/views/stores/RootStore"; interface IProps { messageText: string, messageType: string } + +const useStyles = createStyles((theme, options:any) => ({ + bodyWidth:{ + width: options.chatPanelWidth - 20, + } +})); + const MessageBody = observer((props: IProps) => { const { messageText, messageType } = props; + const { chat } = useMst(); + const {classes} = useStyles({ + chatPanelWidth:chat.chatPanelWidth + }); return ( messageType === 'bot' - ? + ? {messageText} : { + children: string, + className: string } -const MessageMarkdown = observer((props: IProps) => { - const { messageText } = props; +const MessageMarkdown = observer((props: MessageMarkdownProps) => { + const { children } = props; const { chat } = useMst(); const LanguageCorner = (props: any) => { @@ -133,6 +134,7 @@ Generate a professionally written and formatted release note in markdown with th }; return ; } - }}> - {messageText} + } + }> + {children} ; }); diff --git a/src/views/pages/ChatPanel.tsx b/src/views/pages/ChatPanel.tsx index b1a90e8..1c592fc 100644 --- a/src/views/pages/ChatPanel.tsx +++ b/src/views/pages/ChatPanel.tsx @@ -29,7 +29,7 @@ const chatPanel = observer(() => { const [chatContainerRef, chatContainerRect] = useResizeObserver(); const scrollViewport = useRef(null); - const { height, width } = useViewportSize(); + const { height } = useViewportSize(); const { ref:inputAreatRef, height:inputAreaHeight } = useElementSize(); @@ -137,6 +137,10 @@ const chatPanel = observer(() => { scrollToBottom(); }, [chat.scrollBottom]); + useEffect(() => { + chat.updateChatPanelWidth(chatPanelWidth); + },[chatPanelWidth]); + return ( { onScrollPositionChange={onScrollPositionChange} viewportRef={scrollViewport} > - + {chat.errorMessage && ( { }} title="Bottom" variant="transparent" - sx={{ position: "absolute", bottom: 5, right: 16, zIndex: 1 }} + sx={{ position: "absolute", bottom: 5, right: 16, zIndex: 2 }} > @@ -218,7 +228,7 @@ const chatPanel = observer(() => { borderTop:'1px solid #ced4da', }} > - + ); diff --git a/src/views/stores/ChatStore.ts b/src/views/stores/ChatStore.ts index 633ca30..2d058b1 100644 --- a/src/views/stores/ChatStore.ts +++ b/src/views/stores/ChatStore.ts @@ -76,6 +76,7 @@ export const ChatStore = types.model('Chat', { isTop: false, scrollBottom: 0, chatModel: 'GPT-3.5', + chatPanelWidth: 300, rechargeSite: 'https://devchat.ai/pricing/', features: types.optional(types.frozen(), {}) }) @@ -114,6 +115,9 @@ You can configure DevChat from [Settings](#settings).`; return { helpMessage, + updateChatPanelWidth: (width: number) => { + self.chatPanelWidth = width; + }, changeChatModel: (chatModel: string) => { self.chatModel = chatModel; },