Skip to content
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

fix: Sort thread history groups in fixed order #1967

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

goda6565
Copy link
Contributor

@goda6565 goda6565 commented Mar 7, 2025

This PR fixes the inconsistent order of thread history groups in the left sidebar. The groups (Today, Yesterday, Previous 7 days, Previous 30 days) were stored as object keys, and JavaScript does not guarantee their order. I added explicit sorting using a fixed order array so that the groups always appear in the intended order.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working frontend Pertains to the frontend. labels Mar 7, 2025
Copy link
Collaborator

@willydouhard willydouhard left a comment

Choose a reason for hiding this comment

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

LGTM overall, curious to know in which scenario the keys were not sorted correctly naturally

<SidebarMenuButton
isActive={isSelected}
className="relative truncate h-9 group/thread"
{Object.keys(threadHistory.timeGroupedThreads ?? {})
Copy link
Collaborator

Choose a reason for hiding this comment

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

we could use useMemo here

@goda6565
Copy link
Contributor Author

goda6565 commented Mar 7, 2025

It’s difficult to reproduce intentionally, but I’ve seen instances—and others have too—where the keys ended up in a different order than expected. This isn’t something we can easily trigger on demand, but those sporadic cases were enough to warrant adding explicit sorting for consistency.

@goda6565 goda6565 requested a review from willydouhard March 7, 2025 18:43
Copy link
Collaborator

@willydouhard willydouhard left a comment

Choose a reason for hiding this comment

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

lgtm

@willydouhard willydouhard added this pull request to the merge queue Mar 7, 2025
Merged via the queue into Chainlit:main with commit d7ae77e Mar 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Pertains to the frontend. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants