fix(sync): prefer freshest session status and persist active-now list

This commit is contained in:
Bohdan Triapitsyn
2026-04-16 19:16:32 +03:00
parent 16ec1f605e
commit af7cf6ec9c
3 changed files with 114 additions and 11 deletions
@@ -58,6 +58,27 @@ describe('live aggregate', () => {
expect(findLiveSessionStatus(states, 'ses-2')?.type).toBe('retry')
})
it('lets a fresher idle snapshot override a stale busy status', () => {
const states = [
{
session: [session('ses-1', '/a', 10)],
session_status: {
'ses-1': { type: 'busy' },
},
},
{
session: [session('ses-1', '/a', 30)],
session_status: {
'ses-1': { type: 'idle' },
},
},
]
const statuses = aggregateLiveSessionStatuses(states)
expect(statuses['ses-1']?.type).toBe('idle')
expect(findLiveSessionStatus(states, 'ses-1')?.type).toBe('idle')
})
it('derives active-now sessions from live statuses instead of persisted history', () => {
const sessions = [
session('ses-1', '/a', 20),