[PR #368] [MERGED] Add SSE-powered Team Huddle feed with polling fallback #674

Closed
opened 2026-03-13 21:03:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/368
Author: @AJaySi
Created: 3/2/2026
Status: Merged
Merged: 3/3/2026
Merged by: @AJaySi

Base: mainHead: codex/add-server-sent-events-endpoint


📝 Commits (1)

  • c0d9289 Add agent huddle SSE feed with frontend live subscriptions

📊 Changes

5 files changed (+522 additions, -156 deletions)

View changed files

📝 backend/api/agents_api.py (+245 -1)
📝 frontend/src/App.tsx (+2 -0)
📝 frontend/src/components/MainDashboard/components/TeamHuddleWidget.tsx (+42 -155)
frontend/src/hooks/useAgentHuddleFeed.ts (+167 -0)
frontend/src/pages/TeamActivityPage.tsx (+66 -0)

📄 Description

Motivation

  • Provide real-time updates for team agent activity (run lifecycle, events, alerts, approvals) and let frontend components reconcile with an initial snapshot for a robust live view.
  • Ensure the UI remains responsive when SSE is unavailable by implementing reconnect/backoff and a polling fallback.

Description

  • Added backend aggregation and serialization utilities in backend/api/agents_api.py and implemented GET /api/agents/huddle/feed to return an initial/delta snapshot and GET /api/agents/huddle/stream as an authenticated SSE stream that emits snapshot, delta, and heartbeat events and detects run lifecycle changes.
  • Implemented cursor-based snapshot builder and serializers for AgentRun, AgentEvent, AgentAlert, and AgentApprovalRequest and included a lightweight signature cache to surface run lifecycle updates.
  • Added a reusable frontend hook frontend/src/hooks/useAgentHuddleFeed.ts that hydrates from /api/agents/huddle/feed, subscribes to the SSE stream via authenticated fetch, reconciles incoming deltas into bounded lists by id, tracks heartbeats, performs exponential reconnect/backoff, and falls back to periodic polling when SSE is unreliable.
  • Updated TeamHuddleWidget to consume the live feed and display connection state/heartbeat, added a new TeamActivityPage to surface runs/events/alerts/approvals from the same feed, and registered the /team-activity route in frontend/src/App.tsx.

Testing

  • Ran Python byte-compile for modified backend modules with python -m compileall backend/api/agents_api.py backend/services/agent_activity_service.py, which succeeded.
  • Ran TypeScript check with npx tsc --noEmit --pretty false, which failed due to pre-existing type declaration errors in third-party package @copilotkit/react-core (errors unrelated to these changes).
  • Attempted an end-to-end visual validation via Playwright to capture /team-activity, but the headless Chromium process crashed in this environment (SIGSEGV), so no screenshot could be produced.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/368 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/3/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/add-server-sent-events-endpoint` --- ### 📝 Commits (1) - [`c0d9289`](https://github.com/AJaySi/ALwrity/commit/c0d9289d4db82a3870fc3d4562f6c3611a5fd6a0) Add agent huddle SSE feed with frontend live subscriptions ### 📊 Changes **5 files changed** (+522 additions, -156 deletions) <details> <summary>View changed files</summary> 📝 `backend/api/agents_api.py` (+245 -1) 📝 `frontend/src/App.tsx` (+2 -0) 📝 `frontend/src/components/MainDashboard/components/TeamHuddleWidget.tsx` (+42 -155) ➕ `frontend/src/hooks/useAgentHuddleFeed.ts` (+167 -0) ➕ `frontend/src/pages/TeamActivityPage.tsx` (+66 -0) </details> ### 📄 Description ### Motivation - Provide real-time updates for team agent activity (run lifecycle, events, alerts, approvals) and let frontend components reconcile with an initial snapshot for a robust live view. - Ensure the UI remains responsive when SSE is unavailable by implementing reconnect/backoff and a polling fallback. ### Description - Added backend aggregation and serialization utilities in `backend/api/agents_api.py` and implemented `GET /api/agents/huddle/feed` to return an initial/delta snapshot and `GET /api/agents/huddle/stream` as an authenticated SSE stream that emits `snapshot`, `delta`, and `heartbeat` events and detects run lifecycle changes. - Implemented cursor-based snapshot builder and serializers for `AgentRun`, `AgentEvent`, `AgentAlert`, and `AgentApprovalRequest` and included a lightweight signature cache to surface run lifecycle updates. - Added a reusable frontend hook `frontend/src/hooks/useAgentHuddleFeed.ts` that hydrates from `/api/agents/huddle/feed`, subscribes to the SSE stream via authenticated fetch, reconciles incoming deltas into bounded lists by `id`, tracks heartbeats, performs exponential reconnect/backoff, and falls back to periodic polling when SSE is unreliable. - Updated `TeamHuddleWidget` to consume the live feed and display connection state/heartbeat, added a new `TeamActivityPage` to surface runs/events/alerts/approvals from the same feed, and registered the `/team-activity` route in `frontend/src/App.tsx`. ### Testing - Ran Python byte-compile for modified backend modules with `python -m compileall backend/api/agents_api.py backend/services/agent_activity_service.py`, which succeeded. - Ran TypeScript check with `npx tsc --noEmit --pretty false`, which failed due to pre-existing type declaration errors in third-party package `@copilotkit/react-core` (errors unrelated to these changes). - Attempted an end-to-end visual validation via Playwright to capture `/team-activity`, but the headless Chromium process crashed in this environment (SIGSEGV), so no screenshot could be produced. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69a5b3912cd48328936f341e4b60850b) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-13 21:03:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#674
No description provided.