Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(chats): group the sidebar chat list under one heading per day (#517)

Ruben Lütke12367751a076
diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
index 898aeb526d..9b1d7b215d 100644
--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
@@ -2,15 +2,15 @@ import { useState } from "react";
import { Archive, Pin, PinOff, Trash2 } from "lucide-react";
import { useAgentChatStore } from "@/store/agentChat";
-import { useT } from "@/i18n";
+import { useT, useUiLanguage } from "@/i18n";
import { cn } from "@/lib/utils";
import { AllChatsDialog } from "@/components/home/AllChatsDialog";
import { ChatKindMark } from "@/components/home/ChatKindMark";
-import { chatRowLabel, useChatRows, type ChatRow } from "@/components/home/chatRows";
+import { chatRowLabel, formatChatDay, groupChatRowsByDay, useChatRows, type ChatRow } from "@/components/home/chatRows";
import { useHistoryPolling } from "@/hooks/useHistoryPolling";
-/** Flat sidebar history: pinned conversations first, then the latest chats. */
+/** Sidebar history: pinned conversations first, then the chats under one heading per day. */
const PINNED_KEY = "jarvis.sidebar.pinned-chats.v1";
function readPins(): string[] {
try {
@@ -24,6 +24,7 @@ function readPins(): string[] {
const rowKey = (row: ChatRow) => `${row.kind}:${row.id}`;
export function RecentChats() {
const t = useT();
+ const lang = useUiLanguage();
const { rows, isActive, open: openRow, remove } = useChatRows({ poll: true });
const loadSessions = useAgentChatStore((s) => s.loadSessions);
const [pins, setPins] = useState(readPins);
@@ -43,7 +44,7 @@ export function RecentChats() {
// Every chat is listed in one column: the
// sidebar scrolls instead of hiding the history behind "Show all"
// (maintainer, 2026-10-01). The archive dialog stays for searching it.
- const shown = recentRows;
+ const days = groupChatRowsByDay(recentRows);
return (
<>
@@ -54,24 +55,33 @@ export function RecentChats() {
active={isActive(row)} pinned onPin={() => togglePin(row)} onOpen={() => openRow(row)}
onDelete={row.kind === "agent" ? () => remove(row) : undefined} />)}</ul>
</section>}
- <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">{t("sidebar.recent")}</h2>
- {shown.length === 0 ? (
- <p className="py-1 px-3 text-sm text-foreground-faint">
- {t("sidebar.no_chats")}
- </p>
+ {recentRows.length === 0 ? (
+ <>
+ <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">{t("sidebar.recent")}</h2>
+ <p className="py-1 px-3 text-sm text-foreground-faint">
+ {t("sidebar.no_chats")}
+ </p>
+ </>
) : (
- <ul className="space-y-0.5">
- {shown.map((row) => (
- <ChatRowItem
- key={`${row.kind}-${row.id}`}
- row={row}
- active={isActive(row)}
- onPin={() => togglePin(row)}
- onOpen={() => openRow(row)}
- onDelete={row.kind === "agent" ? () => remove(row) : undefined}
- />
- ))}
- </ul>
+ days.map((day) => (
+ <section key={day.dayMs} data-testid="chat-day" className="mb-6 last:mb-1">
+ <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">
+ {day.relative ? t(`all_chats.group_${day.relative}`) : formatChatDay(day.dayMs, lang)}
+ </h2>
+ <ul className="space-y-0.5">
+ {day.rows.map((row) => (
+ <ChatRowItem
+ key={`${row.kind}-${row.id}`}
+ row={row}
+ active={isActive(row)}
+ onPin={() => togglePin(row)}
+ onOpen={() => openRow(row)}
+ onDelete={row.kind === "agent" ? () => remove(row) : undefined}
+ />
+ ))}
+ </ul>
+ </section>
+ ))
)}
{rows.length > 0 && (
<button
diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.test.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.test.ts
new file mode 100644
index 0000000000..da77290fbc
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, test } from "vitest";
+
+import { formatChatDay, groupChatRowsByDay, type ChatRow } from "@/components/home/chatRows";
+
+const at = (y: number, m: number, d: number, h = 12, min = 0) => new Date(y, m - 1, d, h, min).getTime();
+const row = (id: string, updatedMs: number): ChatRow => ({
+ kind: "agent", id, title: id, preview: "", updatedMs, messageCount: 1, provider: "", raw: null,
+});
+
+describe("groupChatRowsByDay", () => {
+ const now = at(2026, 10, 9, 18);
+
+ test("one heading per calendar day, newest day and newest chat first", () => {
+ const groups = groupChatRowsByDay(
+ [row("oct7-am", at(2026, 10, 7, 9)), row("today", at(2026, 10, 9, 8)), row("oct7-pm", at(2026, 10, 7, 21)),
+ row("yesterday", at(2026, 10, 8, 23, 50)), row("oct3", at(2026, 10, 3))],
+ now,
+ );
+ expect(groups.map((g) => g.relative)).toEqual(["today", "yesterday", null, null]);
+ expect(groups.map((g) => g.rows.map((r) => r.id))).toEqual([["today"], ["yesterday"], ["oct7-pm", "oct7-am"], ["oct3"]]);
+ });
+
+ test("a chat just before midnight and one just after land on different days", () => {
+ const groups = groupChatRowsByDay([row("late", at(2026, 10, 8, 23, 59)), row("early", at(2026, 10, 9, 0, 1))], now);
+ expect(groups.map((g) => g.rows[0].id)).toEqual(["early", "late"]);
+ });
+
+ test("the date carries the year only when it is not this year", () => {
+ expect(formatChatDay(at(2026, 10, 7, 0), "en-US", now)).toBe("Oct 7");
+ expect(formatChatDay(at(2025, 10, 7, 0), "en-US", now)).toBe("Oct 7, 2025");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
index cabb02e033..2fc650846b 100644
--- a/jarvis/ui/web/frontend/src/components/home/chatRows.ts
+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
@@ -213,6 +213,50 @@ export function groupChatRows(rows: ChatRow[], now = Date.now()): Array<{ bucket
}));
}
+export interface ChatDayGroup {
+ /** Local midnight of the day, so a key stays stable across renders. */
+ dayMs: number;
+ /** "today" and "yesterday" get a word; every other day is a date. */
+ relative: "today" | "yesterday" | null;
+ rows: ChatRow[];
+}
+
+/**
+ * Group rows under one heading per calendar day, newest day first and the
+ * newest chat first inside each day. Days are local days, so a chat at 23:50
+ * and one at 00:10 land under different headings.
+ */
+export function groupChatRowsByDay(rows: ChatRow[], now = Date.now()): ChatDayGroup[] {
+ const startOfDay = (ms: number) => {
+ const d = new Date(ms);
+ d.setHours(0, 0, 0, 0);
+ return d.getTime();
+ };
+ const today = startOfDay(now);
+ const yesterday = startOfDay(today - 1);
+ const days = new Map<number, ChatRow[]>();
+ for (const row of [...rows].sort((a, b) => b.updatedMs - a.updatedMs)) {
+ const day = startOfDay(row.updatedMs);
+ const list = days.get(day);
+ if (list) list.push(row);
+ else days.set(day, [row]);
+ }
+ return [...days.entries()]
+ .sort(([a], [b]) => b - a)
+ .map(([dayMs, group]) => ({
+ dayMs,
+ relative: dayMs >= today ? "today" : dayMs === yesterday ? "yesterday" : null,
+ rows: group,
+ }));
+}
+
+/** A day heading's date: "Oct 7", with the year only when it is not this year's. */
+export function formatChatDay(dayMs: number, lang: string, now = Date.now()): string {
+ const d = new Date(dayMs);
+ const sameYear = d.getFullYear() === new Date(now).getFullYear();
+ return d.toLocaleDateString(lang, sameYear ? { month: "short", day: "numeric" } : { month: "short", day: "numeric", year: "numeric" });
+}
+
/** Case-insensitive match over title and preview. An empty query keeps everything. */
export function filterChatRows(rows: ChatRow[], query: string): ChatRow[] {
const q = query.trim().toLowerCase();