From 7a688ca32308506dd7545e059a4183c36093e20f Mon Sep 17 00:00:00 2001 From: Maciej Topor Date: Tue, 26 Sep 2023 22:55:18 +0200 Subject: [PATCH 1/4] Code refactor after review --- .vscode/launch.json | 54 +- LICENSE | 21 + README.md | 30 +- custom.d.ts | 4 + package.json | 9 +- src/constants.ts | 52 + src/types.ts | 1 + src/ui/GoButton.tsx | 8 +- src/ui/Header.tsx | 12 +- src/ui/Icons/MinionIconFill1.tsx | 22 + src/ui/Icons/MinionIconFill10.tsx | 22 + src/ui/Icons/MinionIconFill11.tsx | 22 + src/ui/Icons/MinionIconFill12.tsx | 22 + src/ui/Icons/MinionIconFill2.tsx | 22 + src/ui/Icons/MinionIconFill3.tsx | 34 + src/ui/Icons/MinionIconFill4.tsx | 58 + src/ui/Icons/MinionIconFill5.tsx | 22 + src/ui/Icons/MinionIconFill6.tsx | 34 + src/ui/Icons/MinionIconFill7.tsx | 40 + src/ui/Icons/MinionIconFill8.tsx | 22 + src/ui/Icons/MinionIconFill9.tsx | 22 + src/ui/Icons/MinionIconOutline1.tsx | 40 + src/ui/Icons/MinionIconOutline10.tsx | 34 + src/ui/Icons/MinionIconOutline11.tsx | 40 + src/ui/Icons/MinionIconOutline12.tsx | 34 + src/ui/Icons/MinionIconOutline2.tsx | 40 + src/ui/Icons/MinionIconOutline3.tsx | 39 + src/ui/Icons/MinionIconOutline4.tsx | 39 + src/ui/Icons/MinionIconOutline5.tsx | 39 + src/ui/Icons/MinionIconOutline6.tsx | 39 + src/ui/Icons/MinionIconOutline7.tsx | 39 + src/ui/Icons/MinionIconOutline8.tsx | 40 + src/ui/Icons/MinionIconOutline9.tsx | 40 + src/ui/Icons/index.ts | 25 + src/ui/MinionIconsFill.tsx | 237 -- src/ui/MinionIconsOutline.tsx | 441 --- src/ui/MinionTaskButtons.tsx | 20 +- src/ui/MinionTaskCollapseContent.tsx | 89 + src/ui/MinionTaskCollapseHeader.tsx | 97 + src/ui/MinionTaskComponent.tsx | 320 -- src/ui/MinionTaskListItem.tsx | 59 + src/ui/MinionTaskSelection.tsx | 37 + src/ui/MinionTaskTextField.tsx | 122 + ...kListComponent.tsx => MinionTasksList.tsx} | 12 +- src/ui/MissingApiKeyInfoMessage.tsx | 6 +- src/ui/ProgressBar.tsx | 2 +- src/ui/SideBarWebViewInnerComponent.tsx | 368 --- src/ui/Sidebar.tsx | 194 ++ src/ui/SidebarFooter.tsx | 26 + src/ui/SidebarSuggestions.tsx | 104 + src/ui/Spinner.tsx | 27 + src/ui/hooks/useSuggestions.ts | 106 + src/ui/useUserQueryPreview.tsx | 2 +- src/ui/utils/adjustTextAreaHeight.ts | 11 + src/ui/utils/blendColors.tsx | 4 +- src/ui/utils/getRobotOutlineIcons.ts | 14 + src/ui/utils/postMessageToVsCode.ts | 8 + src/vscode/VSCommandHistoryManager.ts | 8 +- src/vscode/VSEditorManager.ts | 2 +- src/vscode/VSLogProvider.ts | 5 +- src/vscode/VSMinionTaskAutoRunner.ts | 8 +- src/vscode/VSMinionTasksManager.ts | 67 +- src/vscode/VSOriginalContentProvider.ts | 4 +- src/vscode/VSViewProvider.ts | 55 +- src/vscode/extension.ts | 103 +- src/vscode/utils/extractExecutionIdFromUri.ts | 2 +- .../utils/findNewPositionForOldSelection.ts | 4 +- src/vscode/vscodeUtils.ts | 2 +- tsconfig.json | 5 +- webpack.config.js | 68 +- yarn.lock | 2599 ++++++----------- 71 files changed, 2997 insertions(+), 3262 deletions(-) create mode 100644 LICENSE create mode 100644 custom.d.ts create mode 100644 src/constants.ts create mode 100644 src/types.ts create mode 100644 src/ui/Icons/MinionIconFill1.tsx create mode 100644 src/ui/Icons/MinionIconFill10.tsx create mode 100644 src/ui/Icons/MinionIconFill11.tsx create mode 100644 src/ui/Icons/MinionIconFill12.tsx create mode 100644 src/ui/Icons/MinionIconFill2.tsx create mode 100644 src/ui/Icons/MinionIconFill3.tsx create mode 100644 src/ui/Icons/MinionIconFill4.tsx create mode 100644 src/ui/Icons/MinionIconFill5.tsx create mode 100644 src/ui/Icons/MinionIconFill6.tsx create mode 100644 src/ui/Icons/MinionIconFill7.tsx create mode 100644 src/ui/Icons/MinionIconFill8.tsx create mode 100644 src/ui/Icons/MinionIconFill9.tsx create mode 100644 src/ui/Icons/MinionIconOutline1.tsx create mode 100644 src/ui/Icons/MinionIconOutline10.tsx create mode 100644 src/ui/Icons/MinionIconOutline11.tsx create mode 100644 src/ui/Icons/MinionIconOutline12.tsx create mode 100644 src/ui/Icons/MinionIconOutline2.tsx create mode 100644 src/ui/Icons/MinionIconOutline3.tsx create mode 100644 src/ui/Icons/MinionIconOutline4.tsx create mode 100644 src/ui/Icons/MinionIconOutline5.tsx create mode 100644 src/ui/Icons/MinionIconOutline6.tsx create mode 100644 src/ui/Icons/MinionIconOutline7.tsx create mode 100644 src/ui/Icons/MinionIconOutline8.tsx create mode 100644 src/ui/Icons/MinionIconOutline9.tsx create mode 100644 src/ui/Icons/index.ts delete mode 100644 src/ui/MinionIconsFill.tsx delete mode 100644 src/ui/MinionIconsOutline.tsx create mode 100644 src/ui/MinionTaskCollapseContent.tsx create mode 100644 src/ui/MinionTaskCollapseHeader.tsx delete mode 100644 src/ui/MinionTaskComponent.tsx create mode 100644 src/ui/MinionTaskListItem.tsx create mode 100644 src/ui/MinionTaskSelection.tsx create mode 100644 src/ui/MinionTaskTextField.tsx rename src/ui/{MinionTaskListComponent.tsx => MinionTasksList.tsx} (79%) delete mode 100644 src/ui/SideBarWebViewInnerComponent.tsx create mode 100644 src/ui/Sidebar.tsx create mode 100644 src/ui/SidebarFooter.tsx create mode 100644 src/ui/SidebarSuggestions.tsx create mode 100644 src/ui/Spinner.tsx create mode 100644 src/ui/hooks/useSuggestions.ts create mode 100644 src/ui/utils/adjustTextAreaHeight.ts create mode 100644 src/ui/utils/getRobotOutlineIcons.ts create mode 100644 src/ui/utils/postMessageToVsCode.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index d4df9e9..cd54052 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,33 +3,29 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { - "version": "0.2.0", - "configurations": [ - { - "name": "Run Extension", - "type": "extensionHost", - "request": "launch", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}" - ], - "outFiles": [ - "${workspaceFolder}/dist/**/*.js" - ], - "preLaunchTask": "${defaultBuildTask}" - }, - { - "name": "Extension Tests", - "type": "extensionHost", - "request": "launch", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" - ], - "outFiles": [ - "${workspaceFolder}/out/**/*.js", - "${workspaceFolder}/dist/**/*.js" - ], - "preLaunchTask": "tasks: watch-tests" - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": ["--extensionDevelopmentPath=${workspaceFolder}"], + "outFiles": ["${workspaceFolder}/dist/**/*.js"], + "preLaunchTask": "${defaultBuildTask}" + }, + { + "name": "Extension Tests", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}", + "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" + ], + "outFiles": [ + "${workspaceFolder}/out/**/*.js", + "${workspaceFolder}/dist/**/*.js" + ], + "preLaunchTask": "tasks: watch-tests" + } + ] } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3cd5b39 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 10Clouds + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index dd8585a..6ca3f2c 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,8 @@ Experience increased productivity, better code quality, and seamless integration Code smarter, not harder! -

- - ## πŸ’‘ Key Features 10Minions empowers you to: @@ -29,19 +26,17 @@ Code smarter, not harder! 10Minions works with any programming language and seamlessly integrates with Visual Studio Code, making it an invaluable tool for developers, data scientists, and other professionals working with code. - ## 🌐 Limitations Please note that 10Minions plugin is currently in its Alpha version and under continuous improvement hence has certain limitations. It's good to bear in mind that: - Minions work within the scope of a single file only. They may not comprehend or factor in the context of the rest of your code in other files. - Minions do have a limit on how big of a file or selection they can work on. Attempting to process a file or selection above this size limitation will produce an error. - -We are actively working on overcoming these restrictions for a more personalized experience. +- Minions working speed is mainly limited by the speed of OpenAI GPT-4 API. + We are actively working on overcoming these restrictions for a more personalized experience. The users' feedback is key to its development and adjustments according to specific requirements. Feel free to share your thoughts, every review is a price and leads us to create a better product! - ## πŸš€ Getting Started 1. Install 10Minions from the Visual Studio Code marketplace @@ -49,7 +44,6 @@ The users' feedback is key to its development and adjustments according to speci 3. Set up keybindings for 10Minions commands (refer to the Keybindings section below for more details) 4. Remember that GPT-4 API Access is required for usage - ## ⌨️ Keybindings 10Minions provides a default keybinding for the `10minions.ask` command, which allows you to quickly ask for assistance from 10Minions while maintaining your focus on the editor. To use this command, simply press the following keybinding depending on your operating system: @@ -59,7 +53,6 @@ The users' feedback is key to its development and adjustments according to speci The `10minions.ask` command can be triggered when your text cursor is focused within the editor. - ## πŸ“š Use Cases 10Minions excels in various scenarios, such as: @@ -79,44 +72,34 @@ The `10minions.ask` command can be triggered when your text cursor is focused wi And many more! - ## πŸ› οΈ Extension Settings Configurable settings: - `10minions.apiKey`: OpenAI API key (requires your own key, no data sent to 10Clouds) - ## πŸ“Έ Examples - Create a better quality code with 10Minions. Here you can find some examples. - -**Fix issues** +**Fix issues** ![10C-minions-use-case-1](https://github.com/10clouds/10Minions/assets/135703473/1230cbda-c159-4791-841c-cd4f88437502) - **Write test cases** ![10C-minions-use-case-2](https://github.com/10clouds/10Minions/assets/135703473/94372102-f83c-4236-9b1c-50a6d79e0932) - -**Cleanup** +**Cleanup** ![10C-minions-use-case-3](https://github.com/10clouds/10Minions/assets/135703473/b6b75a77-497a-428d-a78d-234e9fa32f43) - **Add new states** ![10C-minions-use-case-4](https://github.com/10clouds/10Minions/assets/135703473/0898ef73-c180-4478-81ed-791a2869f594) - - Feel free to prompt it yourself or use suggestions from the tool! - ## ⭐ Testimonials Our users love 10Minions! See what they have to say: @@ -125,14 +108,9 @@ Our users love 10Minions! See what they have to say: - β€œGreat tool for developers – a must-have!" - "The integration with Visual Studio Code is impressive." - ## πŸ’Ό Resources and Links - [Official GitHub Repository](https://github.com/10clouds/10Minions) - [10Minions in Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=10clouds.10Minions) - [Official Discord Channel](https://discord.gg/CGSX4Btamx) - [10Clouds webpage](https://10clouds.com) - - - - diff --git a/custom.d.ts b/custom.d.ts new file mode 100644 index 0000000..5783313 --- /dev/null +++ b/custom.d.ts @@ -0,0 +1,4 @@ +declare module "*.svg" { + const content: React.FunctionComponent>; + export default content; +} \ No newline at end of file diff --git a/package.json b/package.json index 3911408..3cedc04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "10minions-vscode", "displayName": "10Minions (GPT-4 enabled)", + "license": "MIT", "description": "Your Army of GPT-4 Powered Coding Buddies.", "publisher": "10Clouds", "icon": "resources/ext-icon.png", @@ -157,6 +158,7 @@ "async": "^3.2.4", "babel-loader": "^9.1.2", "chalk": "^5.3.0", + "clsx": "^2.0.0", "commander": "^11.0.0", "eslint": "^8.39.0", "eslint-config-prettier": "^8.8.0", @@ -172,11 +174,9 @@ "webpack-cli": "^5.0.2" }, "dependencies": { - "10minions-engine": "^0.0.4", "@heroicons/react": "^2.0.18", + "@svgr/webpack": "^8.1.0", "async-lock": "^1.4.0", - "firebase": "^9.22.2", - "firebase-admin": "^11.9.0", "gpt-tokenizer": "^2.1.1", "jsonschema": "^1.4.1", "langchain": "^0.0.77", @@ -184,7 +184,6 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-flip-move": "^3.0.5", - "react-transition-group": "^4.4.5", - "request": "^2.88.2" + "react-transition-group": "^4.4.5" } } diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..d9af6f9 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,52 @@ +import { + MinionIconFill1, + MinionIconFill2, + MinionIconFill3, + MinionIconFill4, + MinionIconFill5, + MinionIconFill6, + MinionIconFill7, + MinionIconFill8, + MinionIconFill9, + MinionIconFill10, + MinionIconFill11, + MinionIconFill12, + MinionIconOutline1, + MinionIconOutline10, + MinionIconOutline12, + MinionIconOutline2, + MinionIconOutline3, + MinionIconOutline4, + MinionIconOutline5, + MinionIconOutline6, + MinionIconOutline7, + MinionIconOutline9, +} from './ui/Icons'; + +export const ALL_MINION_ICONS_FILL = [ + MinionIconFill1, + MinionIconFill2, + MinionIconFill3, + MinionIconFill4, + MinionIconFill5, + MinionIconFill6, + MinionIconFill7, + MinionIconFill8, + MinionIconFill9, + MinionIconFill10, + MinionIconFill11, + MinionIconFill12, +]; + +export const ALL_MINION_ICONS_OUTLINE = [ + MinionIconOutline1, + MinionIconOutline2, + MinionIconOutline3, + MinionIconOutline4, + MinionIconOutline5, + MinionIconOutline6, + MinionIconOutline7, + MinionIconOutline9, + MinionIconOutline10, + MinionIconOutline12, +]; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..23898e5 --- /dev/null +++ b/src/types.ts @@ -0,0 +1 @@ +export type IconProps = React.SVGProps; diff --git a/src/ui/GoButton.tsx b/src/ui/GoButton.tsx index d785faf..b5cbd15 100644 --- a/src/ui/GoButton.tsx +++ b/src/ui/GoButton.tsx @@ -3,10 +3,10 @@ import { BRAND_COLOR, blendWithForeground } from './utils/blendColors'; export function GoButton({ onClick, - justClickedGo, + clicked, }: { onClick?: () => void; - justClickedGo: boolean; + clicked: boolean; }) { return ( diff --git a/src/ui/Header.tsx b/src/ui/Header.tsx index ce5a1a2..b2d616a 100644 --- a/src/ui/Header.tsx +++ b/src/ui/Header.tsx @@ -2,17 +2,17 @@ import React from 'react'; import { BRAND_COLOR, blendWithForeground } from './utils/blendColors'; export function Header({ - RobotIcon1, - RobotIcon2, + leftIcon: LeftIcon, + rightIcon: RightIcon, }: { - RobotIcon1: React.ElementType; - RobotIcon2: React.ElementType; + leftIcon: React.ElementType; + rightIcon: React.ElementType; }) { return ( <>

- @@ -20,7 +20,7 @@ export function Header({ 10 Minions - diff --git a/src/ui/Icons/MinionIconFill1.tsx b/src/ui/Icons/MinionIconFill1.tsx new file mode 100644 index 0000000..124f71f --- /dev/null +++ b/src/ui/Icons/MinionIconFill1.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill1 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill1; diff --git a/src/ui/Icons/MinionIconFill10.tsx b/src/ui/Icons/MinionIconFill10.tsx new file mode 100644 index 0000000..9489e0a --- /dev/null +++ b/src/ui/Icons/MinionIconFill10.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill10 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill10; diff --git a/src/ui/Icons/MinionIconFill11.tsx b/src/ui/Icons/MinionIconFill11.tsx new file mode 100644 index 0000000..05eb889 --- /dev/null +++ b/src/ui/Icons/MinionIconFill11.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill11 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill11; diff --git a/src/ui/Icons/MinionIconFill12.tsx b/src/ui/Icons/MinionIconFill12.tsx new file mode 100644 index 0000000..cb9861b --- /dev/null +++ b/src/ui/Icons/MinionIconFill12.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill12 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill12; diff --git a/src/ui/Icons/MinionIconFill2.tsx b/src/ui/Icons/MinionIconFill2.tsx new file mode 100644 index 0000000..abb5926 --- /dev/null +++ b/src/ui/Icons/MinionIconFill2.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill2 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill2; diff --git a/src/ui/Icons/MinionIconFill3.tsx b/src/ui/Icons/MinionIconFill3.tsx new file mode 100644 index 0000000..ad8e753 --- /dev/null +++ b/src/ui/Icons/MinionIconFill3.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline3 = ({ ...props }: IconProps) => ( + + + + + +); + +export default MinionIconOutline3; diff --git a/src/ui/Icons/MinionIconFill4.tsx b/src/ui/Icons/MinionIconFill4.tsx new file mode 100644 index 0000000..c8807e8 --- /dev/null +++ b/src/ui/Icons/MinionIconFill4.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline4 = ({ ...props }: IconProps) => ( + + + + + + + + + +); + +export default MinionIconOutline4; diff --git a/src/ui/Icons/MinionIconFill5.tsx b/src/ui/Icons/MinionIconFill5.tsx new file mode 100644 index 0000000..87b9c24 --- /dev/null +++ b/src/ui/Icons/MinionIconFill5.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill5 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill5; diff --git a/src/ui/Icons/MinionIconFill6.tsx b/src/ui/Icons/MinionIconFill6.tsx new file mode 100644 index 0000000..25e2862 --- /dev/null +++ b/src/ui/Icons/MinionIconFill6.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline6 = ({ ...props }: IconProps) => ( + + + + + +); + +export default MinionIconOutline6; diff --git a/src/ui/Icons/MinionIconFill7.tsx b/src/ui/Icons/MinionIconFill7.tsx new file mode 100644 index 0000000..b834d95 --- /dev/null +++ b/src/ui/Icons/MinionIconFill7.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline7 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline7; diff --git a/src/ui/Icons/MinionIconFill8.tsx b/src/ui/Icons/MinionIconFill8.tsx new file mode 100644 index 0000000..f3a2d7c --- /dev/null +++ b/src/ui/Icons/MinionIconFill8.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill8 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill8; diff --git a/src/ui/Icons/MinionIconFill9.tsx b/src/ui/Icons/MinionIconFill9.tsx new file mode 100644 index 0000000..1cf64fe --- /dev/null +++ b/src/ui/Icons/MinionIconFill9.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +const MinionIconFill9 = ({ ...props }: IconProps) => ( + + + +); + +export default MinionIconFill9; diff --git a/src/ui/Icons/MinionIconOutline1.tsx b/src/ui/Icons/MinionIconOutline1.tsx new file mode 100644 index 0000000..e9624d9 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline1.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline1 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline1; diff --git a/src/ui/Icons/MinionIconOutline10.tsx b/src/ui/Icons/MinionIconOutline10.tsx new file mode 100644 index 0000000..6ab6409 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline10.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline10 = ({ ...props }: IconProps) => ( + + + + + +); + +export default MinionIconOutline10; diff --git a/src/ui/Icons/MinionIconOutline11.tsx b/src/ui/Icons/MinionIconOutline11.tsx new file mode 100644 index 0000000..d5cdf97 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline11.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline12.tsx b/src/ui/Icons/MinionIconOutline12.tsx new file mode 100644 index 0000000..b87add6 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline12.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline12 = ({ ...props }: IconProps) => ( + + + + + +); + +export default MinionIconOutline12; diff --git a/src/ui/Icons/MinionIconOutline2.tsx b/src/ui/Icons/MinionIconOutline2.tsx new file mode 100644 index 0000000..94336df --- /dev/null +++ b/src/ui/Icons/MinionIconOutline2.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline2 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline2; diff --git a/src/ui/Icons/MinionIconOutline3.tsx b/src/ui/Icons/MinionIconOutline3.tsx new file mode 100644 index 0000000..fc5223f --- /dev/null +++ b/src/ui/Icons/MinionIconOutline3.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline4.tsx b/src/ui/Icons/MinionIconOutline4.tsx new file mode 100644 index 0000000..fc5223f --- /dev/null +++ b/src/ui/Icons/MinionIconOutline4.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline5.tsx b/src/ui/Icons/MinionIconOutline5.tsx new file mode 100644 index 0000000..fc5223f --- /dev/null +++ b/src/ui/Icons/MinionIconOutline5.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline6.tsx b/src/ui/Icons/MinionIconOutline6.tsx new file mode 100644 index 0000000..fc5223f --- /dev/null +++ b/src/ui/Icons/MinionIconOutline6.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline7.tsx b/src/ui/Icons/MinionIconOutline7.tsx new file mode 100644 index 0000000..fc5223f --- /dev/null +++ b/src/ui/Icons/MinionIconOutline7.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline11 = ({ ...props }: IconProps) => ( + + + + + + +); +export default MinionIconOutline11; diff --git a/src/ui/Icons/MinionIconOutline8.tsx b/src/ui/Icons/MinionIconOutline8.tsx new file mode 100644 index 0000000..b2bad12 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline8.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline8 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline8; diff --git a/src/ui/Icons/MinionIconOutline9.tsx b/src/ui/Icons/MinionIconOutline9.tsx new file mode 100644 index 0000000..5709fc4 --- /dev/null +++ b/src/ui/Icons/MinionIconOutline9.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { IconProps } from '../../types'; + +export const MinionIconOutline9 = ({ ...props }: IconProps) => ( + + + + + + +); + +export default MinionIconOutline9; diff --git a/src/ui/Icons/index.ts b/src/ui/Icons/index.ts new file mode 100644 index 0000000..b93d191 --- /dev/null +++ b/src/ui/Icons/index.ts @@ -0,0 +1,25 @@ +export { default as MinionIconFill1 } from './MinionIconFill1'; +export { default as MinionIconFill2 } from './MinionIconFill2'; +export { default as MinionIconFill3 } from './MinionIconFill3'; +export { default as MinionIconFill4 } from './MinionIconFill4'; +export { default as MinionIconFill5 } from './MinionIconFill5'; +export { default as MinionIconFill6 } from './MinionIconFill6'; +export { default as MinionIconFill7 } from './MinionIconFill7'; +export { default as MinionIconFill8 } from './MinionIconFill8'; +export { default as MinionIconFill9 } from './MinionIconFill9'; +export { default as MinionIconFill10 } from './MinionIconFill10'; +export { default as MinionIconFill11 } from './MinionIconFill11'; +export { default as MinionIconFill12 } from './MinionIconFill12'; + +export { default as MinionIconOutline1 } from './MinionIconOutline1'; +export { default as MinionIconOutline2 } from './MinionIconOutline2'; +export { default as MinionIconOutline3 } from './MinionIconOutline3'; +export { default as MinionIconOutline4 } from './MinionIconOutline4'; +export { default as MinionIconOutline5 } from './MinionIconOutline5'; +export { default as MinionIconOutline6 } from './MinionIconOutline6'; +export { default as MinionIconOutline7 } from './MinionIconOutline7'; +export { default as MinionIconOutline8 } from './MinionIconOutline8'; +export { default as MinionIconOutline9 } from './MinionIconOutline9'; +export { default as MinionIconOutline10 } from './MinionIconOutline10'; +export { default as MinionIconOutline11 } from './MinionIconOutline11'; +export { default as MinionIconOutline12 } from './MinionIconOutline12'; diff --git a/src/ui/MinionIconsFill.tsx b/src/ui/MinionIconsFill.tsx deleted file mode 100644 index 0286622..0000000 --- a/src/ui/MinionIconsFill.tsx +++ /dev/null @@ -1,237 +0,0 @@ -import React from 'react'; - -type RobotIconProps = React.SVGProps; - -export const MinionIconFill1 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill10 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill11 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill12 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill2 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill3 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill4 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill5 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill6 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill7 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill8 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const MinionIconFill9 = ({ ...props }: RobotIconProps) => ( - - - -); - -export const ALL_MINION_ICONS_FILL = [ - MinionIconFill1, - MinionIconFill2, - MinionIconFill3, - - MinionIconFill4, - MinionIconFill5, - MinionIconFill6, - - MinionIconFill7, - //MinionIconFill8,// remove this as well - MinionIconFill9, - - MinionIconFill10, - //MinionIconFill11,// sad one :() - MinionIconFill12, -]; diff --git a/src/ui/MinionIconsOutline.tsx b/src/ui/MinionIconsOutline.tsx deleted file mode 100644 index ca9ee04..0000000 --- a/src/ui/MinionIconsOutline.tsx +++ /dev/null @@ -1,441 +0,0 @@ -import React from 'react'; - -type RobotIconProps = React.SVGProps; - -export const MinionIconOutline1 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const MinionIconOutline10 = ({ ...props }: RobotIconProps) => ( - - - - - -); - -export const MinionIconOutline11 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const MinionIconOutline12 = ({ ...props }: RobotIconProps) => ( - - - - - -); - -export const MinionIconOutline2 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const MinionIconOutline3 = ({ ...props }: RobotIconProps) => ( - - - - - -); - -export const MinionIconOutline4 = ({ ...props }: RobotIconProps) => ( - - - - - - - - - -); - -export const MinionIconOutline5 = ({ ...props }: RobotIconProps) => ( - - - - - -); - -export const MinionIconOutline6 = ({ ...props }: RobotIconProps) => ( - - - - - -); - -export const MinionIconOutline7 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const MinionIconOutline8 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const MinionIconOutline9 = ({ ...props }: RobotIconProps) => ( - - - - - - -); - -export const ALL_MINION_ICONS_OUTLINE = [ - MinionIconOutline1, - MinionIconOutline2, - MinionIconOutline3, - - MinionIconOutline4, - MinionIconOutline5, - MinionIconOutline6, - - MinionIconOutline7, - //MinionIconOutline8, - MinionIconOutline9, - - MinionIconOutline10, - //MinionIconOutline11, sad one :( - MinionIconOutline12, -]; diff --git a/src/ui/MinionTaskButtons.tsx b/src/ui/MinionTaskButtons.tsx index 39ad2ae..b461bae 100644 --- a/src/ui/MinionTaskButtons.tsx +++ b/src/ui/MinionTaskButtons.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { MessageToVSCodeType } from '10minions-engine/dist/Messages'; +import { MessageToVSCodeType } from '10minions-engine/dist/src/managers/Messages'; import { OutlineButton } from './OutlineButton'; -import { postMessageToVsCode } from './SideBarWebViewInnerComponent'; import ChevronDownIcon from '@heroicons/react/24/solid/ChevronDownIcon'; import ChevronUpIcon from '@heroicons/react/24/solid/ChevronUpIcon'; import XMarkIcon from '@heroicons/react/24/solid/XMarkIcon'; +import { postMessageToVsCode } from './utils/postMessageToVsCode'; interface MinionTaskButtonProps { minionTaskId: string; @@ -18,7 +18,7 @@ export const StopButton = ({ minionTaskId }: MinionTaskButtonProps) => ( description="Stop" onClick={() => { postMessageToVsCode({ - type: MessageToVSCodeType.StopExecution, + type: MessageToVSCodeType.STOP_EXECUTION, minionTaskId, }); }} @@ -35,7 +35,7 @@ export const ApplyButton = ({ description="Apply" onClick={(e) => { postMessageToVsCode({ - type: MessageToVSCodeType.ApplyAndReviewTask, + type: MessageToVSCodeType.APPLY_AND_REVIEW_TASK, minionTaskId, reapply: false, }); @@ -55,7 +55,7 @@ export const MarkAsReadButton = ({ description="Acknowledge" onClick={(e: React.MouseEvent) => { postMessageToVsCode({ - type: MessageToVSCodeType.MarkAsApplied, + type: MessageToVSCodeType.MARK_AS_APPLIED, minionTaskId, }); setIsExpanded?.(true); @@ -76,7 +76,7 @@ export const CloseButton = ({ minionTaskId }: MinionTaskButtonProps) => ( title="Close Execution" onClick={(e) => { postMessageToVsCode({ - type: MessageToVSCodeType.CloseExecution, + type: MessageToVSCodeType.CLOSE_EXECUTION, minionTaskId, }); e.stopPropagation(); @@ -91,7 +91,7 @@ export const RetryButton = ({ minionTaskId }: MinionTaskButtonProps) => ( description="Retry" onClick={() => { postMessageToVsCode({ - type: MessageToVSCodeType.ReRunExecution, + type: MessageToVSCodeType.RERUN_EXECUTION, minionTaskId, }); }} @@ -104,7 +104,7 @@ export const DiffButton = ({ minionTaskId }: MinionTaskButtonProps) => ( description="Review" onClick={(e) => { postMessageToVsCode({ - type: MessageToVSCodeType.ShowDiff, + type: MessageToVSCodeType.SHOW_DIFF, minionTaskId, }); @@ -121,7 +121,7 @@ export const ReapplyModificationButton = ({ description="Reapply" onClick={() => { postMessageToVsCode({ - type: MessageToVSCodeType.ApplyAndReviewTask, + type: MessageToVSCodeType.APPLY_AND_REVIEW_TASK, minionTaskId, reapply: true, }); @@ -135,7 +135,7 @@ export const OpenLogFileButton = ({ minionTaskId }: MinionTaskButtonProps) => ( description="Open Log file" onClick={() => { postMessageToVsCode({ - type: MessageToVSCodeType.OpenLog, + type: MessageToVSCodeType.OPEN_LOG, minionTaskId, }); }} diff --git a/src/ui/MinionTaskCollapseContent.tsx b/src/ui/MinionTaskCollapseContent.tsx new file mode 100644 index 0000000..ea953b6 --- /dev/null +++ b/src/ui/MinionTaskCollapseContent.tsx @@ -0,0 +1,89 @@ +import React from 'react'; +import { APPLIED_STAGE_NAME } from '10minions-engine/dist/src/tasks/stageNames'; +import { + DiffButton, + OpenLogFileButton, + ReapplyModificationButton, +} from './MinionTaskButtons'; +import { MessageToVSCodeType } from '10minions-engine/dist/src/managers/Messages'; +import { postMessageToVsCode } from './utils/postMessageToVsCode'; +import { MinionTaskUIInfo } from '10minions-engine/dist/src/managers/MinionTaskUIInfo'; +import MinionTaskSelection from './MinionTaskSelection'; +import MinionTaskTextField from './MinionTaskTextField'; + +const openDocument = (minionTaskId: string) => () => { + postMessageToVsCode({ + type: MessageToVSCodeType.OPEN_DOCUMENT, + minionTaskId, + }); +}; + +interface MinionTaskCollapseContentProps { + minionTask: MinionTaskUIInfo; +} + +const MinionTaskCollapseContent = ({ + minionTask, +}: MinionTaskCollapseContentProps) => { + const { + inlineMessage, + userQuery, + id: minionTaskId, + stopped, + executionStage, + selectedText, + modificationProcedure, + documentName, + } = minionTask; + + return ( + <> +
+ {inlineMessage ? ( +
{inlineMessage}
+ ) : null} +
+
+
Log:
+ + + + +
File:
+ + + {documentName}{' '} + {executionStage === APPLIED_STAGE_NAME && modificationProcedure && ( + + )} + + + +
Status:
+ + {executionStage}{' '} + {executionStage === APPLIED_STAGE_NAME && ( + + )} + + + {selectedText && ( + + )} +
+ + ); +}; + +export default MinionTaskCollapseContent; diff --git a/src/ui/MinionTaskCollapseHeader.tsx b/src/ui/MinionTaskCollapseHeader.tsx new file mode 100644 index 0000000..97d1b55 --- /dev/null +++ b/src/ui/MinionTaskCollapseHeader.tsx @@ -0,0 +1,97 @@ +import React from 'react'; +import clsx from 'clsx'; +import { ALL_MINION_ICONS_FILL } from '../constants'; +import { + APPLYING_STAGE_NAME, + CANCELED_STAGE_NAME, + FINISHED_STAGE_NAME, +} from '10minions-engine/dist/src/tasks/stageNames'; +import { + ApplyButton, + ChevronButton, + CloseButton, + MarkAsReadButton, + RetryButton, + StopButton, +} from './MinionTaskButtons'; +import { blendWithForeground, getBaseColor } from './utils/blendColors'; +import { MinionTaskUIInfo } from '10minions-engine/dist/src/managers/MinionTaskUIInfo'; + +interface MinionTaskCollapseHeaderProps { + isExpanded: boolean; + setIsExpanded: (value: React.SetStateAction) => void; + minionTask: MinionTaskUIInfo; +} + +const MinionTaskCollapseHeader = ({ + minionTask, + isExpanded, + setIsExpanded, +}: MinionTaskCollapseHeaderProps) => { + const { + inlineMessage, + id: minionTaskId, + minionIndex, + stopped, + executionStage, + shortName, + modificationProcedure, + isError, + } = minionTask; + const RobotIcon = ALL_MINION_ICONS_FILL[minionIndex]; + const minionTaskColor = blendWithForeground(getBaseColor(minionTask)); + const isRobotBusy = !stopped || executionStage === APPLYING_STAGE_NAME; + const isFinishedStage = executionStage === FINISHED_STAGE_NAME; + + const toggle = () => { + setIsExpanded(!isExpanded); + }; + + return ( +
+
+ +
+
+ {shortName} +
+ {inlineMessage && isFinishedStage && ( + + )} + {modificationProcedure && isFinishedStage && ( + + )} + {(executionStage === CANCELED_STAGE_NAME || isError) && ( + + )} + {!stopped ? : null} + + +
+ ); +}; + +export default MinionTaskCollapseHeader; diff --git a/src/ui/MinionTaskComponent.tsx b/src/ui/MinionTaskComponent.tsx deleted file mode 100644 index c07206b..0000000 --- a/src/ui/MinionTaskComponent.tsx +++ /dev/null @@ -1,320 +0,0 @@ -import React, { useEffect, useLayoutEffect, forwardRef } from 'react'; -import { blendWithForeground, getBaseColor } from './utils/blendColors'; -import { ALL_MINION_ICONS_FILL } from './MinionIconsFill'; -import { MinionTaskUIInfo } from '10minions-engine/dist/managers/MinionTaskUIInfo'; -import { - APPLIED_STAGE_NAME, - APPLYING_STAGE_NAME, - CANCELED_STAGE_NAME, - FINISHED_STAGE_NAME, -} from '10minions-engine/dist/const'; -import { ProgressBar } from './ProgressBar'; -import { postMessageToVsCode } from './SideBarWebViewInnerComponent'; -import { MessageToVSCodeType } from '10minions-engine/dist/Messages'; -import { useUserQueryPreview } from './useUserQueryPreview'; -import { - ApplyButton, - ChevronButton, - CloseButton, - DiffButton, - MarkAsReadButton, - OpenLogFileButton, - ReapplyModificationButton, - RetryButton, - StopButton, -} from './MinionTaskButtons'; - -// Constants -export const MAX_PREVIEW_LENGTH = 100; -const EDIT_TASK_TEXT_AREA_MIN_HEIGHT = 22; - -function adjustTextAreaHeight(target: HTMLTextAreaElement) { - const parent = target.parentElement; - const textAreaHeight = target.scrollHeight; - if (textAreaHeight > EDIT_TASK_TEXT_AREA_MIN_HEIGHT && parent) { - parent.style.maxHeight = `${textAreaHeight}px`; - target.style.height = `${textAreaHeight}px`; - target.style.marginTop = '-1px'; - } -} - -export const MinionTaskComponent = forwardRef( - ( - { - minionTask, - ...props - }: { minionTask: MinionTaskUIInfo } & React.HTMLAttributes, - ref: React.ForwardedRef, - ) => { - const { className, ...propsWithoutClassName } = props; - const { - inlineMessage, - userQuery, - id: minionTaskId, - minionIndex, - stopped, - executionStage, - shortName, - selectedText, - modificationProcedure, - isError, - documentName, - } = minionTask; - const userQueryPreview = useUserQueryPreview(userQuery); - const [isExpanded, setIsExpanded] = React.useState(false); - - // State variables for managing the input field state - const [isInputOpen, setIsInputOpen] = React.useState(false); - const [updatedPrompt, setUpdatedPrompt] = React.useState(userQuery); - - useEffect(() => { - if (!!inlineMessage) { - setIsExpanded(true); - } - }, [inlineMessage]); - - useEffect(() => { - setUpdatedPrompt(userQuery); - }, [userQuery]); - - useLayoutEffect(() => { - if (isInputOpen) { - const textAreaElement = document.querySelector( - '.execution textarea', - ); - if (textAreaElement) { - adjustTextAreaHeight(textAreaElement); - } - } - }, [isInputOpen]); - - function handleKeyDown(event: React.KeyboardEvent) { - // Only call handleRun() when Enter key is pressed without Shift - if (event.key === 'Enter' && !event.shiftKey) { - event.preventDefault(); - setIsInputOpen(false); - - handleRun(); - } - } - - function handleRun() { - if (updatedPrompt !== userQuery) { - // Stop the current execution - postMessageToVsCode({ - type: MessageToVSCodeType.StopExecution, - minionTaskId, - }); - - // Retry the execution with the updated prompt - postMessageToVsCode({ - type: MessageToVSCodeType.ReRunExecution, - minionTaskId, - newUserQuery: updatedPrompt, // Pass the updated prompt value - }); - } - } - - const RobotIcon = ALL_MINION_ICONS_FILL[minionIndex]; - - const moveToSelection = () => { - postMessageToVsCode({ - type: MessageToVSCodeType.OpenSelection, - minionTaskId, - }); - }; - - const recalculateTextAreaHeight = ( - event: React.FormEvent, - ) => adjustTextAreaHeight(event.target as HTMLTextAreaElement); - - const handleTextAreaBlur = () => { - setIsInputOpen(false); - handleRun(); - }; - - const minionTaskColor = blendWithForeground(getBaseColor(minionTask)); - const isRobotBusy = !stopped || executionStage === APPLYING_STAGE_NAME; - const isFinishedStage = executionStage === FINISHED_STAGE_NAME; - return ( -
-
-
{ - setIsExpanded(!isExpanded); - }} - > -
- -
-
- {shortName} -
- {inlineMessage && isFinishedStage && ( - - )} - {modificationProcedure && isFinishedStage && ( - - )} - {(executionStage === CANCELED_STAGE_NAME || isError) && ( - - )} - - {!stopped ? : null} - - -
- - {!isExpanded ? ( -
- ) : ( - <> -
- {inlineMessage ? ( -
{inlineMessage}
- ) : ( - <> - )} -
-
-
Log:
- - - - -
File:
- - - { - postMessageToVsCode({ - type: MessageToVSCodeType.OpenDocument, - minionTaskId, - }); - }} - > - {documentName}{' '} - {executionStage === APPLIED_STAGE_NAME && - modificationProcedure && ( - - )} - - - -
Status:
- - - {executionStage}{' '} - {executionStage === APPLIED_STAGE_NAME && ( - - )} - - -
Task:
- -
- {isInputOpen ? ( -