Skip to content

The agent that grows with you

fix(desktop): open cron-run transcripts stay live

Tekniuma0e4ce252c90
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts
index 7d1bd2cc640..30f1e4f8d31 100644
--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts
+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts
@@ -8,6 +8,7 @@ import {
$activeSessionId,
$selectedStoredSessionId,
setBusy,
+ setCronSessions,
setMessagingSessions,
setSessionOwnerHint,
setSessions
@@ -155,6 +156,7 @@ afterEach(() => {
$activeSessionId.set(null)
$selectedStoredSessionId.set(null)
setSessions([])
+ setCronSessions([])
setMessagingSessions([])
setBusy(false)
vi.clearAllMocks()
@@ -555,6 +557,19 @@ describe('reconcileActiveTranscript', () => {
})
})
+ it('resolves and hydrates a cron session from the cron sessions store', async () => {
+ setCronSessions([{ id: ACTIVE_STORED_ID, profile: 'cron-profile', source: 'cron' } as never])
+ const fixture = makeRefresh(resolveActiveTranscriptSession)
+ vi.mocked(getLatestSessionMessages).mockResolvedValue(transcript('cron progress') as never)
+
+ await fixture.refresh()
+
+ expect(getLatestSessionMessages).toHaveBeenCalledWith(ACTIVE_STORED_ID, 'cron-profile')
+ expect(fixture.states.get(ACTIVE_RUNTIME_ID)?.messages.at(-1)?.parts[0]).toMatchObject({
+ text: 'cron progress'
+ })
+ })
+
it('fails closed when a hidden session id has multiple owner hints', async () => {
const ambiguousStoredSessionId = 'ambiguous-hidden-chat'
setSessionOwnerHint(ambiguousStoredSessionId, {
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
index 663f190a517..ee803cfa3b4 100644
--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts
@@ -13,10 +13,9 @@ import {
$activeSessionId,
$busy,
$currentCwd,
- $messagingSessions,
$selectedStoredSessionId,
- $sessions,
getSessionOwnerHint,
+ ownerLookupSessionRows,
sessionMatchesStoredId,
setCurrentCwd
} from '@/store/session'
@@ -39,9 +38,7 @@ interface ActiveTranscriptSession {
/** Resolve an active transcript from visible rows or its unique hidden owner. */
export function resolveActiveTranscriptSession(storedSessionId: string): ActiveTranscriptSession | undefined {
- const visible =
- $sessions.get().find(session => sessionMatchesStoredId(session, storedSessionId)) ??
- $messagingSessions.get().find(session => sessionMatchesStoredId(session, storedSessionId))
+ const visible = ownerLookupSessionRows().find(session => sessionMatchesStoredId(session, storedSessionId))
if (visible) {
return { profile: visible.profile }