Skip to content

The agent that grows with you

fix(desktop): roster age reflects the last worker run, not only the last chat (#105874)

PRATHAMESH75ec34ec1f28c7
diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
index afff3498aa0..d2f039aaa3a 100644
--- a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
@@ -265,3 +265,31 @@ describe('a group row', () => {
act(() => $groupChats.set({}))
})
})
+
+describe('age label reflects the last worker run, not only the last conversation (#105874)', () => {
+ const nowSec = () => Date.now() / 1000
+
+ it('shows the worker-run age for a delegate-only bot whose worker is past the liveness window', () => {
+ // A specialist driven only via delegate_task: its newest human conversation is 11 days old,
+ // but it ran a `tool`/`kanban` worker 2h ago (well past the 150s liveness window). The label
+ // must read "2h", not "11d" — the busiest bot in the system used to read as the most idle.
+ renderRow({
+ name: 'auswerter',
+ last_session: { last_active: nowSec() - 11 * 86400 },
+ worker_session: { last_active: nowSec() - 2 * 3600 }
+ } as RosterRow)
+
+ expect(screen.getByText('2h')).toBeTruthy()
+ expect(screen.queryByText('11d')).toBeNull()
+ })
+
+ it('falls back to conversation age when there is no worker session', () => {
+ // worker_session can be absent (None past the 20-row window); the max degrades to the chat age.
+ renderRow({
+ name: 'chatty',
+ last_session: { last_active: nowSec() - 3 * 86400 }
+ } as RosterRow)
+
+ expect(screen.getByText('3d')).toBeTruthy()
+ })
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
index 1079cfe32a8..cefaa36d2aa 100644
--- a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
@@ -152,9 +152,14 @@ export function BotRow({ bot, onDelete, onEdit, onGroup, onNewSection, showHandl
// runs, falling back to chat activity when it ends.
const workerActive = workerActiveAt(bot)
- const rowAgeTs = workerActive
- ? Math.max(activitySession?.last_active || 0, bot.worker_session?.last_active || 0)
- : activitySession?.last_active || 0
+ // Age reflects the last time the bot did ANYTHING — a human chat or a delegated worker run
+ // (source `tool`/`kanban`) — not only conversations. A delegate-only specialist that ran 24×
+ // today used to read "11d ago" the instant its worker's 150s liveness window lapsed, because
+ // the worker stamp only counted while workerActive (#105874). Take the max unconditionally; the
+ // worker stamp degrades to 0 when absent (worker_session can be None past the 20-row window), so
+ // the age falls back to chat activity. workerActive still gates only the live pulse/mood below.
+ const rowAgeTs = Math.max(
+ activitySession?.last_active || 0, bot.worker_session?.last_active || 0)
const groupKeys = useValue($activeGroupMemberKeys)
const botMood = botWorkingMood(bot, focusedOwner, turnBusy, activeConnectionId, Date.now(), groupKeys)