Sort sidebar threads by most recent user message#827
Sort sidebar threads by most recent user message#827dbalders wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.tsmodule with pure helpers (getLatestUserMessageAt,getThreadSidebarRecency,compareThreadsForSidebar) and their tests - New
optimisticUserSendAtByThreadIdstate field in the Zustand store, withmarkThreadOptimisticUserSend/clearThreadOptimisticUserSendactions, and cleanup logic insyncServerReadModel Sidebar.tsxnow usescompareThreadsForSidebarinstead of inline creation-date comparators;ChatView.tsxcallsmarkThreadOptimisticUserSendon send andclearThreadOptimisticUserSendon 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.
53de14b to
3383fd8
Compare
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.
3383fd8 to
e9db229
Compare
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:
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
Note
Sort sidebar threads by most recent user message using optimistic timestamps
compareThreadsForSidebarutility in threadRecency.ts that sorts threads by the latest confirmed user message time, falling back to thread creation time, with deterministic tiebreakers.optimisticUserSendAtByThreadIdto 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.syncServerReadModelprunes optimistic timestamps when the server-confirmed user message time catches up or the thread no longer exists.compareThreadsForSidebarwith the optimistic map, replacing previous inline sort comparators.Macroscope summarized e9db229.