Skip to content

Conversation

urmauur
Copy link
Member

@urmauur urmauur commented May 29, 2025

Describe Your Changes

This pull request focuses on improving thread sorting logic and cleaning up code formatting in the ThreadList and DataProvider components. The most significant changes include refining the thread sorting mechanism to handle missing order 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 in ThreadList to prioritize threads with an order value, followed by updated time for threads without an order. This ensures a consistent and predictable sorting mechanism.
  • web-app/src/providers/DataProvider.tsx: Enhanced thread initialization by sorting threads and assigning default order values to those without one, ensuring compatibility with future drag-and-drop operations.

Code Formatting Improvements:

Fixes Issues

  • Closes #
  • Closes #

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

Important

Improves thread sorting logic and code formatting in ThreadList.tsx and DataProvider.tsx, handling missing order values and removing unnecessary semicolons.

  • Behavior:
    • Updated sorting logic in ThreadList.tsx to prioritize threads with order, then by updated time if order is missing.
    • In DataProvider.tsx, threads are initialized with default order values for future drag-and-drop operations.
  • Code Formatting:
    • Removed unnecessary semicolons in ThreadList.tsx for cleaner syntax.
  • Misc:
    • Adjusted setThreads in useThreads.ts to assign order values during thread initialization.
    • Updated createThread and updateThread in threads.ts to handle order metadata.

This description was created by Ellipsis for 683e9b8. You can customize this summary. It will automatically update as commits are pushed.

@urmauur urmauur added this to the v0.5.18 milestone May 29, 2025
@urmauur urmauur requested a review from louis-menlo May 29, 2025 15:14
@urmauur urmauur self-assigned this May 29, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 2 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 Ellipsis 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) => {
Copy link
Contributor

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.

Suggested change
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) => {
Copy link
Contributor

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.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 2 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% <= threshold 50% 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% <= threshold 50% None

Workflow ID: wflow_RQ0cW8pK7TVaWfgP

You can customize Ellipsis 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)
Copy link
Contributor

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.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 1 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% <= threshold 50% 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 Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@urmauur urmauur merged commit 426dc2a into release/v0.5.18 May 29, 2025
13 checks passed
@urmauur urmauur deleted the fix/thread-list-state branch May 29, 2025 17:00
@github-project-automation github-project-automation bot moved this from Done to QA in Jan May 29, 2025
@github-actions github-actions bot modified the milestones: v0.5.18, v0.5.19 May 29, 2025
@david-menloai david-menloai moved this from QA to Done in Jan Jun 20, 2025
@LazyYuuki LazyYuuki removed this from the v0.7.2 milestone Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants