Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,9 @@
"available": "Ready on Commonly",
"revoked": "Disconnected: key revoked",
"stale": "Not seen in {{count}} min",
"staleHours": "Not seen in {{count}} h",
"staleDays_one": "Not seen in {{count}} day",
"staleDays_other": "Not seen in {{count}} days",
"never": "Not connected yet",
"reconnect": "Reconnect",
"reconnectWaiting": "Waiting for your computer to reconnect this agent.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,8 @@
"available": "可在 Commonly 使用",
"revoked": "密钥已撤销,连接已断开",
"stale": "已{{count}}分钟未连接",
"staleHours": "已{{count}}小时未连接",
"staleDays_other": "已{{count}}天未连接",
"never": "尚未连接",
"reconnect": "重新连接",
"reconnectWaiting": "正在等待电脑重新连接此智能体。",
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/v2/__tests__/agentConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ it('shows elapsed minutes from the last poll', () => {
expect(connectionLabel({ state: 'stale', lastSeenAt: '2026-10-23T15:54:00Z' }, t,
Date.parse('2026-10-23T16:00:00Z'))).toBe('Not seen in 6 min');
});

it('reads an hour-plus gap in hours, and a day-plus gap in days', () => {
const now = Date.parse('2026-10-30T16:00:00Z');
// 6390 minutes is 106 hours: four days, the case that read "6390 min" on the page.
expect(connectionLabel({ state: 'stale', lastSeenAt: new Date(now - 6390 * 60000).toISOString() }, (k, o) => `${k}:${o?.count}`, now))
.toBe('agentConnection.staleDays:4');
expect(connectionLabel({ state: 'stale', lastSeenAt: new Date(now - 90 * 60000).toISOString() }, (k, o) => `${k}:${o?.count}`, now))
.toBe('agentConnection.staleHours:1');
expect(connectionLabel({ state: 'stale', lastSeenAt: new Date(now - 59 * 60000).toISOString() }, (k, o) => `${k}:${o?.count}`, now))
.toBe('agentConnection.stale:59');
});
5 changes: 4 additions & 1 deletion frontend/src/v2/utils/agentConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ export const connectionLabel = (
if (connection.state === 'connected') return t('agentConnection.connected');
const seen = connection.lastSeenAt ? new Date(connection.lastSeenAt).getTime() : NaN;
const minutes = Number.isFinite(seen) ? Math.max(1, Math.floor((now - seen) / 60000)) : 1;
return t('agentConnection.stale', { count: minutes });
// Past an hour, minutes stop helping: 6390 min reads as four days.
if (minutes < 60) return t('agentConnection.stale', { count: minutes });
if (minutes < 1440) return t('agentConnection.staleHours', { count: Math.floor(minutes / 60) });
return t('agentConnection.staleDays', { count: Math.floor(minutes / 1440) });
};
Loading