Skip to content

The agent that grows with you

fix(desktop): prefer messaging/cron slice when restoring a dual-listed session

Jeremyadd24666d53c
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
index 74f5e97efda..57ef54e503c 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
@@ -3534,4 +3534,19 @@ describe('removeSession / archiveSession profile routing (#78836)', () => {
expect($sessions.get()).toEqual([])
expect($messagingSessions.get()).toEqual([])
})
+
+ it('restores a dual-listed messaging row to messaging, not recents', async () => {
+ const row = storedSession({ id: 'tg-dual', profile: 'winefox', source: 'telegram' })
+ setMessagingSessions([row])
+ setSessions([row])
+ mockDeleteSession.mockRejectedValue(new Error('backend down'))
+
+ const handle = await readyActions()
+ await act(async () => {
+ await handle.removeSession('tg-dual')
+ })
+
+ expect($messagingSessions.get().map(session => session.id)).toEqual(['tg-dual'])
+ expect($sessions.get()).toEqual([])
+ })
})
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
index 368661f07f7..7b054f860d1 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
@@ -1298,12 +1298,6 @@ export function findListedSession(
storedSessionId: string
): { session: SessionInfo; slice: ListedSessionSlice } | undefined {
const match = (session: SessionInfo) => sessionMatchesStoredId(session, storedSessionId)
- const fromSessions = $sessions.get().find(match)
-
- if (fromSessions) {
- return { session: fromSessions, slice: 'sessions' }
- }
-
const fromMessaging = $messagingSessions.get().find(match)
if (fromMessaging) {
@@ -1316,6 +1310,12 @@ export function findListedSession(
return { session: fromCron, slice: 'cron' }
}
+ const fromSessions = $sessions.get().find(match)
+
+ if (fromSessions) {
+ return { session: fromSessions, slice: 'sessions' }
+ }
+
return undefined
}