Skip to content

Commit 9f374ab

Browse files
authored
Merge pull request #1342 from RooVetGit/checkpoint_delay_warning
Show a warning if checkpoints are taking too long to load
2 parents 261bfd0 + cd46ab5 commit 9f374ab

File tree

2 files changed

+69
-12
lines changed

2 files changed

+69
-12
lines changed

.changeset/stale-toys-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Show a warning if checkpoints are taking too long to load

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
1+
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
22
import debounce from "debounce"
33
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
44
import { useDeepCompareEffect, useEvent, useMount } from "react-use"
@@ -88,6 +88,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
8888
const [isAtBottom, setIsAtBottom] = useState(false)
8989

9090
const [wasStreaming, setWasStreaming] = useState<boolean>(false)
91+
const [showCheckpointWarning, setShowCheckpointWarning] = useState<boolean>(false)
9192

9293
// UI layout depends on the last 2 messages
9394
// (since it relies on the content of these messages, we are deep comparing. i.e. the button state after hitting button sets enableButtons to false, and this effect otherwise would have to true again even if messages didn't change
@@ -882,6 +883,48 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
882883
}, [])
883884
useEvent("wheel", handleWheel, window, { passive: true }) // passive improves scrolling performance
884885

886+
// Effect to handle showing the checkpoint warning after a delay
887+
useEffect(() => {
888+
// Only show the warning when there's a task but no visible messages yet
889+
if (task && modifiedMessages.length === 0 && !isStreaming) {
890+
const timer = setTimeout(() => {
891+
setShowCheckpointWarning(true)
892+
}, 5000) // 5 seconds
893+
894+
return () => clearTimeout(timer)
895+
}
896+
}, [task, modifiedMessages.length, isStreaming])
897+
898+
// Effect to hide the checkpoint warning when messages appear
899+
useEffect(() => {
900+
if (modifiedMessages.length > 0 || isStreaming) {
901+
setShowCheckpointWarning(false)
902+
}
903+
}, [modifiedMessages.length, isStreaming])
904+
905+
// Checkpoint warning component
906+
const CheckpointWarningMessage = useCallback(
907+
() => (
908+
<div className="flex items-center p-3 my-3 bg-vscode-inputValidation-warningBackground border border-vscode-inputValidation-warningBorder rounded">
909+
<span className="codicon codicon-loading codicon-modifier-spin mr-2" />
910+
<span className="text-vscode-foreground">
911+
Still initializing checkpoint... If this takes too long, you can{" "}
912+
<VSCodeLink
913+
href="#"
914+
onClick={(e) => {
915+
e.preventDefault()
916+
window.postMessage({ type: "action", action: "settingsButtonClicked" }, "*")
917+
}}
918+
className="inline px-0.5">
919+
disable checkpoints in settings
920+
</VSCodeLink>{" "}
921+
and restart your task.
922+
</span>
923+
</div>
924+
),
925+
[],
926+
)
927+
885928
const placeholderText = useMemo(() => {
886929
const baseText = task ? "Type a message..." : "Type your task here..."
887930
const contextText = "(@ to add context, / to switch modes"
@@ -1014,17 +1057,26 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
10141057
overflow: "hidden",
10151058
}}>
10161059
{task ? (
1017-
<TaskHeader
1018-
task={task}
1019-
tokensIn={apiMetrics.totalTokensIn}
1020-
tokensOut={apiMetrics.totalTokensOut}
1021-
doesModelSupportPromptCache={selectedModelInfo.supportsPromptCache}
1022-
cacheWrites={apiMetrics.totalCacheWrites}
1023-
cacheReads={apiMetrics.totalCacheReads}
1024-
totalCost={apiMetrics.totalCost}
1025-
contextTokens={apiMetrics.contextTokens}
1026-
onClose={handleTaskCloseButtonClick}
1027-
/>
1060+
<>
1061+
<TaskHeader
1062+
task={task}
1063+
tokensIn={apiMetrics.totalTokensIn}
1064+
tokensOut={apiMetrics.totalTokensOut}
1065+
doesModelSupportPromptCache={selectedModelInfo.supportsPromptCache}
1066+
cacheWrites={apiMetrics.totalCacheWrites}
1067+
cacheReads={apiMetrics.totalCacheReads}
1068+
totalCost={apiMetrics.totalCost}
1069+
contextTokens={apiMetrics.contextTokens}
1070+
onClose={handleTaskCloseButtonClick}
1071+
/>
1072+
1073+
{/* Checkpoint warning message */}
1074+
{showCheckpointWarning && (
1075+
<div className="px-3">
1076+
<CheckpointWarningMessage />
1077+
</div>
1078+
)}
1079+
</>
10281080
) : (
10291081
<div
10301082
style={{

0 commit comments

Comments
 (0)