: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(stamphog): add runs and digests scenes (#84025)
Julian Bez417fe3e812a1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex aae45054107a..32cdab80c71a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7692,6 +7692,22 @@ snapshots:hash: v1.k794b7964.ffb964f61f0771bb4560c6d754a9673747b0ea5d6643ba741cd4b13f01ab7c95.SDwAPYQ0JyZMmgBTHh56d434aKNWdNiNCJN51UaDg8Uscenes-app-sidepanels--side-panel-support--light:hash: v1.k794b7964.50d7924caa4bfab7d0099308586ffe1b92c0a609d460345c2827d9c14e7ad268.DqqxgOWoF4kRn33GTYxmO6LBVZQthTmzG5Og91gGv-4+ scenes-app-stamphog-digests--digests-list--dark:+ hash: v1.k794b7964.52ab3cbc8628710e9bccc9efde6669e7dcb58b4c367ab48f831409c5c61e61cd.C0cs0B5vmeiwKujqYeAnF_FdzE69c6F2ozZejzzpOQg+ scenes-app-stamphog-digests--digests-list--light:+ hash: v1.k794b7964.18ad6824f862d6dd319341a17d6f4d41f55d7494ae9de1d4144aaa66e794a485.lfct5L30yYd4UQGkcm8iR2I-AXbLDuNBCPeEbgsYlLQ+ scenes-app-stamphog-digests--digests-list-empty--dark:+ hash: v1.k794b7964.fd5e3fa0b7a122ea7ebbe15d768c37f3d7ee3034a93cb963693a54cc2a415b90.o_ITUUHriRKnmh9HwQBd4jbEbWe0bRkpkssGmAVp8f8+ scenes-app-stamphog-digests--digests-list-empty--light:+ hash: v1.k794b7964.263fbb5b5a3f273fceb1caf8df91f638c6583c498204c8c13379c7d1bbbfcbef.yfy_HmjihBxV9yHsx2q-DIBQAZOorDfP7F44Eq_lJCw+ scenes-app-stamphog-runs--runs-list--dark:+ hash: v1.k794b7964.0f6fb2d21628b8c0f8781d21610ca6fd605216cb07cfeae30f9fc6189ca72d2b.GzyJek2YNFSPSBQoznkgE_FcldLmSLCiVa0gCaHUIxI+ scenes-app-stamphog-runs--runs-list--light:+ hash: v1.k794b7964.0a5f37c1c888fd4231e2c635103aa6d159c160d40be2cb809dbfad07d0fc7c00.ySBwJI-qfeOUCyydO_cnLKGMLLFbK_kSEfkBN6OKKY0+ scenes-app-stamphog-runs--runs-list-empty--dark:+ hash: v1.k794b7964.97190abf6b2cb1c02e955555559874e975140d4479843089f1a9535e6100a194.t9t3ni1Sd9qf56MyNquC5SbflzhcT9m5d3GyZhBkUZo+ scenes-app-stamphog-runs--runs-list-empty--light:+ hash: v1.k794b7964.e3f2449aaf242198553ecade4b10006f816108242c273060fa456e9504ee3fcf.vsiDO5c59UASwyXQZZtwifVbT-qaaUdTa-TxoKNSpmEscenes-app-support-threadreportentry--fix-merged--dark:hash: v1.k794b7964.e0c8db4f933b58c3af999c559176838e77f9e8b9d5b0566ec8ed08771f62cb30.FTz_l6gFhX_pFY7GyxECQ7-z2PTBJd6bvTO9emHIdM8scenes-app-support-threadreportentry--fix-merged--light:diff --git a/frontend/src/productScenes.tsx b/frontend/src/productScenes.tsxindex 168ff932c04b..362fbe84d8a4 100644--- a/frontend/src/productScenes.tsx+++ b/frontend/src/productScenes.tsx@@ -133,6 +133,8 @@ export const productScenes: Record<string, () => Promise<any>> = {Skill: () => import('../../products/skills/frontend/LLMSkillScene'),CommunitySkills: () => import('../../products/skills/frontend/CommunitySkillsScene'),Stamphog: () => import('../../products/stamphog/frontend/scenes/StamphogScene/StamphogScene'),+ StamphogRuns: () => import('../../products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene'),+ StamphogDigests: () => import('../../products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene'),StreamlitApps: () => import('../../products/streamlit_apps/frontend/StreamlitApps'),StreamlitApp: () => import('../../products/streamlit_apps/frontend/StreamlitApp'),StreamlitAppEdit: () => import('../../products/streamlit_apps/frontend/StreamlitAppEdit'),diff --git a/frontend/src/products.tsx b/frontend/src/products.tsxindex 3d04ba138eaa..05e0d85a8ec9 100644--- a/frontend/src/products.tsx+++ b/frontend/src/products.tsx@@ -228,6 +228,8 @@ export const productRoutes: Record<string, [string, string]> = {'/community-skills': ['CommunitySkills', 'communitySkills'],'/skills/:name': ['Skill', 'skill'],'/stamphog': ['Stamphog', 'stamphog'],+ '/stamphog/runs': ['StamphogRuns', 'stamphogRuns'],+ '/stamphog/digests': ['StamphogDigests', 'stamphogDigests'],'/stamphog/install/callback': ['Stamphog', 'stamphogCallback'],'/streamlit-apps': ['StreamlitApps', 'streamlitApps'],'/streamlit-apps/new': ['StreamlitAppEdit', 'streamlitAppNew'],@@ -872,6 +874,8 @@ export const productConfiguration: Record<string, any> = {iconType: 'llm_prompts',},Stamphog: { projectBased: true, name: 'Stamphog', iconType: 'stamphog' },+ StamphogRuns: { projectBased: true, name: 'Stamphog runs', iconType: 'stamphog' },+ StamphogDigests: { projectBased: true, name: 'Stamphog digests', iconType: 'stamphog' },StreamlitApps: { name: 'Streamlit apps', projectBased: true },StreamlitApp: { name: 'Streamlit app', projectBased: true },StreamlitAppEdit: { name: 'Edit Streamlit app', projectBased: true },@@ -1429,6 +1433,8 @@ export const productUrls = {): string => combineUrl(`/skills/${name}`, params).url,communitySkills: (): string => '/community-skills',stamphog: (): string => '/stamphog',+ stamphogRuns: (): string => '/stamphog/runs',+ stamphogDigests: (): string => '/stamphog/digests',stamphogCallback: (): string => '/stamphog/install/callback',streamlitApps: (): string => '/streamlit-apps',streamlitApp: (id: string): string => `/streamlit-apps/${id}`,diff --git a/products/stamphog/backend/facade/api.py b/products/stamphog/backend/facade/api.pyindex 73cc31345609..a4f225d0b6b4 100644--- a/products/stamphog/backend/facade/api.py+++ b/products/stamphog/backend/facade/api.py@@ -13,14 +13,22 @@ from typing import Any, TypeVar, overloadfrom uuid import UUIDfrom django.db import IntegrityError-from django.db.models import QuerySet+from django.db.models import Q, QuerySetfrom django.utils import timezoneimport structlogfrom ..models import DigestChannel, DigestRun, PullRequest, ReviewRun, StamphogRepoConfigfrom . import contracts-from .enums import TERMINAL_STATUSES, ChannelResolutionSource, DigestRunStatus, ReviewRunStatus, ReviewVerdict+from .enums import (+ TERMINAL_STATUSES,+ ChannelResolutionSource,+ DigestRunStatus,+ ReviewMode,+ ReviewRunStatus,+ ReviewTrigger,+ ReviewVerdict,+)logger = structlog.get_logger(__name__)@@ -129,6 +137,45 @@ def _digest_run_to_dto(obj: DigestRun) -> contracts.DigestRunDTO:)+# A run dispatched from the inbox records its provenance on `output`. Both writers in tasks.py+# either omit the key or write a populated dict, so testing for the key and testing for truthiness+# agree — which is what lets the filter below stay in step with the derivation above it.+_SELF_DRIVING = Q(output__has_key="inbox_review")++# Preserves the caller's queryset type, so a team-scoped queryset stays team-scoped through the filter.+_RunQS = TypeVar("_RunQS", bound=QuerySet)+++def _derive_trigger(obj: ReviewRun) -> ReviewTrigger:+ """Why stamphog looked at this PR: inbox provenance first, then the repo's review mode.++ Inbox provenance outranks the repo mode: a self-driving run is dispatched from the inbox+ whether or not the repo also reviews every PR event.+ """+ if (obj.output or {}).get("inbox_review"):+ return ReviewTrigger.SELF_DRIVING+ if obj.pull_request.repo_config.review_mode == ReviewMode.LABEL:+ return ReviewTrigger.LABEL+ return ReviewTrigger.ALL+++def _filter_by_trigger(qs: _RunQS, trigger: str) -> _RunQS:+ """Narrow to one trigger, mirroring _derive_trigger in SQL.++ The trigger is not a column, so the precedence has to be spelled out twice. Keep the two in+ step: a run that reads as self-driving in the list must be reachable by that filter, or the+ filter quietly hides rows the caller just saw. An unrecognized value narrows to nothing rather+ than falling through to the unfiltered list.+ """+ if trigger == ReviewTrigger.SELF_DRIVING:+ return qs.filter(_SELF_DRIVING)+ if trigger == ReviewTrigger.LABEL:+ return qs.exclude(_SELF_DRIVING).filter(pull_request__repo_config__review_mode=ReviewMode.LABEL)+ if trigger == ReviewTrigger.ALL:+ return qs.exclude(_SELF_DRIVING).filter(pull_request__repo_config__review_mode=ReviewMode.ALL)+ return qs.none()++def _review_run_to_dto(obj: ReviewRun) -> contracts.ReviewRunDTO:return contracts.ReviewRunDTO(id=obj.id,@@ -141,10 +188,16 @@ def _review_run_to_dto(obj: ReviewRun) -> contracts.ReviewRunDTO:head_sha=obj.head_sha,status=ReviewRunStatus(obj.status),verdict=ReviewVerdict(obj.verdict),+ trigger=_derive_trigger(obj),+ title=obj.pull_request.title,+ author_login=obj.pull_request.author_login,delivery_id=obj.delivery_id,gate_result=obj.gate_result,output=obj.output,error=obj.error,+ posted_review_id=obj.posted_review_id,+ verdict_posted_at=obj.verdict_posted_at,+ approval_dismissed_at=obj.approval_dismissed_at,created_at=obj.created_at,updated_at=obj.updated_at,completed_at=obj.completed_at,@@ -311,6 +364,7 @@ def list_review_runs(repository: str | None = None,pr_number: int | None = None,status: str | None = None,+ trigger: str | None = None,) -> LazyDTOList[contracts.ReviewRunDTO]:qs = ReviewRun.objects.for_team(team_id).select_related("pull_request__repo_config").order_by("-created_at")if repository:@@ -319,6 +373,8 @@ def list_review_runs(qs = qs.filter(pull_request__pr_number=pr_number)if status:qs = qs.filter(status=status)+ if trigger:+ qs = _filter_by_trigger(qs, trigger)return LazyDTOList(qs, _review_run_to_dto)diff --git a/products/stamphog/backend/facade/contracts.py b/products/stamphog/backend/facade/contracts.pyindex f42216ca15e8..0533d44100fd 100644--- a/products/stamphog/backend/facade/contracts.py+++ b/products/stamphog/backend/facade/contracts.py@@ -16,7 +16,7 @@ from uuid import UUIDfrom pydantic import Fieldfrom pydantic.dataclasses import dataclass-from .enums import ChannelResolutionSource, DigestRunStatus, ReviewRunStatus, ReviewVerdict+from .enums import ChannelResolutionSource, DigestRunStatus, ReviewRunStatus, ReviewTrigger, ReviewVerdict@dataclass(frozen=True)@@ -108,10 +108,18 @@ class ReviewRunDTO:head_sha: strstatus: ReviewRunStatusverdict: ReviewVerdict+ # Why stamphog looked at this PR at all. Derived rather than stored — see the facade's+ # trigger helpers, which own both the derivation and the matching filter.+ trigger: ReviewTrigger+ title: str = ""+ author_login: str = ""delivery_id: str | None = Nonegate_result: dict | None = Noneoutput: dict = Field(default_factory=dict)error: str = ""+ posted_review_id: int | None = None+ verdict_posted_at: datetime | None = None+ approval_dismissed_at: datetime | None = Nonecreated_at: datetime | None = Noneupdated_at: datetime | None = Nonecompleted_at: datetime | None = Nonediff --git a/products/stamphog/backend/facade/enums.py b/products/stamphog/backend/facade/enums.pyindex 9f2fc71bde8e..74ef06a93814 100644--- a/products/stamphog/backend/facade/enums.py+++ b/products/stamphog/backend/facade/enums.py@@ -33,6 +33,22 @@ TERMINAL_STATUSES = frozenset()+class ReviewTrigger(StrEnum):+ """What caused a run to exist, derived from the run and its repo config.++ Not stored: a run records `inbox_review` provenance on its output and inherits the repo's+ review_mode, and this collapses the two into the one answer a reader wants — why did stamphog+ look at this PR at all.+ """++ # Self-driving: stamphog reviewed a bot-authored PR off its own inbox provenance.+ SELF_DRIVING = "self_driving"+ # The repo is in LABEL mode, so the trigger label opted this PR in.+ LABEL = "label"+ # The repo reviews every relevant PR event.+ ALL = "all"++class ReviewVerdict(StrEnum):NONE = "none"APPROVED = "approved"diff --git a/products/stamphog/backend/presentation/serializers.py b/products/stamphog/backend/presentation/serializers.pyindex c21df3c6a83f..57764a225f67 100644--- a/products/stamphog/backend/presentation/serializers.py+++ b/products/stamphog/backend/presentation/serializers.py@@ -15,7 +15,14 @@ from rest_framework_dataclasses.serializers import DataclassSerializerfrom posthog.models.integration import Integrationfrom ..facade import contracts-from ..facade.enums import ChannelResolutionSource, DigestRunStatus, ReviewMode, ReviewRunStatus, ReviewVerdict+from ..facade.enums import (+ ChannelResolutionSource,+ DigestRunStatus,+ ReviewMode,+ ReviewRunStatus,+ ReviewTrigger,+ ReviewVerdict,+)class _GateResultSummarySerializer(serializers.Serializer):@@ -323,10 +330,23 @@ class ReviewRunSerializer(DataclassSerializer):read_only=True,help_text="Full URL to the pull request on GitHub.",)+ title = serializers.CharField(+ read_only=True,+ help_text="Pull request title as of the last webhook delivery applied.",+ )+ author_login = serializers.CharField(+ read_only=True,+ help_text="GitHub login of the pull request author.",+ )head_branch = serializers.CharField(read_only=True,help_text="Branch name of the PR head.",)+ trigger = serializers.ChoiceField(+ choices=[(t.value, t.name) for t in ReviewTrigger],+ read_only=True,+ help_text="What caused this run to exist: self-driving inbox provenance, the repo's trigger label, or the repo reviewing every PR event.",+ )status = serializers.ChoiceField(choices=[(s.value, s.name) for s in ReviewRunStatus],read_only=True,@@ -347,6 +367,21 @@ class ReviewRunSerializer(DataclassSerializer):allow_null=True,help_text="When the review run reached a terminal state, if it has.",)+ posted_review_id = serializers.IntegerField(+ read_only=True,+ allow_null=True,+ help_text="ID of the GitHub review this run posted, null if it never posted one.",+ )+ verdict_posted_at = serializers.DateTimeField(+ read_only=True,+ allow_null=True,+ help_text="When this run's verdict reached GitHub, null if it never did.",+ )+ approval_dismissed_at = serializers.DateTimeField(+ read_only=True,+ allow_null=True,+ help_text="When this run's GitHub approval was retracted because the head moved, null if it wasn't.",+ )gate_result = serializers.SerializerMethodField(help_text=("Allowlisted deterministic gate outcome (gate_blocked, final_verdict). The nested gate, "@@ -394,14 +429,20 @@ class ReviewRunSerializer(DataclassSerializer):"repository","pr_number","pr_url",+ "title",+ "author_login","head_sha","head_branch","delivery_id",+ "trigger","status","verdict","gate_result","output","error",+ "posted_review_id",+ "verdict_posted_at",+ "approval_dismissed_at","created_at","updated_at","completed_at",diff --git a/products/stamphog/backend/presentation/views.py b/products/stamphog/backend/presentation/views.pyindex 48f15c2a6118..233e87b4e595 100644--- a/products/stamphog/backend/presentation/views.py+++ b/products/stamphog/backend/presentation/views.py@@ -32,6 +32,7 @@ from products.stamphog.backend.facade import (api as facade_api,contracts,)+from products.stamphog.backend.facade.enums import ReviewTriggerfrom ..facade.github import (StamphogGitHubError,@@ -383,6 +384,7 @@ class ReviewRunViewSet(_StamphogTeamScopedViewSet, viewsets.GenericViewSet):repository=self.request.query_params.get("repository"),pr_number=pr_number_value,status=self.request.query_params.get("status"),+ trigger=self.request.query_params.get("trigger"),)def retrieve(self, request: Request, pk: str | None = None, **kwargs) -> Response:@@ -414,6 +416,14 @@ class ReviewRunViewSet(_StamphogTeamScopedViewSet, viewsets.GenericViewSet):required=False,description="Filter by review run status.",),+ OpenApiParameter(+ "trigger",+ OpenApiTypes.STR,+ OpenApiParameter.QUERY,+ required=False,+ enum=[t.value for t in ReviewTrigger],+ description="Filter by what caused the run: self_driving, label, or all.",+ ),],responses={200: ReviewRunSerializer(many=True)},)diff --git a/products/stamphog/backend/tests/test_api.py b/products/stamphog/backend/tests/test_api.pyindex 83d8bec8fb5a..ba9a29239ef7 100644--- a/products/stamphog/backend/tests/test_api.py+++ b/products/stamphog/backend/tests/test_api.py@@ -13,7 +13,7 @@ from posthog.models.team import Teamfrom posthog.models.utils import generate_random_token_personal, uuid7from products.stamphog.backend.facade import contracts-from products.stamphog.backend.facade.enums import ReviewRunStatus+from products.stamphog.backend.facade.enums import ReviewMode, ReviewRunStatusfrom products.stamphog.backend.models import DigestChannel, PullRequest, ReviewRun, StamphogRepoConfigfrom products.stamphog.backend.presentation.serializers import StamphogRepoConfigWriteSerializerfrom products.stamphog.backend.presentation.views import _INSTALL_STATE_SALT@@ -237,7 +237,15 @@ class TestReviewRunAPI(StamphogTeamScopedTestMixin, APIBaseTest):team_id=self.team.id, repository="PostHog/posthog", installation_id="1")- def _make_run(self, *, team=None, repo_config=None, pr_number: int = 1, status_value: str = "queued") -> ReviewRun:+ def _make_run(+ self,+ *,+ team=None,+ repo_config=None,+ pr_number: int = 1,+ status_value: str = "queued",+ output: dict | None = None,+ ) -> ReviewRun:team = team or self.teamrepo_config = repo_config or self.repo_configpull_request, _ = PullRequest.objects.unscoped().update_or_create(@@ -251,6 +259,7 @@ class TestReviewRunAPI(StamphogTeamScopedTestMixin, APIBaseTest):pull_request=pull_request,head_sha="abc123",status=status_value,+ output=output or {},)def test_list_only_returns_own_team_runs(self) -> None:@@ -292,6 +301,42 @@ class TestReviewRunAPI(StamphogTeamScopedTestMixin, APIBaseTest):ids = [row["id"] for row in response.json()["results"]]assert ids == [str(queued_run.id)]+ @parameterized.expand(+ [+ # Inbox provenance outranks the repo mode: a self-driving run is dispatched from the inbox+ # whether or not the repo also reviews every PR event.+ ("self_driving_beats_all_mode", ReviewMode.ALL, {"inbox_review": {"trigger": "inbox"}}, "self_driving"),+ ("self_driving_beats_label_mode", ReviewMode.LABEL, {"inbox_review": {"trigger": "inbox"}}, "self_driving"),+ ("label_mode", ReviewMode.LABEL, {}, "label"),+ ("all_mode", ReviewMode.ALL, {}, "all"),+ ]+ )+ def test_trigger_is_derived_and_filterable(+ self, _name: str, review_mode: ReviewMode, output: dict, expected: str+ ) -> None:+ # The facade derives `trigger` in Python and filters on it in SQL through two separate code+ # paths. They must agree: a run that reads as self-driving in the list has to be reachable by+ # the self-driving filter, or the filter quietly hides rows the table just showed.+ self.repo_config.review_mode = review_mode+ self.repo_config.save(update_fields=["review_mode"])+ run = self._make_run(output=output)++ listed = self.client.get(self.url)+ assert listed.status_code == status.HTTP_200_OK, listed.content+ assert [row["trigger"] for row in listed.json()["results"]] == [expected]++ filtered = self.client.get(self.url, {"trigger": expected})+ assert filtered.status_code == status.HTTP_200_OK, filtered.content+ assert [row["id"] for row in filtered.json()["results"]] == [str(run.id)]++ def test_unknown_trigger_returns_empty_not_everything(self) -> None:+ # The filter is exposed via API/MCP. An unrecognized value must narrow to nothing rather than+ # fall through and hand back the unfiltered list as if the filter had applied.+ self._make_run()+ response = self.client.get(self.url, {"trigger": "not-a-trigger"})+ assert response.status_code == status.HTTP_200_OK, response.content+ assert response.json()["results"] == []+def test_readonly_viewset_rejects_writes(self) -> None:# ReviewRun is created by the webhook/task pipeline, never directly# by API clients; the viewset must stay read-only.diff --git a/products/stamphog/frontend/components/StamphogTabs.tsx b/products/stamphog/frontend/components/StamphogTabs.tsxnew file mode 100644index 000000000000..f4fd13039303--- /dev/null+++ b/products/stamphog/frontend/components/StamphogTabs.tsx@@ -0,0 +1,33 @@+import { LemonTabs } from 'lib/lemon-ui/LemonTabs'+import { urls } from 'scenes/urls'++export type StamphogTabKey = 'repositories' | 'runs' | 'digests'++// Top-level tab strip for stamphog. Every tab is team-scoped, so this is purely presentational —+// each scene passes the key it is. Repositories stays first: it's the only tab you have to visit+// before the other two have anything to show.+export function StamphogTabs({ activeKey }: { activeKey: StamphogTabKey }): JSX.Element {+ return (+ <LemonTabs+ activeKey={activeKey}+ sceneInset+ tabs={[+ {+ key: 'repositories' satisfies StamphogTabKey,+ label: 'Repositories',+ link: urls.stamphog(),+ },+ {+ key: 'runs' satisfies StamphogTabKey,+ label: 'Runs',+ link: urls.stamphogRuns(),+ },+ {+ key: 'digests' satisfies StamphogTabKey,+ label: 'Digests',+ link: urls.stamphogDigests(),+ },+ ]}+ />+ )+}diff --git a/products/stamphog/frontend/generated/api.schemas.ts b/products/stamphog/frontend/generated/api.schemas.tsindex b6888fdd3b1f..12c6fb44d80b 100644--- a/products/stamphog/frontend/generated/api.schemas.ts+++ b/products/stamphog/frontend/generated/api.schemas.ts@@ -351,6 +351,19 @@ export interface StamphogSyncInstallationResponseApi {readonly installations: readonly StamphogDiscoveredInstallationApi[]}+/**+ * * `self_driving` - SELF_DRIVING+ * * `label` - LABEL+ * * `all` - ALL+ */+export type ReviewRunTriggerEnumApi = (typeof ReviewRunTriggerEnumApi)[keyof typeof ReviewRunTriggerEnumApi]++export const ReviewRunTriggerEnumApi = {+ SelfDriving: 'self_driving',+ Label: 'label',+ All: 'all',+} as const+/*** * `queued` - QUEUED* * `gated` - GATED@@ -428,6 +441,10 @@ export interface ReviewRunApi {readonly pr_number: number/** Full URL to the pull request on GitHub. */readonly pr_url: string+ /** Pull request title as of the last webhook delivery applied. */+ readonly title: string+ /** GitHub login of the pull request author. */+ readonly author_login: string/** Commit SHA of the PR head at the time this run started. */readonly head_sha: string/** Branch name of the PR head. */@@ -437,6 +454,12 @@ export interface ReviewRunApi {* @nullable*/readonly delivery_id: string | null+ /** What caused this run to exist: self-driving inbox provenance, the repo's trigger label, or the repo reviewing every PR event.+ *+ * * `self_driving` - SELF_DRIVING+ * * `label` - LABEL+ * * `all` - ALL */+ readonly trigger: ReviewRunTriggerEnumApi/** Current stage of the review run's lifecycle.** * `queued` - QUEUED@@ -461,6 +484,21 @@ export interface ReviewRunApi {readonly output: _ReviewOutputSummaryApi/** Error message if the run failed, blank otherwise. */readonly error: string+ /**+ * ID of the GitHub review this run posted, null if it never posted one.+ * @nullable+ */+ readonly posted_review_id: number | null+ /**+ * When this run's verdict reached GitHub, null if it never did.+ * @nullable+ */+ readonly verdict_posted_at: string | null+ /**+ * When this run's GitHub approval was retracted because the head moved, null if it wasn't.+ * @nullable+ */+ readonly approval_dismissed_at: string | null/** When the review run was created. */readonly created_at: string/** When the review run was last updated. */@@ -558,4 +596,17 @@ export type StamphogReviewRunsListParams = {* Filter by review run status.*/status?: string+ /**+ * Filter by what caused the run: self_driving, label, or all.+ */+ trigger?: StamphogReviewRunsListTrigger}++export type StamphogReviewRunsListTrigger =+ (typeof StamphogReviewRunsListTrigger)[keyof typeof StamphogReviewRunsListTrigger]++export const StamphogReviewRunsListTrigger = {+ All: 'all',+ Label: 'label',+ SelfDriving: 'self_driving',+} as constdiff --git a/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.stories.tsx b/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.stories.tsxnew file mode 100644index 000000000000..6d498c7d3b33--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.stories.tsx@@ -0,0 +1,129 @@+import type { Meta, StoryObj } from '@storybook/react'++import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'++import type { DigestChannelApi, DigestRunApi } from '../../generated/api.schemas'++const digestChannels = {+ count: 2,+ next: null,+ previous: null,+ results: [+ {+ id: '00000000-0000-0000-0000-0000000000d1',+ audience_key: 'repo:PostHog/posthog',+ slack_integration_id: 1,+ slack_channel_id: 'C012AB3CD',+ slack_channel_name: 'team-devex',+ resolution_source: 'stamphog_config',+ enabled: true,+ last_digest_at: '2026-08-17T09:00:00Z',+ created_at: '2026-07-01T00:00:00Z',+ updated_at: '2026-08-17T09:00:00Z',+ },+ {+ id: '00000000-0000-0000-0000-0000000000d2',+ audience_key: 'repo:PostHog/hogland',+ slack_integration_id: 1,+ slack_channel_id: 'C045EF6GH',+ slack_channel_name: '',+ resolution_source: 'slack_name_match',+ enabled: true,+ last_digest_at: null,+ created_at: '2026-07-01T00:00:00Z',+ updated_at: '2026-07-01T00:00:00Z',+ },+ ] as DigestChannelApi[],+}++const digestRun = (overrides: Partial<DigestRunApi>): DigestRunApi =>+ ({+ id: '00000000-0000-0000-0000-0000000000e0',+ digest_channel: '00000000-0000-0000-0000-0000000000d1',+ status: 'completed',+ pr_count: 14,+ slack_message_ts: '1755424800.001900',+ error: '',+ created_at: '2026-08-17T09:00:00Z',+ posted_at: '2026-08-17T09:00:04Z',+ ...overrides,+ }) as DigestRunApi++const digestRuns = {+ count: 4,+ next: null,+ previous: null,+ results: [+ digestRun({}),+ // A channel with no slack_channel_name falls back to its ID. This run also found nothing worth+ // summarizing, so it completed with posted_at stamped but never called Slack — only the empty+ // slack_message_ts separates it from a real post.+ digestRun({+ id: '00000000-0000-0000-0000-0000000000e1',+ digest_channel: '00000000-0000-0000-0000-0000000000d2',+ pr_count: 0,+ slack_message_ts: '',+ created_at: '2026-08-17T09:00:01Z',+ posted_at: '2026-08-17T09:00:06Z',+ }),+ digestRun({+ id: '00000000-0000-0000-0000-0000000000e2',+ status: 'failed',+ pr_count: 9,+ slack_message_ts: '',+ error: 'slack_api_error: channel_not_found',+ created_at: '2026-08-16T09:00:00Z',+ posted_at: null,+ }),+ digestRun({+ id: '00000000-0000-0000-0000-0000000000e3',+ status: 'pending',+ pr_count: 0,+ slack_message_ts: '',+ created_at: '2026-08-18T09:00:00Z',+ posted_at: null,+ }),+ ],+}++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Stamphog/Digests',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-08-18 12:00:00',+ pageUrl: urls.stamphogDigests(),+ testOptions: { waitForSelector: '[data-attr="stamphog-digests-channel-filter"]' },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/digest_runs/': digestRuns,+ '/api/projects/:team_id/stamphog/digest_channels/': digestChannels,+ },+ }),+ ],+}+export default meta++// Posted, posted-but-empty, failed to reach Slack, and not yet run.+export const DigestsList: StoryObj = {}++export const DigestsListEmpty: StoryObj = {+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/digest_runs/': {+ count: 0,+ next: null,+ previous: null,+ results: [],+ },+ },+ }),+ ],+}diff --git a/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.tsx b/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.tsxnew file mode 100644index 000000000000..893ce9f3b869--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogDigestsScene/StamphogDigestsScene.tsx@@ -0,0 +1,148 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonSelect, LemonTable, LemonTag } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'+import { SceneExport } from 'scenes/sceneTypes'++import { SceneContent } from '~/layout/scenes/components/SceneContent'+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'++import { StamphogTabs } from '../../components/StamphogTabs'+import { DigestRunApi } from '../../generated/api.schemas'+import { digestChannelLabel, digestStatusDisplay } from './digestDisplay'+import { DIGESTS_PAGE_SIZE, stamphogDigestsSceneLogic } from './stamphogDigestsSceneLogic'++export const scene: SceneExport = {+ component: StamphogDigestsScene,+ logic: stamphogDigestsSceneLogic,+}++function DigestFilters(): JSX.Element {+ const { digestChannel, channelOptions, digestChannelsLoading } = useValues(stamphogDigestsSceneLogic)+ const { setDigestChannel } = useActions(stamphogDigestsSceneLogic)++ return (+ <div className="flex gap-2 flex-wrap items-center">+ <LemonSelect+ value={digestChannel}+ onChange={setDigestChannel}+ loading={digestChannelsLoading}+ placeholder="All channels"+ className="min-w-60"+ options={[{ value: null, label: 'All channels' }, ...channelOptions]}+ data-attr="stamphog-digests-channel-filter"+ />+ </div>+ )+}++function DigestsTable(): JSX.Element {+ const { digestRuns, digestRunsCount, digestRunsResponseLoading, digestRunsFailed, page, channelsById } =+ useValues(stamphogDigestsSceneLogic)+ const { setPage, loadDigestRuns } = useActions(stamphogDigestsSceneLogic)++ const columns: LemonTableColumns<DigestRunApi> = [+ {+ title: 'Created',+ dataIndex: 'created_at',+ render: (created_at) => <TZLabel time={created_at as string} />,+ },+ {+ title: 'Channel',+ key: 'digest_channel',+ render: (_, run) => {+ const channel = channelsById[run.digest_channel]+ return <span className="font-mono text-xs">{channel ? digestChannelLabel(channel) : '—'}</span>+ },+ },+ {+ title: 'Audience',+ key: 'audience_key',+ render: (_, run) => (+ <span className="font-mono text-xs">{channelsById[run.digest_channel]?.audience_key ?? '—'}</span>+ ),+ },+ {+ title: 'Status',+ key: 'status',+ render: (_, run) => {+ const { type, label } = digestStatusDisplay(run)+ return <LemonTag type={type}>{label}</LemonTag>+ },+ },+ {+ title: 'PRs',+ dataIndex: 'pr_count',+ render: (pr_count) => <span className="font-mono text-xs">{pr_count as number}</span>,+ },+ {+ title: 'Posted',+ key: 'posted_at',+ render: (_, run) => (run.posted_at ? <TZLabel time={run.posted_at} /> : null),+ },+ ]++ if (digestRunsFailed) {+ return (+ <LemonBanner+ type="error"+ action={{ children: 'Try again', onClick: () => loadDigestRuns() }}+ data-attr="stamphog-digests-error"+ >+ Could not load digests. This is usually temporary.+ </LemonBanner>+ )+ }++ return (+ <LemonTable+ columns={columns}+ dataSource={digestRuns}+ loading={digestRunsResponseLoading}+ rowKey="id"+ expandable={{+ expandedRowRender: (run) => <DigestRunDetails run={run} />,+ rowExpandable: (run) => !!run.error || !!run.slack_message_ts,+ }}+ pagination={{+ controlled: true,+ pageSize: DIGESTS_PAGE_SIZE,+ currentPage: page,+ entryCount: digestRunsCount,+ onForward: () => setPage(page + 1),+ onBackward: () => setPage(page - 1),+ }}+ emptyState="No digests yet. Stamphog posts one per channel on its digest schedule."+ />+ )+}++function DigestRunDetails({ run }: { run: DigestRunApi }): JSX.Element {+ return (+ <div className="flex flex-col gap-2 pl-2 pr-4 py-4 text-xs">+ {run.error && <span className="font-mono text-danger break-all">{run.error}</span>}+ {run.slack_message_ts && (+ <span className="font-mono text-muted break-all">Slack message timestamp: {run.slack_message_ts}</span>+ )}+ </div>+ )+}++export function StamphogDigestsScene(): JSX.Element {+ return (+ <SceneContent>+ <SceneTitleSection+ name="Digests"+ description="Every digest Stamphog posted, and where it went."+ resourceType={{ type: 'stamphog' }}+ />+ <StamphogTabs activeKey="digests" />+ <DigestFilters />+ <DigestsTable />+ </SceneContent>+ )+}++export default StamphogDigestsScenediff --git a/products/stamphog/frontend/scenes/StamphogDigestsScene/digestDisplay.ts b/products/stamphog/frontend/scenes/StamphogDigestsScene/digestDisplay.tsnew file mode 100644index 000000000000..633f1daded23--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogDigestsScene/digestDisplay.ts@@ -0,0 +1,33 @@+import { LemonTagType } from 'lib/lemon-ui/LemonTag'++import { DigestChannelApi, DigestRunApi, DigestRunStatusEnumApi } from '../../generated/api.schemas'++const STATUS_DISPLAY: Record<DigestRunStatusEnumApi, { type: LemonTagType; label: string }> = {+ pending: { type: 'default', label: 'Pending' },+ completed: { type: 'success', label: 'Posted' },+ failed: { type: 'danger', label: 'Failed' },+}++/**+ * What happened to a digest run.+ *+ * A run that found nothing worth summarizing completes without calling Slack, and still stamps+ * posted_at. Only slack_message_ts proves a message exists, so it decides "Posted" against+ * "Nothing to post" — otherwise the table claims a Slack post the reader will not find.+ */+export function digestStatusDisplay(run: DigestRunApi): { type: LemonTagType; label: string } {+ if (run.status === DigestRunStatusEnumApi.Completed && !run.slack_message_ts) {+ return { type: 'muted', label: 'Nothing to post' }+ }+ return STATUS_DISPLAY[run.status] ?? { type: 'muted', label: run.status }+}++/**+ * Where a digest went, as a person would say it.+ *+ * slack_channel_name is display-only and can be blank on a channel resolved by ID, so the ID is the+ * fallback — a row with neither would otherwise render as an empty cell.+ */+export function digestChannelLabel(channel: DigestChannelApi): string {+ return `#${channel.slack_channel_name || channel.slack_channel_id}`+}diff --git a/products/stamphog/frontend/scenes/StamphogDigestsScene/stamphogDigestsSceneLogic.ts b/products/stamphog/frontend/scenes/StamphogDigestsScene/stamphogDigestsSceneLogic.tsnew file mode 100644index 000000000000..3fe61bf8bdeb--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogDigestsScene/stamphogDigestsSceneLogic.ts@@ -0,0 +1,238 @@+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'+import { actionToUrl, urlToAction } from 'kea-router'++import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { stamphogDigestChannelsList, stamphogDigestRunsList } from '../../generated/api'+import type { DigestChannelApi, DigestRunApi, PaginatedDigestRunListApi } from '../../generated/api.schemas'+import { digestChannelLabel } from './digestDisplay'++export const DIGESTS_PAGE_SIZE = 50++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogDigestsSceneLogicValues {+ currentProjectId: number | string // teamLogic+ channelOptions: {+ label: string+ value: string+ }[]+ channelsById: Record<string, DigestChannelApi>+ digestChannel: string | null+ digestChannels: DigestChannelApi[]+ digestChannelsLoading: boolean+ digestRuns: DigestRunApi[]+ digestRunsCount: number+ digestRunsFailed: boolean+ digestRunsResponse: PaginatedDigestRunListApi | null+ digestRunsResponseLoading: boolean+ page: number+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogDigestsSceneLogicActions {+ loadDigestChannels: () => any+ loadDigestChannelsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadDigestChannelsSuccess: (+ digestChannels: DigestChannelApi[],+ payload?: any+ ) => {+ digestChannels: DigestChannelApi[]+ payload?: any+ }+ loadDigestRuns: () => {+ value: true+ }+ loadDigestRunsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadDigestRunsSuccess: (+ digestRunsResponse: PaginatedDigestRunListApi,+ payload?: {+ value: true+ }+ ) => {+ digestRunsResponse: PaginatedDigestRunListApi+ payload?: {+ value: true+ }+ }+ setDigestChannel: (digestChannel: string | null) => {+ digestChannel: string | null+ }+ setPage: (page: number) => {+ page: number+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogDigestsSceneLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ digestRuns: (digestRunsResponse: PaginatedDigestRunListApi | null) => DigestRunApi[]+ digestRunsCount: (digestRunsResponse: PaginatedDigestRunListApi | null) => number+ channelsById: (digestChannels: DigestChannelApi[]) => Record<string, DigestChannelApi>+ channelOptions: (digestChannels: DigestChannelApi[]) => {+ label: string+ value: string+ }[]+ }+}++export type stamphogDigestsSceneLogicType = MakeLogicType<+ stamphogDigestsSceneLogicValues,+ stamphogDigestsSceneLogicActions,+ Record<string, any>,+ stamphogDigestsSceneLogicMeta+>++export const stamphogDigestsSceneLogic = kea<stamphogDigestsSceneLogicType>([+ path(['products', 'stamphog', 'frontend', 'scenes', 'StamphogDigestsScene', 'stamphogDigestsSceneLogic']),++ connect(() => ({+ values: [teamLogic, ['currentProjectId']],+ })),++ actions({+ // Declared explicitly rather than left to the loaders builder: the loader takes a breakpoint,+ // so typegen would otherwise infer a required payload from its first parameter and every+ // `loadDigestRuns()` call site would stop compiling.+ loadDigestRuns: true,+ setDigestChannel: (digestChannel: string | null) => ({ digestChannel }),+ setPage: (page: number) => ({ page }),+ }),++ reducers({+ digestChannel: [null as string | null, { setDigestChannel: (_, { digestChannel }) => digestChannel }],+ // Changing the channel resets the page: page 4 of every channel's runs is rarely a page at+ // all once one channel is picked, and the reader would land on an empty table.+ page: [+ 1,+ {+ setPage: (_, { page }) => page,+ setDigestChannel: () => 1,+ },+ ],+ // A failed request resolves the loader with a null response, which the runs selector turns into+ // an empty list. Without this the table would claim there are no digests when it simply could+ // not ask. Loading, empty and error are three different screens.+ digestRunsFailed: [+ false,+ {+ loadDigestRuns: () => false,+ loadDigestRunsSuccess: () => false,+ loadDigestRunsFailure: () => true,+ },+ ],+ }),++ loaders(({ values }) => ({+ digestRunsResponse: [+ null as PaginatedDigestRunListApi | null,+ {+ loadDigestRuns: async (_, breakpoint) => {+ // urlToAction replays on mount, so a deep link sets the channel and the page in+ // turn, each with its own listener. Debounce so only the settled filters load.+ await breakpoint(1)+ return stamphogDigestRunsList(String(values.currentProjectId), {+ limit: DIGESTS_PAGE_SIZE,+ offset: (values.page - 1) * DIGESTS_PAGE_SIZE,+ ...(values.digestChannel ? { digest_channel: values.digestChannel } : {}),+ })+ },+ },+ ],+ // Populates the channel filter and names the channel on each row — a digest run carries only+ // its channel id, and a bare UUID tells the reader nothing about where the digest went.+ digestChannels: [+ [] as DigestChannelApi[],+ {+ loadDigestChannels: async () => {+ // Follow LimitOffset pagination the same way the repositories scene does: a truncated+ // first page would leave channels out of the filter while their digests still show up.+ const pageSize = 100+ const all: DigestChannelApi[] = []+ for (let offset = 0; ; offset += pageSize) {+ const response = await stamphogDigestChannelsList(String(values.currentProjectId), {+ limit: pageSize,+ offset,+ })+ all.push(...response.results)+ if (all.length >= response.count || response.results.length === 0) {+ break+ }+ }+ return all+ },+ },+ ],+ })),++ selectors({+ digestRuns: [+ (s) => [s.digestRunsResponse],+ (digestRunsResponse: PaginatedDigestRunListApi | null): DigestRunApi[] => digestRunsResponse?.results ?? [],+ ],+ digestRunsCount: [+ (s) => [s.digestRunsResponse],+ (digestRunsResponse: PaginatedDigestRunListApi | null): number => digestRunsResponse?.count ?? 0,+ ],+ // A digest run carries only its channel id, so the table joins against this to name the row.+ channelsById: [+ (s) => [s.digestChannels],+ (digestChannels: DigestChannelApi[]): Record<string, DigestChannelApi> =>+ Object.fromEntries(digestChannels.map((channel) => [channel.id, channel])),+ ],+ channelOptions: [+ (s) => [s.digestChannels],+ (digestChannels: DigestChannelApi[]): { value: string; label: string }[] =>+ digestChannels.map((channel) => ({ value: channel.id, label: digestChannelLabel(channel) })),+ ],+ }),++ listeners(({ actions }) => ({+ setDigestChannel: () => actions.loadDigestRuns(),+ setPage: () => actions.loadDigestRuns(),+ })),++ actionToUrl(({ values }) => {+ const toUrl = (): [string, Record<string, string>] => [+ urls.stamphogDigests(),+ {+ ...(values.digestChannel ? { digest_channel: values.digestChannel } : {}),+ ...(values.page > 1 ? { page: String(values.page) } : {}),+ },+ ]+ return { setDigestChannel: toUrl, setPage: toUrl }+ }),++ urlToAction(({ actions, values }) => ({+ [urls.stamphogDigests()]: (_: any, searchParams: Record<string, any>) => {+ const digestChannel = (searchParams.digest_channel as string | undefined) ?? null+ const page = Number(searchParams.page ?? 1) || 1+ // Guard each against its current value: setDigestChannel resets the page, so replaying an+ // unchanged filter on a deep link would knock the reader back to page 1.+ if (digestChannel !== values.digestChannel) {+ actions.setDigestChannel(digestChannel)+ }+ if (page !== values.page) {+ actions.setPage(page)+ }+ },+ })),++ afterMount(({ actions }) => {+ actions.loadDigestRuns()+ actions.loadDigestChannels()+ }),+])diff --git a/products/stamphog/frontend/scenes/StamphogRunsScene/ExpandedRunDetails.tsx b/products/stamphog/frontend/scenes/StamphogRunsScene/ExpandedRunDetails.tsxnew file mode 100644index 000000000000..a1edcb6bee4c--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogRunsScene/ExpandedRunDetails.tsx@@ -0,0 +1,130 @@+import { combineUrl } from 'kea-router'++import { LemonBanner, LemonTag, Link } from '@posthog/lemon-ui'++import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'+import { TZLabel } from 'lib/components/TZLabel'+import { urls } from 'scenes/urls'++import { PropertyFilterType, PropertyOperator } from '~/types'++import { ReviewRunApi } from '../../generated/api.schemas'+import { runDuration } from './runDisplay'++// The engine emits its LLM traces under these product tags. They carry no review run id, so a link+// can only narrow to stamphog's traces in the run's own time window, not to this exact run.+const STAMPHOG_AI_PRODUCTS = ['stamphog', 'aio_stamphog']++function Field({ label, children }: { label: string; children: React.ReactNode }): JSX.Element {+ return (+ <>+ <dt className="text-muted">{label}</dt>+ <dd className="m-0 min-w-0 font-mono text-xs break-all">+ {children ?? <span className="text-muted">—</span>}+ </dd>+ </>+ )+}++function TimeField({ label, time }: { label: string; time?: string | null }): JSX.Element {+ return <Field label={label}>{time ? <TZLabel time={time} /> : null}</Field>+}++function Section({+ title,+ note,+ children,+}: {+ title: string+ note?: React.ReactNode+ children: React.ReactNode+}): JSX.Element {+ return (+ <section className="min-w-0">+ <h5 className="text-muted mb-1.5">{title}</h5>+ {/* An auto label column sits against its longest label — a fixed width would open a ragged+ gap beside the short ones. Baseline alignment keeps plain values level with the tag rows. */}+ <dl className="grid grid-cols-[auto_1fr] items-baseline gap-x-4 gap-y-1.5 text-xs">{children}</dl>+ {note && <p className="text-muted text-xs mt-2 mb-0">{note}</p>}+ </section>+ )+}++function llmTracesUrl(run: ReviewRunApi): string {+ return combineUrl(urls.aiObservabilityTraces(), {+ filters: [+ {+ key: 'ai_product',+ value: STAMPHOG_AI_PRODUCTS,+ operator: PropertyOperator.Exact,+ type: PropertyFilterType.Event,+ },+ ],+ date_from: run.created_at,+ date_to: run.completed_at ?? undefined,+ }).url+}++export function ExpandedRunDetails({ run }: { run: ReviewRunApi }): JSX.Element {+ return (+ <div className="flex flex-col gap-4 pl-2 pr-4 py-4">+ {run.error && (+ <LemonBanner type="error">+ <span className="font-mono text-xs">{run.error}</span>+ </LemonBanner>+ )}++ <div className="grid grid-cols-1 md:grid-cols-3 gap-x-8 gap-y-6">+ <Section+ title="Decision"+ note="The reviewer's reasoning, the individual gates and the sandbox output name changed files, so the API keeps them on the server."+ >+ <Field label="Engine verdict">{run.gate_result?.final_verdict || null}</Field>+ <Field label="Gates">+ {/* The API omits gate_blocked entirely when the run never reached the gates, so an+ absent value has to read as "didn't get there", not as a pass. */}+ {run.gate_result?.gate_blocked === undefined ? null : run.gate_result.gate_blocked ? (+ <LemonTag type="danger">Blocked before review</LemonTag>+ ) : (+ <LemonTag type="success">Passed</LemonTag>+ )}+ </Field>+ <Field label="Engine version">{run.output?.stamphog_version || null}</Field>+ <Field label="Exit code">{run.output?.reviewer_exit_code ?? null}</Field>+ </Section>++ <Section title="Posted to GitHub">+ <Field label="Review">+ {run.posted_review_id ? (+ <Link to={`${run.pr_url}#pullrequestreview-${run.posted_review_id}`} target="_blank">+ {run.posted_review_id}+ </Link>+ ) : null}+ </Field>+ <TimeField label="Posted" time={run.verdict_posted_at} />+ <TimeField label="Approval retracted" time={run.approval_dismissed_at} />+ <Field label="Branch">{run.head_branch || null}</Field>+ <Field label="Head commit">{run.head_sha || null}</Field>+ </Section>++ <Section+ title="Run"+ note={<Link to={llmTracesUrl(run)}>See stamphog's LLM traces from this window</Link>}+ >+ <Field label="Run ID">+ {/* A full UUID doesn't fit the column and wraps to three lines. The prefix is enough+ to eyeball one row against another, and copy still yields the whole id — which is+ what it's actually for (grepping worker logs). */}+ <CopyToClipboardInline description="run ID" explicitValue={run.id}>+ {run.id.slice(0, 8)}+ </CopyToClipboardInline>+ </Field>+ <Field label="Delivery ID">{run.delivery_id || null}</Field>+ <TimeField label="Started" time={run.created_at} />+ <TimeField label="Finished" time={run.completed_at} />+ <Field label="Took">{runDuration(run)}</Field>+ </Section>+ </div>+ </div>+ )+}diff --git a/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.stories.tsx b/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.stories.tsxnew file mode 100644index 000000000000..5c5b39219030--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.stories.tsx@@ -0,0 +1,191 @@+import type { Meta, StoryObj } from '@storybook/react'++import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'++import type { ReviewRunApi, StamphogRepoConfigApi } from '../../generated/api.schemas'++const repoConfigs = {+ count: 2,+ next: null,+ previous: null,+ results: [+ {+ id: '00000000-0000-0000-0000-0000000000a1',+ repository: 'PostHog/posthog',+ provider: 'github',+ enabled: true,+ digest_enabled: true,+ installation_id: '1',+ review_mode: 'all',+ trigger_label: 'stamphog',+ created_at: '2026-07-01T00:00:00Z',+ updated_at: '2026-07-01T00:00:00Z',+ },+ {+ id: '00000000-0000-0000-0000-0000000000a2',+ repository: 'PostHog/hogland',+ provider: 'github',+ enabled: true,+ digest_enabled: false,+ installation_id: '2',+ review_mode: 'label',+ trigger_label: 'stamphog',+ created_at: '2026-07-01T00:00:00Z',+ updated_at: '2026-07-01T00:00:00Z',+ },+ ] as StamphogRepoConfigApi[],+}++const run = (overrides: Partial<ReviewRunApi>): ReviewRunApi =>+ ({+ id: '00000000-0000-0000-0000-0000000000b0',+ pull_request: '00000000-0000-0000-0000-0000000000c0',+ repository: 'PostHog/posthog',+ pr_number: 83812,+ pr_url: 'https://github.com/PostHog/posthog/pull/83812',+ title: 'fix(cdp): stop double-encoding hog function inputs',+ author_login: 'posthog[bot]',+ head_sha: 'a91f3cd8e2b1447fa0c2d9e5b7318fa4c02d1e77',+ head_branch: 'fix/hog-inputs-encoding',+ delivery_id: '7d2a91e0-9b44-11f0-8f31-2c1a4b6d90ff',+ trigger: 'self_driving',+ status: 'completed',+ verdict: 'approved',+ gate_result: { gate_blocked: false, final_verdict: 'APPROVED' },+ output: { stamphog_version: '2.0.0b4', reviewer_exit_code: 0 },+ error: '',+ posted_review_id: 2884991204,+ verdict_posted_at: '2026-08-17T14:05:52Z',+ approval_dismissed_at: null,+ created_at: '2026-08-17T14:02:11Z',+ updated_at: '2026-08-17T14:05:52Z',+ completed_at: '2026-08-17T14:05:52Z',+ ...overrides,+ }) as ReviewRunApi++const reviewRuns = {+ count: 6,+ next: null,+ previous: null,+ results: [+ run({}),+ run({+ id: '00000000-0000-0000-0000-0000000000b1',+ pr_number: 83809,+ title: 'feat(warehouse): add incremental sync cursor overrides',+ head_sha: 'c02b17a4e9d8331fb7245c8a1e60d3b9f4a7c112',+ status: 'gated',+ verdict: 'refused',+ gate_result: { gate_blocked: true, final_verdict: 'REFUSED' },+ output: { stamphog_version: '2.0.0b4' },+ posted_review_id: null,+ verdict_posted_at: '2026-08-17T13:47:13Z',+ created_at: '2026-08-17T13:47:02Z',+ completed_at: '2026-08-17T13:47:13Z',+ } as Partial<ReviewRunApi>),+ run({+ id: '00000000-0000-0000-0000-0000000000b2',+ repository: 'PostHog/hogland',+ pr_number: 402,+ pr_url: 'https://github.com/PostHog/hogland/pull/402',+ title: 'chore(deps): bump temporalio to 1.9.0',+ author_login: 'webjunkie',+ head_sha: '4fe8b2077c1a9e3d5b06f8241ac93de70b115f6a',+ trigger: 'label',+ status: 'failed',+ verdict: 'error',+ gate_result: {},+ output: { reviewer_exit_code: 124 },+ error: 'Reviewer exited with code 124: sandbox command timed out after 1500s',+ posted_review_id: null,+ verdict_posted_at: null,+ created_at: '2026-08-17T13:31:44Z',+ completed_at: '2026-08-17T13:56:47Z',+ } as Partial<ReviewRunApi>),+ run({+ id: '00000000-0000-0000-0000-0000000000b3',+ pr_number: 83801,+ title: 'fix(insights): guard empty series in trend export',+ head_sha: '8ba0e4192f7c6ab35d0e17c9f4a82b6d503e1a99',+ // The supersede paths stamp the status and updated_at but leave completed_at null, so this+ // row is what proves a terminal run's duration stops instead of growing against now.+ status: 'superseded',+ verdict: 'none',+ gate_result: {},+ output: {},+ posted_review_id: null,+ verdict_posted_at: null,+ created_at: '2026-08-17T13:12:08Z',+ updated_at: '2026-08-17T13:12:50Z',+ completed_at: null,+ } as Partial<ReviewRunApi>),+ run({+ id: '00000000-0000-0000-0000-0000000000b4',+ pr_number: 83790,+ title: 'chore(devex): split oversized reviewer module',+ head_sha: '1d40b9c8a2e74f13c95b0da6e28f7143b6c09e55',+ status: 'reviewing',+ verdict: 'none',+ gate_result: {},+ output: {},+ posted_review_id: null,+ verdict_posted_at: null,+ created_at: '2026-08-17T12:44:19Z',+ completed_at: null,+ } as Partial<ReviewRunApi>),+ run({+ id: '00000000-0000-0000-0000-0000000000b5',+ pr_number: 83781,+ title: 'feat(flags): local evaluation payload v2',+ head_sha: '70ab3f1d6e28c4590b7fa1362d84e0c7195bf3a2',+ verdict: 'escalate',+ gate_result: { gate_blocked: false, final_verdict: 'ESCALATE' },+ posted_review_id: null,+ created_at: '2026-08-17T12:20:55Z',+ completed_at: '2026-08-17T12:26:07Z',+ } as Partial<ReviewRunApi>),+ ],+}++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Stamphog/Runs',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-08-17 23:30:00',+ pageUrl: urls.stamphogRuns(),+ testOptions: { waitForSelector: '[data-attr="stamphog-runs-trigger-filter"]' },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/review_runs/': reviewRuns,+ '/api/projects/:team_id/stamphog/repo_configs/': repoConfigs,+ },+ }),+ ],+}+export default meta++// Every lifecycle state stamphog can leave behind: approved, gate-blocked, failed, superseded,+// still reviewing, and escalated to a human.+export const RunsList: StoryObj = {}++export const RunsListEmpty: StoryObj = {+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/review_runs/': {+ count: 0,+ next: null,+ previous: null,+ results: [],+ },+ },+ }),+ ],+}diff --git a/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.tsx b/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.tsxnew file mode 100644index 000000000000..16a5e3c77a67--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogRunsScene/StamphogRunsScene.tsx@@ -0,0 +1,162 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonSelect, LemonTable, LemonTag, Link } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'+import { SceneExport } from 'scenes/sceneTypes'++import { SceneContent } from '~/layout/scenes/components/SceneContent'+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'++import { StamphogTabs } from '../../components/StamphogTabs'+import { ReviewRunApi } from '../../generated/api.schemas'+import { ExpandedRunDetails } from './ExpandedRunDetails'+import { TRIGGER_OPTIONS, runDuration, shortSha, statusDisplay, triggerLabel, verdictDisplay } from './runDisplay'+import { RUNS_PAGE_SIZE, stamphogRunsSceneLogic } from './stamphogRunsSceneLogic'++export const scene: SceneExport = {+ component: StamphogRunsScene,+ logic: stamphogRunsSceneLogic,+}++function RunFilters(): JSX.Element {+ const { repository, trigger, repositoryOptions, repoConfigsLoading } = useValues(stamphogRunsSceneLogic)+ const { setRepository, setTrigger } = useActions(stamphogRunsSceneLogic)++ return (+ <div className="flex gap-2 flex-wrap items-center">+ <LemonSelect+ value={repository}+ onChange={setRepository}+ loading={repoConfigsLoading}+ placeholder="All repositories"+ className="min-w-60"+ options={[{ value: null, label: 'All repositories' }, ...repositoryOptions]}+ data-attr="stamphog-runs-repository-filter"+ />+ <LemonSelect+ value={trigger}+ onChange={setTrigger}+ placeholder="Any trigger"+ className="min-w-40"+ options={[{ value: null, label: 'Any trigger' }, ...TRIGGER_OPTIONS]}+ data-attr="stamphog-runs-trigger-filter"+ />+ </div>+ )+}++function RunsTable(): JSX.Element {+ const { runs, runCount, runsResponseLoading, runsFailed, page } = useValues(stamphogRunsSceneLogic)+ const { setPage, loadRuns } = useActions(stamphogRunsSceneLogic)++ const columns: LemonTableColumns<ReviewRunApi> = [+ {+ title: 'Started',+ dataIndex: 'created_at',+ render: (created_at) => <TZLabel time={created_at as string} />,+ },+ {+ title: 'Repository',+ dataIndex: 'repository',+ render: (repository) => <span className="font-mono text-xs">{repository as string}</span>,+ },+ {+ title: 'Pull request',+ key: 'pull_request',+ render: (_, run) => (+ <div className="flex items-center gap-2 min-w-0">+ <Link to={run.pr_url} target="_blank" className="font-mono text-xs shrink-0">+ #{run.pr_number}+ </Link>+ <span className="truncate">{run.title}</span>+ </div>+ ),+ },+ {+ title: 'Author',+ dataIndex: 'author_login',+ render: (author_login) => <span className="font-mono text-xs">{author_login as string}</span>,+ },+ {+ title: 'Trigger',+ key: 'trigger',+ render: (_, run) => <LemonTag type="option">{triggerLabel(run.trigger)}</LemonTag>,+ },+ {+ title: 'Status',+ key: 'status',+ render: (_, run) => {+ const { type, label } = statusDisplay(run.status)+ return <LemonTag type={type}>{label}</LemonTag>+ },+ },+ {+ title: 'Verdict',+ key: 'verdict',+ render: (_, run) => {+ const { type, label } = verdictDisplay(run.verdict)+ return <LemonTag type={type}>{label}</LemonTag>+ },+ },+ {+ title: 'Head',+ dataIndex: 'head_sha',+ render: (head_sha) => <span className="font-mono text-xs">{shortSha(head_sha as string)}</span>,+ },+ {+ title: 'Took',+ key: 'duration',+ render: (_, run) => <span className="font-mono text-xs">{runDuration(run)}</span>,+ },+ ]++ if (runsFailed) {+ return (+ <LemonBanner+ type="error"+ action={{ children: 'Try again', onClick: () => loadRuns() }}+ data-attr="stamphog-runs-error"+ >+ Could not load runs. This is usually temporary.+ </LemonBanner>+ )+ }++ return (+ <LemonTable+ columns={columns}+ dataSource={runs}+ loading={runsResponseLoading}+ rowKey="id"+ expandable={{ expandedRowRender: (run) => <ExpandedRunDetails run={run} /> }}+ pagination={{+ controlled: true,+ pageSize: RUNS_PAGE_SIZE,+ currentPage: page,+ entryCount: runCount,+ onForward: () => setPage(page + 1),+ onBackward: () => setPage(page - 1),+ }}+ emptyState="No runs yet. Stamphog records one here every time it looks at a pull request."+ />+ )+}++export function StamphogRunsScene(): JSX.Element {+ return (+ <SceneContent>+ <SceneTitleSection+ name="Runs"+ description="Every time Stamphog reviewed a pull request, and what it decided."+ resourceType={{ type: 'stamphog' }}+ />+ <StamphogTabs activeKey="runs" />+ <RunFilters />+ <RunsTable />+ </SceneContent>+ )+}++export default StamphogRunsScenediff --git a/products/stamphog/frontend/scenes/StamphogRunsScene/runDisplay.ts b/products/stamphog/frontend/scenes/StamphogRunsScene/runDisplay.tsnew file mode 100644index 000000000000..dcb3a850c095--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogRunsScene/runDisplay.ts@@ -0,0 +1,96 @@+import { dayjs } from 'lib/dayjs'+import { LemonTagType } from 'lib/lemon-ui/LemonTag'+import { humanFriendlyDuration } from 'lib/utils/durations'++import {+ ReviewRunApi,+ ReviewRunStatusEnumApi,+ ReviewRunTriggerEnumApi,+ ReviewRunVerdictEnumApi,+ StamphogReviewRunsListTrigger,+} from '../../generated/api.schemas'++/** How a run's outcome reads at a glance: the tag color plus the word on the tag. */+export type OutcomeDisplay = { type: LemonTagType; label: string }++const VERDICT_DISPLAY: Record<ReviewRunVerdictEnumApi, OutcomeDisplay> = {+ [ReviewRunVerdictEnumApi.Approved]: { type: 'success', label: 'Approved' },+ [ReviewRunVerdictEnumApi.Refused]: { type: 'danger', label: 'Refused' },+ [ReviewRunVerdictEnumApi.Escalate]: { type: 'warning', label: 'Escalated' },+ [ReviewRunVerdictEnumApi.Error]: { type: 'danger', label: 'Errored' },+ [ReviewRunVerdictEnumApi.Wait]: { type: 'default', label: 'Waiting' },+ [ReviewRunVerdictEnumApi.None]: { type: 'muted', label: 'No verdict' },+}++const STATUS_DISPLAY: Record<ReviewRunStatusEnumApi, OutcomeDisplay> = {+ [ReviewRunStatusEnumApi.Queued]: { type: 'default', label: 'Queued' },+ [ReviewRunStatusEnumApi.Reviewing]: { type: 'primary', label: 'Reviewing' },+ [ReviewRunStatusEnumApi.Gated]: { type: 'caution', label: 'Gated' },+ [ReviewRunStatusEnumApi.Completed]: { type: 'muted', label: 'Completed' },+ [ReviewRunStatusEnumApi.Failed]: { type: 'danger', label: 'Failed' },+ [ReviewRunStatusEnumApi.Superseded]: { type: 'muted', label: 'Superseded' },+}++const TRIGGER_LABEL: Record<ReviewRunTriggerEnumApi, string> = {+ [ReviewRunTriggerEnumApi.SelfDriving]: 'Self-driving',+ [ReviewRunTriggerEnumApi.Label]: 'Label',+ [ReviewRunTriggerEnumApi.All]: 'Every PR',+}++export function verdictDisplay(verdict: ReviewRunVerdictEnumApi): OutcomeDisplay {+ return VERDICT_DISPLAY[verdict] ?? { type: 'muted', label: verdict }+}++export function statusDisplay(status: ReviewRunStatusEnumApi): OutcomeDisplay {+ return STATUS_DISPLAY[status] ?? { type: 'muted', label: status }+}++export function triggerLabel(trigger: ReviewRunTriggerEnumApi): string {+ return TRIGGER_LABEL[trigger] ?? trigger+}++/**+ * Options for the trigger filter, derived from the labels the table already uses.+ *+ * The query-param enum and the response enum carry the same values, so one list keeps the filter+ * and the column from calling the same run different things.+ */+export const TRIGGER_OPTIONS: { value: StamphogReviewRunsListTrigger; label: string }[] = Object.entries(+ TRIGGER_LABEL+).map(([value, label]) => ({ value: value as StamphogReviewRunsListTrigger, label }))++// Statuses that mean the run is over. Mirrors TERMINAL_STATUSES in the backend's facade/enums.py.+const TERMINAL_STATUSES: ReadonlySet<ReviewRunStatusEnumApi> = new Set([+ ReviewRunStatusEnumApi.Completed,+ ReviewRunStatusEnumApi.Failed,+ ReviewRunStatusEnumApi.Superseded,+ ReviewRunStatusEnumApi.Gated,+])++/**+ * How long the run took, or how long it has been going.+ *+ * A run still in flight is measured against now — a run wedged in the sandbox is exactly what someone+ * opens this table to find, and a blank cell would hide it. The status column is what says which of+ * the two a given number is.+ *+ * Terminal runs fall back to updated_at, because the supersede paths set the status without stamping+ * completed_at. Measuring those against now would grow a finished run's duration forever.+ */+export function runDuration(run: ReviewRunApi): string {+ const end = run.completed_at+ ? dayjs(run.completed_at)+ : TERMINAL_STATUSES.has(run.status)+ ? dayjs(run.updated_at)+ : dayjs()+ const seconds = end.diff(dayjs(run.created_at), 'second')+ if (seconds < 0) {+ return ''+ }+ return humanFriendlyDuration(seconds, { maxUnits: 2 })+}++/** Short SHA, the length GitHub itself shows. */+export function shortSha(sha: string): string {+ return sha.slice(0, 7)+}diff --git a/products/stamphog/frontend/scenes/StamphogRunsScene/stamphogRunsSceneLogic.ts b/products/stamphog/frontend/scenes/StamphogRunsScene/stamphogRunsSceneLogic.tsnew file mode 100644index 000000000000..d776fd56fd77--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogRunsScene/stamphogRunsSceneLogic.ts@@ -0,0 +1,251 @@+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'+import { actionToUrl, urlToAction } from 'kea-router'++import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { stamphogRepoConfigsList, stamphogReviewRunsList } from '../../generated/api'+import type {+ PaginatedReviewRunListApi,+ ReviewRunApi,+ StamphogRepoConfigApi,+ StamphogReviewRunsListTrigger,+} from '../../generated/api.schemas'++export const RUNS_PAGE_SIZE = 50++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogRunsSceneLogicValues {+ currentProjectId: number | string // teamLogic+ page: number+ repoConfigs: StamphogRepoConfigApi[]+ repoConfigsLoading: boolean+ repository: string | null+ repositoryOptions: {+ label: string+ value: string+ }[]+ runCount: number+ runs: ReviewRunApi[]+ runsFailed: boolean+ runsResponse: PaginatedReviewRunListApi | null+ runsResponseLoading: boolean+ trigger: StamphogReviewRunsListTrigger | null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogRunsSceneLogicActions {+ loadRepoConfigs: () => any+ loadRepoConfigsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadRepoConfigsSuccess: (+ repoConfigs: StamphogRepoConfigApi[],+ payload?: any+ ) => {+ repoConfigs: StamphogRepoConfigApi[]+ payload?: any+ }+ loadRuns: () => {+ value: true+ }+ loadRunsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadRunsSuccess: (+ runsResponse: PaginatedReviewRunListApi,+ payload?: {+ value: true+ }+ ) => {+ runsResponse: PaginatedReviewRunListApi+ payload?: {+ value: true+ }+ }+ setPage: (page: number) => {+ page: number+ }+ setRepository: (repository: string | null) => {+ repository: string | null+ }+ setTrigger: (trigger: StamphogReviewRunsListTrigger | null) => {+ trigger: StamphogReviewRunsListTrigger | null+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface stamphogRunsSceneLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ runs: (runsResponse: PaginatedReviewRunListApi | null) => ReviewRunApi[]+ runCount: (runsResponse: PaginatedReviewRunListApi | null) => number+ repositoryOptions: (repoConfigs: StamphogRepoConfigApi[]) => {+ label: string+ value: string+ }[]+ }+}++export type stamphogRunsSceneLogicType = MakeLogicType<+ stamphogRunsSceneLogicValues,+ stamphogRunsSceneLogicActions,+ Record<string, any>,+ stamphogRunsSceneLogicMeta+>++export const stamphogRunsSceneLogic = kea<stamphogRunsSceneLogicType>([+ path(['products', 'stamphog', 'frontend', 'scenes', 'StamphogRunsScene', 'stamphogRunsSceneLogic']),++ connect(() => ({+ values: [teamLogic, ['currentProjectId']],+ })),++ actions({+ // Declared explicitly rather than left to the loaders builder: the loader takes a breakpoint,+ // so typegen would otherwise infer a required payload from its first parameter and every+ // `loadRuns()` call site would stop compiling.+ loadRuns: true,+ setRepository: (repository: string | null) => ({ repository }),+ setTrigger: (trigger: StamphogReviewRunsListTrigger | null) => ({ trigger }),+ setPage: (page: number) => ({ page }),+ }),++ reducers({+ repository: [null as string | null, { setRepository: (_, { repository }) => repository }],+ trigger: [null as StamphogReviewRunsListTrigger | null, { setTrigger: (_, { trigger }) => trigger }],+ // Every filter change resets the page: page 4 of the unfiltered list is rarely a page at all+ // once a filter narrows the result set, and the reader would land on an empty table.+ page: [+ 1,+ {+ setPage: (_, { page }) => page,+ setRepository: () => 1,+ setTrigger: () => 1,+ },+ ],+ // A failed request resolves the loader with a null response, which the runs selector turns into+ // an empty list. Without this the table would claim there are no runs when it simply could not+ // ask. Loading, empty and error are three different screens.+ runsFailed: [+ false,+ {+ loadRuns: () => false,+ loadRunsSuccess: () => false,+ loadRunsFailure: () => true,+ },+ ],+ }),++ loaders(({ values }) => ({+ runsResponse: [+ null as PaginatedReviewRunListApi | null,+ {+ loadRuns: async (_, breakpoint) => {+ // urlToAction replays on mount, so a deep link sets repository, trigger and page+ // in turn, each with its own listener. Debounce so only the settled filters load.+ await breakpoint(1)+ return stamphogReviewRunsList(String(values.currentProjectId), {+ limit: RUNS_PAGE_SIZE,+ offset: (values.page - 1) * RUNS_PAGE_SIZE,+ ...(values.repository ? { repository: values.repository } : {}),+ ...(values.trigger ? { trigger: values.trigger } : {}),+ })+ },+ },+ ],+ // Populates the repository filter. Read-only here — the toggles that own these rows live on+ // the repositories scene, so this list is never written back.+ repoConfigs: [+ [] as StamphogRepoConfigApi[],+ {+ loadRepoConfigs: async () => {+ // An installation can surface hundreds of repos, so follow LimitOffset pagination and+ // fetch every page. A truncated first page would leave repos out of the filter while+ // their runs still show up in the table.+ const pageSize = 100+ const all: StamphogRepoConfigApi[] = []+ for (let offset = 0; ; offset += pageSize) {+ const response = await stamphogRepoConfigsList(String(values.currentProjectId), {+ limit: pageSize,+ offset,+ })+ all.push(...response.results)+ if (all.length >= response.count || response.results.length === 0) {+ break+ }+ }+ return all+ },+ },+ ],+ })),++ selectors({+ runs: [+ (s) => [s.runsResponse],+ (runsResponse: PaginatedReviewRunListApi | null): ReviewRunApi[] => runsResponse?.results ?? [],+ ],+ runCount: [+ (s) => [s.runsResponse],+ (runsResponse: PaginatedReviewRunListApi | null): number => runsResponse?.count ?? 0,+ ],+ // Only repositories stamphog is configured for — filtering by one it never reviewed would be+ // an empty table with no explanation for why.+ repositoryOptions: [+ (s) => [s.repoConfigs],+ (repoConfigs: StamphogRepoConfigApi[]): { value: string; label: string }[] =>+ repoConfigs.map((repo) => ({ value: repo.repository, label: repo.repository })),+ ],+ }),++ listeners(({ actions }) => ({+ setRepository: () => actions.loadRuns(),+ setTrigger: () => actions.loadRuns(),+ setPage: () => actions.loadRuns(),+ })),++ actionToUrl(({ values }) => {+ const toUrl = (): [string, Record<string, string>] => [+ urls.stamphogRuns(),+ {+ ...(values.repository ? { repository: values.repository } : {}),+ ...(values.trigger ? { trigger: values.trigger } : {}),+ ...(values.page > 1 ? { page: String(values.page) } : {}),+ },+ ]+ return { setRepository: toUrl, setTrigger: toUrl, setPage: toUrl }+ }),++ urlToAction(({ actions, values }) => ({+ [urls.stamphogRuns()]: (_: any, searchParams: Record<string, any>) => {+ const repository = (searchParams.repository as string | undefined) ?? null+ const trigger = (searchParams.trigger as StamphogReviewRunsListTrigger | undefined) ?? null+ const page = Number(searchParams.page ?? 1) || 1+ // Guard each against its current value: setRepository resets the page, so replaying an+ // unchanged filter on a deep link would knock the reader back to page 1.+ if (repository !== values.repository) {+ actions.setRepository(repository)+ }+ if (trigger !== values.trigger) {+ actions.setTrigger(trigger)+ }+ if (page !== values.page) {+ actions.setPage(page)+ }+ },+ })),++ afterMount(({ actions }) => {+ actions.loadRuns()+ actions.loadRepoConfigs()+ }),+])diff --git a/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsxindex be11d4a8979d..69a9de5f9805 100644--- a/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx+++ b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx@@ -10,6 +10,7 @@ import { SceneExport } from 'scenes/sceneTypes'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { StamphogTabs } from '../../components/StamphogTabs'import { ReviewModeEnumApi, type StamphogRepoConfigApi } from '../../generated/api.schemas'import { stamphogSceneLogic } from './stamphogSceneLogic'@@ -235,11 +236,9 @@ export function StamphogScene(): JSX.Element {resourceType={{ type: 'stamphog' }}actions={<ConnectRepositoryButton />}/>+ <StamphogTabs activeKey="repositories" /><SyncedBanner />- <div>- <h3>Repositories</h3>- <RepoConfigsTable />- </div>+ <RepoConfigsTable /></SceneContent>)}diff --git a/products/stamphog/manifest.tsx b/products/stamphog/manifest.tsxindex 93cfae1bbbf8..4a9bcf27ec1a 100644--- a/products/stamphog/manifest.tsx+++ b/products/stamphog/manifest.tsx@@ -16,9 +16,23 @@ export const manifest: ProductManifest = {name: 'Stamphog',iconType: 'stamphog',},+ StamphogRuns: {+ import: () => import('./frontend/scenes/StamphogRunsScene/StamphogRunsScene'),+ projectBased: true,+ name: 'Stamphog runs',+ iconType: 'stamphog',+ },+ StamphogDigests: {+ import: () => import('./frontend/scenes/StamphogDigestsScene/StamphogDigestsScene'),+ projectBased: true,+ name: 'Stamphog digests',+ iconType: 'stamphog',+ },},routes: {'/stamphog': ['Stamphog', 'stamphog'],+ '/stamphog/runs': ['StamphogRuns', 'stamphogRuns'],+ '/stamphog/digests': ['StamphogDigests', 'stamphogDigests'],// GitHub App Setup URL — GitHub redirects here after install with an installation_id search// param. Lives under the product's own /stamphog namespace, not /integrations/*, so the generic// /integrations/:kind/callback scene route can't shadow it (product routes register after core).@@ -27,6 +41,8 @@ export const manifest: ProductManifest = {redirects: {},urls: {stamphog: (): string => '/stamphog',+ stamphogRuns: (): string => '/stamphog/runs',+ stamphogDigests: (): string => '/stamphog/digests',stamphogCallback: (): string => '/stamphog/install/callback',},fileSystemTypes: {},diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 77b8453fa25a..841b52d4c067 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -51301,6 +51301,20 @@ export namespace Schemas {results: ReviewQueue[];}+ /**+ * * `self_driving` - SELF_DRIVING+ * * `label` - LABEL+ * * `all` - ALL+ */+ export type ReviewRunTriggerEnum = typeof ReviewRunTriggerEnum[keyof typeof ReviewRunTriggerEnum];+++ export const ReviewRunTriggerEnum = {+ SelfDriving: 'self_driving',+ Label: 'label',+ All: 'all',+ } as const;+/*** * `queued` - QUEUED* * `gated` - GATED@@ -51380,6 +51394,10 @@ export namespace Schemas {readonly pr_number: number;/** Full URL to the pull request on GitHub. */readonly pr_url: string;+ /** Pull request title as of the last webhook delivery applied. */+ readonly title: string;+ /** GitHub login of the pull request author. */+ readonly author_login: string;/** Commit SHA of the PR head at the time this run started. */readonly head_sha: string;/** Branch name of the PR head. */@@ -51389,6 +51407,12 @@ export namespace Schemas {* @nullable*/readonly delivery_id: string | null;+ /** What caused this run to exist: self-driving inbox provenance, the repo's trigger label, or the repo reviewing every PR event.+ *+ * * `self_driving` - SELF_DRIVING+ * * `label` - LABEL+ * * `all` - ALL */+ readonly trigger: ReviewRunTriggerEnum;/** Current stage of the review run's lifecycle.** * `queued` - QUEUED@@ -51413,6 +51437,21 @@ export namespace Schemas {readonly output: _ReviewOutputSummary;/** Error message if the run failed, blank otherwise. */readonly error: string;+ /**+ * ID of the GitHub review this run posted, null if it never posted one.+ * @nullable+ */+ readonly posted_review_id: number | null;+ /**+ * When this run's verdict reached GitHub, null if it never did.+ * @nullable+ */+ readonly verdict_posted_at: string | null;+ /**+ * When this run's GitHub approval was retracted because the head moved, null if it wasn't.+ * @nullable+ */+ readonly approval_dismissed_at: string | null;/** When the review run was created. */readonly created_at: string;/** When the review run was last updated. */@@ -91011,8 +91050,21 @@ export namespace Schemas {* Filter by review run status.*/status?: string;+ /**+ * Filter by what caused the run: self_driving, label, or all.+ */+ trigger?: StamphogReviewRunsListTrigger;};+ export type StamphogReviewRunsListTrigger = typeof StamphogReviewRunsListTrigger[keyof typeof StamphogReviewRunsListTrigger];+++ export const StamphogReviewRunsListTrigger = {+ All: 'all',+ Label: 'label',+ SelfDriving: 'self_driving',+ } as const;+export type StreamlitAppsListParams = {/*** Number of results to return per page.diff --git a/services/mcp/src/generated/stamphog/api.ts b/services/mcp/src/generated/stamphog/api.tsindex d793fba13487..30bce69eb4d4 100644--- a/services/mcp/src/generated/stamphog/api.ts+++ b/services/mcp/src/generated/stamphog/api.ts@@ -168,6 +168,10 @@ export const StamphogReviewRunsListQueryParams = /* @__PURE__ */ zod.object({pr_number: zod.number().optional().describe('Filter by pull request number.'),repository: zod.string().optional().describe("Filter by repository full name, e.g. 'PostHog\/posthog'."),status: zod.string().optional().describe('Filter by review run status.'),+ trigger: zod+ .enum(['all', 'label', 'self_driving'])+ .optional()+ .describe('Filter by what caused the run: self_driving, label, or all.'),})/**diff --git a/services/mcp/src/tools/generated/stamphog.ts b/services/mcp/src/tools/generated/stamphog.tsindex 395804f0d4a7..27b1bbe6ac87 100644--- a/services/mcp/src/tools/generated/stamphog.ts+++ b/services/mcp/src/tools/generated/stamphog.ts@@ -238,6 +238,7 @@ const stamphogReviewRunsList = (): ToolBase<pr_number: params.pr_number,repository: params.repository,status: params.status,+ trigger: params.trigger,},})const filtered = {