55 Commits

Author SHA1 Message Date
Rankin Zheng
addc1bcd33 Remove unused ScrollArea type in ChatPanel.tsx
- Removed the unused type "never" for ScrollArea in ChatPanel.tsx.
2023-08-03 20:49:00 +08:00
Rankin Zheng
d7371149f1 Move MessageContainer to components folder
- Moved MessageContainer from views to components folder.
- Updated import path for MessageContainer in ChatPanel.tsx.
2023-08-03 17:02:02 +08:00
Rankin Zheng
7e2d622236 Move CurrentMessage to components folder
- Moved CurrentMessage from views to components folder.
2023-08-03 16:53:31 +08:00
Rankin Zheng
cec95185b3 Move chatSlice and inputSlice to reducers folder
- Moved chatSlice and inputSlice from views to reducers folder.
- Updated import paths for chatSlice and inputSlice in various files.
- Adjusted import paths for chatSlice and inputSlice in store.ts.
2023-08-03 16:49:30 +08:00
Rankin Zheng
b900fe0b8b 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.
2023-08-03 16:47:26 +08:00
Rankin Zheng
4acbf8a8eb Refactor chat panel and move buttons to components folder
- Moved StopButton and RegenerationButton from views to components folder.
- Updated import paths for StopButton and RegenerationButton in ChatPanel.tsx.
- Adjusted import paths for chatSlice in StopButton and RegenerationButton.
- Improved code formatting in ChatPanel.tsx.
2023-08-03 16:34:52 +08:00
Rankin Zheng
c60443e509
Merge pull request #215 from devchat-ai/128-extract-inline-styles-to-separate-css-files-in-react-component
128 extract inline styles to separate css files in react component
2023-07-24 13:06:30 +08:00
Rankin Zheng
3c2345af0b Refactor ChatPanel by extracting button components
- Extracted RegenerationButton and StopButton components from ChatPanel into separate files.
- Removed unused imports and state from ChatPanel.
- Updated ChatPanel to use the new button components.
2023-07-24 11:34:10 +08:00
bobo.yang
81fc4be2db Implement system message handling in chat panel
- Registered a new handler for 'systemMessage' in ChatPanel.
- Added a new action 'startSystemMessage' in chatSlice to handle system messages.
- The new action updates the state to indicate the start of a system message.
2023-07-24 08:21:25 +08:00
Rankin Zheng
8a5ecbc001 Enhance message handling in chatSlice
- Added condition to check if `action.payload.hasDone` is true, then update the hash of the last two messages in `state.messages`.
- Fixed the `splice` method in `deleteMessage.fulfilled` to correctly remove the message from `state.messages`.
- Updated `stopGenerating` dispatch in `ChatPanel.tsx` to include the message in the payload.
- Modified the delete message action in `MessageHeader.tsx` to handle the case when `item.hash` is not present.
2023-07-19 16:03:39 +08:00
Rankin Zheng
2d12c8978d Enhance CurrentMessage component with dynamic width and improved styling
- Passed dynamic width from ChatPanel to CurrentMessage component.
- Imported Container from "@mantine/core" for better layout control in CurrentMessage.
- Added styling to the CurrentMessage component to handle dynamic width and improve text display.
- Added 'whiteSpace: 'break-spaces'' to preserve white spaces and line breaks in the preformatted text.
2023-07-06 05:56:36 +08:00
Rankin Zheng
8773633d44 Update chat message handling and state management
- Modified the stopGenerating action to accept a payload indicating if the task has been completed.
- Added a new state property 'hasDone' to track if a task has been completed.
- Updated the CurrentMessage component to handle the new 'hasDone' state and update the last message accordingly.
- Introduced a new action 'updateLastMessage' to update the last message in the state.
- Added a new state property 'lastMessage' to keep track of the last message.
- Refactored the CurrentMessage component to split the message into blocks for better rendering.
2023-07-06 05:51:03 +08:00
Rankin Zheng
cb3a2cbc29 Refactor chat message handling and UI components
- Extracted current message handling logic into a new component, CurrentMessage.tsx.
- Removed redundant code and imports from ChatPanel.tsx.
- Removed MessageBlink component from MessageContainer.tsx as it's now part of CurrentMessage.tsx.
- Added import for CurrentMessage in ChatPanel.tsx.
- Removed unused selectors from ChatPanel.tsx.
- Simplified useEffect hooks in ChatPanel.tsx by moving some logic to CurrentMessage.tsx.
2023-07-05 15:00:20 +08:00
Rankin Zheng
fdbe1d0565 Temporarily disable message loading logic
- Comment out dispatch(fetchHistoryMessages) in ChatPanel.tsx.
- Add TODO comment explaining the reason for disabling the logic.
2023-06-15 20:52:33 +08:00
Rankin Zheng
439838bb21 Improve chat history pagination and fetching
- Remove selectMessageCount, selectIsMiddle, and related useEffect in ChatPanel.tsx.
- Add selectPageIndex and selectIsLastPage to chatSlice.ts.
- Update fetchHistoryMessages to accept pageIndex parameter.
- Modify chatSlice to handle pageIndex and isLastPage states.
2023-06-13 17:53:05 +08:00
Rankin Zheng
bcdc78d65f Update import paths with alias
- Replace relative import paths with '@/...' alias in multiple files.
- Update tsconfig.json to include paths configuration.
- Add alias configuration to webpack.config.js.
2023-06-13 17:03:48 +08:00
Rankin Zheng
9a906a1c0f Update ChatPanel to handle scroll position and message fetching
- Added selectors for isTop, isBottom, and isMiddle in chatSlice.
- Removed scrollPosition and stopScrolling states from ChatPanel.
- Added onScrollPositionChange function to handle scroll events.
- Dispatch onMessagesTop, onMessagesBottom, and onMessagesMiddle actions based on scroll position.
2023-06-13 11:54:31 +08:00
Rankin Zheng
ec440be005 Refactor history messages fetching
- Add fetchHistoryMessages async thunk in chatSlice.
- Replace messageUtil.sendMessage with dispatch(fetchHistoryMessages()) in ChatPanel.tsx.
- Remove redundant message handler registration in ChatPanel.tsx.
2023-06-13 11:11:29 +08:00
Rankin Zheng
b4a8839313 Refactor command menu fetching
- Remove messageUtil.sendMessage from ChatPanel.tsx.
- Add fetchCommandMenus to inputSlice using createAsyncThunk.
- Replace local commandMenus state with Redux store in InputMessage.tsx.
2023-06-13 10:12:13 +08:00
Rankin Zheng
e594ef75c5 Refactor context menu fetching
- Move context menu fetching to inputSlice using createAsyncThunk.
- Remove redundant message handler registration in InputMessage.tsx.
- Use fetched context menus from the Redux store.
2023-06-13 10:00:27 +08:00
Rankin Zheng
7f25e426b2 Refactor directory structure 2023-06-13 09:20:12 +08:00
Rankin Zheng
572513126e refactor: Move ChatPanel.tsx to ChatPanel/index.tsx
The ChatPanel.tsx file was moved to ChatPanel/index.tsx to better organize the project structure. The import statement for MessageUtil was also updated to reflect the new file path.
2023-05-17 20:41:31 +08:00
Rankin Zheng
335db745cc Update styles to match VSCode theme
- Use VSCode theme variables for colors and fonts in App.tsx and ChatPanel.tsx
- Update background, foreground, and border colors for various components
- Update hover and disabled states for buttons and icons
2023-05-16 21:25:37 +08:00
Rankin Zheng
8e4b010197 Update chat message sending shortcut and placeholder text
- Change the keyboard shortcut for sending a message from Ctrl+Enter to Enter without Shift
- Update the placeholder text to remove the reference to the old shortcut
2023-05-16 16:57:20 +08:00
Rankin Zheng
ba27e80ac1 feat: Adjust width of chat panel messages and scroll area
- Set message width to the width of the scroll viewport
- Set scroll area width to the width of the chat panel minus 2rem
2023-05-15 19:11:58 +08:00
Rankin Zheng
52555699fd Limit displayed chat history to 5 messages
- Added a messageCount constant to limit the number of displayed messages
- Removed excess messages when the message length exceeds double the messageCount
- Ensured only the last 5 messages are loaded from the history
2023-05-12 10:08:38 +08:00
Rankin Zheng
ad1ff0ed7f Fix chat panel content wrapping issue
Wrap chat panel content within a <pre> tag with overflowWrap set to 'normal' to prevent unintended line breaks.
2023-05-11 15:41:59 +08:00
Rankin Zheng
dcb0f3bced Add ScrollArea to Accordion.Panel in ChatPanel
- Wrapped the content inside Accordion.Panel with ScrollArea
- Set the height of ScrollArea to 300
- Changed 'mah' prop to 'h' for Accordion.Panel
2023-05-11 15:24:32 +08:00
Rankin Zheng
e7ccb132c9 Update Accordion styles in ChatPanel
- Adjust Accordion.Item and Accordion.Control styles for better layout
- Set max-height for Accordion.Panel to improve content display
2023-05-11 15:20:22 +08:00
Rankin Zheng
da14609a68 Improve chat scrolling and UI adjustments
- Add a setTimeout function to scrollToBottom in useEffect to ensure smooth scrolling when ChatPanel is mounted.
- Adjust the height of the ScrollArea based on the generating state.
- Move the "Stop generating" button to a more appropriate location in the UI.
- Update the display property of the blinking cursor for better visibility.
2023-05-11 15:10:05 +08:00
Rankin Zheng
7b8d9e2373 feat: Add history messages to ChatPanel
Add a new message handler to load history messages when the ChatPanel component is mounted. The handler receives a list of message entries and appends them to the messageHandlers state. Each entry contains a hash, user, date, request, response, and context. The context is an array of objects with a content and role property, which is parsed and added to the messageHandlers state as well.

Also, add a useEffect hook to the ChatPanel component to call the new message handler when the component is mounted.
2023-05-11 14:06:06 +08:00
Rankin Zheng
578e18044b feat: Add stop generating button
Add a button to stop generating messages during a dev chat session. The button is displayed when generating messages and stops the generation process when clicked. The button is represented by the IconPlayerStop icon from the Tabler Icons library. The button is disabled during message generation.
2023-05-11 14:06:06 +08:00
Rankin Zheng
3e9f428a0b feat: Add commit functionality to code blocks
This commit adds the ability to commit code blocks with the commit message syntax highlighting. The commit button appears only when the code block is a commit message. The commit button sends the commit message content to the server. The commit button changes color to teal when the commit is successful.
2023-05-11 12:35:14 +08:00
Rankin Zheng
a254f02824 feat: Add functionality to view, insert, and replace code in ChatPanel 2023-05-10 20:49:06 +08:00
Rankin Zheng
dd35eff4b4 feat: Add focus to input when chat menu is opened
Add focus to input when chat menu is opened to improve user experience. This commit modifies the onChange function in ChatPanel.tsx to set focus to the input field when the menu is opened.
2023-05-10 20:27:43 +08:00
Rankin Zheng
ea32ab6e24 Refactor ChatPanel to handle missing contexts
Refactored `ChatPanel` to handle missing contexts by adding conditional rendering for the `Accordion` and `contexts` map. Also, added `pre` tag styling to the message content.
2023-05-10 17:38:24 +08:00
Rankin Zheng
767933cf95 feat: add context to user messages
The user's message now includes a context object that contains the file and context information. This allows the extension to process the message more accurately. The context object is also displayed in the chat UI.
2023-05-10 17:38:24 +08:00
Rankin Zheng
26fb027c6c feat: Add context menu to DevChat
Added a context menu to DevChat that allows users to select code or file and right-click to add it as a context. The context is then added to the list of contexts in the chat panel.
2023-05-10 17:38:24 +08:00
Rankin Zheng
dd3e6a9fea feat: Add view-diff and insert icons to code block
Add view-diff and insert icons to code block for better user experience.
2023-05-10 17:38:24 +08:00
Rankin Zheng
e7634c442f feat: Add context menu to ChatPanel
Added a context menu to the ChatPanel component that allows users to quickly insert context-specific commands. The context menu is populated with items based on the `contexts` array.
2023-05-09 19:15:28 +08:00
Rankin Zheng
106b77d6de refactor: Add context and command registration to MessageUtil 2023-05-09 19:10:46 +08:00
Rankin Zheng
3d34a364bc feat: Add padding to chat container and focus on input on mount
Add a padding to the top of the chat container to prevent the first message from being hidden behind the input field. Also, focus on the input field when the chat panel mounts for better user experience.
2023-05-09 12:27:35 +08:00
Rankin Zheng
5bcd1fa42f Refactor chat panel to improve user experience
- Remove unused CSS class
- Add dynamic height to chat container
- Add smooth scrolling to bottom when new messages are received
- Fix input field width to match container width
- Use Mantine's useResizeObserver hook to get input field width
- Remove console.log statements
2023-05-09 12:13:22 +08:00
Rankin Zheng
f7c93f35a9 feat: Refactor ChatPanel component to show typing indicator 2023-05-09 10:38:28 +08:00
Rankin Zheng
8e59f2bc6b feat: Add functionality to display received messages in chat UI
Add useEffect hooks to display received messages in the chat UI as bot messages. Also, update the Input component to use Textarea and add the ability to send messages using Ctrl + Enter
2023-05-09 09:44:51 +08:00
Rankin Zheng
6328b868c8 feat: Add copy button to code blocks
Add a copy button to code blocks in ChatPanel.tsx. The copy button allows users to easily copy code snippets to their clipboard. The button is implemented using the CopyButton component from @mantine/core and the IconCopy and IconCheck components from @tabler/icons-react.
2023-05-07 20:00:51 +08:00
Rankin Zheng
9712d9a976 feat: Add react-syntax-highlighter and react-markdown to package.json
Add react-syntax-highlighter and react-markdown to package.json to enable syntax highlighting and markdown rendering in the chat panel.

Also, update ChatPanel.tsx to use ReactMarkdown instead of Remark for markdown rendering. Additionally, add SyntaxHighlighter from react-syntax-highlighter to render code blocks with syntax highlighting.
2023-05-07 18:27:01 +08:00
Rankin Zheng
287c4f1762 feat: Add focus to input on load and new commands to command menu
Add focus to input on load and new commands to command menu. Also, added new icons to the plus menu.
2023-05-07 01:19:48 +08:00
Rankin Zheng
5e78696e4f feat: Add message handling and display in chat panel
This commit adds message handling for sending and receiving messages between the chat panel and the extension. It also displays the messages in the chat panel. The messages are displayed as a list of messages, with each message containing an avatar and the message content. The message content is displayed using the `Remark` component from the `react-remark` library.
2023-05-07 00:50:03 +08:00
Rankin Zheng
12f4cfbd11 refactor: Create a singleton instance for MessageUtil
Create a singleton instance for MessageUtil to avoid multiple instances of the class. The instance is created only once and returned on subsequent calls. This commit also removes the creation of a new instance of MessageUtil in ChatPanel.tsx.
2023-05-06 17:03:25 +08:00