The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): exclude cron sessions from the titlebar unread badge
Teknium57ece811013b
diff --git a/apps/desktop/src/store/session-dot-state.test.ts b/apps/desktop/src/store/session-dot-state.test.tsindex 52b614ecf4c..46b6e933213 100644--- a/apps/desktop/src/store/session-dot-state.test.ts+++ b/apps/desktop/src/store/session-dot-state.test.ts@@ -3,10 +3,20 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'import { createClientSessionState } from '@/lib/chat-runtime'import type { SessionInfo } from '@/types/hermes'-import { $sessions, $unreadFinishedSessionIds, setSessions } from './session'+import {+ $cronSessions,+ $messagingSessions,+ $sessions,+ $unreadFinishedSessionIds,+ markAllSessionsRead,+ setCronSessions,+ setMessagingSessions,+ setSessions+} from './session'import {$delegatingSessionIds,$sessionDotStateById,+ $unreadSessionCount,hasLiveTurn,showsRunningArc,unreadSessionCount@@ -171,3 +181,62 @@ describe('unreadSessionCount', () => {expect(unreadSessionCount({ tip: 'unread', root: 'unread' }, [{ id: 'tip' }])).toBe(1)})})++describe('$unreadSessionCount (titlebar badge)', () => {+ beforeEach(() => {+ clearAllSessionStates()+ $sessions.set([])+ $cronSessions.set([])+ $messagingSessions.set([])+ $unreadFinishedSessionIds.set([])+ $unreadWriteGuard.set(new Map())+ })++ afterEach(() => {+ clearAllSessionStates()+ $sessions.set([])+ $cronSessions.set([])+ $messagingSessions.set([])+ $unreadFinishedSessionIds.set([])+ $unreadWriteGuard.set(new Map())+ })++ it('does not count an unread cron session — cron runs finish unwatched by design (#93552)', () => {+ setCronSessions([storedRow('cron-1', { source: 'cron' })])+ $unreadFinishedSessionIds.set(['cron-1'])++ // The cron row itself still paints unread in the sidebar cron section...+ expect($sessionDotStateById.get()['cron-1']).toBe('unread')+ // ...but the titlebar badge stays quiet.+ expect($unreadSessionCount.get()).toBe(0)+ })++ it('counts an unread regular session', () => {+ setSessions([storedRow('reg-1', { unread: true })])++ expect($unreadSessionCount.get()).toBe(1)+ })++ it('counts regular + messaging but never cron', () => {+ setSessions([storedRow('reg-1', { unread: true })])+ setMessagingSessions([storedRow('msg-1')])+ setCronSessions([storedRow('cron-1', { source: 'cron' })])+ $unreadFinishedSessionIds.set(['msg-1', 'cron-1'])++ expect($unreadSessionCount.get()).toBe(2)+ })++ it('mark-all-read clears regular and cron unread alike', () => {+ setSessions([storedRow('reg-1')])+ setCronSessions([storedRow('cron-1', { source: 'cron' })])+ $unreadFinishedSessionIds.set(['reg-1', 'cron-1'])++ expect($unreadSessionCount.get()).toBe(1)+ expect($sessionDotStateById.get()['cron-1']).toBe('unread')++ markAllSessionsRead()++ expect($unreadSessionCount.get()).toBe(0)+ expect($sessionDotStateById.get()['cron-1']).not.toBe('unread')+ })+})diff --git a/apps/desktop/src/store/session-dot-state.ts b/apps/desktop/src/store/session-dot-state.tsindex 58c0f8182c6..d4413f0b518 100644--- a/apps/desktop/src/store/session-dot-state.ts+++ b/apps/desktop/src/store/session-dot-state.ts@@ -28,7 +28,7 @@ import { computed } from 'nanostores'import { stableArray, stableRecord } from '@/lib/stable-array'import { $backgroundRunningSessionIds } from './composer-status'-import { $cronSessions, $messagingSessions, $sessions, $unreadFinishedSessionIds, lineageAliases } from './session'+import { $messagingSessions, $sessions, $unreadFinishedSessionIds, lineageAliases } from './session'import {$attentionSessionIds,$draftSessionIds,@@ -202,7 +202,12 @@ export function unreadSessionCount(return n}+/** The titlebar badge. Cron sessions are deliberately EXCLUDED: cron runs+ * finish unwatched by design, so counting them turns the badge into a cron+ * run counter that is permanently lit (#93552). Their unread state stays+ * visible where it belongs — the sidebar's cron section rows — and+ * "mark all as read" still acks them (ackAllSessionsRead iterates cron rows). */export const $unreadSessionCount = computed(- [$sessionDotStateById, $sessions, $cronSessions, $messagingSessions],- (byId, sessions, cron, messaging) => unreadSessionCount(byId, sessions, cron, messaging)+ [$sessionDotStateById, $sessions, $messagingSessions],+ (byId, sessions, messaging) => unreadSessionCount(byId, sessions, messaging))