Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🖌️ style: Update conversation history groups (#1770)

Trevor Swanson14b61fc86196
diff --git a/client/src/utils/convos.spec.ts b/client/src/utils/convos.spec.ts
index 1d21d8654c..4541544253 100644
--- a/client/src/utils/convos.spec.ts
+++ b/client/src/utils/convos.spec.ts
@@ -15,12 +15,21 @@ describe('Conversation Utilities', () => {
const conversations = [
{ conversationId: '1', updatedAt: '2023-04-01T12:00:00Z' },
{ conversationId: '2', updatedAt: new Date().toISOString() },
+ { conversationId: '3', updatedAt: new Date(Date.now() - 86400000).toISOString() }, // 86400 seconds ago = yesterday
+ { conversationId: '4', updatedAt: new Date(Date.now() - 86400000 * 2).toISOString() }, // 2 days ago (previous 7 days)
+ { conversationId: '5', updatedAt: new Date(Date.now() - 86400000 * 8).toISOString() }, // 8 days ago (previous 30 days)
];
const grouped = groupConversationsByDate(conversations as TConversation[]);
expect(grouped[0][0]).toBe('Today');
expect(grouped[0][1]).toHaveLength(1);
- expect(grouped[1][0]).toBe(' 2023');
+ expect(grouped[1][0]).toBe('Yesterday');
expect(grouped[1][1]).toHaveLength(1);
+ expect(grouped[2][0]).toBe('Previous 7 days');
+ expect(grouped[2][1]).toHaveLength(1);
+ expect(grouped[3][0]).toBe('Previous 30 days');
+ expect(grouped[3][1]).toHaveLength(1);
+ expect(grouped[4][0]).toBe(' 2023');
+ expect(grouped[4][1]).toHaveLength(1);
});
it('returns an empty array for no conversations', () => {
diff --git a/client/src/utils/convos.ts b/client/src/utils/convos.ts
index 5f2741bd8d..c6f33e6d47 100644
--- a/client/src/utils/convos.ts
+++ b/client/src/utils/convos.ts
@@ -1,4 +1,14 @@
-import { parseISO, isToday, isWithinInterval, subDays, getYear } from 'date-fns';
+import {
+ parseISO,
+ isToday,
+ isWithinInterval,
+ subDays,
+ getMonth,
+ getYear,
+ startOfDay,
+ startOfYear,
+ format,
+} from 'date-fns';
import type {
TConversation,
ConversationData,
@@ -11,11 +21,17 @@ const getGroupName = (date: Date) => {
if (isToday(date)) {
return 'Today';
}
+ if (isWithinInterval(date, { start: startOfDay(subDays(now, 1)), end: now })) {
+ return 'Yesterday';
+ }
if (isWithinInterval(date, { start: subDays(now, 7), end: now })) {
- return 'Last 7 days';
+ return 'Previous 7 days';
}
if (isWithinInterval(date, { start: subDays(now, 30), end: now })) {
- return 'Last 30 days';
+ return 'Previous 30 days';
+ }
+ if (isWithinInterval(date, { start: startOfYear(now), end: now })) {
+ return ' ' + format(date, 'MMMM');
}
return ' ' + getYear(date).toString();
};