Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,26 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
}

// regular message
// Check if this follow-up question has been answered
// For current session: check if it matches currentFollowUpTs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments are helpful but could be more concise. Consider combining them:

// For history: check if there's a message after this follow-up question
const isFollowUpAnswered = (() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice this logic is duplicated from what appears around line 1521. Could we extract this into a reusable function to follow DRY principles? Something like:

if (messageOrGroup.ask === "followup") {
// First check if it's the current follow-up that was just answered
if (messageOrGroup.ts === currentFollowUpTs) {
return true
}
// For historical messages, check if there's a message after this follow-up
// If there is, it means the follow-up was answered
const messageIndex = modifiedMessages.findIndex((msg) => msg.ts === messageOrGroup.ts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using on for every render could impact performance with large message lists. Have you considered memoizing this check or perhaps storing the answered state in a more efficient data structure?

if (messageIndex !== -1 && messageIndex < modifiedMessages.length - 1) {
// There's at least one message after this follow-up, so it was answered
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current logic assumes any message after a follow-up means it was answered. What if there's an error message or system message immediately after? Should we verify the next message is actually a user response or an action that indicates the follow-up was handled?

return true
}
}
return false
})()

return (
<ChatRow
key={messageOrGroup.ts}
Expand All @@ -1498,7 +1518,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
onSuggestionClick={handleSuggestionClickInRow} // This was already stabilized
onBatchFileResponse={handleBatchFileResponse}
onFollowUpUnmount={handleFollowUpUnmount}
isFollowUpAnswered={messageOrGroup.ts === currentFollowUpTs}
isFollowUpAnswered={isFollowUpAnswered}
editable={
messageOrGroup.type === "ask" &&
messageOrGroup.ask === "tool" &&
Expand Down
Loading