948 Commits

Author SHA1 Message Date
bobo.yang
3462248cb8 update unit test 2023-07-24 00:11:56 +08:00
bobo.yang
c41fe6906b Remove unnecessary comment in contextManager
- Remove comment "// 处理所有命令" from processText method.
2023-07-24 00:11:56 +08:00
bobo.yang
944e4e0c9b Update customAction and add tests
- Change temp subdirectory from 'devchat/context' to 'devchat/action'.
- Add check for tempFile existence before unlinking.
- Add new test cases for actionManager and customAction.
2023-07-24 00:11:56 +08:00
bobo.yang
1a75347bd1 Refactor variable names and improve condition checks
- Rename WaitCreateTopic to waitCreateTopic for consistency.
- Update condition check to use parsedMessage.instruction.
2023-07-24 00:11:56 +08:00
bobo.yang
bf531a8fd6 Allow outputFile to be undefined in runCommandStringAndWriteOutput
- Change outputFile parameter type to string | undefined.
- Update function to handle cases when outputFile is undefined.
2023-07-24 00:11:56 +08:00
bobo.yang
f19feef302 Load and save custom actions in DevChatViewProvider
- Import CustomActions from '../action/customAction'.
- Load custom actions from the workflows directory.
- Save action instruction file to the .chat directory.
2023-07-24 00:11:56 +08:00
bobo.yang
78d1db75f5 Improve applyAction function and add error handling
- Add compressText function to truncate long text.
- Wrap applyAction in try-catch block for error handling.
- Send error message to devchat if codeBlock type is 'command'.
2023-07-24 00:11:56 +08:00
bobo.yang
d99548b3a0 Add unit tests for actions with valid and empty args
- Add a test case for applying an action with valid args.
- Add a test case for applying an action with empty args.
2023-07-24 00:11:56 +08:00
bobo.yang
dc96991fca Refactor symbol reference and definition handling
- Extracted getSelectedSymbol function to improve code readability.
- Fixed the scope of refLocations variable to avoid reference error.
- Added error handling for vscode.executeReferenceProvider command.
- Refactored the way symbol references are retrieved and handled.
- Improved the logic for getting symbol definitions.
2023-07-24 00:11:56 +08:00
bobo.yang
5cf0828a93 Refine context descriptions and add checks for selected text
- Updated descriptions for 'symbol references' and 'symbol definitions' contexts for clarity.
- Added checks to return early if no text has been selected in both contexts.
- Removed unnecessary logging of selected text and files list.
- Added logic to handle cases where symbol kind is a variable.
- Removed redundant logging of reference URI and range.
2023-07-24 00:11:56 +08:00
bobo.yang
77493db13f Add symbol references and definitions contexts
- Created two new contexts for symbol references and definitions.
- Updated the handler in ChatContext interface to return an array of strings.
- Updated the processText method in ChatContextManager to return an array of strings.
- Registered the new contexts in loadContexts.ts.
- Updated the addContext function to handle multiple context strings.
2023-07-24 00:11:56 +08:00
bobo.yang
c1b8ee2f88 Update message deletion and topic management
- Added a check in deleteChatMessageBase to remove the message from the current topic if deletion is successful.
- Modified updateFirstMessageHashAndName in Topic class to accept undefined values.
- Added a new method deleteMessage in TopicManager to update the topic when a message is deleted.
2023-07-21 17:17:43 +08:00
Rankin Zheng
2695f9829a
Merge pull request #210 from devchat-ai/52-i-hope-that-chat-messages-in-devchat-can-be-selectively-deleted
Modify parent_hash assignment in sendMessage command
2023-07-19 17:00:57 +08:00
Rankin Zheng
318540c632 Modify parent_hash assignment in sendMessage command
- Updated the assignment of parent_hash in the sendMessage command to be null when lastNonEmptyHash is 'message'.
2023-07-19 16:52:13 +08:00
Rankin Zheng
03a698e38a
Merge pull request #209 from devchat-ai/52-i-hope-that-chat-messages-in-devchat-can-be-selectively-deleted
52 i hope that chat messages in devchat can be selectively deleted
2023-07-19 16:17:35 +08:00
Rankin Zheng
1a2c31badf Refactor deleteMessage handler and remove debugger statement
- Updated the 'deleteChatMessage' handler to directly access the hash from the message object.
- Removed a debugger statement from the 'deleteMessage.fulfilled' case in chatSlice.
2023-07-19 16:15:26 +08:00
bobo.yang
3136283970 Update DevChat dependency check and configuration update
- Added version check for DevChat in checkDevChatDependency function.
- Updated configuration in both Global and Workspace scopes.
- Commented out the initial DevChat check in install.py and added --force flag to pip install command.
2023-07-19 16:06:45 +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
bobo.yang
70be0acd16 Refactor delete method in DevChat class
- Un-commented and updated the delete method logic.
- Added logging for the devchat command execution.
- Added error handling for stderr, failure to delete prompt, and non-zero exit code.
2023-07-18 23:11:28 +08:00
bobo.yang
0ceab66eb6 Fix deleteChatMessage functionality
- Changed the deleteChatMessageBase function call to be awaited.
- Adjusted the condition to send a 'deletedChatMessage' command only when the message is successfully deleted.
2023-07-18 22:54:08 +08:00
Rankin Zheng
38598d1fde Add functionality to find last non-empty hash
- Introduced a loop to iterate over the state.messages array in reverse order.
- The loop finds the last message with a non-empty hash and assigns it to lastNonEmptyHash.
- The parent_hash of the new message is now set to lastNonEmptyHash.
2023-07-18 19:54:57 +08:00
Rankin Zheng
d7105b9c5e Remove debugger 2023-07-18 19:36:25 +08:00
Rankin Zheng
819fe9f302 Refactor InputContexts into a separate component
- Created a new file `InputContexts.tsx` and moved the `InputContexts` component from `InputMessage.tsx` to this new file.
- Imported `InputContexts` in `InputMessage.tsx` and removed the old `InputContexts` component definition.
- This change improves code organization and readability by separating concerns.
2023-07-18 18:10:55 +08:00
Rankin Zheng
8258d7e01a Implement delete message functionality
- Added a new `deleteMessage` function in `chatSlice.ts` to handle message deletion.
- Modified `MessageContainer.tsx` and `MessageHeader.tsx` to pass the entire message item instead of individual properties.
- Updated the `showDelete` prop in `MessageContainer.tsx` to only show the delete icon for the second last message.
- Dispatch the `deleteMessage` action when the delete icon is clicked in `MessageHeader.tsx`.
- Updated the message structure in `chatSlice.ts` to include `date` and `hash` properties.
- Added a case for `deleteMessage.fulfilled` in `chatSlice.ts` to remove the deleted message from the state.
2023-07-17 21:07:42 +08:00
Rankin Zheng
21fb29f72c Add delete icon to MessageHeader component
- Imported IconTrash from "@tabler/icons-react" in MessageHeader.tsx.
- Added a new prop 'showDelete' to the MessageHeader component with a default value of true.
- Added a new Tooltip for the delete icon with the label "Delete message".
- The delete icon is conditionally rendered based on the 'showDelete' prop.
2023-07-17 20:31:01 +08:00
Rankin Zheng
90d0064e15 Add edit message functionality to MessageHeader
- Imported SimpleGrid and IconEdit from respective libraries in MessageHeader.tsx.
- Added a new prop 'showEdit' to MessageHeader component to conditionally show the edit icon.
- Wrapped the refill prompt and edit message icons in a Flex container for better alignment.
- Added a Tooltip and ActionIcon for the edit message functionality.
2023-07-17 20:31:01 +08:00
Rankin Zheng
ac1d9705ec Refactor MessageHeader into a separate component
- Extracted MessageHeader from MessageContainer.tsx into its own file MessageHeader.tsx.
- Removed unused imports from MessageContainer.tsx.
- Added necessary imports to MessageHeader.tsx.
- Updated MessageContainer.tsx to import MessageHeader from the new file.
2023-07-17 20:31:01 +08:00
bobo.yang
3819d7679c Refactor parent hash handling in sendMessageBase.ts
- Replaced the getParentHash function with direct access to message.parent_hash.
- Updated the handleTopic function to accept undefined parentHash.
- This simplifies the code and makes the parent hash handling more straightforward.
2023-07-17 20:31:01 +08:00
bobo.yang
1957ddd280 Add delete chat message functionality
- Removed 'Cancel' option from topicDeleteCallback in commands.ts.
- Imported deleteChatMessage in loadHandlers.ts and registered it as a handler.
- Added deleteChatMessage function in sendMessage.ts to prompt user for confirmation before deleting a message.
- Added deleteChatMessageBase function in sendMessageBase.ts to delete a message from messageHistory and by devchat.
- Added delete function in devchat.ts to delete a message by hash.
- Added delete function in messageHistory.ts to remove a message from history by hash.
2023-07-17 18:56:56 +08:00
bobo.yang
b057d93593 Add log message for successful DevChat installation check
- Added a log message in commandsBase.ts to confirm successful DevChat installation check.
2023-07-12 17:37:00 +08:00
bobo.yang
116defdec7 Refactor install.py and statusBarViewBase.ts
- Added pip_cmd_run and pip_cmd_with_retries functions in install.py to handle pip command execution and retries.
- Simplified the installation of devchat and virtualenv in install.py using the new functions.
- Removed unnecessary checks in statusBarViewBase.ts.
2023-07-12 14:04:08 +08:00
bobo.yang
b4d21be26c update install 2023-07-12 09:02:00 +08:00
bobo.yang
15141dd6ff Refactor error handling and logging in DevChat dependency check
- Added a new optional parameter 'showError' in checkDevChatDependency function in commandsBase.ts.
- Updated the conditions for logging error messages in checkDevChatDependency function.
- Updated the call to checkDevChatDependency in dependencyCheck function in statusBarViewBase.ts to pass 'showError' parameter.
- Updated the condition for logging stderr in CommandRun class in commonUtil.ts.
2023-07-07 08:56:28 +08:00
bobo.yang
cfaff1d3d6 Update DevChat installation process and status check
- Increased the runStatus check interval from 20 to 60 in statusBarView.ts.
- Added a new import, CommandRun, in statusBarViewBase.ts.
- Updated the conditions for checking devchatStatus in dependencyCheck function.
- Replaced the terminal run command for DevChat installation with a new CommandRun instance.
- Added error handling for the installation process, updating devchatStatus accordingly.
2023-07-06 11:52:00 +08:00
bobo.yang
46ea8cc436 Fix command execution in checkDevChatDependency function
- Enclosed the pipxDevChat command in quotes to ensure correct execution, especially when the path contains spaces.
2023-07-06 09:06:48 +08:00
bobo.yang
8f846e2d62 Refactor checkDevChatDependency function in commandsBase.ts
- Imported path module for handling file paths.
- Added pipxBinPath variable to store the pipx environment path.
- Changed error logging level from error to warn.
- Updated the way DevChat command is run and its path is updated.
2023-07-06 07:42:44 +08:00
bobo.yang
1019658bf2 Refactor DevChat class in devchat.ts
- Added a semicolon after the object declaration for better code readability.
- Added a line break for better code structure and readability.
2023-07-06 07:42:44 +08:00
bobo.yang
e53b0576b3 Refactor command location and DevChat installation
- Updated the locateCommand function to split the output of the 'where' and 'which' commands and return the first line.
- Modified the DevChat installation command to include the path in quotes to handle paths with spaces.
2023-07-06 07:42:44 +08:00
bobo.yang
e6f184cfe6 update devchat check logic 2023-07-06 07:42:44 +08:00
bobo.yang
8bc7f63c09 Add API key validation and pip installation check
- Added a check in commands.ts to validate the API key when setting it.
- If the API key is invalid, an error message is displayed to the user.
- Added a function in install.py to ensure pip is installed.
- This function attempts to install and upgrade pip using the ensurepip module.
- The function is called at the beginning of the main function in install.py.
2023-07-06 07:42:44 +08:00
bobo.yang
5bad06e967 Handle exceptions in dependencyCheck function
- Wrapped the version comparison logic in a try-catch block to handle potential exceptions.
- If an exception occurs, the isVersionChangeCompare flag is set to false.
- The version comparison is now only performed if the DevChat dependency check passes and the DevChat instance is not already initialized.
2023-07-06 07:42:44 +08:00
bobo.yang
d474957fe8 Add Python Path configuration and command to package.json
- Added a new configuration 'DevChat.PythonPath' in package.json.
- This configuration allows users to specify the location of the Python binary.
- Also added a new command 'DevChat.PythonPath' to the command palette.
- Updated commandsBase.ts to use the Python Path from the configuration.
- If the Python Path is not set in the configuration, it will use the default Python command.
- If the DevChat status is 'Missing required dependency: Python3', the status bar item will trigger the 'devchat.PythonPath' command.
2023-07-06 07:42:44 +08:00
bobo.yang
892c3638cc Add command to set Python Path in DevChat configuration
- Added a new command 'devchat.PythonPath' in commands.ts.
- This command prompts the user to input a Python Path and updates the DevChat configuration with the provided path.
- The new command is registered in the extension.ts file.
2023-07-06 07:42:44 +08:00
bobo.yang
f63f88e7f6 Add updateConfiguration method to UiUtil
- Added a new method updateConfiguration to the UiUtil interface.
- Implemented the updateConfiguration method in the UiUtilWrapper and UiUtilVscode classes.
- This method updates a given configuration key with a new value.
2023-07-06 07:42:44 +08:00
Rankin Zheng
b573dff2cf Enhance message copying and refilling in MessageContainer
- Imported CopyButton and Icon360 from respective libraries for improved functionality.
- Replaced the refill prompt icon with a 360 icon for better user understanding.
- Added a copy message functionality for bot messages with a tooltip indicating the copy status.
- Changed the state variable name from 'refilled' to 'done' for better context understanding.
2023-07-06 06:22:04 +08:00
Rankin Zheng
f58e2fe333 Improve text formatting in CodeBlock component
- Imported Container from "@mantine/core" for better layout control in CodeBlock.
- Wrapped the preformatted text in a Container to apply additional styles.
- Added 'whiteSpace: 'pre-wrap'' and 'wordBreak: 'break-word'' to preserve white spaces, line breaks and ensure long words do not overflow the container.
2023-07-06 06:12:55 +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
9f222f7d1a Update tooltip label in CodeBlock component
- Changed the tooltip label from 'Replace' to 'Replace File' in CodeBlock.tsx.
- This provides a clearer indication of the button's functionality.
2023-07-03 15:40:13 +08:00