Skip to content

fix(cloud): prewarm selected sandbox image#3511

Merged
trunk-io[bot] merged 2 commits into
mainfrom
posthog-code/fix-custom-image-warm-reuse
Jul 16, 2026
Merged

fix(cloud): prewarm selected sandbox image#3511
trunk-io[bot] merged 2 commits into
mainfrom
posthog-code/fix-custom-image-warm-reuse

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Cloud runs could reuse a prewarmed default sandbox even when the user selected a cloud environment or custom base image. This caused the run to start on the wrong sandbox configuration.

Why: Prewarming should remain available while respecting the selected VM image and environment.

Changes

Include the cloud environment and custom image in warm requests and warm-lease identity. Reuse a configured warm run only when its full sandbox selection matches, with cold provisioning as a safe fallback when no matching warm lease is available.

Ignore stale warm responses after the selection changes, so an older request cannot replace the lease for the latest image. Environments and explicit custom images are intentionally composable: the environment supplies its other settings, while the explicit image overrides its base image, matching cold-run behavior.

The corresponding backend support must enforce the same project/user access and image-readiness checks as cold runs before accepting these optional IDs. Backends that do not support them reject the warm request and the client safely falls back to cold provisioning.

@trunk-io

trunk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 620253b.

@tatoalo tatoalo changed the title fix(cloud): honor selected sandbox image fix(cloud): prewarm selected sandbox image Jul 16, 2026
@tatoalo tatoalo self-assigned this Jul 16, 2026
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 16, 2026
@tatoalo
tatoalo marked this pull request as ready for review July 16, 2026 15:04
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Security Review

The warm endpoint now accepts caller-controlled environment and custom-image IDs. It must validate project ownership and repository eligibility for both resources before provisioning.

Reviews (1): Last reviewed commit: "fix(cloud): prewarm selected sandbox ima..." | Re-trigger Greptile

Comment thread packages/ui/src/features/task-detail/hooks/useWarmTask.ts
Comment thread packages/api-client/src/posthog-client.ts
Comment thread packages/ui/src/features/task-detail/hooks/useWarmTask.ts
github-actions[bot]
github-actions Bot previously approved these changes Jul 16, 2026

@github-actions github-actions 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.

Purely additive optional fields propagated consistently through the pre-warm → lease → task-creation chain, mirroring the existing pattern for model/reasoningEffort. The cold-run path already had these fields; this PR adds the missing warm-activation counterpart. All new code paths are covered by tests.

Include cloud environment and custom image selections in warm requests and lease matching. Reuse only matching configured warm runs, preserve cold fallback, and ignore stale warm responses after the selection changes.
@tatoalo
tatoalo force-pushed the posthog-code/fix-custom-image-warm-reuse branch from 559c741 to 4e3c1d7 Compare July 16, 2026 15:15
@github-actions
github-actions Bot dismissed their stale review July 16, 2026 15:16

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions 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.

No showstoppers. Additive change that propagates two optional config fields through the pre-warm pipeline, fixes a latent out-of-order response race, and follows existing patterns throughout. Human reviewer approved, all bot concerns addressed and resolved, comprehensive test coverage added for warm, cold, debounce, and race-condition paths.

@tatoalo
tatoalo enabled auto-merge (squash) July 16, 2026 15:27
@tatoalo

tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 5298cb9 into main Jul 16, 2026
31 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-custom-image-warm-reuse branch July 16, 2026 16:16
Gilbert09 added a commit that referenced this pull request Jul 20, 2026
Thread the selected sandbox environment / custom base image through the mobile
cloud-task warm path so a warmed sandbox matches what the task will actually run
on.

- `warmTask()` now optionally includes `sandbox_environment_id` / `custom_image_id`
  in the request body (only when set).
- `useWarmTask` folds both ids into the debounce/dedupe key, so changing the
  selection re-warms, and forwards them to the warm call.
- `runTaskInCloud` carries the ids on the run so a reused warm sandbox matches
  the selection instead of a mismatched default.

Generated-By: PostHog Code
Task-Id: 5c715645-baa3-460e-91ca-73ee7e7fad86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants