Fix session list freshness and unread indicators#470
Open
Liu-KM wants to merge 4 commits intotiann:mainfrom
Open
Fix session list freshness and unread indicators#470Liu-KM wants to merge 4 commits intotiann:mainfrom
Liu-KM wants to merge 4 commits intotiann:mainfrom
Conversation
There was a problem hiding this comment.
Findings
- [Major] Selected-session SSE connection never reports visibility changes — The new second
useSSEcall opens another/events?sessionId=...stream, but only the globalsubscriptionIdis passed touseVisibilityReporter. That leaves the session-scoped subscription stuck with whatever visibility it had at connect time. Because push fallback checkshasVisibleConnection(namespace)before sending notifications, backgrounding the app after opening a session can suppress push delivery and keep routing toasts to a hidden tab instead. Evidenceweb/src/App.tsx:259, related contextweb/src/hooks/useVisibilityReporter.ts:13,hub/src/push/pushNotificationChannel.ts:39.
Suggested fix:const { subscriptionId } = useSSE({ ...globalOptions }) const { subscriptionId: sessionSubscriptionId } = useSSE({ enabled: Boolean(api && token && selectedSessionId), token: token ?? '', baseUrl, subscription: sessionEventSubscription, onEvent: handleSseEvent }) useVisibilityReporter({ api, subscriptionId, enabled: Boolean(api && token) }) useVisibilityReporter({ api, subscriptionId: sessionSubscriptionId, enabled: Boolean(api && token && selectedSessionId) })
Summary
- Review mode: initial
- 1 finding. Main regression: the new per-session SSE stream can keep a hidden client marked visible, which suppresses push notifications for that namespace.
Testing
- Not run (automation)
HAPI Bot
| onToast: handleToast | ||
| }) | ||
|
|
||
| useSSE({ |
There was a problem hiding this comment.
[MAJOR] This second SSE stream never gets a visibility report. useVisibilityReporter only receives the global subscriptionId below, so this session-scoped subscription stays visible after a visible connect. PushNotificationChannel then sees hasVisibleConnection(namespace) and can skip push delivery even when the tab is hidden.
Suggested fix:
const { subscriptionId: sessionSubscriptionId } = useSSE({
enabled: Boolean(api && token && selectedSessionId),
token: token ?? '',
baseUrl,
subscription: sessionEventSubscription,
onEvent: handleSseEvent
})
useVisibilityReporter({
api,
subscriptionId: sessionSubscriptionId,
enabled: Boolean(api && token && selectedSessionId)
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix stale session-list state and add lightweight unread indicators for sessions that update while the user is looking elsewhere.
sessions.updated_atwhenever messages are stored or moved between sessionsmessage-receivedeventsWhy
The sidebar could show stale thinking/status and stale relative times until a session was opened. This made completed sessions still look active and made it hard to tell which background sessions had new output.
Validation
cd hub && bun test src/sync/sessionModel.test.tscd web && bun test src/components/SessionList.test.tsbun run typecheck:hubbun run typecheck:webNotes
AI-assisted with GPT-5.4.