Skip to content

Sort sidebar threads by most recent user message#827

Open
dbalders wants to merge 1 commit intopingdotgg:mainfrom
dbalders:sidebar-ordering
Open

Sort sidebar threads by most recent user message#827
dbalders wants to merge 1 commit intopingdotgg:mainfrom
dbalders:sidebar-ordering

Conversation

@dbalders
Copy link
Contributor

@dbalders dbalders commented Mar 10, 2026

Makes the left sidebar feel more natural by moving threads up when you send a message in them.

Instead of sorting by creation date, the sidebar now uses your latest user prompt to determine recency. It updates immediately when you hit send, then settles back onto confirmed server state.

Tests added:

  • thread recency derivation and comparator behavior
  • ignoring assistant-only messages for sorting
  • optimistic recency winning immediately after send
  • snapshot reconciliation clearing optimistic state once confirmed messages catch up
  • dropping stale optimistic state for missing threads

What Changed

Updated sidebar thread ordering so threads are no longer sorted by creation date. The sidebar now uses the latest user prompt as the recency signal, and it moves a thread up immediately when you send a message in it. That optimistic move then settles back onto confirmed server state once the message appears in the synced snapshot.

Why

Fixes #805, which I agree is a nicer user flow and more fits the expectations of how using ChatGPT like systems and Codex App itself by bringing most recent chats to the top.

UI Changes

The left sidebar now reorders threads when you send a message, rather than keeping them fixed by original creation time.

Video:
https://github.com/user-attachments/assets/3570d19c-a10f-4481-abf4-9507af096289

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Sort sidebar threads by most recent user message using optimistic timestamps

  • Adds a compareThreadsForSidebar utility in threadRecency.ts that sorts threads by the latest confirmed user message time, falling back to thread creation time, with deterministic tiebreakers.
  • Introduces optimisticUserSendAtByThreadId to the Zustand store to track per-thread optimistic timestamps when a user sends a message, so the sidebar reorders immediately without waiting for a server response.
  • syncServerReadModel prunes optimistic timestamps when the server-confirmed user message time catches up or the thread no longer exists.
  • The Sidebar now uses compareThreadsForSidebar with the optimistic map, replacing previous inline sort comparators.
  • Behavioral Change: threads previously sorted by assistant activity or creation time will now sort by user message recency, which may reorder existing thread lists.

Macroscope summarized e9db229.

Copilot AI review requested due to automatic review settings March 10, 2026 18:24
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5f0badb6-b661-4505-a4b2-cdf69c862c3c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Issue #805 by changing the left sidebar thread ordering from creation date to most-recent-user-message date. It introduces an optimistic update mechanism so the sidebar reorders immediately when you send a message, then settles to confirmed server state when the message is synced.

Changes:

  • New threadRecency.ts module with pure helpers (getLatestUserMessageAt, getThreadSidebarRecency, compareThreadsForSidebar) and their tests
  • New optimisticUserSendAtByThreadId state field in the Zustand store, with markThreadOptimisticUserSend / clearThreadOptimisticUserSend actions, and cleanup logic in syncServerReadModel
  • Sidebar.tsx now uses compareThreadsForSidebar instead of inline creation-date comparators; ChatView.tsx calls markThreadOptimisticUserSend on send and clearThreadOptimisticUserSend on error

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/web/src/lib/threadRecency.ts New module with recency helpers for sidebar sorting
apps/web/src/lib/threadRecency.test.ts Tests for new threadRecency helpers
apps/web/src/store.ts Adds optimisticUserSendAtByThreadId state, new actions, and cleanup in syncServerReadModel
apps/web/src/store.test.ts Tests for new store actions and syncServerReadModel cleanup behavior
apps/web/src/components/Sidebar.tsx Replaces inline creation-date sort with compareThreadsForSidebar
apps/web/src/components/ChatView.tsx Marks/clears the optimistic send timestamp on send and error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Makes the left sidebar feel more natural by moving threads up when you send a message in them.

Instead of sorting by creation date, the sidebar now uses your latest user prompt to determine recency. It updates immediately when you hit send, then settles back onto confirmed server state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order threads in a project based on activity

2 participants