diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 4fa921f4435..17732dd2dbc 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -60,6 +60,11 @@ interface ChatRowProps { onFollowUpUnmount?: () => void isFollowUpAnswered?: boolean editable?: boolean + lastCheckpointInfo?: { + ts: number + commitHash: string + checkpoint?: Record + } | null } // eslint-disable-next-line @typescript-eslint/no-empty-object-type @@ -74,7 +79,7 @@ const ChatRow = memo( const [chatrow, { height }] = useSize(
- +
, ) @@ -114,7 +119,7 @@ export const ChatRowContent = ({ editable, }: ChatRowContentProps) => { const { t } = useTranslation() - const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode } = useExtensionState() + const { mcpServers, alwaysAllowMcp, currentCheckpoint: _currentCheckpoint, mode } = useExtensionState() const [reasoningCollapsed, setReasoningCollapsed] = useState(true) const [isDiffErrorExpanded, setIsDiffErrorExpanded] = useState(false) const [showCopySuccess, setShowCopySuccess] = useState(false) @@ -1157,14 +1162,8 @@ export const ChatRowContent = ({ case "shell_integration_warning": return case "checkpoint_saved": - return ( - - ) + // Don't render the checkpoint_saved message itself + return null case "condense_context": if (message.partial) { return @@ -1346,3 +1345,34 @@ export const ChatRowContent = ({ } } } + +// Create a wrapper component to handle the checkpoint UI +export const ChatRowWithCheckpoint: React.FC = (props) => { + const { message, lastCheckpointInfo } = props + const { currentCheckpoint } = useExtensionState() + + // Render the regular content + const content = + + // Check if we should show checkpoint UI + const shouldShowCheckpoint = + lastCheckpointInfo && message.ts > lastCheckpointInfo.ts && message.say !== "checkpoint_saved" + + if (shouldShowCheckpoint) { + return ( + <> + {content} +
+ +
+ + ) + } + + return content +} diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index efd2db856c0..6563aca5a4c 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -145,6 +145,19 @@ const ChatViewComponent: React.ForwardRefRenderFunction messages.filter((msg) => msg.say === "checkpoint_saved"), [messages]) + const lastCheckpointInfo = useMemo(() => { + if (checkpointMessages.length === 0) return null + + const lastCheckpoint = checkpointMessages[checkpointMessages.length - 1] + return { + ts: lastCheckpoint.ts, + commitHash: lastCheckpoint.text || "", + checkpoint: lastCheckpoint.checkpoint, + } + }, [checkpointMessages]) + const modifiedMessages = useMemo(() => combineApiRequests(combineCommandSequences(messages.slice(1))), [messages]) // Has to be after api_req_finished are all reduced into api_req_started messages. @@ -1398,6 +1411,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction