Skip to main content

Streaming Init Report (SSE)

Overview

Config reload now streams the init report in real time via Server-Sent Events (SSE), so each source appears in the UI as soon as it is processed — instead of waiting for the entire init to complete.

How it works

  1. The frontend calls POST /config/reload-stream using @microsoft/fetch-event-source.
  2. The backend initStream() AsyncGenerator yields one chunk per source.
  3. The config validation result appears immediately before webhook init starts.
  4. The full report is persisted once at the end (no partial writes).
  5. The old POST /config/reload endpoint is removed.

Key files

  • src/protocol/source/source.service.tsinitStream() AsyncGenerator
  • src/app.controller.tsPOST /config/reload-stream + calculateStatus
  • ui/src/protocol/tower.api.tsreloadConfigStream() with fetchEventSource
  • ui/src/pages/settings/Status.tsx — Streaming reload, guard ref for React StrictMode

Technical decisions

  • Report is written once at the end to avoid partial/inconsistent state on disk.
  • Demo mode detects the mock path and uses mockReloadStream (simulates SSE with progressive delays) instead of real fetchEventSource.
  • A guard ref in Status.tsx prevents React StrictMode double-render from triggering two concurrent reload streams.