Replace polling with SSE push for tasks/workers lists#12
Merged
Conversation
The tasks and workers list pages previously polled every 2s via hx-trigger="every 2s", firing requests whether or not anything changed. Now mutation handlers (create, claim, run, cancel, finish, delete for tasks; launch, stop, delete for workers) notify an in-process EventHub, which broadcasts to SSE subscribers. The HTMX tables connect via sse-connect and refresh only when they receive a "tasks-changed" or "workers-changed" event. Also cleans up NextUp.md: removes completed items (branch protection, SSE list push, UI modernization candidate). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hx-trigger="every 2s"polling on tasks and workers list pages with SSE-based pushEventHubpub/sub (server/event_hub.go) — mutation handlers callNotify(), SSE endpoints fan out to connected browsers/ui/sse/tasksand/ui/sse/workerssend named events; HTMXsse-connect+hx-trigger="sse:tasks-changed"triggers the partial re-fetch only when data actually changesDesign
The
EventHubis intentionally minimal: buffered(1) channels per subscriber with non-blocking send means rapid mutations coalesce into a single event. SSE endpoints send an initial event on connect for catch-up, plus 30s keepalive pings.Notifications are wired to state-changing mutations only — not worker heartbeats or progress updates (neither is visible in the list tables).
Test plan
make docker-test— Go unit tests passmake docker-test-smoke— smoke test passesmake docker-test-browser— all 22 Playwright tests pass (updated auto-refresh tests to assert SSE attributes)🤖 Generated with Claude Code