-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: thread list state order after dragable #5141
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
Conversation
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.
Caution
Changes requested ❌
Reviewed everything up to b0b8189 in 1 minute and 47 seconds. Click for details.
- Reviewed
109
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/containers/ThreadList.tsx:269
- Draft comment:
Avoid mutating the props array using sort(); consider cloning the array (e.g., [...threads].sort(...)) to prevent potential side effects. - Reason this comment was not posted:
Comment was on unchanged code.
2. web-app/src/containers/ThreadList.tsx:328
- Draft comment:
Using index as a key in the list can lead to issues with component identity during drag-and-drop. Use thread.id as a unique key instead. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_mbsHvghlFPa3g8fy
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
@@ -35,7 +35,26 @@ export function DataProvider() { | |||
|
|||
useEffect(() => { | |||
fetchThreads().then((threads) => { | |||
setThreads(threads) | |||
// Sort threads by order if available, otherwise by updated time | |||
const sortedThreads = threads.sort((a, b) => { |
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.
Sort is performed directly on the fetched threads
array. Cloning it before sorting (e.g., [...threads].sort(...)
) would avoid unintended mutations.
const sortedThreads = threads.sort((a, b) => { | |
const sortedThreads = [...threads].sort((a, b) => { |
@@ -268,9 +268,14 @@ function ThreadList({ threads }: ThreadListProps) { | |||
|
|||
const sortedThreads = useMemo(() => { | |||
return threads.sort((a, b) => { |
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.
The sorting comparator logic is duplicated in both ThreadList
and DataProvider
. Consider extracting it into a shared utility to reduce maintenance overhead.
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.
Caution
Changes requested ❌
Reviewed 820b378 in 1 minute and 48 seconds. Click for details.
- Reviewed
152
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
3
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/hooks/useThreads.ts:38
- Draft comment:
Avoid directly mutating threads (e.g. setting thread.order) in setThreads; consider using an immutable approach (e.g. mapping to new objects) to prevent side‐effects. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. web-app/src/services/threads.ts:58
- Draft comment:
Good update: Propagating the order using 'order: thread.order' (with fallback via e.metadata?.order) ensures proper thread ordering. Verify that thread.order is always defined as expected. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
3. web-app/src/hooks/useThreads.ts:55
- Draft comment:
Formatting improvements (e.g. consistent trailing commas and removal of unnecessary semicolons) enhance readability; no action needed. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
Workflow ID: wflow_RQ0cW8pK7TVaWfgP
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
const reorderedThreads = [createdThread, ...existingThreads] | ||
|
||
// Use setThreads to handle proper ordering (this will assign order 1, 2, 3...) | ||
get().setThreads(reorderedThreads) |
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.
Calling get().setThreads
inside a set()
callback (in createThread
) causes nested state updates. Consider merging updates into a single set
call to simplify state management.
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.
Important
Looks good to me! 👍
Reviewed 683e9b8 in 1 minute and 17 seconds. Click for details.
- Reviewed
48
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/providers/DataProvider.tsx:1
- Draft comment:
Removed unused useThreads import and setThreads usage. Ensure thread state is now managed elsewhere (e.g., in ThreadList). - Reason this comment was not posted:
Comment looked like it was already resolved.
2. web-app/src/providers/DataProvider.tsx:36
- Draft comment:
Thread sorting logic and default order assignment were removed. Confirm that ordering is now correctly managed (perhaps in ThreadList) to support drag-and-drop. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%
<= threshold50%
The comment is asking the PR author to confirm that the ordering is correctly managed after removing the sorting logic. This falls under asking the author to confirm their intention or ensure behavior, which is against the rules.
Workflow ID: wflow_WqI3WMuH1BqA0eXd
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Describe Your Changes
This pull request focuses on improving thread sorting logic and cleaning up code formatting in the
ThreadList
andDataProvider
components. The most significant changes include refining the thread sorting mechanism to handle missingorder
values, ensuring consistent drag-and-drop behavior, and removing unnecessary semicolons for cleaner syntax.Thread Sorting Enhancements:
web-app/src/containers/ThreadList.tsx
: Updated the sorting logic inThreadList
to prioritize threads with anorder
value, followed by updated time for threads without anorder
. This ensures a consistent and predictable sorting mechanism.web-app/src/providers/DataProvider.tsx
: Enhanced thread initialization by sorting threads and assigning defaultorder
values to those without one, ensuring compatibility with future drag-and-drop operations.Code Formatting Improvements:
web-app/src/containers/ThreadList.tsx
: Removed unnecessary semicolons across multiple sections of the code for cleaner syntax. [1] [2] [3]Fixes Issues
Self Checklist
Important
Improves thread sorting logic and code formatting in
ThreadList.tsx
andDataProvider.tsx
, handling missingorder
values and removing unnecessary semicolons.ThreadList.tsx
to prioritize threads withorder
, then by updated time iforder
is missing.DataProvider.tsx
, threads are initialized with defaultorder
values for future drag-and-drop operations.ThreadList.tsx
for cleaner syntax.setThreads
inuseThreads.ts
to assignorder
values during thread initialization.createThread
andupdateThread
inthreads.ts
to handleorder
metadata.This description was created by
for 683e9b8. You can customize this summary. It will automatically update as commits are pushed.