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

Reimplements PR #89728 on top of the ownerRoute rework. The active
transcript resolver only looked in $sessions and $messagingSessions, so an
open cron-run transcript resolved to nothing and every sessions.changed
tick was dropped — the pane froze until the user reopened it. Resolve
through ownerLookupSessionRows() (recents + cron + messaging) instead.

Co-authored-by: fangliquanflq <fangliquan@qq.com>
This commit is contained in:
Teknium
2026-09-02 04:11:46 -07:00
parent a53286999b
commit a0e4ce252c
2 changed files with 17 additions and 5 deletions
@@ -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, {
@@ -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 }