Skip to content

Commit ee6f074

Browse files
committed
fix: address review feedback
- Remove unused lastCheckpointInfo parameter from ChatRowContent - Remove unreachable return null statement - Optimize useMemo performance for lastCheckpointInfo calculation
1 parent e9fdf23 commit ee6f074

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export const ChatRowContent = ({
117117
onBatchFileResponse,
118118
isFollowUpAnswered,
119119
editable,
120-
lastCheckpointInfo: _lastCheckpointInfo,
121120
}: ChatRowContentProps) => {
122121
const { t } = useTranslation()
123122
const { mcpServers, alwaysAllowMcp, currentCheckpoint: _currentCheckpoint, mode } = useExtensionState()
@@ -1345,9 +1344,6 @@ export const ChatRowContent = ({
13451344
return null
13461345
}
13471346
}
1348-
1349-
// Default return for messages that don't match any case
1350-
return null
13511347
}
13521348

13531349
// Create a wrapper component to handle the checkpoint UI
@@ -1356,7 +1352,7 @@ export const ChatRowWithCheckpoint: React.FC<ChatRowContentProps> = (props) => {
13561352
const { currentCheckpoint } = useExtensionState()
13571353

13581354
// Render the regular content
1359-
const content = <ChatRowContent {...props} lastCheckpointInfo={null} />
1355+
const content = <ChatRowContent {...props} />
13601356

13611357
// Check if we should show checkpoint UI
13621358
const shouldShowCheckpoint =

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
145145
return getLatestTodo(messages)
146146
}, [messages])
147147

148-
// Track the last checkpoint message
148+
// Track the last checkpoint message - optimized to only recalculate when checkpoint messages change
149+
const checkpointMessages = useMemo(() => messages.filter((msg) => msg.say === "checkpoint_saved"), [messages])
149150
const lastCheckpointInfo = useMemo(() => {
150-
// Find the last checkpoint_saved message
151-
const checkpointMessages = messages.filter((msg) => msg.say === "checkpoint_saved")
152151
if (checkpointMessages.length === 0) return null
153152

154153
const lastCheckpoint = checkpointMessages[checkpointMessages.length - 1]
@@ -157,7 +156,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
157156
commitHash: lastCheckpoint.text || "",
158157
checkpoint: lastCheckpoint.checkpoint,
159158
}
160-
}, [messages])
159+
}, [checkpointMessages])
161160

162161
const modifiedMessages = useMemo(() => combineApiRequests(combineCommandSequences(messages.slice(1))), [messages])
163162

0 commit comments

Comments
 (0)