diff --git a/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx b/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx index 4085e1d88ed..b631dc0958e 100644 --- a/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx +++ b/src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx @@ -333,77 +333,6 @@ function SessionDetailEmptyState({ message }: { message: string }): React.JSX.El ) } -export function SessionTime({ - value, - className -}: { - value: string - className?: string -}): React.JSX.Element { - const timestamp = Date.parse(value) - if (!Number.isFinite(timestamp)) { - return ( - - {translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.unknownTime', - 'Unknown time' - )} - - ) - } - - const date = new Date(timestamp) - return ( - - - - ) -} - -function formatTimeAgo(timestamp: number): string { - const diffMs = Date.now() - timestamp - if (diffMs < 60_000) { - return translate('auto.components.right.sidebar.AiVaultSessionDetails.justNow', 'Just now') - } - const minutes = Math.floor(diffMs / 60_000) - if (minutes < 60) { - return translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.minutesAgo', - '{{value0}}m ago', - { value0: minutes } - ) - } - const hours = Math.floor(minutes / 60) - if (hours < 24) { - return translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.hoursAgo', - '{{value0}}h ago', - { value0: hours } - ) - } - const days = Math.floor(hours / 24) - if (days < 30) { - return translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.daysAgo', - '{{value0}}d ago', - { value0: days } - ) - } - const months = Math.floor(days / 30) - if (months < 12) { - return translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.monthsAgo', - '{{value0}}mo ago', - { value0: months } - ) - } - return translate( - 'auto.components.right.sidebar.AiVaultSessionDetails.yearsAgo', - '{{value0}}y ago', - { value0: Math.floor(months / 12) } - ) -} - function conversationRoleLabel(role: AiVaultSession['previewMessages'][number]['role']): string { if (role === 'user') { return translate('auto.components.right.sidebar.AiVaultSessionDetails.userRole', 'You') diff --git a/src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx b/src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx index 48bbcfb8610..a2c9f1410cf 100644 --- a/src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx +++ b/src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx @@ -13,7 +13,7 @@ import { type AiVaultSession } from '../../../../shared/ai-vault-types' import { translate } from '@/i18n/i18n' -import { SessionTime } from './AiVaultSessionDetails' +import { SessionTime } from './ai-vault-session-time' import { sessionModelLabel } from './ai-vault-session-display' import { agentLabel } from './ai-vault-session-filters' import { diff --git a/src/renderer/src/components/right-sidebar/ai-vault-session-time.tsx b/src/renderer/src/components/right-sidebar/ai-vault-session-time.tsx new file mode 100644 index 00000000000..99afa98621b --- /dev/null +++ b/src/renderer/src/components/right-sidebar/ai-vault-session-time.tsx @@ -0,0 +1,74 @@ +import type React from 'react' +import { cn } from '@/lib/utils' +import { translate } from '@/i18n/i18n' + +export function SessionTime({ + value, + className +}: { + value: string + className?: string +}): React.JSX.Element { + const timestamp = Date.parse(value) + if (!Number.isFinite(timestamp)) { + return ( + + {translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.unknownTime', + 'Unknown time' + )} + + ) + } + + const date = new Date(timestamp) + return ( + + + + ) +} + +function formatTimeAgo(timestamp: number): string { + const diffMs = Date.now() - timestamp + if (diffMs < 60_000) { + return translate('auto.components.right.sidebar.AiVaultSessionDetails.justNow', 'Just now') + } + const minutes = Math.floor(diffMs / 60_000) + if (minutes < 60) { + return translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.minutesAgo', + '{{value0}}m ago', + { value0: minutes } + ) + } + const hours = Math.floor(minutes / 60) + if (hours < 24) { + return translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.hoursAgo', + '{{value0}}h ago', + { value0: hours } + ) + } + const days = Math.floor(hours / 24) + if (days < 30) { + return translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.daysAgo', + '{{value0}}d ago', + { value0: days } + ) + } + const months = Math.floor(days / 30) + if (months < 12) { + return translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.monthsAgo', + '{{value0}}mo ago', + { value0: months } + ) + } + return translate( + 'auto.components.right.sidebar.AiVaultSessionDetails.yearsAgo', + '{{value0}}y ago', + { value0: Math.floor(months / 12) } + ) +}