@@ -17,7 +17,6 @@ import { COMMAND_OUTPUT_STRING, COMMAND_REQ_APP_STRING } from "@shared/combineCo
1717import { useExtensionState } from "@/context/ExtensionStateContext"
1818import { findMatchingResourceOrTemplate , getMcpServerDisplayName } from "@/utils/mcp"
1919import { vscode } from "@/utils/vscode"
20- import { useChatRowStyles } from "@/hooks/useChatRowStyles"
2120import { CheckmarkControl } from "@/components/common/CheckmarkControl"
2221import { CheckpointControls , CheckpointOverlay } from "../common/CheckpointControls"
2322import CodeAccordian , { cleanPathPrefix } from "../common/CodeAccordian"
@@ -48,12 +47,11 @@ interface ChatRowProps {
4847 isExpanded : boolean
4948 onToggleExpand : ( ) => void
5049 lastModifiedMessage ?: ClineMessage
51- isFirst : boolean
5250 isLast : boolean
5351 onHeightChange : ( isTaller : boolean ) => void
5452}
5553
56- interface ChatRowContentProps extends Omit < ChatRowProps , "onHeightChange" | "isFirst" > { }
54+ interface ChatRowContentProps extends Omit < ChatRowProps , "onHeightChange" > { }
5755
5856export const ProgressIndicator = ( ) => (
5957 < div
@@ -86,40 +84,36 @@ const Markdown = memo(({ markdown }: { markdown?: string }) => {
8684
8785const ChatRow = memo (
8886 ( props : ChatRowProps ) => {
89- const { isLast, isFirst , onHeightChange, message } = props
87+ const { isLast, onHeightChange, message, lastModifiedMessage } = props
9088 // Store the previous height to compare with the current height
89+ // This allows us to detect changes without causing re-renders
9190 const prevHeightRef = useRef ( 0 )
92- // Calculate dynamic styles using the custom hook
93- const { ...chatRowStyles } = useChatRowStyles ( message )
9491
95- const isCheckpointMessage = message . say === "checkpoint_created"
92+ // NOTE: for tools that are interrupted and not responded to (approved or rejected) there won't be a checkpoint hash
93+ let shouldShowCheckpoints =
94+ message . lastCheckpointHash != null &&
95+ ( message . say === "tool" ||
96+ message . ask === "tool" ||
97+ message . say === "command" ||
98+ message . ask === "command" ||
99+ // message.say === "completion_result" ||
100+ // message.ask === "completion_result" ||
101+ message . say === "use_mcp_server" ||
102+ message . ask === "use_mcp_server" )
96103
97- // Special handling for first row checkpoint
98- const checkpointStyles = useMemo ( ( ) => {
99- if ( isCheckpointMessage ) {
100- // Apply additional styles for first row checkpoints
101- if ( isFirst ) {
102- return {
103- ...chatRowStyles ,
104- marginTop : "3px" , // Add a small margin to ensure visibility
105- }
106- }
107- return chatRowStyles
108- }
109- return chatRowStyles
110- } , [ chatRowStyles , isCheckpointMessage , isFirst ] )
104+ if ( shouldShowCheckpoints && isLast ) {
105+ shouldShowCheckpoints =
106+ lastModifiedMessage ?. ask === "resume_completed_task" || lastModifiedMessage ?. ask === "resume_task"
107+ }
111108
112- // ChatRowContainer with updated styles
113109 const [ chatrow , { height } ] = useSize (
114- < ChatRowContainer style = { checkpointStyles } >
110+ < ChatRowContainer >
115111 < ChatRowContent { ...props } />
112+ { shouldShowCheckpoints && < CheckpointOverlay messageTs = { message . ts } /> }
116113 </ ChatRowContainer > ,
117114 )
118115
119116 useEffect ( ( ) => {
120- // Skip height change effects for checkpoint messages
121- if ( isCheckpointMessage ) return
122-
123117 // used for partials command output etc.
124118 // NOTE: it's important we don't distinguish between partial or complete here since our scroll effects in chatview need to handle height change during partial -> complete
125119 const isInitialRender = prevHeightRef . current === 0 // prevents scrolling when new element is added since we already scroll for that
@@ -130,7 +124,7 @@ const ChatRow = memo(
130124 }
131125 prevHeightRef . current = height
132126 }
133- } , [ height , isLast , onHeightChange , message , isCheckpointMessage ] )
127+ } , [ height , isLast , onHeightChange , message ] )
134128
135129 // we cannot return null as virtuoso does not support it so we use a separate visibleMessages array to filter out messages that should not be rendered
136130 return chatrow
0 commit comments