-
Notifications
You must be signed in to change notification settings - Fork 775
fix(sidebar): misleading thread timestamp #1030
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,25 @@ function formatRelativeTime(iso: string): string { | |
| return `${Math.floor(hours / 24)}d ago`; | ||
| } | ||
|
|
||
| function getThreadSidebarTimestamp(thread: Thread): string { | ||
| if (thread.messages.length === 0) { | ||
| return thread.createdAt; | ||
| } | ||
|
|
||
| let earliestTimestamp = thread.messages[0]?.createdAt ?? thread.createdAt; | ||
| let earliestTime = new Date(earliestTimestamp).getTime(); | ||
|
|
||
| for (const message of thread.messages) { | ||
| const messageTime = new Date(message.createdAt).getTime(); | ||
| if (messageTime < earliestTime) { | ||
| earliestTimestamp = message.createdAt; | ||
| earliestTime = messageTime; | ||
| } | ||
| } | ||
|
|
||
| return earliestTimestamp; | ||
|
Comment on lines
+108
to
+123
|
||
| } | ||
|
Comment on lines
+107
to
+124
|
||
|
|
||
| interface TerminalStatusIndicator { | ||
| label: "Terminal process running"; | ||
| colorClass: string; | ||
|
|
@@ -386,7 +405,9 @@ export default function Sidebar() { | |
| const latestThread = threads | ||
| .filter((thread) => thread.projectId === projectId) | ||
| .toSorted((a, b) => { | ||
| const byDate = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(); | ||
| const byDate = | ||
| new Date(getThreadSidebarTimestamp(b)).getTime() - | ||
| new Date(getThreadSidebarTimestamp(a)).getTime(); | ||
| if (byDate !== 0) return byDate; | ||
| return b.id.localeCompare(a.id); | ||
| })[0]; | ||
|
|
@@ -1297,7 +1318,8 @@ export default function Sidebar() { | |
| .filter((thread) => thread.projectId === project.id) | ||
| .toSorted((a, b) => { | ||
| const byDate = | ||
| new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(); | ||
| new Date(getThreadSidebarTimestamp(b)).getTime() - | ||
| new Date(getThreadSidebarTimestamp(a)).getTime(); | ||
|
Comment on lines
+1321
to
+1322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new comparator recomputes Useful? React with 👍 / 👎. |
||
| if (byDate !== 0) return byDate; | ||
| return b.id.localeCompare(a.id); | ||
| }); | ||
|
|
@@ -1551,7 +1573,7 @@ export default function Sidebar() { | |
| : "text-muted-foreground/40" | ||
| }`} | ||
| > | ||
| {formatRelativeTime(thread.createdAt)} | ||
| {formatRelativeTime(getThreadSidebarTimestamp(thread))} | ||
| </span> | ||
| </div> | ||
| </SidebarMenuSubButton> | ||
|
|
||
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.
🟢 Low
Issue on line in
apps/web/src/components/Sidebar.tsx:107:getThreadSidebarTimestampreturns the earliest message timestamp, but the sidebar sorting logic expects the latest timestamp so that more recent activity appears first. This causes threads to sort incorrectly — for example, a thread with messages at [10:01, 10:05] returns 10:01 and appears older than a thread with a single message at 10:03. Change the comparison to find the maximum timestamp instead.🚀 Reply "fix it for me" or copy this AI Prompt for your agent: