hover cancel button

This commit is contained in:
Dallin Romney 2024-11-04 23:48:53 -08:00
parent 066bf17a86
commit 19e4a2e566
4 changed files with 81 additions and 75 deletions

2
gui/package-lock.json generated
View file

@ -37,7 +37,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.47.0",
"react-intersection-observer": "^9.10.3",
"react-intersection-observer": "^9.13.1",
"react-markdown": "^9.0.1",
"react-redux": "^8.0.5",
"react-remark": "^2.1.0",

View file

@ -45,7 +45,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.47.0",
"react-intersection-observer": "^9.10.3",
"react-intersection-observer": "^9.13.1",
"react-markdown": "^9.0.1",
"react-redux": "^8.0.5",
"react-remark": "^2.1.0",

View file

@ -107,53 +107,55 @@ function StepContainer(props: StepContainerProps) {
/>
)}
</ContentDiv>
{shouldRenderActions && (
// Height of this should be the same as height of "Cancel" div to prevent jump
<div className="h-7 mb-2 flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 pb-0 cursor-default">
{truncatedEarly && (
<ButtonWithTooltip
tabIndex={-1}
text="Continue generation"
onClick={props.onContinueGeneration}
>
<BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
{props.index !== 1 && (
<ButtonWithTooltip
text="Delete"
tabIndex={-1}
onClick={props.onDelete}
>
<TrashIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
clipboardIconClassName="h-3.5 w-3.5 text-gray-500"
checkIconClassName="h-3.5 w-3.5 text-green-400"
/>
<div className="h-7 mb-2 mx-2 flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 pb-0 cursor-default"
style={{
opacity: shouldRenderActions ? 1 : 0,
pointerEvents: shouldRenderActions ? "auto" : "none"
}}
>
{truncatedEarly && (
<ButtonWithTooltip
text="Helpful"
tabIndex={-1}
onClick={() => sendFeedback(true)}
text="Continue generation"
onClick={props.onContinueGeneration}
>
<HandThumbUpIcon className={`h-3.5 w-3.5 mx-0.5 ${feedback === true ? 'text-green-400' : 'text-gray-500'}`} />
<BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
{props.index !== 1 && (
<ButtonWithTooltip
text="Unhelpful"
text="Delete"
tabIndex={-1}
onClick={() => sendFeedback(false)}
onClick={props.onDelete}
>
<HandThumbDownIcon className={`h-3.5 w-3.5 ${feedback === false ? 'text-red-400' : 'text-gray-500'}`} />
<TrashIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
</div>
)}
)}
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
clipboardIconClassName="h-3.5 w-3.5 text-gray-500"
checkIconClassName="h-3.5 w-3.5 text-green-400"
/>
<ButtonWithTooltip
text="Helpful"
tabIndex={-1}
onClick={() => sendFeedback(true)}
>
<HandThumbUpIcon className={`h-3.5 w-3.5 mx-0.5 ${feedback === true ? 'text-green-400' : 'text-gray-500'}`} />
</ButtonWithTooltip>
<ButtonWithTooltip
text="Unhelpful"
tabIndex={-1}
onClick={() => sendFeedback(false)}
>
<HandThumbDownIcon className={`h-3.5 w-3.5 ${feedback === false ? 'text-red-400' : 'text-gray-500'}`} />
</ButtonWithTooltip>
</div>
</div>
);
}

View file

@ -75,6 +75,7 @@ const TopGuiDiv = styled.div<{
`;
const StopButton = styled.div`
background-color: ${vscBackground};
width: fit-content;
margin-right: auto;
margin-left: auto;
@ -148,15 +149,17 @@ export function Chat() {
const { saveSession, getLastSessionId, loadLastSession } =
useHistory(dispatch);
useEffect(() => {
if (!active || !topGuiDivRef.current) return
const scrollAreaElement = topGuiDivRef.current;
scrollAreaElement.scrollTop =
scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight;
const scrollToBottom = useCallback(() => {
if (!topGuiDivRef.current) return
const elem = topGuiDivRef.current;
elem.scrollTop = elem.scrollHeight - elem.clientHeight;
setIsAtBottom(true);
}, [topGuiDivRef, active, setIsAtBottom])
}, [topGuiDivRef, setIsAtBottom])
useEffect(() => {
if (active) scrollToBottom()
}, [active, scrollToBottom])
useEffect(() => {
// Cmd + Backspace to delete current step
@ -424,34 +427,35 @@ export function Chat() {
/>
</TopGuiDiv>
{ttsActive && (
<StopButton
className="mb-4 mt-2"
onClick={() => {
ideMessenger.post("tts/kill", undefined);
}}
>
■ Stop TTS
</StopButton>
)}
{active && (
<div className="h-7 mb-2">
<StopButton
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
<div className={`relative ${state.history.length > 0 ? 'pt-1 border-0 border-t border-solid border-t-zinc-700' : ''}`}>
<div className="absolute -top-8 right-2 z-30">
{ttsActive && (
<StopButton
className=""
onClick={() => {
ideMessenger.post("tts/kill", undefined);
}}
>
■ Stop TTS
</StopButton>
)}
{active && (
<StopButton
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
)}
</div>
)}
<div className={`${state.history.length > 0 ? 'pt-1 border-0 border-t border-solid border-t-zinc-700' : ''}`}>
<ContinueInputBox
isMainInput
isLastUserInput={false}
@ -460,7 +464,7 @@ export function Chat() {
}}
/>
<div style={{
opacity: active ? 0 : 1,
// opacity: active ? 0 : 1,
pointerEvents: active ? 'none' : 'auto',
}}>
{state.history.length > 0 ? (