Files
boss/docs/superpowers/specs/2026-04-10-sse-refresh-noise-reduction-design.md
2026-04-10 12:55:43 +08:00

2.8 KiB

SSE Refresh Noise Reduction Design

Goal

Reduce unnecessary realtime refreshes on scoped conversation folder pages while preserving the global conversation list's ability to refresh when device-level imports or thread discovery change the folder structure.

Context

Boss currently publishes conversation.updated events for both project-scoped message changes and device-scoped import or discovery changes. The conversations root page should continue listening broadly because it needs to reflect new folders and latest replies across all devices. Folder detail pages are narrower: they should reload only when an event references a project in that folder, or when a device-scoped event targets that folder's owning device.

Design

Keep the existing backend event names stable. Add device scope support to the shared RealtimeRefresh filter so a scoped page can opt into deviceId or deviceIds alongside projectId or projectIds. If a scoped listener receives an event without any matching scoped identifier, it must ignore that event. If an event carries a project id, the listener should match it against the scoped project list. If an event carries only a device id, the listener should match it against the scoped device list.

The Web folder route passes the folder's deviceId to RealtimeRefresh in addition to its thread project ids. The Android folder activity mirrors the same rule locally: project events match known project ids; device-only conversation events match the parsed or loaded folder device id; unrelated device events do not reload the folder.

Error Handling

Malformed or empty SSE payloads are treated as unscoped. Scoped pages ignore them to avoid broad reload storms. Unscoped pages, including the conversations root list, keep the prior broad refresh behavior because they intentionally represent aggregate state.

Testing

The shared realtime refresh utility tests cover project matching, missing identifiers, matching device scope, and mismatched device scope. Static route tests assert that the Web folder page wires folder.deviceId into RealtimeRefresh. Android static tests assert that ConversationFolderActivity tracks a folder device id and filters device-scoped payloads against it.

The deployment script test also asserts that local IDE metadata paths are excluded from rsync, because untracked Android IDE files should not be uploaded during this release.

Out Of Scope

This change does not rename backend event types, remove device-level conversation.updated publications, or alter the root conversation list. It also does not include IDE metadata generated under android/.project, android/.settings, android/app/.project, android/app/.settings, or android/app/.classpath; those paths are explicitly excluded from deployment rsync.