Skip to content

Commit a1d144d

Browse files
authored
fix(web): handle legacy session summaries (#751)
1 parent 5b797bb commit a1d144d

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

web/src/lib/sessionAttention.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ describe('classifySessionAttention', () => {
4242
expect(attention).toEqual({ kind: 'permission' })
4343
})
4444

45+
it('handles summaries from older APIs without pendingRequestKinds', () => {
46+
const legacySummary = makeSummary({ id: 'legacy', updatedAt: 5000 }) as unknown as SessionSummary
47+
delete (legacySummary as Partial<SessionSummary>).pendingRequestKinds
48+
49+
const attention = classifySessionAttention(
50+
legacySummary,
51+
{ selected: false, lastSeenAt: 1000 }
52+
)
53+
54+
expect(attention).toEqual({ kind: 'unread' })
55+
})
56+
4557
it('shows unread activity when the session has updated since last seen', () => {
4658
const attention = classifySessionAttention(
4759
makeSummary({ id: 'a', updatedAt: 5000 }),

web/src/lib/sessionAttention.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ export function classifySessionAttention(
1414
return null
1515
}
1616

17-
if (summary.pendingRequestKinds.includes('permission')) {
17+
const pendingRequestKinds = Array.isArray(summary.pendingRequestKinds)
18+
? summary.pendingRequestKinds
19+
: []
20+
21+
if (pendingRequestKinds.includes('permission')) {
1822
return { kind: 'permission' }
1923
}
2024

21-
if (summary.pendingRequestKinds.includes('input')) {
25+
if (pendingRequestKinds.includes('input')) {
2226
return { kind: 'input' }
2327
}
2428

25-
if (summary.active && summary.backgroundTaskCount > 0) {
29+
if (summary.active && (summary.backgroundTaskCount ?? 0) > 0) {
2630
return { kind: 'background' }
2731
}
2832

0 commit comments

Comments
 (0)