Skip to content

feat(cloud): cloud task SSE streaming#1559

Open
tatoalo wants to merge 1 commit intomainfrom
feat/cloud-agent/sse-support-ph-code
Open

feat(cloud): cloud task SSE streaming#1559
tatoalo wants to merge 1 commit intomainfrom
feat/cloud-agent/sse-support-ph-code

Conversation

@tatoalo
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo commented Apr 8, 2026

Problem

ph_code_sse_streaming_cloud_runs.mp4

Cloud task log viewing used polling (500ms when viewing, 60s if in background) which was inefficient, had dedup complexity, and couldn't stream status changes in realtime. Also it was kinda bad.
We also had missing comms when a remote sandbox was torn down before the terminal status event arrived, which resulted in ph-code to nevel learn about the run being completed and always show a broken "in progress" state which was not the reflection of the real one.

Added a ton of tests just to make sure this is robust and covers some edge cases.
Diid a lot of manual testing, would appreciate a couple of eyes testing this as well please 🙏🏻

(PostHog/posthog#53754)

Changes

  • Complete rewrite of CloudTaskService from polling to SSE streaming with bootstrap (fetch history + open SSE with start=latest), exponential backoff reconnect, and handleStreamCompletion that checks actual run status on any stream error
  • aadded an sse parse to parse strem chunks with support for id, event, and multi-line data fields
  • a bit of refactor to extract TaskRunStatus, TERMINAL_STATUSES, and isTerminalStatus() to @shared/types
  • rewrote watchCloudTask to pass apiHost/teamId directly, added retryCloudTaskWatch, and handleCloudTaskUpdate now handles SSE error events (moved the auth concern to the renderer which already has the auth state, keeping the main-process service simpler)
  • sidebar now reads cloudStatus from session store (updated via SSE) instead of waiting for API task refetch
  • status rename "started""queued" to match BE API

@tatoalo tatoalo marked this pull request as draft April 8, 2026 15:53
@tatoalo tatoalo force-pushed the feat/cloud-agent/sse-support-ph-code branch 3 times, most recently from 94d2fe1 to 12decce Compare April 8, 2026 16:05
@tatoalo tatoalo self-assigned this Apr 8, 2026
@tatoalo tatoalo force-pushed the feat/cloud-agent/sse-support-ph-code branch from 12decce to 9223724 Compare April 8, 2026 16:16
@tatoalo tatoalo changed the title feat(code): replace cloud task polling with SSE streaming feat(cloud): cloud task SSE streaming Apr 8, 2026
@tatoalo tatoalo marked this pull request as ready for review April 9, 2026 08:03
@tatoalo tatoalo force-pushed the feat/cloud-agent/sse-support-ph-code branch from 9223724 to 88b4e96 Compare April 9, 2026 08:03
@tatoalo tatoalo requested a review from a team April 9, 2026 10:04
@tatoalo tatoalo force-pushed the feat/cloud-agent/sse-support-ph-code branch from 88b4e96 to 65ab1a8 Compare April 9, 2026 13:05
@tatoalo tatoalo force-pushed the feat/cloud-agent/sse-support-ph-code branch from 65ab1a8 to 2422d8a Compare April 9, 2026 14:45
@tatoalo tatoalo requested a review from a team April 9, 2026 16:13
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