Skip to content

[Good First Issue] Implement WebSocket real-time run status updates #11

Description

@Oshgig

Overview

The dashboard currently polls for run status. We need a WebSocket endpoint so the frontend can receive real-time push updates when a prediction job completes or fails.

Scope

  • Implement /ws/runs/{run_id} WebSocket endpoint in FastAPI
  • Emit status updates: running → completed / failed
  • Include result payload (or error message) in the final completed/failed event
  • Handle client disconnections gracefully
  • Update frontend useRunPolling hook to prefer WebSocket, falling back to polling
  • Update NewAnalysis and RunHistory pages to listen for WebSocket events

Acceptance Criteria

  • Opening a WebSocket connection to /ws/runs/{run_id} receives status updates in real time
  • Frontend replaces polling with WebSocket when supported
  • Connection gracefully degrades to polling if WebSocket is unavailable
  • All changes covered by at least basic tests

Resources

Difficulty: Intermediate
Labels: help wanted, backend, frontend, real-time

Activity

  1. added
    help wantedExtra attention is needed
    and removed
    help wantedExtra attention is needed
    on Apr 19, 2026
  2. changed the title [-][Help Wanted] Implement WebSocket real-time run status updates[/-] [+][Good First Issue] Implement WebSocket real-time run status updates[/+] on Apr 25, 2026
  3. sonakshigupta29 commented on May 10, 2026

    @sonakshigupta29

    Hello @Oshgig, I looked into this issue and traced it to
    src/climatevision/api/main.py , and i saw that the predict endpoint already
    tracks status as completed or failed internally.

    So, my approach would be to add a WebSocket endpoint that broadcasts
    these status updates in real time, so the frontend doesn't need
    to poll. I'll also handle case of client disconnection gracefully.

    Happy to open a PR if this looks right. Open to feedback on the
    approach.

  4. Ayomipo18 commented on Aug 18, 2026

    @Ayomipo18
    Contributor

    I'd like to work on this.

    Planned approach, so it can be corrected before I build:

    Backend — add a /ws/runs/{run_id} WebSocket. Since /api/predict runs inference inline, status changes happen in-process, so I plan a small in-process pub/sub hub that the predict paths publish to and the socket subscribes to. On connect the socket sends the current status straight from the DB (so a client attaching late to an already-finished run still gets a terminal event), then streams transitions until completed/failed, including the result payload or error on the final event.

    Frontend — a useRunWebSocket hook that useRunPolling prefers, falling back to the existing 5s polling when the socket cannot connect or errors.

    One question: frontend tests need the Vitest runner from #125, which is green but not yet merged. I will write the frontend tests to that setup and keep this PR free of package.json changes, so they simply start running once #125 lands — no conflict either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions