-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't workingdata layerPertains to data layers.Pertains to data layers.needs-triagestaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Description
Describe the bug
Elements belonging to a thread may be rendered in the wrong order on the UI. This happens because the SQL query used to fetch elements in SQLAlchemyDataLayer.get_all_user_threads does not contain an ORDER BY clause, which may cause the database to return elements in an arbitrary order. This can cause elements to appear out of place or pages to render unexpectedly.
To Reproduce
Steps to reproduce the behavior:
- Create several elements attached to a Step.
- Open the thread in the UI.
- Expand the Step element if it is collapsed
- Observe that elements sometimes are displayed out of sequence.
Expected behavior
Elements should be rendered in a deterministic, page-based and/or creation order, matching the order they were added or their intended arrangement.
Additional context
Relevant code snippet (in backend/chainlit/data/sql_alchemy.py):
elements_query = f"""
SELECT ...
FROM elements e
WHERE e."threadId" IN {thread_ids}
"""Suggested fix:
Add something like:
ORDER BY e."page" ASC NULLS LAST, e."id" ASCto ensure deterministic ordering.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdata layerPertains to data layers.Pertains to data layers.needs-triagestaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed