Skip to content

feat(sessions): add stop run control for cloud runs#3382

Open
tatoalo wants to merge 1 commit into
mainfrom
posthog-code/stop-cloud-run-control
Open

feat(sessions): add stop run control for cloud runs#3382
tatoalo wants to merge 1 commit into
mainfrom
posthog-code/stop-cloud-run-control

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

There is no way to stop a cloud run from PostHog Code. Esc only interrupts the current response (a turn-level cancel command), so the sandbox keeps running until the backend's inactivity timeout.

stop_cloud_run.mp4

closes #2634

Changes

  • add a Stop run button for active cloud sessions next to Continue locally, with a confirmation dialog and a disabled Stopping... state until the run reaches a terminal status.

  • add CloudTaskService.stop, exposed through the shared host router, to call the new cancel endpoint and automatically retry transient 503/5xx failures.

  • add sessionService.stopCloudRun to handle cloud run cancellation, ignore non-cloud or terminal sessions, and clear the pending state if the request fails.

  • add a dedicated TASK_RUN_STOPPED analytics event, separate from the existing TASK_RUN_CANCELLED event used for turn interrupts.

@tatoalo tatoalo self-assigned this Jul 13, 2026
@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@tatoalo tatoalo force-pushed the posthog-code/stop-cloud-run-control branch from a8cad3d to f57936c Compare July 13, 2026 12:02
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit a2870c0.

@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 13, 2026
@tatoalo tatoalo force-pushed the posthog-code/stop-cloud-run-control branch from f57936c to 48eb6b9 Compare July 13, 2026 12:59
@tatoalo tatoalo marked this pull request as ready for review July 13, 2026 13:08

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a 23-file, 782-line behavioral feature (stop cloud run) touching session state, archive flow, API calls, and UI — it exceeded the automated size gate and has zero reviews. The implementation looks reasonable and well-tested, but a change of this scope affecting cloud task lifecycle needs at least one human reviewer before auto-approval.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 13, 2026
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Security Review

The new stop endpoint can forward the authenticated bearer token to a renderer-supplied apiHost. The fetch target should be derived or validated at the trusted service boundary.

Reviews (1): Last reviewed commit: "feat(sessions): add stop run control for..." | Re-trigger Greptile

Comment thread packages/core/src/cloud-task/cloud-task.ts Outdated
Comment thread packages/core/src/sessions/sessionService.ts
Comment thread packages/core/src/sessions/sessionService.ts
Comment thread packages/core/src/archive/archiveOrchestration.ts Outdated
@tatoalo tatoalo force-pushed the posthog-code/stop-cloud-run-control branch from 48eb6b9 to a2870c0 Compare July 13, 2026 13:49
@tatoalo tatoalo requested a review from a team July 13, 2026 14:18
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.

Should be able to stop a cloud task from spinning up if you dont actually care about it / misclick

1 participant