Repository navigation
feat(webui): realtime update channel for ingest events (#957) - #1128
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughImplements a Server-Sent Events realtime notification channel ( ChangesRealtime Event Streaming
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add a Server-Sent Events channel from the daemon to the web reader so new conversations and ingest activity surface without a manual refresh. - polylogue/daemon/events.py: query_events_since() and get_latest_event_id() expose the daemon-event ledger as a monotonic cursor. - polylogue/daemon/events_http.py (new): GET /api/events handler with two shapes — SSE stream (default) and JSON snapshot (poll=1) — plus Last-Event-ID resume semantics for EventSource reconnects. - polylogue/daemon/http.py: routes /api/events; status payload gains last_event_id + weak ETag and returns 304 on If-None-Match; auth accepts access_token query param so EventSource can authenticate without a custom header. - polylogue/daemon/web_shell.py: subscribes via EventSource, refreshes conversations/facets/status on relevant kinds, falls back to polling on persistent failure, and surfaces a live/stale/offline status chip. - tests + budget/topology/CHANGELOG updates. Closes #957 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5f4f307 to
b6c63b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f4f30762c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds a realtime update channel from the daemon to the web reader so the
conversation list, facets, and status chips refresh as the daemon
ingests new sessions, without a manual page reload. Closes #957.
Problem
The web reader (
polylogue/daemon/web_shell.py) was strictlyrequest/response: opening the page pinned a snapshot of archive state
and only
setInterval(loadStatus, 30000)polled — and only the statuschips, not the conversation list. New sessions landing in seconds
elsewhere in the system required an F5. The daemon already emits
operational events (
ingestion_batch,ingest,reset,operation)to a SQLite ledger at
daemon_events.db(viapolylogue/daemon/events.py), but there was no surface that turnedthose events into reader notifications.
Solution
Wire the existing daemon-event ledger to the reader as a streaming
channel, with an ETag-style fallback when SSE is not available.
polylogue/daemon/events.py— addquery_events_since(last_id, kinds, limit)andget_latest_event_id(). These expose the ledger asa monotonic cursor and are the substrate for both the SSE stream and
the polling fallback.
polylogue/daemon/events_http.py(new module to keepdaemon/http.pyunder its file-size budget) — implementsGET /api/eventswith two shapes: SSE stream (default) writing one frameper event with
id:/event:/data:lines and a heartbeat commentbetween idle ticks, bounded by
max_secondsso HTTP idle timeouts andtests cannot deadlock; and
?poll=1returning a JSON snapshot of{events, last_event_id}for the ETag fallback. HonorsLast-Event-IDforEventSourcereconnect semantics and akindswhitelist.
polylogue/daemon/http.py— routes/api/eventsto the new module;GET /api/statusadvertiseslast_event_idand a weakETag, andreturns
304 Not ModifiedwhenIf-None-Matchmatches._check_authaccepts
?access_token=...soEventSource(which cannot send customheaders) can authenticate when a daemon token is configured.
polylogue/daemon/web_shell.py— replaces the naiveloadStatuspoller with an
EventSourcesubscription that debounce-refreshes theconversation list, facets, and status chips on relevant event kinds,
falls back to a 5s
?poll=1loop on persistent SSE failure, anddrives a
live: live | stale | polling | offline | connectingstatuschip with the last-seen event id.
tests/unit/daemon/test_daemon_events_endpoint.py— 9contract tests covering poll envelopes, kinds whitelist, strict-
gtsince semantics, SSE frame shape,
Last-Event-IDresume, status ETagaccess_tokenquery auth fallback. Existing daemonhttp contract tests extended with
last_event_idas a requiredstatus key.
docs/plans/file-size-budgets.yaml,docs/plans/topology-target.yaml,docs/topology-status.md,CHANGELOG.mdupdated for the new moduleand the trimmed
daemon/http.pybudget headroom.Alternative rejected: WebSocket. SSE is sufficient for the
server-to-client direction the reader actually needs, works over
HTTP/1.x without protocol upgrade, has built-in reconnect via
EventSource, and reuses the existingBaseHTTPRequestHandlerwithoutintroducing a WS stack.
Out of scope of this PR (the issue explicitly lists granular event
families —
conversation.created,message.appended,insights.refreshed, etc., and per-row animations). The substrate nowexists for those: emit a new event kind from the producer and the
reader will see it. Tracked here:
Verification
exit_code: 0after rendering topology/pages and adding thedaemon/http.pybudget exception.215 passed in 9.17s(9 new + 206 existing).Pre-existing failures in
tests/unit/cli/test_terminal_snapshots.pyreproduce on
origin/masterand are unrelated to this change.Closes #957
Summary by CodeRabbit
Release Notes
New Features
Tests