Skip to content

: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.

fix(wizard): show recent runs of every status in sync fab (#107784)

Fernando Gomes98d4ca6f0636
diff --git a/docs/internal/wizard-runs.md b/docs/internal/wizard-runs.md
index 5d8571369250..7351cb5f9872 100644
--- a/docs/internal/wizard-runs.md
+++ b/docs/internal/wizard-runs.md
@@ -63,12 +63,13 @@ GET /api/projects/{project_id}/wizard/runs/{run_id}/stream/
Run responses include the creator ID and basic creator details for attribution in project-level run lists.
Use `GET /api/projects/{project_id}/wizard/runs/?status=created,running&limit=5` to fetch the newest active runs; `count` gives the total number of active runs in the project. The `status` filter also accepts any individual run status.
-The app-wide sync widget polls this summary and also fetches the five most recently created completed runs with `?status=completed&limit=5`.
-It opens one event stream for the displayed active run. Completed runs do not open a stream.
-It shows the newest active run by default, or the newest completed run when none are active.
-The selector lists up to five active and five completed runs by workspace and status, with the selected run marked and the total active count shown separately.
+The optional `created_after` filter limits results and `count` to runs created after an ISO 8601 timestamp.
+The app-wide sync widget uses a fixed launch cutoff with this filter for active runs and the five newest runs of any status. It shows runs from anyone in the current project, not only runs created by the viewer.
+It opens one event stream for the displayed active run. Terminal runs do not open a stream.
+It shows the newest active run by default, or the newest recent run when none are active.
+The selector lists up to five active and five recent runs by workspace and status, with the selected run marked and the total active count shown separately.
The Wizard page lists any others. A manual selection stays in place while that run remains in either list, including when it completes.
-Its card shows the current task, run stages, elapsed time, environment, and workspace. "Close" hides the current run until the page reloads, while "Don't show this run again" hides that run in this browser. New runs still show the widget, and run details remain on the Wizard page. Recent completed runs remain available after reloading unless dismissed.
+Its card shows the current task, run stages, elapsed time, environment, and workspace. "Close" hides the current run until the page reloads, while "Don't show this run again" hides that run in this browser. New runs still show the widget, and run details remain on the Wizard page. Recent terminal runs remain available after reloading unless dismissed.
The `wizard-run-sync` feature flag uses the `wizard-session` and `wizard-run` variants to select the sync widget in the authenticated shell.
The PATCH request accepts a terminal `status`: `completed`, `failed`, or `cancelled`.
diff --git a/posthog/clickhouse/test/test_schema.py b/posthog/clickhouse/test/test_schema.py
index 6850d0a6e2cd..1246f4d3f942 100644
--- a/posthog/clickhouse/test/test_schema.py
+++ b/posthog/clickhouse/test/test_schema.py
@@ -7,6 +7,7 @@ from pathlib import Path
import pytest
from django.conf import settings as django_settings
+from django.test import override_settings
from posthog.hogql.database.models import DatabaseField, Table
from posthog.hogql.database.schema.flag_evaluations import FLAG_EVALUATIONS_CLICKHOUSE_TABLE, FlagEvaluationsTable
@@ -34,6 +35,7 @@ from posthog.models.flag_evaluations.sql import (
FLAG_EVALUATIONS_TABLE,
FLAG_EVALUATIONS_TABLE_SQL,
)
+from posthog.models.ingestion_warnings.sql_v2 import INGESTION_WARNINGS_V2_DATA_TABLE_SQL
from posthog.settings.data_stores import SUFFIX
from posthog.settings.kafka import KAFKA_PREFIX
@@ -55,6 +57,13 @@ def test_create_table_query_replicated_and_storage(query, snapshot, settings):
assert build_query(query) == snapshot
+def test_ingestion_warnings_v2_keeps_ttl_outside_tests() -> None:
+ with override_settings(TEST=False):
+ query = INGESTION_WARNINGS_V2_DATA_TABLE_SQL()
+
+ assert "\nTTL " in query
+
+
@pytest.mark.parametrize("query", CREATE_KAFKA_TABLE_QUERIES, ids=get_table_name)
def test_create_kafka_table_with_different_kafka_host(query, snapshot):
# Historical name; the override that used to drive `KAFKA_HOSTS_FOR_CLICKHOUSE`
diff --git a/products/wizard/backend/facade/contracts.py b/products/wizard/backend/facade/contracts.py
index 6b38ebcafb11..00c6e6ed0977 100644
--- a/products/wizard/backend/facade/contracts.py
+++ b/products/wizard/backend/facade/contracts.py
@@ -222,6 +222,7 @@ class ListWizardRunsInput:
offset: int
limit: int
statuses: tuple[WizardRunStatus, ...] = ()
+ created_after: datetime | None = None
@frozen
diff --git a/products/wizard/backend/logic/runs/store.py b/products/wizard/backend/logic/runs/store.py
index 7eaec933c108..bd5a9b73a29d 100644
--- a/products/wizard/backend/logic/runs/store.py
+++ b/products/wizard/backend/logic/runs/store.py
@@ -181,6 +181,8 @@ def list_runs(params: ListWizardRunsInput) -> WizardRunPage:
runs = WizardRun.objects.for_team(params.team_id).select_related("created_by").order_by("-created_at")
if params.statuses:
runs = runs.filter(status__in=params.statuses)
+ if params.created_after is not None:
+ runs = runs.filter(created_at__gt=params.created_after)
page = runs[params.offset : params.offset + params.limit]
results: list[WizardRunDTO] = []
for run in page:
diff --git a/products/wizard/backend/presentation/runs/pagination.py b/products/wizard/backend/presentation/runs/pagination.py
index ed0a95ff0e64..c5807af0cd64 100644
--- a/products/wizard/backend/presentation/runs/pagination.py
+++ b/products/wizard/backend/presentation/runs/pagination.py
@@ -1,3 +1,7 @@
+from datetime import datetime
+from typing import cast
+
+from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.request import Request
@@ -24,12 +28,19 @@ class WizardRunPagination(LimitOffsetPagination):
)
except ValueError as error:
raise ValidationError({"status": "Invalid run status."}) from error
+ raw_created_after = request.query_params.get("created_after")
+ created_after = (
+ cast(datetime, serializers.DateTimeField().run_validation(raw_created_after))
+ if raw_created_after is not None
+ else None
+ )
page = wizard_facade.list_runs(
ListWizardRunsInput(
team_id=team_id,
offset=offset,
limit=limit,
statuses=statuses,
+ created_after=created_after,
)
)
self.request = request
diff --git a/products/wizard/backend/presentation/runs/views.py b/products/wizard/backend/presentation/runs/views.py
index adce55038cc3..ffc4537ebd72 100644
--- a/products/wizard/backend/presentation/runs/views.py
+++ b/products/wizard/backend/presentation/runs/views.py
@@ -1,3 +1,4 @@
+from datetime import datetime
from typing import cast
from uuid import UUID
@@ -78,7 +79,12 @@ class WizardRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
style="form",
explode=False,
description="Filter by one or more comma-separated run statuses.",
- )
+ ),
+ OpenApiParameter(
+ name="created_after",
+ type=datetime,
+ description="Only return runs created after this timestamp.",
+ ),
],
description="List Wizard runs for this project, ordered from newest to oldest.",
)
diff --git a/products/wizard/backend/tests/runs/test_presentation.py b/products/wizard/backend/tests/runs/test_presentation.py
index c64c11400873..e3a1398d6849 100644
--- a/products/wizard/backend/tests/runs/test_presentation.py
+++ b/products/wizard/backend/tests/runs/test_presentation.py
@@ -1,3 +1,4 @@
+from datetime import timedelta
from hashlib import sha256
from uuid import UUID
@@ -7,6 +8,7 @@ from unittest.mock import patch
from django.conf import settings
from django.core.cache import cache
from django.test import override_settings
+from django.utils import timezone
from parameterized import parameterized
from rest_framework import status
@@ -167,6 +169,18 @@ class TestWizardRunViewSet(APIBaseTest):
invalid_response = self.client.get(f"{self._url()}?status=unknown")
self.assertEqual(invalid_response.status_code, status.HTTP_400_BAD_REQUEST)
+ WizardRun.objects.for_team(self.team.id).filter(id=run_ids[0]).update(
+ created_at=timezone.now() - timedelta(days=1)
+ )
+ created_after = (timezone.now() - timedelta(hours=1)).isoformat().replace("+00:00", "Z")
+ recent_response = self.client.get(f"{self._url()}?status=created,running&created_after={created_after}")
+ self.assertEqual(recent_response.status_code, status.HTTP_200_OK)
+ self.assertEqual(recent_response.json()["count"], 1)
+ self.assertEqual([run["id"] for run in recent_response.json()["results"]], [run_ids[2]])
+
+ invalid_date_response = self.client.get(f"{self._url()}?created_after=invalid")
+ self.assertEqual(invalid_date_response.status_code, status.HTTP_400_BAD_REQUEST)
+
def test_create_requires_program_id(self) -> None:
response = self.client.post(
self._url(),
diff --git a/products/wizard/frontend/generated/api.schemas.ts b/products/wizard/frontend/generated/api.schemas.ts
index 323c7298b8da..d9e836327d25 100644
--- a/products/wizard/frontend/generated/api.schemas.ts
+++ b/products/wizard/frontend/generated/api.schemas.ts
@@ -653,6 +653,10 @@ export type WizardRegistryListParams = {
}
export type WizardRunsListParams = {
+ /**
+ * Only return runs created after this timestamp.
+ */
+ created_after?: string
/**
* Number of results to return per page.
*/
diff --git a/products/wizard/frontend/runs/wizardRunSyncLogic.test.ts b/products/wizard/frontend/runs/wizardRunSyncLogic.test.ts
index bb7611111e43..561489801512 100644
--- a/products/wizard/frontend/runs/wizardRunSyncLogic.test.ts
+++ b/products/wizard/frontend/runs/wizardRunSyncLogic.test.ts
@@ -17,14 +17,9 @@ jest.mock('../generated/api', () => ({
const mockWizardRunsList = wizardRunsList as jest.Mock
-function mockRunPages(
- activePage: { count: number; results: WizardRunApi[] },
- completedRuns: WizardRunApi[] = []
-): void {
+function mockRunPages(activePage: { count: number; results: WizardRunApi[] }, recentRuns: WizardRunApi[] = []): void {
mockWizardRunsList.mockImplementation((_projectId, { status }) =>
- Promise.resolve(
- status.includes('completed') ? { count: completedRuns.length, results: completedRuns } : activePage
- )
+ Promise.resolve(status ? activePage : { count: recentRuns.length, results: recentRuns })
)
}
@@ -56,7 +51,15 @@ describe('wizardRunSyncLogic', () => {
it('streams only the newest active run and switches when it changes', async () => {
await expectLogic(logic).toFinishAllListeners()
- expect(mockWizardRunsList).toHaveBeenCalledWith('1', { status: ['created', 'running'], limit: 5 })
+ expect(mockWizardRunsList).toHaveBeenCalledWith('1', {
+ status: ['created', 'running'],
+ created_after: '2026-09-28T00:00:00Z',
+ limit: 5,
+ })
+ expect(mockWizardRunsList).toHaveBeenCalledWith('1', {
+ created_after: '2026-09-28T00:00:00Z',
+ limit: 5,
+ })
expect(logic.values.activeCount).toBe(2)
expect(logic.values.run?.id).toBe('newer')
expect(MockEventSource.instances).toHaveLength(1)
@@ -115,42 +118,54 @@ describe('wizardRunSyncLogic', () => {
expect(MockEventSource.instances).toHaveLength(3)
})
- it('loads completed runs after reloading, keeps them selectable, and respects dismissal', async () => {
- await expectLogic(logic).toFinishAllListeners()
- const stream = MockEventSource.last()
- const completed = { ...run('newer'), status: 'completed' as const, stage: null }
- mockRunPages({ count: 0, results: [] }, [completed])
-
- stream.emitMessage(JSON.stringify({ status: 'completed', stage: null, tasks: [] }))
- await expectLogic(logic).toFinishAllListeners()
- expect(logic.values.run?.status).toBe('completed')
- expect(stream.readyState).toBe(MockEventSource.CLOSED)
-
- logic.unmount()
- logic = wizardRunSyncLogic({ projectId: '1' })
- logic.mount()
- await expectLogic(logic).toFinishAllListeners()
- expect(mockWizardRunsList).toHaveBeenCalledWith('1', { status: ['completed'], limit: 5 })
- expect(logic.values.run).toEqual(completed)
- expect(MockEventSource.instances).toHaveLength(1)
+ it.each(['completed', 'failed', 'cancelled'] as const)(
+ 'loads %s runs after reloading, keeps them selectable, and respects dismissal',
+ async (status) => {
+ await expectLogic(logic).toFinishAllListeners()
+ const stream = MockEventSource.last()
+ const terminal = { ...run('newer'), status, stage: null }
+ mockRunPages({ count: 0, results: [] }, [terminal])
+
+ stream.emitMessage(JSON.stringify({ status, stage: null, tasks: [] }))
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.run?.status).toBe(status)
+ expect(stream.readyState).toBe(MockEventSource.CLOSED)
+
+ logic.unmount()
+ logic = wizardRunSyncLogic({ projectId: '1' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(mockWizardRunsList).toHaveBeenCalledWith('1', {
+ created_after: '2026-09-28T00:00:00Z',
+ limit: 5,
+ })
+ expect(logic.values.run).toEqual(terminal)
+ expect(MockEventSource.instances).toHaveLength(1)
+
+ mockRunPages({ count: 1, results: [run('next')] }, [terminal])
+ logic.actions.checkRuns()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.run?.id).toBe('next')
+ logic.actions.selectRun(terminal)
+ expect(MockEventSource.last().readyState).toBe(MockEventSource.CLOSED)
+ expect(MockEventSource.instances).toHaveLength(2)
+
+ logic.actions.dismissRun('newer')
+ expect(logic.values.run?.id).toBe('next')
+ logic.actions.checkRuns()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.visibleRuns.map((run) => run.id)).toEqual(['next'])
+ }
+ )
- mockRunPages({ count: 1, results: [run('next')] }, [completed])
- logic.actions.checkRuns()
+ it('handles a run completing between the active and completed responses', async () => {
await expectLogic(logic).toFinishAllListeners()
- expect(logic.values.run?.id).toBe('next')
- logic.actions.selectRun(completed)
- expect(MockEventSource.last().readyState).toBe(MockEventSource.CLOSED)
- expect(MockEventSource.instances).toHaveLength(2)
-
- logic.actions.dismissRun('newer')
- expect(logic.values.run?.id).toBe('next')
+ mockRunPages({ count: 1, results: [run('newer')] }, [run('newer')])
logic.actions.checkRuns()
await expectLogic(logic).toFinishAllListeners()
- expect(logic.values.visibleRuns.map((run) => run.id)).toEqual(['next'])
- })
+ expect(logic.values.visibleRuns.map((run) => run.id)).toEqual(['newer'])
+ expect(logic.values.activeCount).toBe(1)
- it('handles a run completing between the active and completed responses', async () => {
- await expectLogic(logic).toFinishAllListeners()
const completed = { ...run('newer'), status: 'completed' as const, stage: null }
mockRunPages({ count: 1, results: [run('newer')] }, [completed])
logic.actions.checkRuns()
diff --git a/products/wizard/frontend/runs/wizardRunSyncLogic.ts b/products/wizard/frontend/runs/wizardRunSyncLogic.ts
index 2e60a9312e8a..46740f44dbfb 100644
--- a/products/wizard/frontend/runs/wizardRunSyncLogic.ts
+++ b/products/wizard/frontend/runs/wizardRunSyncLogic.ts
@@ -6,7 +6,12 @@ import type { WizardRunApi, WizardRunTaskApi, WizardRunTaskListApi } from '../ge
import { wizardRunIsActive } from '../wizardRunDisplay'
const RUN_POLL_MS = 30_000
-// ponytail: show five active and five completed runs; the Wizard page lists the rest.
+
+// Cutoff for wizard runs to be shown in the FAB.
+// This prevents users who already ran the wizard to get a FAB
+// for older runs.
+const RUN_VISIBLE_AFTER = '2026-09-28T00:00:00Z'
+
const RUN_LIST_LIMIT = 5
type RunStreamState = Pick<
@@ -121,19 +126,23 @@ export const wizardRunSyncLogic = kea<wizardRunSyncLogicType>([
}
cache.checking = true
try {
- const [activePage, completedPage] = await Promise.all([
+ const [activePage, recentPage] = await Promise.all([
wizardRunsList(logicProps.projectId, {
status: ['created', 'running'],
+ created_after: RUN_VISIBLE_AFTER,
+ limit: RUN_LIST_LIMIT,
+ }),
+ wizardRunsList(logicProps.projectId, {
+ created_after: RUN_VISIBLE_AFTER,
limit: RUN_LIST_LIMIT,
}),
- wizardRunsList(logicProps.projectId, { status: ['completed'], limit: RUN_LIST_LIMIT }),
])
- const activeRuns = activePage.results.filter(
- (run) => !completedPage.results.some((completedRun) => completedRun.id === run.id)
- )
+ const activeRuns = activePage.results
+ .map((run) => recentPage.results.find((recentRun) => recentRun.id === run.id) ?? run)
+ .filter(wizardRunIsActive)
actions.runsLoaded(activePage.count - (activePage.results.length - activeRuns.length), [
...activeRuns,
- ...completedPage.results,
+ ...recentPage.results.filter((run) => !activeRuns.some((activeRun) => activeRun.id === run.id)),
])
} catch {
return
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 618bb0929220..841df46a1197 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -124270,6 +124270,10 @@ export namespace Schemas {
};
export type WizardRunsListParams = {
+ /**
+ * Only return runs created after this timestamp.
+ */
+ created_after?: string;
/**
* Number of results to return per page.
*/