diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-06-12 13:18:16 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-06-12 13:18:16 -0700 | 
| commit | 25262703573e79fc436c32f48b8df428bfeb4c97 (patch) | |
| tree | b3f67f4628b8aeedbb08d9ea6ba32a6692f09267 /extension/react-app/src/tabs | |
| parent | af350f5e70f20d14c361684e361b1e64e5e0b2c3 (diff) | |
| download | sncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.tar.gz sncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.tar.bz2 sncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.zip | |
clear history and delete step buttons
Diffstat (limited to 'extension/react-app/src/tabs')
| -rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 272 | 
1 files changed, 148 insertions, 124 deletions
| diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 9f7e651f..cb7a5440 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -4,6 +4,7 @@ import {    vscBackground,    Loader,    MainTextInput, +  HeaderButton,  } from "../components";  import ContinueButton from "../components/ContinueButton";  import { useCallback, useEffect, useRef, useState } from "react"; @@ -11,7 +12,7 @@ import { History } from "../../../schema/History";  import { HistoryNode } from "../../../schema/HistoryNode";  import StepContainer from "../components/StepContainer";  import useContinueGUIProtocol from "../hooks/useWebsocket"; - +import { Trash } from "@styled-icons/heroicons-outline";  let TopGUIDiv = styled.div`    display: grid;    grid-template-columns: 1fr; @@ -26,6 +27,14 @@ let UserInputQueueItem = styled.div`    text-align: center;  `; +const TopBar = styled.div` +  display: flex; +  flex-direction: row; +  justify-content: space-between; +  padding: 8px; +  align-items: center; +`; +  interface GUIProps {    firstObservation?: any;  } @@ -33,129 +42,128 @@ interface GUIProps {  function GUI(props: GUIProps) {    const [waitingForSteps, setWaitingForSteps] = useState(false);    const [userInputQueue, setUserInputQueue] = useState<string[]>([]); -  const [history, setHistory] = useState<History | undefined>(); -  //   { -  //   timeline: [ -  //     { -  //       step: { -  //         name: "Waiting for user input", -  //         cmd: "python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //         description: -  //           "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py` and ```\nprint(sum(first, second))\n```\n- Testing\n- Testing 2\n- Testing 3", -  //       }, -  //       observation: { -  //         title: "ERROR FOUND", -  //         error: -  //           "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", -  //       }, -  //       output: [ -  //         { -  //           traceback: { -  //             frames: [ -  //               { -  //                 filepath: -  //                   "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //                 lineno: 7, -  //                 function: "<module>", -  //                 code: "print(sum(first, second))", -  //               }, -  //             ], -  //             message: "unsupported operand type(s) for +: 'int' and 'str'", -  //             error_type: -  //               '          ^^^^^^^^^^^^^^^^^^\n  File "/Users/natesesti/Desktop/continue/extension/examples/python/sum.py", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError', -  //             full_traceback: -  //               "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", -  //           }, -  //         }, -  //         null, -  //       ], -  //     }, -  //     { -  //       step: { -  //         name: "EditCodeStep", -  //         range_in_files: [ -  //           { -  //             filepath: -  //               "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //             range: { -  //               start: { -  //                 line: 0, -  //                 character: 0, -  //               }, -  //               end: { -  //                 line: 6, -  //                 character: 25, -  //               }, -  //             }, -  //           }, -  //         ], -  //         prompt: -  //           "I ran into this problem with my Python code:\n\n                Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'\n\n                Below are the files that might need to be fixed:\n\n                {code}\n\n                This is what the code should be in order to avoid the problem:\n", -  //         description: -  //           "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py` and\n```python\nprint(sum(first, second))\n```\n- Testing\n- Testing 2\n- Testing 3", -  //       }, -  //       output: [ -  //         null, -  //         { -  //           reversible: true, -  //           actions: [ -  //             { -  //               reversible: true, -  //               filesystem: {}, -  //               filepath: -  //                 "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //               range: { -  //                 start: { -  //                   line: 0, -  //                   character: 0, -  //                 }, -  //                 end: { -  //                   line: 6, -  //                   character: 25, -  //                 }, -  //               }, -  //               replacement: -  //                 "\nfrom sum import sum\n\nfirst = 1\nsecond = 2\n\nprint(sum(first, second))", -  //             }, -  //           ], -  //         }, -  //       ], -  //     }, -  //     { -  //       step: { -  //         name: "SolveTracebackStep", -  //         traceback: { -  //           frames: [ -  //             { -  //               filepath: -  //                 "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //               lineno: 7, -  //               function: "<module>", -  //               code: "print(sum(first, second))", -  //             }, -  //           ], -  //           message: "unsupported operand type(s) for +: 'int' and 'str'", -  //           error_type: -  //             '          ^^^^^^^^^^^^^^^^^^\n  File "/Users/natesesti/Desktop/continue/extension/examples/python/sum.py", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError', -  //           full_traceback: -  //             "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", -  //         }, -  //         description: "Running step: SolveTracebackStep", -  //       }, -  //       output: [null, null], -  //     }, -  //     { -  //       step: { -  //         name: "RunCodeStep", -  //         cmd: "python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py", -  //         description: -  //           "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py`", -  //       }, -  //       output: [null, null], -  //     }, -  //   ], -  //   current_index: 3, -  // } as any); +  const [history, setHistory] = useState<History | undefined>({ +    timeline: [ +      { +        step: { +          name: "Waiting for user input", +          cmd: "python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py", +          description: +            "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py` and ```\nprint(sum(first, second))\n```\n- Testing\n- Testing 2\n- Testing 3", +        }, +        observation: { +          title: "ERROR FOUND", +          error: +            "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", +        }, +        output: [ +          { +            traceback: { +              frames: [ +                { +                  filepath: +                    "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", +                  lineno: 7, +                  function: "<module>", +                  code: "print(sum(first, second))", +                }, +              ], +              message: "unsupported operand type(s) for +: 'int' and 'str'", +              error_type: +                '          ^^^^^^^^^^^^^^^^^^\n  File "/Users/natesesti/Desktop/continue/extension/examples/python/sum.py", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError', +              full_traceback: +                "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", +            }, +          }, +          null, +        ], +      }, +      { +        step: { +          name: "EditCodeStep", +          range_in_files: [ +            { +              filepath: +                "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", +              range: { +                start: { +                  line: 0, +                  character: 0, +                }, +                end: { +                  line: 6, +                  character: 25, +                }, +              }, +            }, +          ], +          prompt: +            "I ran into this problem with my Python code:\n\n                Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'\n\n                Below are the files that might need to be fixed:\n\n                {code}\n\n                This is what the code should be in order to avoid the problem:\n", +          description: +            "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py` and\n```python\nprint(sum(first, second))\n```\n- Testing\n- Testing 2\n- Testing 3", +        }, +        output: [ +          null, +          { +            reversible: true, +            actions: [ +              { +                reversible: true, +                filesystem: {}, +                filepath: +                  "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", +                range: { +                  start: { +                    line: 0, +                    character: 0, +                  }, +                  end: { +                    line: 6, +                    character: 25, +                  }, +                }, +                replacement: +                  "\nfrom sum import sum\n\nfirst = 1\nsecond = 2\n\nprint(sum(first, second))", +              }, +            ], +          }, +        ], +      }, +      { +        step: { +          name: "SolveTracebackStep", +          traceback: { +            frames: [ +              { +                filepath: +                  "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", +                lineno: 7, +                function: "<module>", +                code: "print(sum(first, second))", +              }, +            ], +            message: "unsupported operand type(s) for +: 'int' and 'str'", +            error_type: +              '          ^^^^^^^^^^^^^^^^^^\n  File "/Users/natesesti/Desktop/continue/extension/examples/python/sum.py", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError', +            full_traceback: +              "Traceback (most recent call last):\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/main.py\", line 7, in <module>\n    print(sum(first, second))\n          ^^^^^^^^^^^^^^^^^^\n  File \"/Users/natesesti/Desktop/continue/extension/examples/python/sum.py\", line 2, in sum\n    return a + b\n           ~~^~~\nTypeError: unsupported operand type(s) for +: 'int' and 'str'", +          }, +          description: "Running step: SolveTracebackStep", +        }, +        output: [null, null], +      }, +      { +        step: { +          name: "RunCodeStep", +          cmd: "python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py", +          description: +            "Run `python3 /Users/natesesti/Desktop/continue/extension/examples/python/main.py`", +        }, +        output: [null, null], +      }, +    ], +    current_index: 3, +  } as any);    const topGuiDivRef = useRef<HTMLDivElement>(null);    const client = useContinueGUIProtocol(); @@ -261,6 +269,19 @@ function GUI(props: GUIProps) {          }        }}      > +      <TopBar> +        <h3>Continue</h3> +        <HeaderButton style={{ padding: "3px" }}> +          Clear History +          <Trash +            size="1.6em" +            onClick={() => { +              client?.sendClear(); +            }} +          /> +        </HeaderButton> +      </TopBar> +        {typeof client === "undefined" && (          <>            <Loader></Loader> @@ -288,6 +309,9 @@ function GUI(props: GUIProps) {                client?.retryAtIndex(index);                setWaitingForSteps(true);              }} +            onDelete={() => { +              client?.deleteAtIndex(index); +            }}            />          );        })} | 
