: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(signals): add self-driving UI for autostart switch and threshold (#71440)
Vojta Bartoš1ef3b4928b1f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b1fe15f54a2b..6e98151e4fe2 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6039,9 +6039,9 @@ snapshots:scenes-app-inbox-pullrequestdiffview--truncated--light:hash: v1.k794b7964.c8211a05cd4404a003460d2c4abe79fb078edd5c7801422dbb3a5c55cc50f6a1.R85Q2EEe3EteBgaslGBlB4Vp7AdPgMstb0whb50OXycscenes-app-inbox-scene--empty--dark:- hash: v1.k794b7964.0aafc7b733bbc111b069cec4a54d0aefb3178d313438f1ead34e674c90b25e3e.-QT6yl-ujsJL_nvqzzk-gZTwKMv0AREbT4tHngwBB-Q+ hash: v1.k794b7964.8f143021c1c40d58ddae66405342d7ecf775a3b8c0a9ad996481325db55b5497.xdG0HoCq82l8pSWAsoRnBRUXf4fr_BtsJDkizyJsUOcscenes-app-inbox-scene--empty--light:- hash: v1.k794b7964.9ac628482107f92f19d4440301e8dad66f38a9df250d5321f6544733a697e2b6.XhpQBR1sBJS3CaCwS02LNxOUFfI6NqlI6BG3vvWWIp8+ hash: v1.k794b7964.be3d92c919f54e31021dfec9f1c4d45ebe28e3bd62b4c34cb0c977e3416052d3.sBpfA6AgbG-fI0JQuWMKD0QL0hN_RMTfxWls1LRzoUgscenes-app-inbox-scene--inbox--dark:hash: v1.k794b7964.7ade0c95519de555691da00b03aaa9aeea1ba0c32762354222d23676099ea0da.OmzLebXW_1EJ-lRFDeh7flQ6cl3OqskJfVarjDu4FQcscenes-app-inbox-scene--inbox--light:diff --git a/frontend/src/scenes/inbox/InboxScene.stories.tsx b/frontend/src/scenes/inbox/InboxScene.stories.tsxindex e1ef332811b9..5c97a752e3dd 100644--- a/frontend/src/scenes/inbox/InboxScene.stories.tsx+++ b/frontend/src/scenes/inbox/InboxScene.stories.tsx@@ -11,6 +11,7 @@ import {mockSignals,mockSourceConfigs,mockTask,+ mockTeamConfig,} from './__mocks__/inboxMocks'import { InboxScene } from './InboxScene'@@ -35,6 +36,7 @@ const sceneMocks = mswDecorator({],'/api/projects/:id/tasks/:taskId': (req) => [200, mockTask(req.params.taskId as string)],'/api/projects/:id/signals/source_configs': () => [200, mockSourceConfigs],+ '/api/projects/:id/signals/config': () => [200, mockTeamConfig],'/api/projects/:id/signals/scout/configs': () => [200, []],'/api/projects/:id/signals/scout/runs': () => [200, []],'/api/projects/:id/external_data_sources': () => [200, { results: [], count: 0 }],diff --git a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts b/frontend/src/scenes/inbox/__mocks__/inboxMocks.tsindex c9f407f2b771..0a433aecbc92 100644--- a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts+++ b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts@@ -556,3 +556,13 @@ export const mockAutonomy = {slack_notification_channel: null,slack_notification_min_priority: null,}++export const mockTeamConfig = {+ id: 'team-cfg-1',+ autostart_enabled: true,+ default_autostart_priority: 'P2',+ default_slack_notification_channel: null,+ autostart_base_branches: {},+ created_at: BASE_DATE,+ updated_at: BASE_DATE,+}diff --git a/frontend/src/scenes/inbox/components/config/ConfigCardHeader.tsx b/frontend/src/scenes/inbox/components/config/ConfigCardHeader.tsxnew file mode 100644index 000000000000..8934cd0f0c36--- /dev/null+++ b/frontend/src/scenes/inbox/components/config/ConfigCardHeader.tsx@@ -0,0 +1,22 @@+import { ReactNode } from 'react'++/** Icon + title + description header shared by the agent-setup config cards. Pass the icon pre-sized (size-5). */+export function ConfigCardHeader({+ icon,+ title,+ description,+}: {+ icon: ReactNode+ title: string+ description: ReactNode+}): JSX.Element {+ return (+ <div className="flex items-start gap-3 min-w-0">+ {icon}+ <div className="min-w-0">+ <div className="font-medium text-sm text-default">{title}</div>+ <p className="text-xs text-secondary mt-0.5 mb-0 max-w-xl">{description}</p>+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/inbox/components/config/SelfDrivingSection.tsx b/frontend/src/scenes/inbox/components/config/SelfDrivingSection.tsxnew file mode 100644index 000000000000..c64579cb856f--- /dev/null+++ b/frontend/src/scenes/inbox/components/config/SelfDrivingSection.tsx@@ -0,0 +1,77 @@+import { useActions, useValues } from 'kea'++import { IconRocket } from '@posthog/icons'+import { LemonSegmentedButton, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'++import { signalTeamConfigLogic } from '../../logics/signalTeamConfigLogic'+import { PRIORITY_THRESHOLD_OPTIONS, SignalReportPriority } from '../../types'++/** Compact segmented-control label per priority. P4 (the lowest bar) reads as "All". */+const THRESHOLD_SEGMENT_LABELS: Record<SignalReportPriority, string> = {+ P0: 'P0',+ P1: 'P1+',+ P2: 'P2+',+ P3: 'P3+',+ P4: 'All',+}+/** Segments derived from the shared priority list, so the value set and order stay single-sourced. */+const THRESHOLD_SEGMENTS = PRIORITY_THRESHOLD_OPTIONS.map(({ value }) => ({+ value,+ label: THRESHOLD_SEGMENT_LABELS[value],+}))++/**+ * Team-wide PR-generation control, backed by `autostart_enabled` and `default_autostart_priority`+ * on `signalTeamConfigLogic`. The inline switch is the master opt-out for autonomous inbox PRs;+ * reports keep generating and notifying either way. The threshold is the team default; a teammate's+ * personal threshold takes precedence for reports suggesting them as reviewer.+ *+ * A standalone card rather than a `SetupWidgetCard` because it hosts inline controls (the switch and+ * threshold) that can't live inside that card's single button/link wrapper.+ */+export function SelfDrivingSection(): JSX.Element {+ const { teamConfig, teamConfigLoading, autostartEnabled, defaultAutostartPriority } =+ useValues(signalTeamConfigLogic)+ const { patchTeamConfig } = useActions(signalTeamConfigLogic)++ if (teamConfigLoading && teamConfig === null) {+ return <LemonSkeleton className="h-20 w-full rounded" />+ }++ return (+ <div className="flex flex-col rounded border border-primary bg-surface-primary overflow-hidden">+ <div className="flex items-start gap-2 px-2.5 py-2">+ <span className="flex size-7 shrink-0 items-center justify-center rounded bg-surface-secondary text-default [&_svg]:size-4">+ <IconRocket />+ </span>+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">+ <div className="flex items-center justify-between gap-2">+ <span className="text-[13px] font-semibold text-default">PR generation</span>+ <LemonSwitch+ checked={autostartEnabled}+ onChange={(enabled) => patchTeamConfig({ autostart_enabled: enabled })}+ aria-label="Generate PRs for actionable reports automatically"+ />+ </div>+ <p className="text-xs text-tertiary leading-snug mb-0">Agents open PRs for actionable reports.</p>+ </div>+ </div>++ <div className="border-t border-primary bg-surface-secondary px-2.5 py-1.5">+ {autostartEnabled ? (+ <div className="flex items-center justify-between gap-2">+ <span className="text-xs text-secondary shrink-0">Threshold</span>+ <LemonSegmentedButton+ size="xsmall"+ value={defaultAutostartPriority}+ options={THRESHOLD_SEGMENTS}+ onChange={(next) => patchTeamConfig({ default_autostart_priority: next })}+ />+ </div>+ ) : (+ <p className="text-xs text-secondary mb-0">Reports still arrive and notify your team.</p>+ )}+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/inbox/components/config/SlackNotificationsSection.tsx b/frontend/src/scenes/inbox/components/config/SlackNotificationsSection.tsxindex 6643dfa045ee..fbfc19af4451 100644--- a/frontend/src/scenes/inbox/components/config/SlackNotificationsSection.tsx+++ b/frontend/src/scenes/inbox/components/config/SlackNotificationsSection.tsx@@ -13,30 +13,25 @@ import { IntegrationType } from '~/types'import { signalTeamConfigLogic } from '../../logics/signalTeamConfigLogic'import { userAutonomyLogic } from '../../logics/userAutonomyLogic'-import { SignalReportPriority } from '../../types'+import { PRIORITY_THRESHOLD_OPTIONS, SignalReportPriority } from '../../types'+import { ConfigCardHeader } from './ConfigCardHeader'const NOTIFY_ALL_VALUE = '__all__'/** Minimum report priority that triggers a Slack ping. "All priorities" maps to a null min-priority. */const MIN_PRIORITY_OPTIONS: { value: SignalReportPriority | typeof NOTIFY_ALL_VALUE; label: string }[] = [{ value: NOTIFY_ALL_VALUE, label: 'All priorities' },- { value: 'P0', label: 'P0 only' },- { value: 'P1', label: 'P1 and above' },- { value: 'P2', label: 'P2 and above' },- { value: 'P3', label: 'P3 and above' },- { value: 'P4', label: 'P4 and above' },+ ...PRIORITY_THRESHOLD_OPTIONS,]/** Icon + title + description header shared by all the Slack cards in this section. */function SlackCardHeader({ title, description }: { title: string; description: ReactNode }): JSX.Element {return (- <div className="flex items-start gap-3 min-w-0">- <IconSlack className="size-5 shrink-0 mt-0.5 grayscale" />- <div className="min-w-0">- <div className="font-medium text-sm text-default">{title}</div>- <p className="text-xs text-secondary mt-0.5 mb-0 max-w-xl">{description}</p>- </div>- </div>+ <ConfigCardHeader+ icon={<IconSlack className="size-5 shrink-0 mt-0.5 grayscale" />}+ title={title}+ description={description}+ />)}diff --git a/frontend/src/scenes/inbox/components/shell/AgentSetupColumn.tsx b/frontend/src/scenes/inbox/components/shell/AgentSetupColumn.tsxindex c1e45f5aab0c..e461191e40c2 100644--- a/frontend/src/scenes/inbox/components/shell/AgentSetupColumn.tsx+++ b/frontend/src/scenes/inbox/components/shell/AgentSetupColumn.tsx@@ -18,6 +18,7 @@ import { signalTeamConfigLogic } from '../../logics/signalTeamConfigLogic'import { userAutonomyLogic } from '../../logics/userAutonomyLogic'import { signalSourcesLogic } from '../../signalSourcesLogic'import { ScoutsFleetSection } from '../config/scouts/ScoutsFleetSection'+import { SelfDrivingSection } from '../config/SelfDrivingSection'import { SignalSourcesPanel } from '../config/SignalSourcesPanel'import { SlackNotificationsSection } from '../config/SlackNotificationsSection'import { AgentSetupModalKey, agentSetupModalLogic } from './agentSetupModalLogic'@@ -347,6 +348,7 @@ export function AgentSetupColumn({ layout }: { layout: 'rail' | 'stacked' }): JS<SetupSection title="Agents"><SignalSourcesWidget /><ScoutTroopWidget />+ <SelfDrivingSection /></SetupSection><SetupSection title="Connections"><CodeAccessWidget />diff --git a/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts b/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.tsindex 8cdd4362d61a..113498b78de6 100644--- a/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts+++ b/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts@@ -1,14 +1,16 @@-import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers } from 'kea'+import { MakeLogicType, actions, afterMount, isBreakpoint, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'import { lemonToast } from '@posthog/lemon-ui'import api from 'lib/api'-import type { SignalTeamConfig } from '../types'+import type { SignalReportPriority, SignalTeamConfig } from '../types'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface signalTeamConfigLogicValues {+ autostartEnabled: boolean+ defaultAutostartPriority: SignalReportPriorityteamConfig: SignalTeamConfig | nullteamConfigLoading: boolean}@@ -35,7 +37,20 @@ export interface signalTeamConfigLogicActions {}}-export type signalTeamConfigLogicType = MakeLogicType<signalTeamConfigLogicValues, signalTeamConfigLogicActions>+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface signalTeamConfigLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ autostartEnabled: (teamConfig: SignalTeamConfig | null) => boolean+ defaultAutostartPriority: (teamConfig: SignalTeamConfig | null) => SignalReportPriority+ }+}++export type signalTeamConfigLogicType = MakeLogicType<+ signalTeamConfigLogicValues,+ signalTeamConfigLogicActions,+ Record<string, any>,+ signalTeamConfigLogicMeta+>/*** Team-level Self-driving config (singleton per team). Wraps the@@ -71,12 +86,31 @@ export const signalTeamConfigLogic = kea<signalTeamConfigLogicType>([patchTeamConfig: (state, { patch }) => (state ? { ...state, ...patch } : state),},}),+ selectors({+ // Master switch for autonomous inbox PRs: only an explicit false disables+ // auto-start, so a team that never touched the setting stays on.+ autostartEnabled: [+ (s) => [s.teamConfig],+ (teamConfig: SignalTeamConfig | null): boolean => teamConfig?.autostart_enabled !== false,+ ],+ defaultAutostartPriority: [+ (s) => [s.teamConfig],+ (teamConfig: SignalTeamConfig | null): SignalReportPriority =>+ teamConfig?.default_autostart_priority ?? 'P4',+ ],+ }),listeners(({ actions }) => ({- patchTeamConfig: async ({ patch }) => {+ patchTeamConfig: async ({ patch }, breakpoint) => {try {const config = await api.signalTeamConfig.update(patch)+ // A newer patch was dispatched while this one was in flight — drop the+ // stale response so out-of-order arrivals can't overwrite the latest value.+ breakpoint()actions.loadTeamConfigSuccess(config)} catch (error: any) {+ if (isBreakpoint(error)) {+ throw error+ }lemonToast.error(error?.detail ?? error?.message ?? 'Failed to update team self-driving settings')// Resync so the optimistic value doesn't linger after a failed update.actions.loadTeamConfig()diff --git a/frontend/src/scenes/inbox/types.ts b/frontend/src/scenes/inbox/types.tsindex 4f297787425b..e2c6cfa3b12b 100644--- a/frontend/src/scenes/inbox/types.ts+++ b/frontend/src/scenes/inbox/types.ts@@ -37,6 +37,15 @@ export interface EnrichedReviewer {/** P0 (highest) – P4 (lowest). Mirrors desktop `SignalReportPriority`. */export type SignalReportPriority = 'P0' | 'P1' | 'P2' | 'P3' | 'P4'+/** Threshold options over SignalReportPriority, strictest first. Shared by the auto-start and Slack min-priority selects. */+export const PRIORITY_THRESHOLD_OPTIONS: { value: SignalReportPriority; label: string }[] = [+ { value: 'P0', label: 'P0 only' },+ { value: 'P1', label: 'P1 and above' },+ { value: 'P2', label: 'P2 and above' },+ { value: 'P3', label: 'P3 and above' },+ { value: 'P4', label: 'P4 and above' },+]+/** Actionability judgment outcome. Mirrors desktop `SignalReportActionability`. */export type SignalReportActionability = 'immediately_actionable' | 'requires_human_input' | 'not_actionable'@@ -239,7 +248,9 @@ export interface SignalUserAutonomyConfig {export interface SignalTeamConfig {id?: string- /** Team-wide default PR auto-start threshold. null = never auto-start by default. */+ /** Master switch for autonomous inbox PRs. Only an explicit false disables auto-start; null (never set) leaves it on. */+ autostart_enabled?: boolean | null+ /** Team-wide default PR auto-start threshold (P0–P4, non-null from the API). "Never" is expressed via autostart_enabled instead. */default_autostart_priority: SignalReportPriority | null/** Default Slack channel for this team's inbox notifications. */default_slack_notification_channel?: string | null