Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): use app language for relative timestamps (#3484)
Bill Yuchen Linaeb35f919a71
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/marketRelativeTime.test.ts b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/marketRelativeTime.test.tsindex e12ae88114..62e4bc7238 100644--- a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/marketRelativeTime.test.ts+++ b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/marketRelativeTime.test.ts@@ -18,6 +18,11 @@ describe('market relative time i18n', () => {expect(formatMarketRelativeTime('2026-06-11T09:00:00.000Z', i18n.t, NOW)).toBe('3 小时前');expect(formatMarketRelativeTime('2026-06-10T09:00:00.000Z', i18n.t, NOW)).toBe('昨天');expect(formatMarketRelativeTime('2026-06-11T11:59:45.000Z', i18n.t, NOW)).toBe('刚刚');++ await i18n.changeLanguage('en');+ expect(formatMarketRelativeTime('2026-06-11T09:00:00.000Z', i18n.t, NOW)).toBe('3 hours ago');+ expect(formatMarketRelativeTime('2026-06-10T09:00:00.000Z', i18n.t, NOW)).toBe('yesterday');+ expect(formatMarketRelativeTime('2026-06-11T11:59:45.000Z', i18n.t, NOW)).toBe('just now');} finally {await i18n.changeLanguage(previousLanguage);}diff --git a/apps/desktop/src/renderer/hooks/__tests__/useRelativeTime.test.ts b/apps/desktop/src/renderer/hooks/__tests__/useRelativeTime.test.tsnew file mode 100644index 0000000000..cd5e7fde98--- /dev/null+++ b/apps/desktop/src/renderer/hooks/__tests__/useRelativeTime.test.ts@@ -0,0 +1,61 @@+/**+ * useRelativeTime — chat message-action-bar relative timestamps follow app language.+ */++import { describe, expect, it } from 'vitest';++import { formatRelative } from '../useRelativeTime';++const JUST_NOW = 'chat.messageActionBar.relative.justNow';+const MINUTES = 'chat.messageActionBar.relative.minutesAgo';+const HOURS = 'chat.messageActionBar.relative.hoursAgo';+const DAYS = 'chat.messageActionBar.relative.daysAgo';++function tReturnsKey(key: string): string {+ return key;+}++function tZhCN(key: string, options?: Record<string, unknown>): string {+ const dict: Record<string, string> = {+ [JUST_NOW]: '刚刚',+ [MINUTES]: '{{count}} 分钟前',+ [HOURS]: '{{count}} 小时前',+ [DAYS]: '{{count}} 天前',+ };+ return (dict[key] ?? key).replace('{{count}}', String(options?.count ?? ''));+}++describe('formatRelative', () => {+ const now = new Date(2026, 4, 20, 12, 0, 0).getTime();++ it('falls back to English when t is missing or returns the key', () => {+ expect(formatRelative(now - 30_000, now)).toBe('just now');+ expect(formatRelative(now - 30_000, now, tReturnsKey)).toBe('just now');+ expect(formatRelative(now - 60_000, now, tReturnsKey)).toBe('1 minute ago');+ expect(formatRelative(now - 2 * 60_000, now, tReturnsKey)).toBe('2 minutes ago');+ expect(formatRelative(now - 60 * 60_000, now, tReturnsKey)).toBe('1 hour ago');+ expect(formatRelative(now - 24 * 60 * 60_000, now, tReturnsKey)).toBe('1 day ago');+ expect(formatRelative(now - 3 * 60 * 60_000, now, tReturnsKey)).toBe('3 hours ago');+ expect(formatRelative(now - 2 * 24 * 60 * 60_000, now, tReturnsKey)).toBe('2 days ago');+ });++ it('uses translated strings when t maps the four relative keys', () => {+ expect(formatRelative(now - 30_000, now, tZhCN)).toBe('刚刚');+ expect(formatRelative(now - 2 * 60_000, now, tZhCN)).toBe('2 分钟前');+ expect(formatRelative(now - 3 * 60 * 60_000, now, tZhCN)).toBe('3 小时前');+ expect(formatRelative(now - 2 * 24 * 60 * 60_000, now, tZhCN)).toBe('2 天前');+ });++ it('covers each delta bucket including numeric dates for older messages', () => {+ expect(formatRelative(now - 59_000, now, tReturnsKey)).toBe('just now');+ expect(formatRelative(now - 5 * 60_000, now, tReturnsKey)).toBe('5 minutes ago');+ expect(formatRelative(now - 23 * 60 * 60_000, now, tReturnsKey)).toBe('23 hours ago');+ expect(formatRelative(now - 6 * 24 * 60 * 60_000, now, tReturnsKey)).toBe('6 days ago');++ const sameYear = new Date(2026, 4, 10, 9, 5, 0).getTime();+ expect(formatRelative(sameYear, now, tReturnsKey)).toBe('05-10 09:05');++ const otherYear = new Date(2025, 11, 25, 14, 30, 0).getTime();+ expect(formatRelative(otherYear, now, tReturnsKey)).toBe('2025-12-25 14:30');+ });+});diff --git a/apps/desktop/src/renderer/hooks/useRelativeTime.ts b/apps/desktop/src/renderer/hooks/useRelativeTime.tsindex 41c3696f11..2a47cf1bc0 100644--- a/apps/desktop/src/renderer/hooks/useRelativeTime.ts+++ b/apps/desktop/src/renderer/hooks/useRelativeTime.ts@@ -2,8 +2,8 @@* useRelativeTime* ---------------------------------------------------------------------------* Hook for the message-actions bar. Renders an ISO timestamp as a smart- * relative-time string (刚刚 / N 分钟前 / N 小时前 / N 天前 / MM-DD HH:mm /- * YYYY-MM-DD HH:mm) per the V1.2 product spec.+ * relative-time string (just now / N minutes ago / N hours ago / N days ago /+ * MM-DD HH:mm / YYYY-MM-DD HH:mm) per the V1.2 product spec.** Refresh policy: compute once on mount + tick every 30s **only while the* message is hovered**. Unhovered messages keep their initial render and@@ -12,24 +12,48 @@*/import { useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';const ONE_MINUTE = 60_000;const ONE_HOUR = 60 * ONE_MINUTE;const ONE_DAY = 24 * ONE_HOUR;const SEVEN_DAYS = 7 * ONE_DAY;+type TFunc = (key: string, options?: Record<string, unknown>) => string;+function pad2(n: number): string {return n < 10 ? `0${n}` : String(n);}-/** Format the relative-time text per V1.2 spec. */-function formatRelative(createdAtMs: number, nowMs: number): string {+function tr(+ t: TFunc | undefined,+ key: string,+ fallback: string,+ options?: Record<string, unknown>,+): string {+ const value = t ? t(key, options) : '';+ return value && value !== key ? value : fallback;+}++/** Format the relative-time text per V1.2 spec. Exported for unit tests. */+export function formatRelative(createdAtMs: number, nowMs: number, t?: TFunc): string {const delta = nowMs - createdAtMs;- if (delta < ONE_MINUTE) return '刚刚';- if (delta < ONE_HOUR) return `${Math.floor(delta / ONE_MINUTE)} 分钟前`;- if (delta < ONE_DAY) return `${Math.floor(delta / ONE_HOUR)} 小时前`;- if (delta < SEVEN_DAYS) return `${Math.floor(delta / ONE_DAY)} 天前`;+ if (delta < ONE_MINUTE) {+ return tr(t, 'chat.messageActionBar.relative.justNow', 'just now');+ }+ if (delta < ONE_HOUR) {+ const count = Math.floor(delta / ONE_MINUTE);+ return tr(t, 'chat.messageActionBar.relative.minutesAgo', count === 1 ? '1 minute ago' : `${count} minutes ago`, { count });+ }+ if (delta < ONE_DAY) {+ const count = Math.floor(delta / ONE_HOUR);+ return tr(t, 'chat.messageActionBar.relative.hoursAgo', count === 1 ? '1 hour ago' : `${count} hours ago`, { count });+ }+ if (delta < SEVEN_DAYS) {+ const count = Math.floor(delta / ONE_DAY);+ return tr(t, 'chat.messageActionBar.relative.daysAgo', count === 1 ? '1 day ago' : `${count} days ago`, { count });+ }const d = new Date(createdAtMs);const now = new Date(nowMs);@@ -68,11 +92,12 @@ export function useRelativeTime(createdAt: string | undefined,{ hovered, tickMs = 30_000 }: Options,): string {+ const { t, i18n } = useTranslation();const [text, setText] = useState(() => {if (!createdAt) return '';const ms = new Date(createdAt).getTime();if (Number.isNaN(ms)) return '';- return formatRelative(ms, Date.now());+ return formatRelative(ms, Date.now(), t);});useEffect(() => {@@ -82,14 +107,14 @@ export function useRelativeTime(// Recompute once whenever hover toggles on so a long-unhovered message// shows the current value the moment it becomes visible.- setText(formatRelative(ms, Date.now()));+ setText(formatRelative(ms, Date.now(), t));if (!hovered) return;const id = setInterval(() => {- setText(formatRelative(ms, Date.now()));+ setText(formatRelative(ms, Date.now(), t));}, tickMs);return () => clearInterval(id);- }, [createdAt, hovered, tickMs]);+ }, [createdAt, hovered, tickMs, t, i18n.language]);return text;}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 8c71540a9a..d33ebd6dc1 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -7396,7 +7396,16 @@"turnCostEstimated": "Token value this turn (API-price equivalent)","turnCostEstimatedValue": "Worth {{cost}}","turnTokens": "{{tokens}} tokens",- "userTurnCostDetailsTitle": "Request details"+ "userTurnCostDetailsTitle": "Request details",+ "relative": {+ "justNow": "just now",+ "minutesAgo_one": "{{count}} minute ago",+ "minutesAgo_other": "{{count}} minutes ago",+ "hoursAgo_one": "{{count}} hour ago",+ "hoursAgo_other": "{{count}} hours ago",+ "daysAgo_one": "{{count}} day ago",+ "daysAgo_other": "{{count}} days ago"+ }},"runningStatus": {"tokenRate": "{{rate}} tok/s",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex ca30ffe0e9..e903a497f9 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -7394,7 +7394,13 @@"turnCostEstimated": "このターンの token 価値(API 単価換算)","turnCostEstimatedValue": "価値 {{cost}}","turnTokens": "{{tokens}} tokens",- "userTurnCostDetailsTitle": "リクエストの明細"+ "userTurnCostDetailsTitle": "リクエストの明細",+ "relative": {+ "justNow": "たった今",+ "minutesAgo_other": "{{count}}分前",+ "hoursAgo_other": "{{count}}時間前",+ "daysAgo_other": "{{count}}日前"+ }},"runningStatus": {"tokenRate": "{{rate}} tok/s",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex c631a8ed85..9cc809ff6e 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -7394,7 +7394,13 @@"turnCostEstimated": "이번 턴 토큰 가치(API 단가 환산)","turnCostEstimatedValue": "가치 {{cost}}","turnTokens": "{{tokens}} tokens",- "userTurnCostDetailsTitle": "이번 요청 상세"+ "userTurnCostDetailsTitle": "이번 요청 상세",+ "relative": {+ "justNow": "방금",+ "minutesAgo_other": "{{count}}분 전",+ "hoursAgo_other": "{{count}}시간 전",+ "daysAgo_other": "{{count}}일 전"+ }},"runningStatus": {"tokenRate": "{{rate}} tok/s",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 2d41bb025b..ec3ec54180 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -7386,7 +7386,13 @@"turnCostEstimated": "本轮 token 价值(按 API 单价折算)","turnCostEstimatedValue": "价值 {{cost}}","turnTokens": "{{tokens}} tokens",- "userTurnCostDetailsTitle": "本轮明细"+ "userTurnCostDetailsTitle": "本轮明细",+ "relative": {+ "justNow": "刚刚",+ "minutesAgo_other": "{{count}} 分钟前",+ "hoursAgo_other": "{{count}} 小时前",+ "daysAgo_other": "{{count}} 天前"+ }},"runningStatus": {"tokenRate": "{{rate}} tok/s",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex a653f8a63e..727e783b20 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -7385,7 +7385,13 @@"turnCostEstimated": "本輪 token 價值(按 API 單價折算)","turnCostEstimatedValue": "價值 {{cost}}","turnTokens": "{{tokens}} tokens",- "userTurnCostDetailsTitle": "本輪明細"+ "userTurnCostDetailsTitle": "本輪明細",+ "relative": {+ "justNow": "剛剛",+ "minutesAgo_other": "{{count}} 分鐘前",+ "hoursAgo_other": "{{count}} 小時前",+ "daysAgo_other": "{{count}} 天前"+ }},"runningStatus": {"tokenRate": "{{rate}} tok/s",diff --git a/apps/mobile/src/__tests__/messageActions.test.ts b/apps/mobile/src/__tests__/messageActions.test.tsindex 1ea0c6f84a..fc2bb6c0c9 100644--- a/apps/mobile/src/__tests__/messageActions.test.ts+++ b/apps/mobile/src/__tests__/messageActions.test.ts@@ -172,6 +172,18 @@ describe('messageActions', () => {expect(formatMessageAbsoluteTime('2026-06-16T09:00:05.000Z')).toContain('2026-06-16');});+ it('formats relative message times in English when the app language is English', async () => {+ const now = new Date('2026-06-16T12:00:00.000Z').getTime();+ await i18n.changeLanguage('en');+ try {+ expect(formatMessageRelativeTime('2026-06-16T11:59:31.000Z', now)).toBe('Just now');+ expect(formatMessageRelativeTime('2026-06-16T11:42:00.000Z', now)).toBe('18 min ago');+ expect(formatMessageRelativeTime('2026-06-16T09:00:00.000Z', now)).toBe('3 h ago');+ } finally {+ await i18n.changeLanguage('zh-CN');+ }+ });+it('formats per-turn cost like the desktop action bar', () => {expect(formatMessageTurnCost(money(12.34))).toBe('$12');expect(formatMessageTurnCost(money(0.034))).toBe('$0.03');diff --git a/apps/mobile/src/__tests__/sessionList.test.ts b/apps/mobile/src/__tests__/sessionList.test.tsindex 5019992c99..b0139aed2b 100644--- a/apps/mobile/src/__tests__/sessionList.test.ts+++ b/apps/mobile/src/__tests__/sessionList.test.ts@@ -108,7 +108,7 @@ describe('sessionList', () => {expect(item).toMatchObject({title: '未命名任务',subtitle: 'Codex · gpt-5.4 · dialogue',- detail: '活跃 · 5 分钟前 · 12 条消息',+ detail: '活跃 · 5 minutes ago · 12 条消息',messagePreview: null,lastActivityAt: '2026-01-01T00:05:00.000Z',});@@ -123,6 +123,19 @@ describe('sessionList', () => {expect(formatRemoteSessionSidebarTime('2025-12-30T12:00:00.000Z', now)).toBe('2 天');});+ it('formats sidebar activity time in English when the app language is English', async () => {+ const now = new Date('2026-01-01T12:00:00.000Z').getTime();+ await i18n.changeLanguage('en');+ try {+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:59:30.000Z', now)).toBe('Just now');+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:55:00.000Z', now)).toBe('5 min');+ expect(formatRemoteSessionSidebarTime('2026-01-01T09:00:00.000Z', now)).toBe('3 hr');+ expect(formatRemoteSessionSidebarTime('2025-12-30T12:00:00.000Z', now)).toBe('2 d');+ } finally {+ await i18n.changeLanguage('zh-CN');+ }+ });+it('includes the latest message preview in rendered session rows', () => {const sections = buildRemoteSessionSections([session('s1', { title: 'Implement mobile polish' }),@@ -221,7 +234,7 @@ describe('sessionList', () => {expect(item).toMatchObject({title: 'Legacy title',subtitle: 'Claude Code · claude-sonnet-4-6',- detail: '活跃 · 10 分钟前 · 自动化执行中 · 1 个自动化未读',+ detail: '活跃 · 10 minutes ago · 自动化执行中 · 1 个自动化未读',});expect(item.scheduleInfo).toMatchObject({scheduleId: 'sched-1',diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.jsonindex 687a4001b8..f4ab194e14 100644--- a/apps/mobile/src/i18n/locales/en/devices.json+++ b/apps/mobile/src/i18n/locales/en/devices.json@@ -98,9 +98,12 @@"time": {"unknown": "Recent activity time unknown","justNow": "Just now",- "minutesAgo": "{{count}} minutes ago",- "hoursAgo": "{{count}} hours ago",- "daysAgo": "{{count}} days ago",+ "minutesAgo_one": "{{count}} minute ago",+ "minutesAgo_other": "{{count}} minutes ago",+ "hoursAgo_one": "{{count}} hour ago",+ "hoursAgo_other": "{{count}} hours ago",+ "daysAgo_one": "{{count}} day ago",+ "daysAgo_other": "{{count}} days ago","minutes": "{{count}} min","hours": "{{count}} hr","days": "{{count}} d",diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.jsonindex 350677dbc2..fae739b309 100644--- a/apps/mobile/src/i18n/locales/ja/devices.json+++ b/apps/mobile/src/i18n/locales/ja/devices.json@@ -98,9 +98,12 @@"time": {"unknown": "最近のアクティビティ時刻は不明です","justNow": "たった今",- "minutesAgo": "{{count}} 分前",- "hoursAgo": "{{count}} 時間前",- "daysAgo": "{{count}} 日前",+ "minutesAgo_one": "{{count}} 分前",+ "minutesAgo_other": "{{count}} 分前",+ "hoursAgo_one": "{{count}} 時間前",+ "hoursAgo_other": "{{count}} 時間前",+ "daysAgo_one": "{{count}} 日前",+ "daysAgo_other": "{{count}} 日前","minutes": "{{count}} 分","hours": "{{count}} 時間","days": "{{count}} 日",diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.jsonindex 973ec5df2d..eaeaf9d3dc 100644--- a/apps/mobile/src/i18n/locales/ko/devices.json+++ b/apps/mobile/src/i18n/locales/ko/devices.json@@ -98,9 +98,13 @@"time": {"unknown": "최근 활동 시간 알 수 없음","justNow": "방금",- "minutesAgo": "{{count}}분 전",- "hoursAgo": "{{count}}시간 전",- "daysAgo": "{{count}}일 전",+ "minutesAgo_one": "{{count}}분 전",+ "minutesAgo_other": "{{count}}분 전",+ "hoursAgo_one": "{{count}}시간 전",+ "hoursAgo_other": "{{count}}시간 전",+ "daysAgo_one": "{{count}}일 전",+ "hoursAgo_other": "{{count}}시간 전",+ "daysAgo_other": "{{count}}일 전","minutes": "{{count}}분","hours": "{{count}}시간","days": "{{count}}일",diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.jsonindex 2c3a634f22..2de0bb6b77 100644--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json@@ -98,9 +98,12 @@"time": {"unknown": "最近活动时间未知","justNow": "刚刚",- "minutesAgo": "{{count}} 分钟前",- "hoursAgo": "{{count}} 小时前",- "daysAgo": "{{count}} 天前",+ "minutesAgo_one": "{{count}} 分钟前",+ "minutesAgo_other": "{{count}} 分钟前",+ "hoursAgo_one": "{{count}} 小时前",+ "hoursAgo_other": "{{count}} 小时前",+ "daysAgo_one": "{{count}} 天前",+ "daysAgo_other": "{{count}} 天前","minutes": "{{count}} 分钟","hours": "{{count}} 小时","days": "{{count}} 天",diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.jsonindex 6e9d0ab7ff..e90f192ab7 100644--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json@@ -98,9 +98,12 @@"time": {"unknown": "最近活動時間不明","justNow": "剛剛",- "minutesAgo": "{{count}} 分鐘前",- "hoursAgo": "{{count}} 小時前",- "daysAgo": "{{count}} 天前",+ "minutesAgo_one": "{{count}} 分鐘前",+ "minutesAgo_other": "{{count}} 分鐘前",+ "hoursAgo_one": "{{count}} 小時前",+ "hoursAgo_other": "{{count}} 小時前",+ "daysAgo_one": "{{count}} 天前",+ "daysAgo_other": "{{count}} 天前","minutes": "{{count}} 分鐘","hours": "{{count}} 小時","days": "{{count}} 天",diff --git a/apps/mobile/src/session/conversationSearch.ts b/apps/mobile/src/session/conversationSearch.tsindex 0d828fd134..7455e840a3 100644--- a/apps/mobile/src/session/conversationSearch.ts+++ b/apps/mobile/src/session/conversationSearch.ts@@ -27,6 +27,7 @@ import {} from '@cindy/maker-shared/session-list';import type { DeviceAccessState } from '@cindy/maker-shared/device-list';import { collapseWorktreeDirForGrouping } from '@cindy/maker-shared/worktree-paths';+import { mobilePresentationLocalizer } from '@/i18n/presentationLocalizer';import { createMobileMakerTransport } from '@/device-link/mobileMakerTransport';import { deviceMirrorCleanupDisposition } from '@/device-link/presenceDevices';import type { RemoteSession } from '@/session/types';@@ -313,6 +314,7 @@ export function toSearchListItem(item.contentHit?.preview ?? cached?.preview ?? null,null,unnamedLabel,+ mobilePresentationLocalizer,);const searchFocusClientId = item.contentHit?.messageClientId?.trim();return {diff --git a/apps/mobile/src/session/mobileHome.ts b/apps/mobile/src/session/mobileHome.tsindex 599fcb26dc..03b80b8188 100644--- a/apps/mobile/src/session/mobileHome.ts+++ b/apps/mobile/src/session/mobileHome.ts@@ -1,5 +1,6 @@import type { RemoteSession } from '@/session/types';import { i18n } from '@/i18n';+import { mobilePresentationLocalizer } from '@/i18n/presentationLocalizer';import { localizeRemoteSessionListItem } from '@/session/sessionList';import {buildMobileHomePresentation as buildMobileHomePresentationShared,@@ -13,7 +14,7 @@ export * from '@cindy/maker-shared/mobile-home';export function buildMobileHomePresentation(options: MobileHomeOptions): MobileHomePresentation {const now = options.now ?? Date.now();- const base = buildMobileHomePresentationShared(options);+ const base = buildMobileHomePresentationShared({ ...options, localizer: mobilePresentationLocalizer });const deviceFilters = base.deviceFilters.map((filter) => ({...filter,label: filter.deviceId === null ? i18n.t('devices.presentation.home.allDevices') : filter.label,diff --git a/apps/mobile/src/session/sessionList.ts b/apps/mobile/src/session/sessionList.tsindex 6455d65e45..b6b15574d3 100644--- a/apps/mobile/src/session/sessionList.ts+++ b/apps/mobile/src/session/sessionList.ts@@ -4,6 +4,7 @@ import {buildRemoteSessionCardPreview as buildRemoteSessionCardPreviewShared,buildRemoteSessionListContext as buildRemoteSessionListContextShared,buildRemoteSessionSections as buildRemoteSessionSectionsShared,+ formatRemoteSessionSidebarTime as formatRemoteSessionSidebarTimeShared,type RemoteSessionListContext,type RemoteSessionListItem,type RemoteSessionListOptions,@@ -19,7 +20,10 @@ export function buildRemoteSessionSections(now = Date.now(),options: RemoteSessionListOptions = {},): RemoteSessionSection[] {- return buildRemoteSessionSectionsShared(sessions, now, options).map((section) => ({+ return buildRemoteSessionSectionsShared(sessions, now, {+ ...options,+ localizer: mobilePresentationLocalizer,+ }).map((section) => ({...section,title: section.key === 'pinned'? i18n.t('devices.presentation.sessionList.section.pinned')@@ -129,23 +133,7 @@ export function buildRemoteSessionCardPreview(}export function formatRemoteSessionSidebarTime(iso: string | undefined, now = Date.now()): string {- if (!iso) return '';- const ts = Date.parse(iso);- if (!Number.isFinite(ts)) return '';- const diffMs = Math.max(0, now - ts);- const minute = 60_000;- const hour = 60 * minute;- const day = 24 * hour;- const week = 7 * day;- const month = 30 * day;- const year = 365 * day;- if (diffMs < minute) return i18n.t('devices.presentation.sessionList.time.justNow');- if (diffMs < hour) return i18n.t('devices.presentation.sessionList.time.minutes', { count: Math.max(1, Math.floor(diffMs / minute)) });- if (diffMs < day) return i18n.t('devices.presentation.sessionList.time.hours', { count: Math.max(1, Math.floor(diffMs / hour)) });- if (diffMs < week) return i18n.t('devices.presentation.sessionList.time.days', { count: Math.max(1, Math.floor(diffMs / day)) });- if (diffMs < month) return i18n.t('devices.presentation.sessionList.time.weeks', { count: Math.max(1, Math.floor(diffMs / week)) });- if (diffMs < year) return i18n.t('devices.presentation.sessionList.time.months', { count: Math.max(1, Math.floor(diffMs / month)) });- return i18n.t('devices.presentation.sessionList.time.years', { count: Math.max(1, Math.floor(diffMs / year)) });+ return formatRemoteSessionSidebarTimeShared(iso, now, mobilePresentationLocalizer);}export function localizeRemoteSessionListItem(diff --git a/packages/maker-shared/src/__tests__/fileBrowserGrid.test.ts b/packages/maker-shared/src/__tests__/fileBrowserGrid.test.tsindex f0bdb6c2a4..39a990a17a 100644--- a/packages/maker-shared/src/__tests__/fileBrowserGrid.test.ts+++ b/packages/maker-shared/src/__tests__/fileBrowserGrid.test.ts@@ -70,17 +70,17 @@ describe('buildFileBrowserGridItems', () => {expect(byName['zeta.png'].thumb).toBe('image');expect(byName['AGENTS.md'].thumb).toBe('doc');expect(byName['sessions.db'].thumb).toBe('generic');- expect(byName['AGENTS.md'].metaLabel).toMatch(/^18\.2 KB · 昨天 \d{2}:\d{2}$/);- expect(byName['docs'].metaLabel).toMatch(/^今天 \d{2}:\d{2}$/);+ expect(byName['AGENTS.md'].metaLabel).toMatch(/^18\.2 KB · Yesterday \d{2}:\d{2}$/);+ expect(byName['docs'].metaLabel).toMatch(/^Today \d{2}:\d{2}$/);});});describe('formatFileBrowserDate', () => {- it('今天/昨天/当年/跨年四种形态', () => {- expect(formatFileBrowserDate(NOW - 60_000, NOW)).toMatch(/^今天 /);- expect(formatFileBrowserDate(NOW - 86_400_000, NOW)).toMatch(/^昨天 /);- expect(formatFileBrowserDate(new Date(2026, 4, 12).getTime(), NOW)).toBe('5月12日');- expect(formatFileBrowserDate(new Date(2025, 11, 31).getTime(), NOW)).toBe('2025年12月31日');+ it('today/yesterday/same-year/cross-year shapes', () => {+ expect(formatFileBrowserDate(NOW - 60_000, NOW)).toMatch(/^Today /);+ expect(formatFileBrowserDate(NOW - 86_400_000, NOW)).toMatch(/^Yesterday /);+ expect(formatFileBrowserDate(new Date(2026, 4, 12).getTime(), NOW)).toBe('05-12');+ expect(formatFileBrowserDate(new Date(2025, 11, 31).getTime(), NOW)).toBe('2025-12-31');expect(formatFileBrowserDate(0, NOW)).toBe('');});});diff --git a/packages/maker-shared/src/__tests__/sessionList.test.ts b/packages/maker-shared/src/__tests__/sessionList.test.tsindex 79f408989e..f26b1e1711 100644--- a/packages/maker-shared/src/__tests__/sessionList.test.ts+++ b/packages/maker-shared/src/__tests__/sessionList.test.ts@@ -16,7 +16,9 @@ import {sessionRowMessagePreview,summarizeRemoteSessionOverview,toRemoteSessionListItem,+ formatRemoteSessionSidebarTime,} from '../sessionList.js';+import type { PresentationLocalizer } from '../presentationLocalization.js';import type { RemoteSchedule, RemoteScheduleRun } from '../scheduleTypes.js';import { CONTINUE_AFTER_ERROR_PROMPT } from '../syntheticTrigger.js';@@ -203,7 +205,7 @@ describe('sessionList', () => {expect(item).toMatchObject({title: '未命名任务',subtitle: 'Codex · gpt-5.4 · dialogue',- detail: '活跃 · 5 分钟前 · 12 条消息',+ detail: '活跃 · 5 minutes ago · 12 条消息',messagePreview: null,lastActivityAt: '2026-01-01T00:05:00.000Z',});@@ -221,7 +223,7 @@ describe('sessionList', () => {}), new Date('2026-01-01T00:10:00.000Z').getTime());expect(item).toMatchObject({- detail: '活跃 · 5 分钟前 · 1000+ 条消息',+ detail: '活跃 · 5 minutes ago · 1000+ 条消息',messagePreview: null,lastActivityAt: '2026-01-01T00:05:00.000Z',});@@ -424,7 +426,7 @@ describe('sessionList', () => {expect(item).toMatchObject({title: 'Legacy title',subtitle: 'Claude Code · claude-sonnet-4-6',- detail: '活跃 · 10 分钟前 · 自动化执行中 · 1 个自动化未读',+ detail: '活跃 · 10 minutes ago · 自动化执行中 · 1 个自动化未读',});expect(item.scheduleInfo).toMatchObject({scheduleId: 'sched-1',@@ -473,7 +475,7 @@ describe('sessionList', () => {expect(group).toMatchObject({title: '移动端巡检',subtitle: '自动化 · 2 个任务 · Claude Code · claude-sonnet-4-6',- detail: '2 个任务 · 4 分钟前 · 自动化执行中 · 1 个自动化未读',+ detail: '2 个任务 · 4 minutes ago · 自动化执行中 · 1 个自动化未读',automationGroup: {key: 'schedule:sched-1',sessionIds: ['running', 'old'],@@ -1079,3 +1081,43 @@ function createLargeSessionFixture(count: number): RemoteSession[] {});});}++function zhTimeLocalizer(): PresentationLocalizer {+ const dict: Record<string, string> = {+ 'devices.presentation.sessionList.time.justNow': '刚刚',+ 'devices.presentation.sessionList.time.minutesAgo': '{{count}} 分钟前',+ 'devices.presentation.sessionList.time.hoursAgo': '{{count}} 小时前',+ 'devices.presentation.sessionList.time.daysAgo': '{{count}} 天前',+ 'devices.presentation.sessionList.time.minutes': '{{count}} 分钟',+ 'devices.presentation.sessionList.time.hours': '{{count}} 小时',+ 'devices.presentation.sessionList.time.days': '{{count}} 天',+ 'devices.presentation.sessionList.time.weeks': '{{count}} 周',+ 'devices.presentation.sessionList.time.months': '{{count}} 月',+ 'devices.presentation.sessionList.time.years': '{{count}} 年',+ };+ return {+ translate: (key, fallback, values) => {+ const template = dict[key] ?? fallback;+ return template.replace(/\{\{(\w+)\}\}/g, (_, name: string) => String(values?.[name] ?? ''));+ },+ };+}++describe('formatRemoteSessionSidebarTime', () => {+ const now = new Date('2026-01-01T12:00:00.000Z').getTime();++ it('falls back to English when no localizer is passed', () => {+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:59:30.000Z', now)).toBe('Just now');+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:55:00.000Z', now)).toBe('5 min');+ expect(formatRemoteSessionSidebarTime('2026-01-01T09:00:00.000Z', now)).toBe('3 hr');+ expect(formatRemoteSessionSidebarTime('2025-12-30T12:00:00.000Z', now)).toBe('2 d');+ });++ it('uses translated compact strings when a localizer is passed', () => {+ const t = zhTimeLocalizer();+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:59:30.000Z', now, t)).toBe('刚刚');+ expect(formatRemoteSessionSidebarTime('2026-01-01T11:55:00.000Z', now, t)).toBe('5 分钟');+ expect(formatRemoteSessionSidebarTime('2026-01-01T09:00:00.000Z', now, t)).toBe('3 小时');+ expect(formatRemoteSessionSidebarTime('2025-12-30T12:00:00.000Z', now, t)).toBe('2 天');+ });+});diff --git a/packages/maker-shared/src/fileBrowserGrid.ts b/packages/maker-shared/src/fileBrowserGrid.tsindex 3df3b276fe..4da6dfe779 100644--- a/packages/maker-shared/src/fileBrowserGrid.ts+++ b/packages/maker-shared/src/fileBrowserGrid.ts@@ -7,6 +7,7 @@* 时间相关格式化一律显式传入 nowMs,保证可测试。*/import { formatByteSize, isTextFilePreviewCandidate, remoteFilePreviewKind, type RemoteFilePreviewKind } from './filePreview.js';+import { presentationDate, presentationText, type PresentationLocalizer } from './presentationLocalization.js';/** `file-browser:remote-op` listDir 返回的目录项(桌面 file-browser-core DirEntry 同形)。 */export interface FileBrowserRemoteOpEntry {@@ -82,6 +83,7 @@ export function buildFileBrowserGridItems(entries: readonly FileBrowserRemoteOpEntry[],sort: FileBrowserSortMode,nowMs: number,+ localizer?: PresentationLocalizer,): FileBrowserGridItem[] {const items = entries.map((entry): FileBrowserGridItem => {const isDir = entry.type === 'directory';@@ -94,8 +96,8 @@ export function buildFileBrowserGridItems(previewKind,thumb: isDir ? 'folder' : fileThumbKind(entry.name),metaLabel: isDir- ? formatFileBrowserDate(entry.mtimeMs, nowMs)- : `${formatByteSize(entry.size)} · ${formatFileBrowserDate(entry.mtimeMs, nowMs)}`,+ ? formatFileBrowserDate(entry.mtimeMs, nowMs, localizer)+ : `${formatByteSize(entry.size)} · ${formatFileBrowserDate(entry.mtimeMs, nowMs, localizer)}`,sizeBytes: entry.size,mtimeMs: entry.mtimeMs,};@@ -118,17 +120,29 @@ export function fileThumbKind(name: string): 'image' | 'doc' | 'generic' {}/** 修改时间的相对化显示:今天/昨天带时分,当年只到月日,跨年带年份。 */-export function formatFileBrowserDate(mtimeMs: number, nowMs: number): string {+export function formatFileBrowserDate(+ mtimeMs: number,+ nowMs: number,+ localizer?: PresentationLocalizer,+): string {if (!mtimeMs) return '';const d = new Date(mtimeMs);const now = new Date(nowMs);const dayStart = (v: Date) => new Date(v.getFullYear(), v.getMonth(), v.getDate()).getTime();const diffDays = Math.round((dayStart(now) - dayStart(d)) / 86_400_000);const hhmm = `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;- if (diffDays === 0) return `今天 ${hhmm}`;- if (diffDays === 1) return `昨天 ${hhmm}`;- if (d.getFullYear() === now.getFullYear()) return `${d.getMonth() + 1}月${d.getDate()}日`;- return `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日`;+ if (diffDays === 0) {+ return presentationText(localizer, 'files.presentation.grid.today', `Today ${hhmm}`, { time: hhmm });+ }+ if (diffDays === 1) {+ return presentationText(localizer, 'files.presentation.grid.yesterday', `Yesterday ${hhmm}`, { time: hhmm });+ }+ if (localizer?.formatDate) return presentationDate(localizer, d);+ const mm = String(d.getMonth() + 1).padStart(2, '0');+ const dd = String(d.getDate()).padStart(2, '0');+ return d.getFullYear() === now.getFullYear()+ ? `${mm}-${dd}`+ : `${d.getFullYear()}-${mm}-${dd}`;}/** 底部汇总:「X 个文件夹、Y 个文件」;单一类别时只报一类;空目录固定文案。 */diff --git a/packages/maker-shared/src/mobileHome.ts b/packages/maker-shared/src/mobileHome.tsindex 14c6deee46..c6cb76a048 100644--- a/packages/maker-shared/src/mobileHome.ts+++ b/packages/maker-shared/src/mobileHome.ts@@ -9,6 +9,7 @@ import {type RemoteSessionScheduleInfo,type RemoteSessionStatusFilter,} from './sessionList.js';+import type { PresentationLocalizer } from './presentationLocalization.js';import { stripTrailingPathSeparators } from './pathText.js';import { normalizeProjectOrderPath } from './projectOrderSync.js';import { collapseWorktreeDirForGrouping } from './worktreePaths.js';@@ -123,6 +124,7 @@ export interface MobileHomeOptions {* 共享层刻意不兜中文串,见 sessionList 的 remoteSessionDisplayTitle。*/unnamedLabel?: string;+ localizer?: PresentationLocalizer;}export function buildMobileHomePresentation({@@ -137,6 +139,7 @@ export function buildMobileHomePresentation({sessions,statusFilter = 'active',unnamedLabel,+ localizer,}: MobileHomeOptions): MobileHomePresentation {// 设备身份归一化在管线源头对每个会话算出 canonicalDeviceId(写入字段,不改 deviceLinkDeviceId):// 后续设备筛选统计、matchesSelectedDevice 过滤、项目分组、概览、卡片 deviceId 全部按 canonicalDeviceId@@ -173,6 +176,7 @@ export function buildMobileHomePresentation({messagePreviewIndex?.get(session.id) ?? sessionRowMessagePreview(session),liveActivityIndex?.get(session.id) ?? null,unnamedLabel,+ localizer,));const pinned = items.filter((item) => !!item.session.pinnedAt);const rest = items.filter((item) => !item.session.pinnedAt);@@ -187,6 +191,7 @@ export function buildMobileHomePresentation({now,true,(item) => sessionDeviceKey(item.session as MobileHomeSessionLike),+ localizer,);const projects = buildProjectGroups(groupAutomationListItems(@@ -194,6 +199,7 @@ export function buildMobileHomePresentation({now,true,(item) => projectGroupKey(item.session),+ localizer,),devices,);diff --git a/packages/maker-shared/src/sessionList.ts b/packages/maker-shared/src/sessionList.tsindex fb188c42de..9f3ea12d83 100644--- a/packages/maker-shared/src/sessionList.ts+++ b/packages/maker-shared/src/sessionList.ts@@ -1,6 +1,6 @@import { messageContentToPreview } from './messageNormalize.js';import { stripTrailingPathSeparators } from './pathText.js';-import { presentationText, type PresentationLocalizer } from './presentationLocalization.js';+import { presentationDate, presentationText, type PresentationLocalizer } from './presentationLocalization.js';import { isSyntheticTriggerText } from './syntheticTrigger.js';import type { RemoteSchedule, RemoteScheduleRun, RemoteScheduleRunStatus } from './scheduleTypes.js';import { toMillis } from './scheduleModel.js';@@ -162,6 +162,8 @@ export interface RemoteSessionListOptions {* 共享层刻意不兜中文串,见 {@link remoteSessionDisplayTitle}。*/unnamedLabel?: string;+ /** Optional localizer so relative timestamps follow the app language. */+ localizer?: PresentationLocalizer;}export function buildRemoteSessionSections(@@ -190,6 +192,7 @@ export function buildRemoteSessionSections(options.messagePreviewIndex?.get(session.id) ?? sessionRowMessagePreview(session),options.liveActivityIndex?.get(session.id) ?? null,options.unnamedLabel,+ options.localizer,));const pinned = items.filter((item) => !!item.session.pinnedAt);@@ -200,7 +203,7 @@ export function buildRemoteSessionSections(sections.push({ key: 'pinned', title: '置顶', data: pinned });}- sections.push(...buildProjectSections(rest, now, groupAutomations));+ sections.push(...buildProjectSections(rest, now, groupAutomations, options.localizer));return sections;}@@ -362,8 +365,9 @@ function buildProjectSections(items: readonly RemoteSessionListItem[],now: number,groupAutomations = true,+ localizer?: PresentationLocalizer,): RemoteSessionSection[] {- const dialogue = groupAutomationListItems(items.filter((item) => isDialogueSession(item.session)), now, groupAutomations);+ const dialogue = groupAutomationListItems(items.filter((item) => isDialogueSession(item.session)), now, groupAutomations, undefined, localizer);const sections: RemoteSessionSection[] = [];if (dialogue.length > 0) {sections.push({ key: 'dialogue', title: '对话', data: dialogue });@@ -383,7 +387,7 @@ function buildProjectSections(sections.push({key: `project:${workingDir}`,title: projectTitle(workingDir),- data: groupAutomationListItems(data, now, groupAutomations),+ data: groupAutomationListItems(data, now, groupAutomations, undefined, localizer),});}return sections;@@ -423,6 +427,7 @@ export function toRemoteSessionListItem(liveActivity: RemoteSessionLiveActivity | null = null,/** 「尚未起名」任务的显示文案,由调用方传已解析的 i18n 值(见 remoteSessionDisplayTitle)。 */unnamedLabel?: string,+ localizer?: PresentationLocalizer,): RemoteSessionListItem {const lastActivityAt = session.userSendAt ?? session.updatedAt ?? session.createdAt;const scheduleInfo = scheduleIndex?.get(session.id) ?? fallbackScheduleInfo(session);@@ -439,7 +444,7 @@ export function toRemoteSessionListItem(].filter(Boolean).join(' · '),detail: [sessionStatusLabel(session.status),- relativeTime(lastActivityAt, now),+ relativeTime(lastActivityAt, now, localizer),scheduleInfo?.running ? '自动化执行中' : null,scheduleInfo && scheduleInfo.unreadCount > 0 ? `${scheduleInfo.unreadCount} 个自动化未读` : null,pendingInteractionCount > 0 ? `等待处理 ${pendingInteractionCount} 个` : null,@@ -799,6 +804,7 @@ export function groupAutomationListItems(now: number,enabled = true,scopeKey?: (item: RemoteSessionListItem) => string | null | undefined,+ localizer?: PresentationLocalizer,): RemoteSessionListItem[] {// 关闭折叠时每个 run 各自成行(项目作用域精简页用,详见 RemoteSessionListOptions.groupAutomations)。if (!enabled) return [...items];@@ -825,7 +831,7 @@ export function groupAutomationListItems(}if (emitted.has(key)) continue;emitted.add(key);- next.push(toAutomationGroupListItem(key, group, now));+ next.push(toAutomationGroupListItem(key, group, now, localizer));}return next;}@@ -847,6 +853,7 @@ function toAutomationGroupListItem(key: string,group: readonly RemoteSessionListItem[],now: number,+ localizer?: PresentationLocalizer,): RemoteSessionListItem {const primary = pickAutomationPrimaryItem(group);const scheduleInfo = mergeScheduleInfo(group);@@ -871,7 +878,7 @@ function toAutomationGroupListItem(].filter(Boolean).join(' · '),detail: [`${group.length} 个任务`,- relativeTime(latestActivityAt, now),+ relativeTime(latestActivityAt, now, localizer),scheduleInfo?.running ? '自动化执行中' : null,scheduleInfo && scheduleInfo.unreadCount > 0 ? `${scheduleInfo.unreadCount} 个自动化未读` : null,pendingInteractionCount > 0 ? `等待处理 ${pendingInteractionCount} 个` : null,@@ -1072,20 +1079,49 @@ function contentRefName(value: unknown): string | null {return null;}-function relativeTime(iso: string, now: number): string {+function relativeTime(iso: string, now: number, localizer?: PresentationLocalizer): string {const ts = Date.parse(iso);- if (!Number.isFinite(ts)) return '最近活动时间未知';+ if (!Number.isFinite(ts)) {+ return presentationText(localizer, 'devices.presentation.sessionList.time.unknown', 'Recent activity time unknown');+ }const diffMinutes = Math.max(0, Math.floor((now - ts) / 60_000));- if (diffMinutes < 1) return '刚刚';- if (diffMinutes < 60) return `${diffMinutes} 分钟前`;+ if (diffMinutes < 1) {+ return presentationText(localizer, 'devices.presentation.sessionList.time.justNow', 'Just now');+ }+ if (diffMinutes < 60) {+ return presentationText(+ localizer,+ 'devices.presentation.sessionList.time.minutesAgo',+ diffMinutes === 1 ? '1 minute ago' : `${diffMinutes} minutes ago`,+ { count: diffMinutes },+ );+ }const diffHours = Math.floor(diffMinutes / 60);- if (diffHours < 24) return `${diffHours} 小时前`;+ if (diffHours < 24) {+ return presentationText(+ localizer,+ 'devices.presentation.sessionList.time.hoursAgo',+ diffHours === 1 ? '1 hour ago' : `${diffHours} hours ago`,+ { count: diffHours },+ );+ }const diffDays = Math.floor(diffHours / 24);- if (diffDays < 7) return `${diffDays} 天前`;- return new Date(ts).toLocaleDateString();+ if (diffDays < 7) {+ return presentationText(+ localizer,+ 'devices.presentation.sessionList.time.daysAgo',+ diffDays === 1 ? '1 day ago' : `${diffDays} days ago`,+ { count: diffDays },+ );+ }+ return presentationDate(localizer, new Date(ts));}-export function formatRemoteSessionSidebarTime(iso: string | undefined, now = Date.now()): string {+export function formatRemoteSessionSidebarTime(+ iso: string | undefined,+ now = Date.now(),+ localizer?: PresentationLocalizer,+): string {if (!iso) return '';const ts = Date.parse(iso);if (!Number.isFinite(ts)) return '';@@ -1098,11 +1134,29 @@ export function formatRemoteSessionSidebarTime(iso: string | undefined, now = Daconst monthMs = 30 * dayMs;const yearMs = 365 * dayMs;- if (diffMs < minuteMs) return '刚刚';- if (diffMs < hourMs) return `${Math.max(1, Math.floor(diffMs / minuteMs))} 分钟`;- if (diffMs < dayMs) return `${Math.max(1, Math.floor(diffMs / hourMs))} 小时`;- if (diffMs < weekMs) return `${Math.max(1, Math.floor(diffMs / dayMs))} 天`;- if (diffMs < monthMs) return `${Math.max(1, Math.floor(diffMs / weekMs))} 周`;- if (diffMs < yearMs) return `${Math.max(1, Math.floor(diffMs / monthMs))} 月`;- return `${Math.max(1, Math.floor(diffMs / yearMs))} 年`;+ if (diffMs < minuteMs) {+ return presentationText(localizer, 'devices.presentation.sessionList.time.justNow', 'Just now');+ }+ if (diffMs < hourMs) {+ const count = Math.max(1, Math.floor(diffMs / minuteMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.minutes', `${count} min`, { count });+ }+ if (diffMs < dayMs) {+ const count = Math.max(1, Math.floor(diffMs / hourMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.hours', `${count} hr`, { count });+ }+ if (diffMs < weekMs) {+ const count = Math.max(1, Math.floor(diffMs / dayMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.days', `${count} d`, { count });+ }+ if (diffMs < monthMs) {+ const count = Math.max(1, Math.floor(diffMs / weekMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.weeks', `${count} wk`, { count });+ }+ if (diffMs < yearMs) {+ const count = Math.max(1, Math.floor(diffMs / monthMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.months', `${count} mo`, { count });+ }+ const count = Math.max(1, Math.floor(diffMs / yearMs));+ return presentationText(localizer, 'devices.presentation.sessionList.time.years', `${count} yr`, { count });}