feat: add notification optimization with visibility tracking and toast messages

Implement a visibility-aware notification system that delivers toast messages via SSE to visible browser tabs instead of sending push notifications, reducing unnecessary push requests. Includes VisibilityTracker for monitoring connection visibility, toast UI components, and enhanced SSEManager with toast delivery capability.
This commit is contained in:
weishu
2026-01-07 18:58:31 +08:00
parent ddbfde57cb
commit 803c2f65a9
16 changed files with 672 additions and 13 deletions
+8
View File
@@ -13,6 +13,7 @@ import type {
PushVapidPublicKeyResponse,
SlashCommandsResponse,
SpawnResponse,
VisibilityPayload,
SessionResponse,
SessionsResponse
} from '@/types/api'
@@ -172,6 +173,13 @@ export class ApiClient {
})
}
async setVisibility(payload: VisibilityPayload): Promise<void> {
await this.request('/api/visibility', {
method: 'POST',
body: JSON.stringify(payload)
})
}
async getSession(sessionId: string): Promise<SessionResponse> {
return await this.request<SessionResponse>(`/api/sessions/${encodeURIComponent(sessionId)}`)
}