From 19e4a2e5666d5e8b6bbded392307fa2029af9791 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 4 Nov 2024 23:48:53 -0800 Subject: [PATCH] hover cancel button --- gui/package-lock.json | 2 +- gui/package.json | 2 +- gui/src/components/gui/StepContainer.tsx | 78 ++++++++++++------------ gui/src/pages/gui/Chat.tsx | 74 +++++++++++----------- 4 files changed, 81 insertions(+), 75 deletions(-) diff --git a/gui/package-lock.json b/gui/package-lock.json index ef9f8cda9..b0be81c6c 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -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", diff --git a/gui/package.json b/gui/package.json index dae097902..ef77ac910 100644 --- a/gui/package.json +++ b/gui/package.json @@ -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", diff --git a/gui/src/components/gui/StepContainer.tsx b/gui/src/components/gui/StepContainer.tsx index 7976880c0..c90d6c9c7 100644 --- a/gui/src/components/gui/StepContainer.tsx +++ b/gui/src/components/gui/StepContainer.tsx @@ -107,53 +107,55 @@ function StepContainer(props: StepContainerProps) { /> )} - {shouldRenderActions && ( - // Height of this should be the same as height of "Cancel" div to prevent jump -
- {truncatedEarly && ( - - - - )} - - {props.index !== 1 && ( - - - - )} - - - +
+ {truncatedEarly && ( sendFeedback(true)} + text="Continue generation" + onClick={props.onContinueGeneration} > - + + )} + {props.index !== 1 && ( sendFeedback(false)} + onClick={props.onDelete} > - + -
- )} + )} + + + + sendFeedback(true)} + > + + + + sendFeedback(false)} + > + + +
); } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index cfde43687..a2e234c70 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -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() { /> - {ttsActive && ( - { - ideMessenger.post("tts/kill", undefined); - }} - > - ■ Stop TTS - - )} - {active && ( -
- { - dispatch(setInactive()); - if ( - state.history[state.history.length - 1]?.message.content - .length === 0 - ) { - dispatch(clearLastResponse()); - } - }} - > - {getMetaKeyLabel()} ⌫ Cancel - + +
0 ? 'pt-1 border-0 border-t border-solid border-t-zinc-700' : ''}`}> +
+ {ttsActive && ( + { + ideMessenger.post("tts/kill", undefined); + }} + > + ■ Stop TTS + + )} + {active && ( + { + dispatch(setInactive()); + if ( + state.history[state.history.length - 1]?.message.content + .length === 0 + ) { + dispatch(clearLastResponse()); + } + }} + > + {getMetaKeyLabel()} ⌫ Cancel + + )}
- )} -
0 ? 'pt-1 border-0 border-t border-solid border-t-zinc-700' : ''}`}>
{state.history.length > 0 ? (