:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): prewarm multi-repository sandboxes (#79670)
Alessandro Pogliaghi1ba046e4b566
diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.tsindex 49533c1b60d2..e19463353303 100644--- a/products/desktop/packages/api-client/src/posthog-client.ts+++ b/products/desktop/packages/api-client/src/posthog-client.ts@@ -3023,6 +3023,7 @@ export class PostHogAPIClient {async warmTask(options: {repository?: string | null;+ repositories?: string[];github_integration?: number | null;branch?: string | null;runtime_adapter?: string | null;@@ -3043,6 +3044,7 @@ export class PostHogAPIClient {overrides: {body: JSON.stringify({repository: options.repository,+ repositories: options.repositories,github_integration: options.github_integration,branch: options.branch ?? null,runtime_adapter: options.runtime_adapter ?? null,diff --git a/products/desktop/packages/core/src/task-detail/taskCreationHost.ts b/products/desktop/packages/core/src/task-detail/taskCreationHost.tsindex ae7ee0dbb0bb..a4330f968f45 100644--- a/products/desktop/packages/core/src/task-detail/taskCreationHost.ts+++ b/products/desktop/packages/core/src/task-detail/taskCreationHost.ts@@ -112,6 +112,7 @@ export interface ITaskCreationHost {*/takeWarmTaskLease(args: {repository?: string | null;+ repositories?: string[];branch?: string | null;runtimeAdapter?: string | null;model?: string | null;diff --git a/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts b/products/desktop/packages/core/src/task-detail/taskCreationSaga.tsindex 86b407f6ebcf..7301dc0c09d3 100644--- a/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts+++ b/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts@@ -737,6 +737,7 @@ export class TaskCreationSaga extends Saga<(input.repository || input.allowNoRepo) && input.runtime !== "pi"? this.deps.host.takeWarmTaskLease({repository: input.repository ?? null,+ repositories: input.repositories,branch: input.branch ?? null,runtimeAdapter: input.adapter ?? null,model: input.model ?? null,diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsxindex 4c0aac667749..dba1501a82c6 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskInput.tsx@@ -859,7 +859,10 @@ export function TaskInput({useWarmTask({workspaceMode,selectedRepository: selectedCloudRepository,- githubIntegrationId: orgGithubIntegrationId,+ repositories: allowNoRepo ? taskRepositories : undefined,+ githubIntegrationId: allowNoRepo+ ? (taskGithubIntegration ?? undefined)+ : orgGithubIntegrationId,allowNoRepo,branch: workspaceMode === "cloud" ? selectedBranch : null,editorIsEmpty,diff --git a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsxindex 9a0d8e5ae8ed..cf8b81ba41c1 100644--- a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx@@ -23,6 +23,7 @@ import { takeWarmTaskLease } from "./warmTaskLease";interface Props {workspaceMode: WorkspaceMode;selectedRepository?: string | null;+ repositories?: string[];githubIntegrationId?: number;allowNoRepo?: boolean;branch?: string | null;@@ -119,6 +120,22 @@ describe("useWarmTask", () => {expect(mockClient.warmTask).toHaveBeenCalledOnce();});+ it("does not reset the debounce when the composer rerenders", async () => {+ const { rerender } = renderHook((props: Props) => useWarmTask(props), {+ initialProps: cloudTyping,+ });++ await act(async () => {+ await vi.advanceTimersByTimeAsync(300);+ });+ rerender({ ...cloudTyping });+ await act(async () => {+ await vi.advanceTimersByTimeAsync(300);+ });++ expect(mockClient.warmTask).toHaveBeenCalledOnce();+ });+it("warms a repo-less cloud task when repositories are optional", async () => {renderHook((props: Props) => useWarmTask(props), {initialProps: {@@ -139,6 +156,37 @@ describe("useWarmTask", () => {});});+ it("warms all repositories selected for a multi-repo task", async () => {+ renderHook((props: Props) => useWarmTask(props), {+ initialProps: {+ ...cloudTyping,+ selectedRepository: null,+ repositories: ["acme/app", "acme/api", "acme/docs"],+ allowNoRepo: true,+ },+ });++ await flushDebounce();++ expect(mockClient.warmTask).toHaveBeenCalledWith({+ repository: "acme/app",+ repositories: ["acme/app", "acme/api", "acme/docs"],+ github_integration: 42,+ branch: "main",+ ...NULL_RUNTIME,+ });+ expect(+ takeWarmTaskLease({+ repository: null,+ repositories: ["acme/app", "acme/api", "acme/docs"],+ branch: "main",+ runtimeAdapter: null,+ model: null,+ reasoningEffort: null,+ }),+ ).toEqual({ taskId: "task-1", runId: "run-1" });+ });+it("ignores a stale repository selection for a repo-less cloud task", async () => {renderHook((props: Props) => useWarmTask(props), {initialProps: { ...cloudTyping, allowNoRepo: true },diff --git a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.ts b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.tsindex 8c49870f2464..ff3b415166e4 100644--- a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.ts+++ b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.ts@@ -4,7 +4,7 @@ import {} from "@posthog/shared";import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";-import { useEffect, useRef } from "react";+import { useEffect, useMemo, useRef } from "react";import { logger } from "../../../shell/logger";import { buildWarmTaskLeaseKey, rememberWarmTaskLease } from "./warmTaskLease";@@ -15,6 +15,7 @@ const WARM_DEBOUNCE_MS = 600;interface UseWarmTaskOptions {workspaceMode: WorkspaceMode;selectedRepository?: string | null;+ repositories?: string[];githubIntegrationId?: number;allowNoRepo?: boolean;branch?: string | null;@@ -29,6 +30,7 @@ interface UseWarmTaskOptions {export function useWarmTask({workspaceMode,selectedRepository,+ repositories,githubIntegrationId,allowNoRepo = false,branch,@@ -55,20 +57,31 @@ export function useWarmTask({const normalizedCustomImageId = customImageId ?? null;// Repo-less channel tasks deliberately discard any persisted/stale picker// selection on submit, so warming and lease matching must do the same.- const warmRepository = allowNoRepo ? null : (selectedRepository ?? null);- const warmGithubIntegrationId = allowNoRepo- ? null- : (githubIntegrationId ?? null);+ const warmRepositories = useMemo(+ () =>+ allowNoRepo+ ? (repositories ?? [])+ : selectedRepository+ ? [selectedRepository]+ : [],+ [allowNoRepo, repositories, selectedRepository],+ );+ const warmRepository = warmRepositories[0] ?? null;+ const warmGithubIntegrationId = warmRepositories.length+ ? (githubIntegrationId ?? null)+ : null;const eligible =enabled &&isCloud &&!!client &&(allowNoRepo || (!!warmRepository && warmGithubIntegrationId !== null)) &&+ (!warmRepositories.length || warmGithubIntegrationId !== null) &&!editorIsEmpty;const key =allowNoRepo || (warmRepository && warmGithubIntegrationId !== null)? `${warmGithubIntegrationId ?? ""}:${buildWarmTaskLeaseKey({repository: warmRepository,+ repositories: warmRepositories,branch: normalizedBranch,runtimeAdapter: normalizedRuntimeAdapter,model: normalizedModel,@@ -77,9 +90,9 @@ export function useWarmTask({customImageId: normalizedCustomImageId,})}`: null;- latestKeyRef.current = key;-useEffect(() => {+ latestKeyRef.current = key;+const clearDebounce = (): void => {if (debounceRef.current) {clearTimeout(debounceRef.current);@@ -109,6 +122,10 @@ export function useWarmTask({void client.warmTask({repository,+ // Older backends ignore this additive field and fall back to cold creation for multi-repo tasks.+ ...(repositories !== undefined+ ? { repositories: warmRepositories }+ : {}),github_integration: githubIntegration,branch: warmBranch,runtime_adapter: warmRuntimeAdapter,@@ -124,6 +141,7 @@ export function useWarmTask({rememberWarmTaskLease(buildWarmTaskLeaseKey({repository,+ repositories: warmRepositories,branch: warmBranch,runtimeAdapter: warmRuntimeAdapter,model: warmModel,@@ -149,6 +167,8 @@ export function useWarmTask({key,client,warmRepository,+ warmRepositories,+ repositories,warmGithubIntegrationId,normalizedBranch,normalizedRuntimeAdapter,diff --git a/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts b/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.tsindex a6b594209623..48394687a1f3 100644--- a/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts+++ b/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts@@ -5,6 +5,7 @@ export interface WarmTaskLease {export interface WarmTaskLeaseKeyParts {repository?: string | null;+ repositories?: string[];branch?: string | null;runtimeAdapter?: string | null;model?: string | null;@@ -15,7 +16,9 @@ export interface WarmTaskLeaseKeyParts {export function buildWarmTaskLeaseKey(parts: WarmTaskLeaseKeyParts): string {return [- parts.repository ?? "",+ (parts.repositories ?? (parts.repository ? [parts.repository] : [])).join(+ ",",+ ),parts.branch ?? "",parts.runtimeAdapter ?? "",parts.model ?? "",diff --git a/products/desktop/packages/ui/src/features/task-detail/taskCreationHostImpl.ts b/products/desktop/packages/ui/src/features/task-detail/taskCreationHostImpl.tsindex 2ec7038bf286..8ad26dbc771f 100644--- a/products/desktop/packages/ui/src/features/task-detail/taskCreationHostImpl.ts+++ b/products/desktop/packages/ui/src/features/task-detail/taskCreationHostImpl.ts@@ -158,6 +158,7 @@ export class TrpcTaskCreationHost implements ITaskCreationHost {takeWarmTaskLease(args: {repository?: string | null;+ repositories?: string[];branch?: string | null;runtimeAdapter?: string | null;model?: string | null;diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.pyindex 7ed49909e049..9d0c8d3eb462 100644--- a/products/tasks/backend/facade/api.py+++ b/products/tasks/backend/facade/api.py@@ -4328,13 +4328,14 @@ def create_task(if (warm_branch_providedand validated_data["origin_product"] == Task.OriginProduct.USER_CREATED- and len(validated_data.get("repositories", [])) <= 1and user_id is not None):warm_run = _find_idling_warm_run(team_id,user_id,repository=validated_data.get("repository"),+ repositories=validated_data.get("repositories", []),+ github_integration_id=getattr(validated_data.get("github_integration"), "id", None),branch=warm_branch,runtime_adapter=warm_runtime_adapter,model=warm_model,@@ -4702,6 +4703,8 @@ def _find_idling_warm_run(user_id: int | None,*,repository: str | None,+ repositories: list[str] | None = None,+ github_integration_id: int | None,branch: str | None,runtime_adapter: str | None = None,model: str | None = None,@@ -4724,6 +4727,7 @@ def _find_idling_warm_run("""if user_id is None:return None+ normalized_repositories = [repo.lower() for repo in (repositories or ([repository] if repository else []))]repository_filter = {"task__repository__iexact": repository} if repository else {"task__repository__isnull": True}candidates = (TaskRun.objects.filter( # nosemgrep: idor-lookup-without-team — team_id filter applied via the task FK below@@ -4731,6 +4735,7 @@ def _find_idling_warm_run(task__created_by_id=user_id,task__origin_product=Task.OriginProduct.USER_CREATED,task__deleted=False,+ task__github_integration_id=github_integration_id,state__await_user_message=True,branch=branch or None,**repository_filter,@@ -4748,6 +4753,11 @@ def _find_idling_warm_run()for run in candidates:state = run.state or {}+ have_repositories = [+ repo.lower() for repo in (run.task.repositories or ([run.task.repository] if run.task.repository else []))+ ]+ if have_repositories != normalized_repositories:+ continuehave = (state.get("runtime_adapter") or None,state.get("model") or None,@@ -4865,6 +4875,7 @@ def warm_task_sandbox(user_id: int,*,repository: str | None,+ repositories: list[str] | None = None,github_integration_id: int | None,branch: str | None,runtime_adapter: str | None = None,@@ -4907,14 +4918,15 @@ def warm_task_sandbox()team = Team.objects.get(id=team_id)+ normalized_repositories = [repo.lower() for repo in (repositories or ([repository] if repository else []))]+ repository = normalized_repositories[0] if normalized_repositories else Nonegithub_integration = Noneif github_integration_id is not None:github_integration = Integration.objects.filter(id=github_integration_id, team_id=team_id, kind="github").first()- if bool(repository) != bool(github_integration):+ if bool(normalized_repositories) != bool(github_integration):return None-sandbox_environment = Noneif sandbox_environment_id is not None:sandbox_environment = SandboxEnvironment.get_accessible_for_task(@@ -4939,6 +4951,8 @@ def warm_task_sandbox(team_id,user_id,repository=repository,+ repositories=normalized_repositories,+ github_integration_id=github_integration_id,branch=branch,runtime_adapter=runtime_adapter,model=model,@@ -4958,6 +4972,9 @@ def warm_task_sandbox(repository=repository,client_provenance=client_provenance,)+ task.repositories = normalized_repositories+ task.github_integration = github_integration+ task.save(update_fields=["repositories", "github_integration", "updated_at"])assert task.created_by is not None # create_without_run always sets created_by from user_idprovider = get_provider_for_runtime_adapter(runtime_adapter)diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.pyindex ad1b09123cec..d25635e78848 100644--- a/products/tasks/backend/presentation/serializers.py+++ b/products/tasks/backend/presentation/serializers.py@@ -2616,6 +2616,16 @@ class WarmTaskRequestSerializer(serializers.Serializer):max_length=255,help_text="Optional GitHub repository to clone, in `organization/repo` format (e.g. `posthog/posthog`).",)+ repositories = serializers.ListField(+ child=serializers.CharField(max_length=255),+ required=False,+ max_length=3,+ help_text="GitHub repositories to clone into the warm sandbox, each in `organization/repo` format.",+ )++ def validate_repositories(self, value: list[str]) -> list[str]:+ return TaskWriteSerializer().validate_repositories(value)+github_integration = serializers.IntegerField(required=False,default=None,diff --git a/products/tasks/backend/presentation/views/api.py b/products/tasks/backend/presentation/views/api.pyindex 6543085125a3..fe6ebecea04a 100644--- a/products/tasks/backend/presentation/views/api.py+++ b/products/tasks/backend/presentation/views/api.py@@ -876,6 +876,7 @@ class TaskViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):self.team_id,user_id,repository=request.validated_data.get("repository"),+ repositories=request.validated_data.get("repositories"),github_integration_id=github_integration_id,branch=request.validated_data.get("branch"),runtime_adapter=request.validated_data.get("runtime_adapter"),diff --git a/products/tasks/backend/temporal/process_task/README.md b/products/tasks/backend/temporal/process_task/README.mdindex f0cbf33021d2..ad3e64c83949 100644--- a/products/tasks/backend/temporal/process_task/README.md+++ b/products/tasks/backend/temporal/process_task/README.md@@ -52,7 +52,7 @@ User ─────────────────────────### PostHog API-`backend/presentation/views/api.py` (thin viewsets) over `backend/facade/api.py` (behavior) — every user-triggered cloud launch path, including prewarming and task automations, checks server-side PostHog Desktop access before provisioning or activating a run. Scheduled automations repeat the entitlement check at execution time so revoked access cannot launch later. `TaskViewSet.run` creates a `TaskRun` (status=QUEUED) and starts the Temporal workflow. `TaskRunViewSet.partial_update` handles status transitions and signals the Temporal workflow on terminal statuses via `signal_workflow_completion`. `TaskRunViewSet.cancel` (`POST .../runs/{id}/cancel/`) is the user-facing kill switch: `cancel_task_run` interrupts the in-flight agent turn, signals `complete_task("cancelled")` so the workflow snapshots the session and tears down the sandbox, and falls back to finalizing the run directly when no workflow is running.+`backend/presentation/views/api.py` (thin viewsets) over `backend/facade/api.py` (behavior) — every user-triggered cloud launch path, including prewarming and task automations, checks server-side PostHog Desktop access before provisioning or activating a run. Composer prewarming carries the complete ordered repository selection, so single- and multi-repository submissions can reuse only an exact matching sandbox. Scheduled automations repeat the entitlement check at execution time so revoked access cannot launch later. `TaskViewSet.run` creates a `TaskRun` (status=QUEUED) and starts the Temporal workflow. `TaskRunViewSet.partial_update` handles status transitions and signals the Temporal workflow on terminal statuses via `signal_workflow_completion`. `TaskRunViewSet.cancel` (`POST .../runs/{id}/cancel/`) is the user-facing kill switch: `cancel_task_run` interrupts the in-flight agent turn, signals `complete_task("cancelled")` so the workflow snapshots the session and tears down the sandbox, and falls back to finalizing the run directly when no workflow is running.### Temporal workflowdiff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.pyindex 7b27dfac38f1..ca26eb32dee6 100644--- a/products/tasks/backend/tests/test_api.py+++ b/products/tasks/backend/tests/test_api.py@@ -1437,7 +1437,19 @@ class TestTaskAPI(BaseTaskAPITest):task = Task.objects.get(id=response.json()["id"])self.assertEqual(task.repositories, ["posthog/posthog", "posthog/code"])self.assertEqual(task.create_run().state["repositories"], task.repositories)- mock_find_warm_run.assert_not_called()+ mock_find_warm_run.assert_called_once_with(+ self.team.id,+ self.user.id,+ repository="posthog/posthog",+ repositories=["posthog/posthog", "posthog/code"],+ github_integration_id=integration.id,+ branch="main",+ runtime_adapter=None,+ model=None,+ reasoning_effort=None,+ sandbox_environment_id=None,+ custom_image_id=None,+ )update = self.client.patch(f"/api/projects/@current/tasks/{task.id}/",diff --git a/products/tasks/backend/tests/test_warm_facade.py b/products/tasks/backend/tests/test_warm_facade.pyindex b04a4e0b6a1d..1474a56e048c 100644--- a/products/tasks/backend/tests/test_warm_facade.py+++ b/products/tasks/backend/tests/test_warm_facade.py@@ -3,6 +3,8 @@ from typing import Anyfrom posthog.test.base import APIBaseTestfrom unittest.mock import patch+from django.utils import timezone as django_timezone+from rest_framework.exceptions import PermissionDenied, Throttledfrom posthog.exceptions import QuotaLimitExceeded@@ -111,6 +113,33 @@ class TestWarmTaskSandbox(APIBaseTest):assert mock_warm.call_args.kwargs["repository"] is Noneassert mock_warm.call_args.kwargs["github_integration_id"] is None+ @patch("products.tasks.backend.presentation.views.api.TaskViewSet._warm_enabled", return_value=True)+ def test_warm_endpoint_rejects_duplicate_repositories(self, _mock_warm_enabled):+ response = self.client.post(+ "/api/projects/@current/tasks/warm/",+ {+ "repositories": ["PostHog/PostHog", "posthog/posthog"],+ "github_integration": self.integration.id,+ },+ format="json",+ )++ assert response.status_code == 400+ assert b"Repositories must be unique" in response.content++ @patch("products.tasks.backend.presentation.views.api.TaskViewSet._warm_enabled", return_value=True)+ def test_warm_endpoint_limits_repository_clone_budget(self, _mock_warm_enabled):+ response = self.client.post(+ "/api/projects/@current/tasks/warm/",+ {+ "repositories": ["posthog/one", "posthog/two", "posthog/three", "posthog/four"],+ "github_integration": self.integration.id,+ },+ format="json",+ )++ assert response.status_code == 400+def test_provisions_selected_sandbox_environment_and_custom_image(self):sandbox_environment = SandboxEnvironment.objects.create(team=self.team,@@ -170,6 +199,22 @@ class TestWarmTaskSandbox(APIBaseTest):task = Task.objects.get(id=result.task_id)assert task.repository is None+ def test_births_multi_repository_draft(self):+ def fake_warm(self_warmer, **kwargs):+ run = self_warmer.task.create_run(mode="interactive", extra_state={"await_user_message": True})+ return WarmResult(run=run, just_created=True)++ repositories = ["posthog/posthog", "posthog/posthog-js"]+ with patch(f"{WARM_SRC}.warm", autospec=True, side_effect=fake_warm):+ result = self._warm(repositories=repositories)++ assert result is not None+ task = Task.objects.get(id=result.task_id)+ run = TaskRun.objects.get(id=result.run_id)+ assert task.repository == repositories[0]+ assert task.repositories == repositories+ assert run.state["repositories"] == repositories+def test_returns_none_and_soft_deletes_draft_when_capped(self):with patch(f"{WARM_SRC}.warm", side_effect=Throttled()):result = self._warm()@@ -288,10 +333,22 @@ class TestCreateTaskWarmReuse(APIBaseTest):def setUp(self) -> None:super().setUp()- self.integration = Integration.objects.create(team=self.team, kind="github", config={})+ self.integration = Integration.objects.create(+ team=self.team,+ kind="github",+ config={},+ repository_cache=[{"id": 1, "name": "posthog", "full_name": "posthog/posthog"}],+ repository_cache_updated_at=django_timezone.now(),+ )def _warm_run(- self, *, repository="posthog/posthog", branch="main", created_by=None, extra_state: dict[str, Any] | None = None+ self,+ *,+ repository="posthog/posthog",+ repositories: list[str] | None = None,+ branch="main",+ created_by=None,+ extra_state: dict[str, Any] | None = None,) -> tuple[Task, TaskRun]:task = Task.objects.create(team=self.team,@@ -300,6 +357,7 @@ class TestCreateTaskWarmReuse(APIBaseTest):origin_product=Task.OriginProduct.USER_CREATED,created_by=created_by or self.user,repository=repository,+ repositories=repositories or ([repository] if repository else []),github_integration=self.integration if repository else None,)run = task.create_run(@@ -310,7 +368,12 @@ class TestCreateTaskWarmReuse(APIBaseTest):return task, rundef _create(self, **data):- validated = {"description": "fix the bug", "repository": "posthog/posthog", "branch": "main"}+ validated = {+ "description": "fix the bug",+ "repository": "posthog/posthog",+ "github_integration": self.integration,+ "branch": "main",+ }validated.update(data)return facade.create_task(self.team.id, self.user.id, validated_data=validated)@@ -333,10 +396,29 @@ class TestCreateTaskWarmReuse(APIBaseTest):# must be persisted for the warm run to honor the setting.assert run.state.get("auto_publish") is True+ def test_reuses_matching_multi_repository_warm_task(self):+ repositories = ["posthog/posthog", "posthog/posthog-js"]+ warm_task, run = self._warm_run(repositories=repositories)++ with patch(f"{FACADE}.signal_task_run_user_message", return_value=True):+ dto = self._create(repositories=repositories, github_integration=self.integration)++ assert str(dto.id) == str(warm_task.id)+ run.refresh_from_db()+ assert "await_user_message" not in run.state++ def test_does_not_reuse_warm_task_from_a_different_github_integration(self):+ warm_task, _ = self._warm_run()+ other_integration = Integration.objects.create(team=self.team, kind="github", config={})++ dto = self._create(github_integration=other_integration)++ assert str(dto.id) != str(warm_task.id)+def test_reuses_matching_repo_less_warm_task(self):warm_task, run = self._warm_run(repository=None, branch=None)with patch(f"{FACADE}.signal_task_run_user_message", return_value=True):- dto = self._create(repository=None, branch=None)+ dto = self._create(repository=None, github_integration=None, branch=None)assert str(dto.id) == str(warm_task.id)run.refresh_from_db()@@ -502,6 +584,7 @@ class TestCreateTaskWarmReuse(APIBaseTest):{"description": "/millie readme this skill","repository": "posthog/posthog",+ "github_integration": self.integration.id,"branch": "main","pending_user_message": "resolved skill message","pending_user_artifact_ids": ["artifact-1"],diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.tsindex a7831e164c04..933edc52cbe7 100644--- a/products/tasks/frontend/generated/api.schemas.ts+++ b/products/tasks/frontend/generated/api.schemas.ts@@ -3970,6 +3970,12 @@ export interface WarmTaskRequestApi {* @nullable*/repository?: string | null+ /**+ * GitHub repositories to clone into the warm sandbox, each in `organization/repo` format.+ * @maxItems 3+ * @items.maxLength 255+ */+ repositories?: string[]/*** Primary key of the team's GitHub integration to clone with when a repository is selected.* @nullablediff --git a/products/tasks/frontend/generated/api.zod.ts b/products/tasks/frontend/generated/api.zod.tsindex 5c57762cdbc1..51fb81536a23 100644--- a/products/tasks/frontend/generated/api.zod.ts+++ b/products/tasks/frontend/generated/api.zod.ts@@ -3063,6 +3063,10 @@ export const TasksSummariesCreateBody = /* @__PURE__ */ zod.object({*/export const tasksWarmCreateBodyRepositoryMax = 255+export const tasksWarmCreateBodyRepositoriesItemMax = 255++export const tasksWarmCreateBodyRepositoriesMax = 3+export const tasksWarmCreateBodyBranchMax = 255export const TasksWarmCreateBody = /* @__PURE__ */ zod@@ -3072,6 +3076,11 @@ export const TasksWarmCreateBody = /* @__PURE__ */ zod.max(tasksWarmCreateBodyRepositoryMax).nullish().describe('Optional GitHub repository to clone, in `organization\/repo` format (e.g. `posthog\/posthog`).'),+ repositories: zod+ .array(zod.string().max(tasksWarmCreateBodyRepositoriesItemMax))+ .max(tasksWarmCreateBodyRepositoriesMax)+ .optional()+ .describe('GitHub repositories to clone into the warm sandbox, each in `organization\/repo` format.'),github_integration: zod.number().nullish()diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 897eb96fd7e0..93db00050ea6 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -76462,6 +76462,12 @@ export namespace Schemas {* @nullable*/repository?: string | null;+ /**+ * GitHub repositories to clone into the warm sandbox, each in `organization/repo` format.+ * @maxItems 3+ * @items.maxLength 255+ */+ repositories?: string[];/*** Primary key of the team's GitHub integration to clone with when a repository is selected.* @nullable