Fix cancel button

This commit is contained in:
Saoud Rizwan
2024-10-02 21:01:04 -04:00
parent e1ab10f24e
commit 0c290b4108
2 changed files with 7 additions and 3 deletions

View File

@@ -451,7 +451,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
timeout: 3_000, timeout: 3_000,
}) })
await this.initClaudeDevWithHistoryItem(historyItem) // clears task again, so we need to abortTask manually above await this.initClaudeDevWithHistoryItem(historyItem) // clears task again, so we need to abortTask manually above
await this.postStateToWebview() // await this.postStateToWebview() // new claude dev instance will post state when it's ready. having this here sent an empty messages array to webview leading to virtuoso having to reload the entire list
} }
break break

View File

@@ -55,6 +55,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const [didScrollUp, setDidScrollUp] = useState(false) const [didScrollUp, setDidScrollUp] = useState(false)
const lastScrollTopRef = useRef(0) const lastScrollTopRef = useRef(0)
const [didClickScrollToBottom, setDidClickScrollToBottom] = useState(false) const [didClickScrollToBottom, setDidClickScrollToBottom] = useState(false)
const [didClickCancel, setDidClickCancel] = useState(false)
useEffect(() => { useEffect(() => {
// if last message is an ask, show user ask UI // if last message is an ask, show user ask UI
@@ -134,6 +135,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
setEnableButtons(true) setEnableButtons(true)
setPrimaryButtonText("Resume Task") setPrimaryButtonText("Resume Task")
setSecondaryButtonText(undefined) setSecondaryButtonText(undefined)
setDidClickCancel(false) // special case where we reset the cancel button state
break break
case "resume_completed_task": case "resume_completed_task":
setTextAreaDisabled(false) setTextAreaDisabled(false)
@@ -141,6 +143,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
setEnableButtons(true) setEnableButtons(true)
setPrimaryButtonText("Start New Task") setPrimaryButtonText("Start New Task")
setSecondaryButtonText(undefined) setSecondaryButtonText(undefined)
setDidClickCancel(false)
break break
} }
break break
@@ -283,6 +286,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const handleSecondaryButtonClick = useCallback(() => { const handleSecondaryButtonClick = useCallback(() => {
if (isStreaming) { if (isStreaming) {
vscode.postMessage({ type: "cancelTask" }) vscode.postMessage({ type: "cancelTask" })
setDidClickCancel(true)
return return
} }
@@ -653,7 +657,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
style={{ style={{
opacity: opacity:
primaryButtonText || secondaryButtonText || isStreaming primaryButtonText || secondaryButtonText || isStreaming
? enableButtons || isStreaming ? enableButtons || (isStreaming && !didClickCancel)
? 1 ? 1
: 0.5 : 0.5
: 0, : 0,
@@ -675,7 +679,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
{(secondaryButtonText || isStreaming) && ( {(secondaryButtonText || isStreaming) && (
<VSCodeButton <VSCodeButton
appearance="secondary" appearance="secondary"
disabled={!enableButtons && !isStreaming} disabled={!enableButtons && !(isStreaming && !didClickCancel)}
style={{ style={{
flex: isStreaming ? 2 : 1, flex: isStreaming ? 2 : 1,
marginLeft: isStreaming ? 0 : "6px", marginLeft: isStreaming ? 0 : "6px",