Per-Tab Stream Deduplication

Copy Markdown View Source

When a user navigates away, an old SSE process can remain alive until the next keepalive. StarView can close the old stream when a new stream starts from the same browser tab.

Add the registry to your supervision tree:

children = [
  StarView.StreamRegistry,
  # ...
]

Set a tabId signal in your layout:

<div data-signals={~s({"tabId": "#{Ecto.UUID.generate()}"})}>

Start streams with:

conn = StarView.start_stream(conn, current_user.id)

If no tabId is present, StarView falls back to a regular SSE stream with no deduplication.