From d75651912e208869c8a4e56521c06d0e5429e1cb Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 6 May 2026 15:12:06 -0700 Subject: [PATCH] feat(ui/agents): add _dayjs helper with relativeTime plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Centralizes dayjs.extend(relativeTime) so fromNow() is typed and loaded across the agents components. relativeOrAbsolute() falls back to '—' for null/invalid timestamps so callers don't have to re-implement the guard. --- .../(dashboard)/agents/components/_dayjs.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ui/litellm-dashboard/src/app/(dashboard)/agents/components/_dayjs.ts diff --git a/ui/litellm-dashboard/src/app/(dashboard)/agents/components/_dayjs.ts b/ui/litellm-dashboard/src/app/(dashboard)/agents/components/_dayjs.ts new file mode 100644 index 00000000000..dd8795b8b9a --- /dev/null +++ b/ui/litellm-dashboard/src/app/(dashboard)/agents/components/_dayjs.ts @@ -0,0 +1,20 @@ +/** + * Shared dayjs helper for the cloud-agents dashboard. + * + * Loads the `relativeTime` plugin once so `dayjs(...).fromNow()` is + * typed and works across all the agents components. Without this, the + * plugin call is untyped and TS rejects it. + */ +import dayjs from "dayjs"; +import relativeTime from "dayjs/plugin/relativeTime"; + +dayjs.extend(relativeTime); + +export function relativeOrAbsolute(value: string | null | undefined): string { + if (!value) return "—"; + const d = dayjs(value); + if (!d.isValid()) return "—"; + return d.fromNow(); +} + +export { dayjs };