diff options
author | Ty Dunn <ty@tydunn.com> | 2023-06-18 19:24:28 -0700 |
---|---|---|
committer | Ty Dunn <ty@tydunn.com> | 2023-06-18 19:24:28 -0700 |
commit | 5311a5b7e8e4322690b5f0b85a839bfa1caa1926 (patch) | |
tree | 236b1699f987ff90f89d905ba4ded7e49b3b8d96 /extension/react-app/src | |
parent | d3f76defe286df20550cbcc87679b56d9f6c72c2 (diff) | |
parent | 8aa8e0b5c8402014b01f6ea6ce2e3d686f3c64b2 (diff) | |
download | sncontinue-5311a5b7e8e4322690b5f0b85a839bfa1caa1926.tar.gz sncontinue-5311a5b7e8e4322690b5f0b85a839bfa1caa1926.tar.bz2 sncontinue-5311a5b7e8e4322690b5f0b85a839bfa1caa1926.zip |
Merge branch 'main' into play-button
Diffstat (limited to 'extension/react-app/src')
-rw-r--r-- | extension/react-app/src/components/CodeBlock.tsx | 7 | ||||
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 9 | ||||
-rw-r--r-- | extension/react-app/src/components/HeaderButtonWithText.tsx | 2 | ||||
-rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 80 |
4 files changed, 86 insertions, 12 deletions
diff --git a/extension/react-app/src/components/CodeBlock.tsx b/extension/react-app/src/components/CodeBlock.tsx index c4524a51..0aae0bbb 100644 --- a/extension/react-app/src/components/CodeBlock.tsx +++ b/extension/react-app/src/components/CodeBlock.tsx @@ -22,7 +22,7 @@ const StyledCopyButton = styled.button<{ visible: boolean }>` /* position: relative; */ float: right; border: none; - background-color: transparent; + background-color: ${secondaryDark}; cursor: pointer; padding: 0; /* margin: 4px; */ @@ -77,7 +77,10 @@ function CodeBlock(props: { language?: string; children: string }) { setHovered(false); }} > - <CopyButton visible={hovered} textToCopy={props.children} /> + <CopyButton + visible={hovered} + textToCopy={(props.children as any).props.children[0]} + /> <StyledCode>{props.children}</StyledCode> </StyledPre> ); diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index ddc9d5dc..8c1f80e0 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -116,6 +116,15 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { disabled={props.disabled} placeholder="Type '/' to see available slash commands." {...getInputProps({ + onChange: (e) => { + const target = e.target as HTMLTextAreaElement; + // Update the height of the textarea to match the content, up to a max of 200px. + target.style.height = "auto"; + target.style.height = `${Math.min( + target.scrollHeight, + 200 + ).toString()}px`; + }, onKeyDown: (event) => { if (event.key === "Enter" && event.shiftKey) { // Prevent Downshift's default 'Enter' behavior. diff --git a/extension/react-app/src/components/HeaderButtonWithText.tsx b/extension/react-app/src/components/HeaderButtonWithText.tsx index f9483f0f..acaca9ce 100644 --- a/extension/react-app/src/components/HeaderButtonWithText.tsx +++ b/extension/react-app/src/components/HeaderButtonWithText.tsx @@ -12,7 +12,7 @@ const HeaderButtonWithText = (props: HeaderButtonWithTextProps) => { const [hover, setHover] = useState(false); return ( <HeaderButton - style={{ padding: "3px" }} + style={{ padding: "1px", paddingLeft: hover ? "4px" : "1px" }} onMouseEnter={() => setHover(true)} onMouseLeave={() => { setHover(false); diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 624d22d5..eee2b1a0 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -1,11 +1,5 @@ import styled from "styled-components"; -import { - defaultBorderRadius, - vscBackground, - Loader, - MainTextInput, - HeaderButton, -} from "../components"; +import { defaultBorderRadius, Loader } from "../components"; import ContinueButton from "../components/ContinueButton"; import { useCallback, useEffect, useRef, useState } from "react"; import { History } from "../../../schema/History"; @@ -20,6 +14,10 @@ import { import ComboBox from "../components/ComboBox"; import TextDialog from "../components/TextDialog"; import HeaderButtonWithText from "../components/HeaderButtonWithText"; +import ReactSwitch from "react-switch"; +import { usePostHog } from "posthog-js/react"; +import { useSelector } from "react-redux"; +import { RootStore } from "../redux/store"; const TopGUIDiv = styled.div` overflow: hidden; @@ -33,7 +31,7 @@ const UserInputQueueItem = styled.div` text-align: center; `; -const Footer = styled.footer` +const Footer = styled.footer<{ dataSwitchChecked: boolean }>` display: flex; flex-direction: row; gap: 8px; @@ -42,6 +40,8 @@ const Footer = styled.footer` align-items: center; margin-top: 8px; border-top: 0.1px solid gray; + background-color: ${(props) => + props.dataSwitchChecked ? "#12887a33" : "transparent"}; `; interface GUIProps { @@ -49,11 +49,18 @@ interface GUIProps { } function GUI(props: GUIProps) { + const posthog = usePostHog(); + const vscMachineId = useSelector( + (state: RootStore) => state.config.vscMachineId + ); + const [waitingForSteps, setWaitingForSteps] = useState(false); const [userInputQueue, setUserInputQueue] = useState<string[]>([]); const [availableSlashCommands, setAvailableSlashCommands] = useState< { name: string; description: string }[] >([]); + const [dataSwitchChecked, setDataSwitchChecked] = useState(false); + const [showDataSharingInfo, setShowDataSharingInfo] = useState(false); const [stepsOpen, setStepsOpen] = useState<boolean[]>([]); const [history, setHistory] = useState<History | undefined>(); // { @@ -390,7 +397,62 @@ function GUI(props: GUIProps) { /> <ContinueButton onClick={onMainTextInput} /> </TopGUIDiv> - <Footer> + <div + style={{ + position: "fixed", + bottom: "50px", + backgroundColor: "white", + color: "black", + borderRadius: defaultBorderRadius, + padding: "16px", + margin: "16px", + }} + hidden={!showDataSharingInfo} + > + By turning on the switch, you will anonymously contribute your Continue + history to an open-source dataset used to train LLMs to use tools just + like a developer in their IDE. + <br /> + <br /> + <b> + {dataSwitchChecked + ? "You are currently contributing data." + : "Your data is not being shared."} + </b> + </div> + <Footer dataSwitchChecked={dataSwitchChecked}> + <div + style={{ + display: "flex", + gap: "4px", + marginRight: "auto", + alignItems: "center", + }} + onMouseEnter={() => { + setShowDataSharingInfo(true); + }} + onMouseLeave={() => { + setShowDataSharingInfo(false); + }} + > + <ReactSwitch + height={20} + handleDiameter={20} + width={40} + onChange={() => { + posthog?.capture("data_switch_toggled", { + vscMachineId: vscMachineId, + dataSwitchChecked: !dataSwitchChecked, + }); + setDataSwitchChecked((prev) => !prev); + }} + onColor="#12887a" + checked={dataSwitchChecked} + /> + <span style={{ cursor: "help", fontSize: "16px" }}> + Contribute Data + </span> + </div> <HeaderButtonWithText onClick={() => { client?.sendClear(); |