fix(webui): multiplex dashboard live updates over one stream
This commit is contained in:
1 parent
c1143ea3db
commit
29004db774
25 files changed
+835
-322
No files matched your search
@@ -44,6 +44,15 @@ that reads it and the path the value takes to get there.
|
||||
not on it requires a restart.
|
||||
6. If the settings page shows it as a plain field, add it to
|
||||
`internal/webui/config_schema.go` and the view in `api_config.go`.
|
||||
7. A generic catalog resource (`replace` command, not domain-managed, no
|
||||
query service) is watched **once per archie-ui process** by `webui.RunLive`,
|
||||
then published to every browser through `/api/stream`. Do not add an
|
||||
EventSource per resource to a settings store or a gRPC Watch per HTTP client.
|
||||
The control-plane server polls `Resource` every 250ms per upstream Watch;
|
||||
verify watch count is independent of client count and that late clients get
|
||||
the hub's current value (`internal/webui/live_hub_test.go`, real server over
|
||||
bufconn). Reopens resume after the last delivered version and charge failed
|
||||
attempts; accepting a gRPC stream does not establish its health.
|
||||
|
||||
## Every new field
|
||||
|
||||
|
||||
@@ -18,7 +18,18 @@ should look.
|
||||
comes from the server. Keep a local default only so the first render works,
|
||||
and keep it in step (`ui/src/lib/task-meta.ts`).
|
||||
5. Run `task ui`, `task test:ui` and `cd ui && npm run typecheck`. Commit the
|
||||
regenerated `ui/dist/`; the Go binaries embed it.
|
||||
regenerated `ui/dist/`; the Go binaries embed it. A fresh git worktree has
|
||||
no ignored `ui/node_modules`: run `cd ui && npm ci` before these commands.
|
||||
6. **One long-lived browser connection:** `ui/src/lib/api.ts` has the only
|
||||
`new EventSource`, owned by `stores/live-updates.ts`. Feature stores consume
|
||||
topics with `live.subscribe(topic, callback)`; do not open a page-owned SSE
|
||||
stream. Logs alone opt in while mounted, replacing that same EventSource
|
||||
with `?topics=logs&since=<last cursor>`; a browser's `Last-Event-ID` only
|
||||
survives its own automatic reconnect, not a newly constructed EventSource.
|
||||
Task and log topics resume by cursor; control-plane, identity and apply-status
|
||||
topics replay the latest snapshot. Test a fetch and same-origin navigation
|
||||
after visiting Settings and Logs: the UI process serves HTTP/1.1 and six
|
||||
persistent streams can starve every later browser request.
|
||||
|
||||
## Adding an API route
|
||||
|
||||
@@ -35,3 +46,10 @@ should look.
|
||||
`internal/app/archieui/compose.go`.
|
||||
5. Settings that live in a control-plane resource need no new route: the
|
||||
Advanced settings page edits every resource from its generated schema.
|
||||
6. For a new live topic, add one process-wide producer to `internal/webui`'s
|
||||
`RunLive` and fan it through the `/api/stream` hub; `internal/app/archieui/run.go`
|
||||
starts the producers with the process context. Never create an upstream
|
||||
watch or poller in an HTTP handler. A slow client must reconnect for cursor
|
||||
and snapshot repair rather than silently lose an update. Prove the producer
|
||||
with several browser clients against the real peer, not just a scripted
|
||||
stream; `live_hub_test.go` is the example.
|
||||
@@ -37,6 +37,7 @@ restating them.
|
||||
tree gets committed. `task check` also adds linter-tool lines to `go.sum`
|
||||
(bead 1e37); restore `go.sum` before committing unless you changed a
|
||||
dependency.
|
||||
- A change to `docs/prds/` or `docs/architecture/` carries the regenerated
|
||||
`docs/data/generated/dev-docs.json`, and PRD edits follow
|
||||
`docs/prds/RULES.md` and pass `task docs:prds`.
|
||||
- A change to `docs/prds/`, `docs/architecture/` **or `docs/development/`**
|
||||
carries the regenerated `docs/data/generated/dev-docs.json`: run
|
||||
`task docs:artifact` (not `task docs:check`, which checks contracts only).
|
||||
PRD edits also follow `docs/prds/RULES.md` and pass `task docs:prds`.
|
||||
Reference in new issue
Block a user