💄 stop button

This commit is contained in:
Nate Sesti 2023-10-12 15:20:11 -07:00
parent b8f45312bf
commit eee940e39f
4 changed files with 59 additions and 18 deletions

View file

@ -140,13 +140,13 @@ jobs:
with:
name: macOSBinary
path: extension/exe/continue_server
- uses: actions/upload-artifact@v2
if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'x64' && matrix.platform == 'linux'
with:
name: LinuxBinary
path: extension/exe/continue_server
- uses: actions/upload-artifact@v2
if: matrix.os == 'windows-latest' && matrix.arch == 'x64'
with:
@ -289,4 +289,4 @@ jobs:
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
branch: ${{ github.ref }}

View file

@ -22,7 +22,6 @@ import {
ArrowLeftIcon,
ArrowRightIcon,
ArrowUpLeftIcon,
StopCircleIcon,
TrashIcon,
XMarkIcon,
} from "@heroicons/react/24/outline";
@ -275,6 +274,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
const workspacePaths = useSelector(
(state: RootStore) => state.config.workspacePaths
);
const sessionHistory = useSelector(
(state: RootStore) => state.serverState.history
);
const [history, setHistory] = React.useState<string[]>([]);
// The position of the current command you are typing now, so the one that will be appended to history once you press enter
@ -1112,9 +1114,8 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
props.active ? `Stop (${getMetaKeyLabel()}⌫)` : "Delete"
}
>
{props.active ? (
<StopCircleIcon width="1.4em" height="1.4em" />
) : (
{props.active ? null : (
// <StopCircleIcon width="1.4em" height="1.4em" />
<XMarkIcon width="1.4em" height="1.4em" />
)}
</HeaderButtonWithText>
@ -1229,8 +1230,30 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
)}
{props.isMainInput && (
<ContinueButton
disabled={!(inputRef.current as any)?.value}
onClick={() => props.onEnter?.(undefined)}
disabled={
!(inputRef.current as any)?.value &&
!(
(typeof sessionHistory?.current_index !== "undefined" &&
sessionHistory.timeline[sessionHistory.current_index]
?.active) ||
false
)
}
onClick={() => {
if (
typeof sessionHistory?.current_index !== "undefined" &&
sessionHistory.timeline[sessionHistory.current_index]?.active
) {
client?.deleteAtIndex(sessionHistory.current_index);
} else {
props.onEnter?.(undefined);
}
}}
showStop={
(typeof sessionHistory?.current_index !== "undefined" &&
sessionHistory.timeline[sessionHistory.current_index]?.active) ||
false
}
/>
)}
</div>

View file

@ -1,6 +1,6 @@
import styled from "styled-components";
import { Button } from ".";
import { PlayIcon } from "@heroicons/react/24/outline";
import { Button, vscBackground } from ".";
import { PlayIcon, StopIcon } from "@heroicons/react/24/outline";
import { useSelector } from "react-redux";
import { RootStore } from "../redux/store";
import { useEffect, useState } from "react";
@ -8,21 +8,28 @@ import { useEffect, useState } from "react";
const StyledButton = styled(Button)<{
color?: string | null;
isDisabled: boolean;
showStop: boolean;
}>`
margin: auto;
margin-top: 8px;
margin-bottom: 16px;
display: grid;
width: 130px;
grid-template-columns: 22px 1fr;
align-items: center;
background-color: ${(props) => props.color || "#be1b55"};
background-color: ${(props) =>
`${props.color || "#be1b55"}${props.showStop ? "33" : ""}`};
opacity: ${(props) => (props.isDisabled ? 0.5 : 1.0)};
border: 1px solid
${(props) => (props.showStop ? props.color || "#be1b55" : "transparent")};
cursor: ${(props) => (props.isDisabled ? "default" : "pointer")};
&:hover:enabled {
background-color: ${(props) => props.color || "#be1b55"};
background-color: ${(props) =>
`${props.color || "#be1b55"}${props.showStop ? "33" : ""}`};
${(props) =>
props.isDisabled
? "cursor: default;"
@ -36,6 +43,7 @@ function ContinueButton(props: {
onClick?: () => void;
hidden?: boolean;
disabled: boolean;
showStop: boolean;
}) {
const vscMediaUrl = useSelector(
(state: RootStore) => state.config.vscMediaUrl
@ -61,6 +69,7 @@ function ContinueButton(props: {
return (
<StyledButton
showStop={props.showStop}
color={buttonColor as any}
hidden={props.hidden}
style={{ fontSize: "10px" }}
@ -68,12 +77,21 @@ function ContinueButton(props: {
onClick={props.disabled ? undefined : props.onClick}
isDisabled={props.disabled}
>
{vscMediaUrl ? (
<img src={`${vscMediaUrl}/play_button.png`} width="16px" />
{props.showStop ? (
<>
<StopIcon width="18px" height="18px" />
STOP
</>
) : (
<PlayIcon />
<>
{vscMediaUrl ? (
<img src={`${vscMediaUrl}/play_button.png`} height="18px" />
) : (
<PlayIcon width="18px" height="18px" />
)}
CONTINUE
</>
)}
CONTINUE
</StyledButton>
);
}

View file

@ -443,7 +443,7 @@ Settings:
"model": self.model,
"model_class": self.__class__.__name__,
"time": ttft,
"tokens": self.count_tokens(sum(m["content"] for m in messages))
"tokens": sum(self.count_tokens(m["content"]) for m in messages)
})
else: