mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
fix automation run inputs, hitl routing, and detail UI polish
This commit is contained in:
parent
ed8d56aa16
commit
91962ba879
8 changed files with 258 additions and 86 deletions
|
|
@ -1,4 +1,12 @@
|
|||
import { differenceInDays, differenceInMinutes, format, isToday, isYesterday } from "date-fns";
|
||||
import {
|
||||
differenceInDays,
|
||||
differenceInMinutes,
|
||||
format,
|
||||
isThisYear,
|
||||
isToday,
|
||||
isTomorrow,
|
||||
isYesterday,
|
||||
} from "date-fns";
|
||||
|
||||
/**
|
||||
* Format a date string as a human-readable relative time
|
||||
|
|
@ -23,6 +31,36 @@ export function formatRelativeDate(dateString: string): string {
|
|||
return format(date, "MMM d, yyyy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a future date string as a human-readable countdown.
|
||||
* - < 1 min: "Any moment"
|
||||
* - < 60 min: "in 15m"
|
||||
* - Today: "Today, 2:30 PM"
|
||||
* - Tomorrow: "Tomorrow, 2:30 PM"
|
||||
* - < 7 days: "in 3d"
|
||||
* - This year: "May 30, 2:30 PM"
|
||||
* - Older: "Jan 15, 2027"
|
||||
*
|
||||
* Mirrors {@link formatRelativeDate} but for moments strictly after now.
|
||||
* Falls back to the past-relative formatter if the timestamp is not in
|
||||
* the future (defensive — guards against stale "next_fire_at" values).
|
||||
*/
|
||||
export function formatRelativeFutureDate(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
const now = new Date();
|
||||
const minutesAhead = differenceInMinutes(date, now);
|
||||
const daysAhead = differenceInDays(date, now);
|
||||
|
||||
if (minutesAhead <= 0) return formatRelativeDate(dateString);
|
||||
if (minutesAhead < 1) return "Any moment";
|
||||
if (minutesAhead < 60) return `in ${minutesAhead}m`;
|
||||
if (isToday(date)) return `Today, ${format(date, "h:mm a")}`;
|
||||
if (isTomorrow(date)) return `Tomorrow, ${format(date, "h:mm a")}`;
|
||||
if (daysAhead < 7) return `in ${daysAhead}d`;
|
||||
if (isThisYear(date)) return format(date, "MMM d, h:mm a");
|
||||
return format(date, "MMM d, yyyy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a thread's last-updated timestamp for the chats sidebars.
|
||||
* Example: "Mar 23, 2026 at 4:30 PM"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue