diff --git a/frontend/src/components/session/SessionCard.tsx b/frontend/src/components/session/SessionCard.tsx
new file mode 100644
index 00000000..df99a8c9
--- /dev/null
+++ b/frontend/src/components/session/SessionCard.tsx
@@ -0,0 +1,70 @@
+import { Card } from "@/components/ui/card";
+import { Checkbox } from "@/components/ui/checkbox";
+import { Trash2, Clock } from "lucide-react";
+import { formatDistanceToNow } from "date-fns";
+import type { Session } from "@/api/types";
+
+interface SessionCardProps {
+ session: Session;
+ isSelected: boolean;
+ isActive: boolean;
+ onSelect: (sessionID: string) => void;
+ onToggleSelection: (selected: boolean) => void;
+ onDelete: (e: React.MouseEvent
) => void;
+}
+
+export const SessionCard = ({
+ session,
+ isSelected,
+ isActive,
+ onSelect,
+ onToggleSelection,
+ onDelete,
+}: SessionCardProps) => {
+ return (
+ onSelect(session.id)}
+ >
+
+
+
{
+ onToggleSelection(checked === true);
+ }}
+ onClick={(e) => {
+ e.stopPropagation();
+ }}
+ className="w-5 h-5 flex-shrink-0 mt-0.5"
+ />
+
+
+ {session.title || "Untitled Session"}
+
+
+
+
+ {formatDistanceToNow(new Date(session.time.updated), {
+ addSuffix: true,
+ })}
+
+
+
+
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/frontend/src/components/session/SessionList.tsx b/frontend/src/components/session/SessionList.tsx
index f6de64a0..a7cc20a0 100644
--- a/frontend/src/components/session/SessionList.tsx
+++ b/frontend/src/components/session/SessionList.tsx
@@ -1,13 +1,11 @@
import { useState, useMemo } from "react";
import { useSessions, useDeleteSession } from "@/hooks/useOpenCode";
-import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
-import { Checkbox } from "@/components/ui/checkbox";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { DeleteSessionDialog } from "./DeleteSessionDialog";
-import { Trash2, Clock, Search, MoreVertical } from "lucide-react";
-import { formatDistanceToNow } from "date-fns";
+import { SessionCard } from "./SessionCard";
+import { Trash2, Search, MoreVertical } from "lucide-react";
interface SessionListProps {
opcodeUrl: string;
@@ -52,6 +50,20 @@ export const SessionList = ({
return filtered.sort((a, b) => b.time.updated - a.time.updated);
}, [sessions, searchQuery, directory]);
+ const todaySessions = useMemo(() => {
+ if (!filteredSessions) return [];
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+ return filteredSessions.filter((session) => new Date(session.time.updated) >= today);
+ }, [filteredSessions]);
+
+ const olderSessions = useMemo(() => {
+ if (!filteredSessions) return [];
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+ return filteredSessions.filter((session) => new Date(session.time.updated) < today);
+ }, [filteredSessions]);
+
if (isLoading) {
return Loading sessions...
;
}
@@ -121,8 +133,8 @@ export const SessionList = ({
return (
-
-
+
+
-
+
{filteredSessions.length === 0 ? (
No sessions found
) : (
- filteredSessions.map((session) => (
-
onSelectSession(session.id)}
- >
-
-
-
{
- toggleSessionSelection(session.id, checked === true);
- }}
- onClick={(e) => {
- e.stopPropagation();
- }}
- className="w-5 h-5 flex-shrink-0 mt-0.5"
- />
-
-
- {session.title || "Untitled Session"}
-
-
-
-
- {formatDistanceToNow(new Date(session.time.updated), {
- addSuffix: true,
- })}
-
-
-
+ <>
+ {todaySessions.length > 0 && (
+ <>
+
+ Today
-
-
-
- ))
+ {todaySessions.map((session) => (
+
{
+ toggleSessionSelection(session.id, selected);
+ }}
+ onDelete={(e) => handleDelete(session.id, e)}
+ />
+ ))}
+ >
+ )}
+
+ {olderSessions.length > 0 && (
+ <>
+
+ Older
+
+ {olderSessions.map((session) => (
+ {
+ toggleSessionSelection(session.id, selected);
+ }}
+ onDelete={(e) => handleDelete(session.id, e)}
+ />
+ ))}
+ >
+ )}
+ >
)}