TypeScript
fix(web): boring sidebar folders put your latest message on top (#26391)
Theo Browne80fcb7f58f90
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex ddc7ad1e7bd..0868554b50f 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -337,6 +337,8 @@ interface SidebarThreadPartitionInput {readonly serverConfigs: ReadonlyMap<EnvironmentId, EnvironmentServerConfig>;readonly optimisticDrop: SidebarOptimisticDrop | null;readonly workingShelfEnabled: boolean;+ /** Boring mode: folders list active threads by the user's latest message. */+ readonly sortActiveBySend: boolean;// Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend// on the clock, so the minute tick, the precise snooze-wake tick and the inbox// tracker's expiry version are inputs: a new key repartitions.@@ -458,6 +460,7 @@ function useSidebarThreads(input: {serverConfigs,optimisticDrop,workingShelfEnabled,+ sortActiveBySend: folderGroups !== null,clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,});@@ -592,6 +595,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {serverConfigs,optimisticDrop,workingShelfEnabled,+ sortActiveBySend,} = input;const preciseNow = new Date().toISOString();const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent);@@ -650,9 +654,11 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {}// A loaded config gates dragging only; the sort must not depend on it, so web and mobile agree.const sortedPinned = sortPinnedThreadsForSidebar(pinned);- const sortedActive = workingShelfEnabled- ? sortInboxThreadsByReturn(active, inboxObservation.returnedAt)- : sortThreadsForSidebar(active);+ const sortedActive = sortActiveBySend+ ? sortWorkingThreadsBySend(active)+ : workingShelfEnabled+ ? sortInboxThreadsByReturn(active, inboxObservation.returnedAt)+ : sortThreadsForSidebar(active);return {pinnedThreads:optimisticDrop?.section !== "pinned" || optimisticDrop.order === null