Skip to content

Replace polling with SSE push for tasks/workers lists#12

Merged
turtlemonvh merged 1 commit into
masterfrom
ai/sse-list-push
May 1, 2026
Merged

Replace polling with SSE push for tasks/workers lists#12
turtlemonvh merged 1 commit into
masterfrom
ai/sse-list-push

Conversation

@turtlemonvh
Copy link
Copy Markdown
Owner

Summary

  • Replaces hx-trigger="every 2s" polling on tasks and workers list pages with SSE-based push
  • New EventHub pub/sub (server/event_hub.go) — mutation handlers call Notify(), SSE endpoints fan out to connected browsers
  • SSE endpoints at /ui/sse/tasks and /ui/sse/workers send named events; HTMX sse-connect + hx-trigger="sse:tasks-changed" triggers the partial re-fetch only when data actually changes
  • Cleans up completed NextUp.md items (branch protection, SSE list push, UI modernization)

Design

The EventHub is 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 pass
  • make docker-test-smoke — smoke test passes
  • make docker-test-browser — all 22 Playwright tests pass (updated auto-refresh tests to assert SSE attributes)
  • Manual: open tasks page, submit a task via API, confirm row appears without clicking Refresh

🤖 Generated with Claude Code

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>
@turtlemonvh turtlemonvh merged commit a7a514a into master May 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant