diff --git a/web/src/components/search/filtering/Filters.tsx b/web/src/components/search/filtering/Filters.tsx
index 545f5eb18d9..bdeb1d8523a 100644
--- a/web/src/components/search/filtering/Filters.tsx
+++ b/web/src/components/search/filtering/Filters.tsx
@@ -24,6 +24,11 @@ import { FilterDropdown } from "./FilterDropdown";
import { listSourceMetadata } from "@/lib/sources";
import { SourceIcon } from "@/components/SourceIcon";
import { TagFilter } from "./TagFilter";
+import { Calendar } from "@/components/ui/calendar";
+import { Popover, PopoverTrigger } from "@/components/ui/popover";
+import { PopoverContent } from "@radix-ui/react-popover";
+import { CalendarIcon } from "lucide-react";
+import { buildDateString, getTimeAgoString } from "@/lib/dateUtils";
const SectionTitle = ({ children }: { children: string }) => (
{children}
@@ -106,10 +111,39 @@ export function SourceSelector({
- Time Range
-
-
-
+
+
+
+
Time Range
+
+ {getTimeAgoString(timeRange?.from!) || "Select a time range"}
+
+
+
+
+ {
+ const initialDate = daterange?.from || new Date();
+ const endDate = daterange?.to || new Date();
+ setTimeRange({
+ from: initialDate,
+ to: endDate,
+ selectValue: timeRange?.selectValue || "",
+ });
+ }}
+ className="rounded-md "
+ />
+
+
{availableTags.length > 0 && (
<>
@@ -424,14 +458,57 @@ export function HorizontalSourceSelector({
return (
-
-
-
+
+
+
+
+
+ {timeRange?.from ? getTimeAgoString(timeRange.from) : "Since"}
+
+
+
+ {
+ const selectedDate = date || new Date();
+ const today = new Date();
+ setTimeRange({
+ from: selectedDate > today ? today : selectedDate,
+ to: today,
+ selectValue: timeRange?.selectValue || "",
+ });
+ }}
+ className="rounded-md "
+ />
+
+
{existingSources.length > 0 && (
{
date.toLocaleTimeString(undefined, timeOptions)
);
};
+
+export const buildDateString = (date: Date | null) => {
+ return date
+ ? `${Math.round(
+ (new Date().getTime() - date.getTime()) / (1000 * 60 * 60 * 24)
+ )} days ago`
+ : "Select a time range";
+};
+export const getTimeAgoString = (date: Date | null) => {
+ if (!date) return null;
+
+ const diffMs = new Date().getTime() - date.getTime();
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
+ const diffWeeks = Math.floor(diffDays / 7);
+ const diffMonths = Math.floor(diffDays / 30);
+
+ if (buildDateString(date).includes("Today")) return "Today";
+ if (diffDays === 1) return "Yesterday";
+ if (diffDays < 7) return `${diffDays}d ago`;
+ if (diffDays < 30) return `${diffWeeks}w ago`;
+ return `${diffMonths}mo ago`;
+};