Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
"use client";
import { useLocale, useT } from "../../i18n";
/** How long ago a chat last moved, as the history lists show it. */
export function useFormatTimeAgo(): (dateStr: string) => string {
const { t } = useT("chat");
const locale = useLocale();
return (dateStr: string) => {
const date = new Date(dateStr);
const now = new Date();
const diffMs = now.getTime() - date.getTime();
const diffMins = Math.floor(diffMs / 60000);
const diffHours = Math.floor(diffMs / 3600000);
const diffDays = Math.floor(diffMs / 86400000);
if (diffMins < 1) return t(($) => $.session_history.time.just_now);
if (diffMins < 60) return t(($) => $.session_history.time.minutes, { count: diffMins });
if (diffHours < 24) return t(($) => $.session_history.time.hours, { count: diffHours });
if (diffDays < 7) return t(($) => $.session_history.time.days, { count: diffDays });
return date.toLocaleDateString(locale);
};
}