-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: prevent countdown timer from showing in history for answered follow-up questions #7625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| // For history: check if there's a message after this follow-up question | ||
| const isFollowUpAnswered = (() => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} | ||
|
|
@@ -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" && | ||
|
|
||
There was a problem hiding this comment.
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: