Skip to content

The agent that grows with you

test(desktop): the live source cache and the read family stay within their own profile (currently failing)

yoniebansc675b4b66978
diff --git a/apps/desktop/src/app/contrib/hooks/live-status-reap.test.ts b/apps/desktop/src/app/contrib/hooks/live-status-reap.test.ts
index 29a7863abff..da7b496e3fc 100644
--- a/apps/desktop/src/app/contrib/hooks/live-status-reap.test.ts
+++ b/apps/desktop/src/app/contrib/hooks/live-status-reap.test.ts
@@ -11,6 +11,7 @@ import {
publishSessionState,
reconcileBusyStatesOnReconnect
} from '@/store/session-states'
+import { isMessagingCompletion } from '@/store/session-unread'
import { rehydrateLiveSessionStatuses } from './use-background-sync'
@@ -70,6 +71,16 @@ describe('rehydrateLiveSessionStatuses — reaping vanished runtimes', () => {
expect($unreadFinishedSessionIds.get()).toEqual([])
})
+ it("keeps another profile's same-id local completion lit when only this profile polled a messaging source", () => {
+ rehydrateLiveSessionStatuses(
+ { sessions: [{ id: 'runtime-alpha', session_key: 'shared', source: 'telegram', status: 'idle' }] },
+ Date.now(),
+ 'alpha'
+ )
+ expect(isMessagingCompletion('shared', 'beta')).toBe(false)
+ expect(isMessagingCompletion('shared', 'alpha')).toBe(true)
+ })
+
// A turn that started just before the socket dropped was never polled, so
// "seen live last poll" cannot gate its confirmation: the reconcile parked it,
// and the first fresh snapshot that does not report it working is the
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.test.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.test.ts
index facbafb3217..f543cd972e9 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.test.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.test.ts
@@ -183,6 +183,22 @@ describe('unread dot for a messaging turn Desktop sent', () => {
expect($unreadFinishedMarkers.get()).toEqual({})
})
+ it("does not mark another profile's same-id compressed conversation read", () => {
+ // Opening alpha's local `tg-tip` must not stamp beta's root: its held completion still lights.
+ $sessions.set([makeSessionInfo({ id: 'tg-tip', source: 'desktop', profile: 'alpha' })])
+ $messagingSessions.set([
+ makeSessionInfo({ id: 'tg-tip', source: 'telegram', _lineage_root_id: 'tg-root', profile: 'beta' })
+ ])
+ complete('beta-late', 'tg-root', 'beta')
+ $activeGatewayProfile.set('alpha')
+ setSelectedStoredSessionId('tg-tip')
+ setSelectedStoredSessionId(null)
+ expect($lastReadAtBySessionId.get()['tg-root']).toBeUndefined()
+ admit('beta-late')
+ expect($unreadFinishedSessionIds.get()).toContain('tg-tip')
+ expect(Object.keys($unreadFinishedMarkers.get())).toEqual(['beta'])
+ })
+
it('marks the listed segment of a compressed conversation', () => {
$messagingSessions.set([makeSessionInfo({ id: 'tg-tip', source: 'telegram', _lineage_root_id: 'tg-root' })])
noteDesktopAdmission('compressed-turn')