From 84fcdc2b289ec5139fe0137558412e8567e967a9 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Wed, 20 May 2026 14:41:45 +0700 Subject: [PATCH] refactor(frontend): use shared formatDate for table cells, drop dup tooltips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Flows, Providers, and API tokens pages each defined a local `formatDateTime`/`formatFullDateTime` pair (~16 lines × 3 files) doing essentially the same trimming-by-recency job as `formatDate` from `@/lib/utils/format`, and each wrapped the cell in a Tooltip that repeated the same text more verbosely. After the previous date-format unification commit (1806956), the trimmed cell already conveys enough context for every recency band: - today → HH:mm:ss - this year → HH:mm, d MMM - older → HH:mm, d MMM yyyy So the Tooltip+full-timestamp pair no longer adds information for the date columns. Replace the three local copies with a direct `formatDate(new Date(dateString))` call and drop the Tooltip wrapper where it only mirrors the cell. The Tooltip on the Terminals column in flows.tsx is kept — it expands the list of terminals with per-row connection status and is not a duplicate. Net delta: -115 / +10 lines. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/pages/flows/flows.tsx | 41 ++---------------- .../pages/settings/settings-api-tokens.tsx | 42 ++----------------- .../src/pages/settings/settings-providers.tsx | 42 ++----------------- 3 files changed, 10 insertions(+), 115 deletions(-) diff --git a/frontend/src/pages/flows/flows.tsx b/frontend/src/pages/flows/flows.tsx index 32d71678..3f270235 100644 --- a/frontend/src/pages/flows/flows.tsx +++ b/frontend/src/pages/flows/flows.tsx @@ -1,7 +1,5 @@ import type { ColumnDef } from '@tanstack/react-table'; -import { format, isToday } from 'date-fns'; -import { enUS } from 'date-fns/locale'; import { Ellipsis, Eye, GitFork, Loader2, Pause, Pencil, PencilLine, Plus, Star, Trash } from 'lucide-react'; import { CheckCircle2, XCircle } from 'lucide-react'; import { useCallback, useMemo, useRef, useState } from 'react'; @@ -33,6 +31,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip import { ResultType, StatusType, type TerminalFragmentFragment, useRenameFlowMutation } from '@/graphql/types'; import { useTableState } from '@/hooks/use-table-state'; import { mergeHrefWithSearchParams } from '@/lib/url-params'; +import { formatDate } from '@/lib/utils/format'; import { useFavorites } from '@/providers/favorites-provider'; import { type Flow, useFlows } from '@/providers/flows-provider'; @@ -62,22 +61,6 @@ const statusConfig: Record< }, }; -const formatDateTime = (dateString: string) => { - const date = new Date(dateString); - - if (isToday(date)) { - return format(date, 'HH:mm:ss', { locale: enUS }); - } - - return format(date, 'd MMM yyyy', { locale: enUS }); -}; - -const formatFullDateTime = (dateString: string) => { - const date = new Date(dateString); - - return format(date, 'd MMM yyyy, HH:mm:ss', { locale: enUS }); -}; - function Flows() { const navigate = useNavigate(); const location = useLocation(); @@ -367,16 +350,7 @@ function Flows() { cell: ({ row }) => { const dateString = row.getValue('createdAt') as string; - return ( - - -
{formatDateTime(dateString)}
-
- -
{formatFullDateTime(dateString)}
-
-
- ); + return
{formatDate(new Date(dateString))}
; }, header: ({ column }) => ( { const dateString = row.getValue('updatedAt') as string; - return ( - - -
{formatDateTime(dateString)}
-
- -
{formatFullDateTime(dateString)}
-
-
- ); + return
{formatDate(new Date(dateString))}
; }, header: ({ column }) => ( { - const date = new Date(dateString); - - if (isToday(date)) { - return format(date, 'HH:mm:ss', { locale: enUS }); - } - - return format(date, 'd MMM yyyy', { locale: enUS }); -}; - -const formatFullDateTime = (dateString: string) => { - const date = new Date(dateString); - - return format(date, 'd MMM yyyy, HH:mm:ss', { locale: enUS }); -}; - const calculateTTL = (expiresAt: Date): number => { const now = new Date(); const diffMs = expiresAt.getTime() - now.getTime(); @@ -673,16 +657,7 @@ function SettingsAPITokens() { const expiresAt = getTokenExpirationDate(token); const expiresAtString = expiresAt.toISOString(); - return ( - - -
{formatDateTime(expiresAtString)}
-
- -
{formatFullDateTime(expiresAtString)}
-
-
- ); + return
{formatDate(new Date(expiresAtString))}
; }, header: ({ column }) => ( - -
{formatDateTime(dateString)}
-
- -
{formatFullDateTime(dateString)}
-
- - ); + return
{formatDate(new Date(dateString))}
; }, header: ({ column }) => ( > = { @@ -63,22 +61,6 @@ const providerTypes = [ { label: 'Qwen', type: ProviderType.Qwen }, ]; -const formatDateTime = (dateString: string) => { - const date = new Date(dateString); - - if (isToday(date)) { - return format(date, 'HH:mm:ss', { locale: enUS }); - } - - return format(date, 'd MMM yyyy', { locale: enUS }); -}; - -const formatFullDateTime = (dateString: string) => { - const date = new Date(dateString); - - return format(date, 'd MMM yyyy, HH:mm:ss', { locale: enUS }); -}; - function SettingsProviders() { const { data, error, loading: isLoading } = useSettingsProvidersQuery(); const [deleteProvider, { error: deleteError, loading: isDeleteLoading }] = useDeleteProviderMutation(); @@ -179,16 +161,7 @@ function SettingsProviders() { cell: ({ row }) => { const dateString = row.getValue('createdAt') as string; - return ( - - -
{formatDateTime(dateString)}
-
- -
{formatFullDateTime(dateString)}
-
-
- ); + return
{formatDate(new Date(dateString))}
; }, header: ({ column }) => ( { const dateString = row.getValue('updatedAt') as string; - return ( - - -
{formatDateTime(dateString)}
-
- -
{formatFullDateTime(dateString)}
-
-
- ); + return
{formatDate(new Date(dateString))}
; }, header: ({ column }) => (