: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): steering rules form on inbox source cards (#83502)
Andrew Maguireab0c376a2fe6
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 2facae4bacc0..53ff565e719a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6541,33 +6541,41 @@ snapshots:scenes-app-inbox-scoutmcpserverspicker--scout-settings-variant--light:hash: v1.k794b7964.2f1013abc412adb4544bca6a00209d3051c46969db69d4242ab201ecf5d189f3.YVfbrzpaRzPwuCbeFXmaVOLla0fvhHmAm1CkuaKWCLIscenes-app-inbox-signalsourcespanel--armed-but-tools-off--dark:- hash: v1.k794b7964.6747f0e7e69605654f1d01460a103c36935d8f6b03cc46d5ccb553d5537451e8.0RmRYEmcbsdEoazRnDeW87aVR0xoagYioC-rco63co4+ hash: v1.k794b7964.ece1c0e16e4970e264f483296aaee56c6e8f271ffd8149c414ae314b1a72c866.kfMXUu0-mbkWvrPMsm0GPuPwIdcSt9t7DfNYHby-X0Iscenes-app-inbox-signalsourcespanel--armed-but-tools-off--light:- hash: v1.k794b7964.09478dcd17ef5eca59d8ca0fd2f743cc6567f7a1bf0a0b1696c8af470c455765.PWv_h7qQqQncL_sclGpghIsiUSrBZH2qF-heJBPFsak+ hash: v1.k794b7964.7d87234546b35bdbf3b0cb48f984aa9ebba423388b09d2727e8397a7d4a09f1a.0PFE3ThqhOUVvISjhBa51KJKAYhP6w-W03dskB11oUgscenes-app-inbox-signalsourcespanel--arming-blocked--dark:- hash: v1.k794b7964.77eec4902b872f0a9e099844c9d546fca76269183de75bb2f81dedbea8231692.HzFIcX0ZhPWVf6Ilrt9Uwii07Ir1PYLpagaBIvwTpXc+ hash: v1.k794b7964.b198639b11e758bab18165f81f9c4ea2ec330192a9294bbc5cedb9beb56f2b97.fGVGYbxR7jztc-SOpgqlsGa8M5KM4X80uwKSMGQbouwscenes-app-inbox-signalsourcespanel--arming-blocked--light:- hash: v1.k794b7964.55f973b3d21ebf7e25e20a8b95bd70648abd5890fa472e381cf9b41bdd05ebe0.-VvwSfM-FXhabZd47zV7E11f0C9FMt0zrW6wuOKVkiM+ hash: v1.k794b7964.6d6d67eeca4a12800dd28be02715472cea370dd7b8e506c74f3722ae98020b31.PvhDuOrtKkLXP3VLift16E-kkVTKt7IEkpZokgyDK1Ascenes-app-inbox-signalsourcespanel--event-definitions-unavailable--dark:- hash: v1.k794b7964.49d77d5da449f14d7d5ac3dedd952f1db0027138a3cb1f1ebbcb740e290cdad9.a6y-0D3q4ixuUQr4jlqaFDdnUA3Z0sGzJzv46wmbPNg+ hash: v1.k794b7964.28d04b89b0825769c9c2cb617fcdb0c5a1371d398da50a8ebd8cdfdf0e01164a.P3b-y2FIqJvXfMBwXfYLteMApq02-T0AKwFRbwfIQa0scenes-app-inbox-signalsourcespanel--event-definitions-unavailable--light:- hash: v1.k794b7964.a34bc31c56796ca2ad8883ebdc34df811f475def77e2855015d96d3ecbc86a84.aiy32uolR6W1o915BKzGg1vxFQgX2QYAsj1HLtlBSME+ hash: v1.k794b7964.26f63405e53830709106738ad58a8310c0b387524c3e71cc80622c02f12b01fb.4Kx1LTcdgaVFz-A9VXyKZGfxhz5EsqplT2WE1H3M4UIscenes-app-inbox-signalsourcespanel--everything-healthy--dark:- hash: v1.k794b7964.44df353cdbb0659a024d5a8ac22101d508bddedb029ee6abd66b5fef85dec1d4.kbUJrXu5MzaCudWv5B5N0lyJQ8Pj7mpwCX7zwlm7U4k+ hash: v1.k794b7964.04173f7032d97b72af91f2253666ab1d1e57ea77b354ac2eaad25526e0f66a9e.ksK911TZrOBifMlKveU0GC6gOQVw7PwN6sQJ9pxFVGYscenes-app-inbox-signalsourcespanel--everything-healthy--light:- hash: v1.k794b7964.da01cfb8b29b94c98e473e5a1c9b0cd23a894133a49e06b0f58a309efe61249e.m7YYe9eopd42q0soUqtbxpEafkikgrw23-6TxA1TyDQ+ hash: v1.k794b7964.4566e55dc26b11196f1dd8d55df92b6be69df45627e916ffffc43d82974e930c.8MRMfKTb6XaJ-1sBZD277M3txzYi8sdP5ZMfbpClGHQscenes-app-inbox-signalsourcespanel--playground--dark:- hash: v1.k794b7964.e625ebc1278bfb5b0a632eceee8af8ecfb9a3291b59113ae83e4cd6dc7e058ec.5hpxYodVx0pNTY4vVAGgXxDBstLhSX1inisoXXTbSO0+ hash: v1.k794b7964.f897b9dd52eae8ad29d04c46ba689c27f47602692b2144b0e75a97ef34fae702.AfAhw2Op6ddRNOGiTznSP6Wn5nrrM4iwiHZ-AaR3IRoscenes-app-inbox-signalsourcespanel--playground--light:- hash: v1.k794b7964.22974fb177402f5d8a0f4932f4fa1bccf3bf9b6599fc3509a9e1aef016da050d.olKbQ6bu27HnLBU5pYoNzLNLRfPRw2PGcsU0hTNNj8g+ hash: v1.k794b7964.13df8c7b214cfd00e7eba5fea6da33f833ac202b7d3a2ebbadd331440bb9f97a.xHWi11Tx7CmT7o1dwJvUjX1q6A5oFMQMHGwPfEi2elgscenes-app-inbox-signalsourcespanel--server-side-exceptions-only--dark:- hash: v1.k794b7964.e625ebc1278bfb5b0a632eceee8af8ecfb9a3291b59113ae83e4cd6dc7e058ec.3lmRhERqp25v4IsVCtNTVZr6Cw1OE9fxNpEEegGXFcc+ hash: v1.k794b7964.f897b9dd52eae8ad29d04c46ba689c27f47602692b2144b0e75a97ef34fae702.qixI7HhZb5rWIcR5HzZB9i8SidHDxo9eBF_dsAFvSewscenes-app-inbox-signalsourcespanel--server-side-exceptions-only--light:- hash: v1.k794b7964.22974fb177402f5d8a0f4932f4fa1bccf3bf9b6599fc3509a9e1aef016da050d.-sF41j5D471cLEZ2XTWH5vPxeeL0Ncb-j_4RUVa0FFI+ hash: v1.k794b7964.13df8c7b214cfd00e7eba5fea6da33f833ac202b7d3a2ebbadd331440bb9f97a.SL1Tzb4sMCHF1TQHfGCWGJYsBO88sT0dkLTlU88JrvQscenes-app-inbox-signalsourcespanel--tools-on-no-recent-data--dark:- hash: v1.k794b7964.6520781eb2e2bf411a83cd78a25b13b7e222e31d52584d6fa8427a6905117757.Zdlz_WiWEU2EjHNjO27QzC8yd168RuPToMNSiIq1VrA+ hash: v1.k794b7964.748be85b9907181d7eb082c40e4d4f93429073c22a34fd3ad19f010006856b4d.m6AmUOQ3eZ_Le5wuOhR7RCAT_xVrzvZJSHptyYmtTpMscenes-app-inbox-signalsourcespanel--tools-on-no-recent-data--light:- hash: v1.k794b7964.5945b2460886f8db3e09a08c6edf74faeda0730487f2bef9ccf9825f5faae281.su94KwLO8C9OBu4Jdwl9HMaRG4pI78QWeDwWlFcWkzU+ hash: v1.k794b7964.ace77adbc25963a6ba9f41c77744f726165855b31c0e4486bc5fbbeeec55250f.vWRUFUczQF3fmjvF_LizkGQaBK-ddzgEIjTB8sJEFro+ scenes-app-inbox-sourcesteeringmodal--no-rules-yet--dark:+ hash: v1.k794b7964.6f8f050084142d4b24339c3bae76ea79b7c9ee2f4117a1b30789c5fcf19d7f19.15Qm_zKixrOfhwvrNG3ppjc95M8ywNgUCO5kC776Zto+ scenes-app-inbox-sourcesteeringmodal--no-rules-yet--light:+ hash: v1.k794b7964.528d9648d48be5dfd57fbe8a9bc73e77d068616a6494007467140a1c1c741699.UYbkqgjLUPZ5QDhX34y25DiD29mqD2Nh67sfdIhoO20+ scenes-app-inbox-sourcesteeringmodal--rules-set--dark:+ hash: v1.k794b7964.eee5b962d9e849371de058017e32ef513268ec4ddf928057d9e6de6acf263e7a._q88iOBj8aTgXKOVWzF3c3ej0TrFuuTe7XwczbfAyKA+ scenes-app-inbox-sourcesteeringmodal--rules-set--light:+ hash: v1.k794b7964.385738bfcd292440eaa22250862067de71f5e2b2b09c77014c89fd47f616c2e8.0E8wRwNii_FGTwEogE_RA51a_JU-8-dFtH41VmbGOKgscenes-app-inbox-tabs--pull-requests--dark:hash: v1.k794b7964.474d8e744637e08afd4bb7540f0f5dafd6a79342c2f547188cb436b55f9ef8e7.PiyD1Zkhkot-_DKLU3W0T5uA7rvpTUTn5bKChCa3AV4scenes-app-inbox-tabs--pull-requests--light:diff --git a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsxindex 474c45380e18..0dc1827414e5 100644--- a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx+++ b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx@@ -1,4 +1,5 @@import clsx from 'clsx'+import { useId } from 'react'import { Tooltip } from 'lib/lemon-ui/Tooltip'@@ -18,6 +19,8 @@ export interface LemonRadioProps<T extends React.Key> {className?: stringradioPosition?: 'center' | 'top'orientation?: 'vertical' | 'horizontal'+ /** Accessible name for the radio group, announced by screen readers. */+ 'aria-label'?: string}/** Single choice radio. */@@ -28,9 +31,14 @@ export function LemonRadio<T extends React.Key>({className,radioPosition,orientation = 'vertical',+ 'aria-label': ariaLabel,}: LemonRadioProps<T>): JSX.Element {+ // A shared name makes the inputs one native radio group, so arrow keys move between them.+ const groupName = useId()return (<div+ role="radiogroup"+ aria-label={ariaLabel}className={clsx('flex font-medium',orientation === 'vertical' ? 'flex-col gap-2' : 'flex-row gap-4',@@ -55,6 +63,7 @@ export function LemonRadio<T extends React.Key>({<inputtype="radio"className="cursor-pointer"+ name={groupName}checked={value === selectedValue}value={String(value)}onChange={() => {diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.tsxindex c5db845ef15e..e1b366a1a727 100644--- a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { memo, useCallback, useMemo, useState } from 'react'-import { IconArrowUpRight, IconChevronRight, IconPlus } from '@posthog/icons'+import { IconArrowUpRight, IconChevronRight, IconGear, IconPlus } from '@posthog/icons'import {LemonButton,LemonInput,@@ -18,11 +18,13 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import type { SyncStatusEnumApi } from 'products/engineering_analytics/frontend/generated/api.schemas'+import { sourceSteeringIsSet } from '../../logics/sourceSteeringModalLogic'import { signalSourcesLogic } from '../../signalSourcesLogic'import type { SourceToolDataStatus, SourceToolStatus } from '../../signalSourcesLogic'import { SignalSourceConfig, SignalSourceConfigStatus, SignalSourceType } from '../../types'import { getSourceProductMeta } from '../badges/sourceProductIcons'import { AGENT_ROSTER_GROUPS, AgentRosterDefinition, AgentRosterSource } from './agentRosterMeta'+import { SourceSteeringModal } from './SourceSteeringModal'type AgentRosterStatus = 'standby' | 'watching' | 'syncing' | 'sync_failed'@@ -92,6 +94,8 @@ interface AgentSourceState {entities: RosterEntity[]/** The entity list is still loading, so the count would read as a wrong zero. */entitiesLoading: boolean+ /** The source's `SignalSourceConfig` row, for sources that persist one. Steering writes to it. */+ sourceConfig: SignalSourceConfig | null}function AgentIcon({ source }: { source: AgentRosterDefinition }): JSX.Element | null {@@ -204,6 +208,8 @@ interface ExpansionProps {onEnableTool: (tool: SourceToolStatus) => voidonToggleEntity: (entityId: string) => voidonConfigureFilters?: () => void+ /** Opens the steering form. Only set for steerable sources that are on with a persisted config row. */+ onSteer?: () => voidonRetryData: () => void}@@ -271,6 +277,7 @@ function Expansion({onEnableTool,onToggleEntity,onConfigureFilters,+ onSteer,onRetryData,}: ExpansionProps): JSX.Element {const [filter, setFilter] = useState('')@@ -323,6 +330,27 @@ function Expansion({</div>)}+ {onSteer && (+ <div className="flex items-center gap-2">+ <span className="text-xs text-secondary">+ {state.sourceConfig && sourceSteeringIsSet(state.sourceConfig)+ ? 'Steering rules are on for this source.'+ : 'Tell this source what matters and what to skip.'}+ </span>+ <LemonButton+ type="secondary"+ size="xsmall"+ icon={<IconGear />}+ onClick={onSteer}+ data-attr="signal-source-steering-open"+ >+ {state.sourceConfig && sourceSteeringIsSet(state.sourceConfig)+ ? 'Edit steering rules'+ : 'Add steering rules'}+ </LemonButton>+ </div>+ )}+{state.entitiesLoading ? (<LemonSkeleton className="h-16 w-full" />) : entities.length > 0 ? (@@ -408,6 +436,7 @@ interface AgentRowProps {onToggleEntity: (source: AgentRosterSource, entityId: string) => voidonEnableTool: (tool: SourceToolStatus) => voidonConfigureFilters?: () => void+ onSteer?: () => voidonRetryData: () => void}@@ -422,6 +451,7 @@ const AgentRow = memo(function AgentRow({onToggleEntity,onEnableTool,onConfigureFilters,+ onSteer,onRetryData,}: AgentRowProps): JSX.Element {const { armed, loading, requiresSetup, syncStatus, entities } = state@@ -494,8 +524,21 @@ const AgentRow = memo(function AgentRow({/>) : null}</div>- <IconChevronRight- className={`shrink-0 text-muted transition-transform ${expanded ? 'rotate-90' : ''}`}+ {/* A real button inside the clickable row, so keyboard users can reach the+ expansion (and the controls inside it, like steering). */}+ <LemonButton+ size="xsmall"+ icon={+ <IconChevronRight+ className={`shrink-0 text-muted transition-transform ${expanded ? 'rotate-90' : ''}`}+ />+ }+ onClick={(e) => {+ e.stopPropagation()+ onExpand()+ }}+ aria-expanded={expanded}+ aria-label={`${expanded ? 'Collapse' : 'Expand'} ${agent.label}`}/></div>{expanded && (@@ -507,6 +550,7 @@ const AgentRow = memo(function AgentRow({onEnableTool={onEnableTool}onToggleEntity={(entityId) => onToggleEntity(agent.source, entityId)}onConfigureFilters={onConfigureFilters}+ onSteer={onSteer}onRetryData={onRetryData}/>)}@@ -558,6 +602,8 @@ export function AgentsRoster(): JSX.Element {} = useActions(signalSourcesLogic)const { featureFlags } = useValues(featureFlagLogic)const [expandedSource, setExpandedSource] = useState<AgentRosterSource | null>(null)+ // Which modal is open is a view concern; the form and save live in sourceSteeringModalLogic.+ const [steeringTarget, setSteeringTarget] = useState<{ config: SignalSourceConfig; label: string } | null>(null)const scannerEntities = useMemo((): RosterEntity[] =>@@ -584,7 +630,11 @@ export function AgentsRoster(): JSX.Element {const stateFor = useCallback((source: AgentRosterSource): AgentSourceState => {- const base = { entities: [] as RosterEntity[], entitiesLoading: false }+ const base = {+ entities: [] as RosterEntity[],+ entitiesLoading: false,+ sourceConfig: null as SignalSourceConfig | null,+ }const dwState = (config: SignalSourceConfig | null, loading: boolean): AgentSourceState => ({...base,armed: !!config?.enabled,@@ -592,6 +642,7 @@ export function AgentsRoster(): JSX.Element {// No config row yet → the source has never been connected; surface a Connect button.requiresSetup: config === null,syncStatus: config?.status,+ sourceConfig: config,})switch (source) {case 'error_tracking':@@ -612,6 +663,7 @@ export function AgentsRoster(): JSX.Element {loading: isConversationsToggling,requiresSetup: false,syncStatus: conversationsConfig?.status,+ sourceConfig: conversationsConfig,}case 'replay_vision':return {@@ -770,29 +822,55 @@ export function AgentsRoster(): JSX.Element {<div key={group.label} className="flex flex-col gap-1"><span className="text-xs font-medium text-muted">{group.label}</span><div className="divide-y divide-primary overflow-hidden rounded border border-primary">- {group.agents.map((agent) => (- <AgentRow- key={agent.source}- agent={agent}- state={stateFor(agent.source)}- tool={toolStatusBySource[agent.source]}- expanded={expandedSource === agent.source}- enablingTool={- !!enablingTool && enablingTool === toolStatusBySource[agent.source]?.enablement- }- onExpand={() =>- setExpandedSource((current) => (current === agent.source ? null : agent.source))- }- onToggle={handleToggle}- onToggleEntity={handleToggleEntity}- onEnableTool={(tool) => tool.enablement && enableSourceTool(tool.enablement)}- onConfigureFilters={undefined}- onRetryData={loadToolDataEvents}- />- ))}+ {group.agents.map((agent) => {+ const state = stateFor(agent.source)+ // Steering needs a persisted row to write to, so optimistic `new_`+ // placeholder rows wait until the reload lands. Disabled sources keep+ // the control: enabling starts a sync immediately, so rules must be+ // settable before the first sync runs.+ const steeringConfig =+ agent.steerable && state.sourceConfig && !state.sourceConfig.id.startsWith('new_')+ ? state.sourceConfig+ : null+ return (+ <AgentRow+ key={agent.source}+ agent={agent}+ state={state}+ tool={toolStatusBySource[agent.source]}+ expanded={expandedSource === agent.source}+ enablingTool={+ !!enablingTool && enablingTool === toolStatusBySource[agent.source]?.enablement+ }+ onExpand={() =>+ setExpandedSource((current) => (current === agent.source ? null : agent.source))+ }+ onToggle={handleToggle}+ onToggleEntity={handleToggleEntity}+ onEnableTool={(tool) => tool.enablement && enableSourceTool(tool.enablement)}+ onConfigureFilters={undefined}+ onSteer={+ steeringConfig+ ? () => setSteeringTarget({ config: steeringConfig, label: agent.label })+ : undefined+ }+ onRetryData={loadToolDataEvents}+ />+ )+ })}</div></div>))}++ {/* Remounts per target (the key), so the form defaults re-derive from that source's config. */}+ {steeringTarget && (+ <SourceSteeringModal+ key={steeringTarget.config.id}+ sourceConfig={steeringTarget.config}+ sourceLabel={steeringTarget.label}+ onClose={() => setSteeringTarget(null)}+ />+ )}</div>)}diff --git a/products/signals/frontend/inbox/components/config/SourceSteeringModal.stories.tsx b/products/signals/frontend/inbox/components/config/SourceSteeringModal.stories.tsxnew file mode 100644index 000000000000..8928528db1b1--- /dev/null+++ b/products/signals/frontend/inbox/components/config/SourceSteeringModal.stories.tsx@@ -0,0 +1,54 @@+import type { Meta, StoryObj } from '@storybook/react'++import { SignalSourceConfig, SignalSourceProduct, SignalSourceType } from '../../types'+import { SourceSteeringModal } from './SourceSteeringModal'++function sourceConfig(config: Record<string, any>): SignalSourceConfig {+ return {+ id: 'config-github-issue',+ source_product: SignalSourceProduct.Github,+ source_type: SignalSourceType.Issue,+ enabled: true,+ config,+ created_at: '2024-03-20T00:00:00Z',+ updated_at: '2024-03-20T00:00:00Z',+ status: null,+ }+}++interface HarnessProps {+ config: Record<string, any>+}++function ModalHarness({ config }: HarnessProps): JSX.Element {+ return <SourceSteeringModal sourceConfig={sourceConfig(config)} sourceLabel="GitHub issues" onClose={() => {}} />+}++const meta: Meta<typeof ModalHarness> = {+ title: 'Scenes-App/Inbox/SourceSteeringModal',+ component: ModalHarness,+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2024-03-20',+ testOptions: { waitForSelector: '[data-attr="signal-source-steering-rules"]' },+ },+}+export default meta++type Story = StoryObj<typeof ModalHarness>++/** First open: no rules yet, blocklist posture selected. */+export const NoRulesYet: Story = {+ args: { config: {} },+}++/** Editing saved rules with the allowlist posture on. */+export const RulesSet: Story = {+ args: {+ config: {+ steering: 'Ignore issues labeled chore or internal. Anything mentioning billing is always actionable.',+ default_not_actionable: true,+ },+ },+}diff --git a/products/signals/frontend/inbox/components/config/SourceSteeringModal.tsx b/products/signals/frontend/inbox/components/config/SourceSteeringModal.tsxnew file mode 100644index 000000000000..c868d3a979c5--- /dev/null+++ b/products/signals/frontend/inbox/components/config/SourceSteeringModal.tsx@@ -0,0 +1,124 @@+import { useValues } from 'kea'+import { Form } from 'kea-forms'+import { useId } from 'react'++import { LemonButton, LemonModal, LemonTextArea } from '@posthog/lemon-ui'++import { LemonField } from 'lib/lemon-ui/LemonField'+import { LemonRadio } from 'lib/lemon-ui/LemonRadio'++import { SourceSteeringModalLogicProps, sourceSteeringModalLogic } from '../../logics/sourceSteeringModalLogic'+import { SOURCE_STEERING_MAX_LENGTH, SignalSourceConfig } from '../../types'++// LemonRadio keys must be React keys, so the boolean `default_not_actionable` postures get names.+const LENIENT = 'lenient'+const STRICT = 'strict'++export interface SourceSteeringModalProps {+ sourceConfig: SignalSourceConfig+ /** The roster label of the source being steered, for the modal title. */+ sourceLabel: string+ onClose: () => void+}++export function SourceSteeringModal({ sourceConfig, sourceLabel, onClose }: SourceSteeringModalProps): JSX.Element {+ const formId = useId()+ const logicProps: SourceSteeringModalLogicProps = { sourceConfig, onClose }+ const logic = sourceSteeringModalLogic(logicProps)+ const { isSourceSteeringSubmitting, sourceSteeringChanged, sourceSteeringValidationErrors } = useValues(logic)++ const handleClose = (): void => {+ if (isSourceSteeringSubmitting) {+ return+ }+ onClose()+ }++ const steeringError =+ typeof sourceSteeringValidationErrors.steering === 'string'+ ? sourceSteeringValidationErrors.steering+ : undefined+ // Freeze the fields while the save is in flight: the submit already captured the form values,+ // so edits made during the request would be silently dropped by a success that closes the modal.+ const savingReason = isSourceSteeringSubmitting ? 'Saving your rules' : undefined++ return (+ <LemonModal+ isOpen+ onClose={handleClose}+ title={`Steering rules for ${sourceLabel}`}+ description="Most records from this source count as actionable and can become reports. Your rules change what gets kept. They apply from the next sync and don't remove anything already in your inbox."+ width={560}+ hasUnsavedInput={sourceSteeringChanged}+ footer={+ <>+ <LemonButton+ type="secondary"+ onClick={handleClose}+ disabledReason={isSourceSteeringSubmitting ? 'Saving your rules' : undefined}+ >+ Cancel+ </LemonButton>+ <LemonButton+ type="primary"+ form={formId}+ htmlType="submit"+ loading={isSourceSteeringSubmitting}+ disabledReason={steeringError}+ data-attr="signal-source-steering-save"+ >+ Save rules+ </LemonButton>+ </>+ }+ >+ <Form+ logic={sourceSteeringModalLogic}+ props={logicProps}+ formKey="sourceSteering"+ id={formId}+ enableFormOnSubmit+ >+ <div className="flex flex-col gap-4">+ <LemonField name="defaultNotActionable" label="Default behavior">+ {({ value, onChange }) => (+ <LemonRadio+ aria-label="Default behavior"+ value={value ? STRICT : LENIENT}+ onChange={(posture: string) => onChange(posture === STRICT)}+ options={[+ {+ value: LENIENT,+ label: 'Include everything except what I list',+ description: 'When in doubt, a record is kept.',+ disabledReason: savingReason,+ },+ {+ value: STRICT,+ label: "Only include what's clearly actionable",+ description: 'When in doubt, a record is skipped.',+ disabledReason: savingReason,+ },+ ]}+ />+ )}+ </LemonField>+ <LemonField+ name="steering"+ label="Your rules for this source"+ help="Include, exclude, or prioritize. Plain language works. Leave it empty to keep only the default behavior above."+ >+ <LemonTextArea+ minRows={4}+ maxRows={10}+ maxLength={SOURCE_STEERING_MAX_LENGTH}+ placeholder="Ignore issues labeled chore or internal. Anything mentioning billing is always actionable."+ disabled={isSourceSteeringSubmitting}+ data-attr="signal-source-steering-rules"+ />+ </LemonField>+ </div>+ </Form>+ </LemonModal>+ )+}diff --git a/products/signals/frontend/inbox/components/config/agentRosterMeta.ts b/products/signals/frontend/inbox/components/config/agentRosterMeta.tsindex 4249abc1b51e..11c38c11828f 100644--- a/products/signals/frontend/inbox/components/config/agentRosterMeta.ts+++ b/products/signals/frontend/inbox/components/config/agentRosterMeta.ts@@ -53,6 +53,13 @@ export interface AgentRosterDefinition {* toggle. The card links there instead of showing a switch.*/manageUrl?: string+ /**+ * The emission pipeline runs an actionability gate on this source's records, and that gate+ * reads the steering keys on `SignalSourceConfig.config` (see `sourceSteeringModalLogic`).+ * Sources without a gate must not offer the steering form: the keys would be stored but+ * nothing would read them.+ */+ steerable?: boolean/** Show this entry only while the given feature flag is enabled (alpha rollouts). */flag?: FeatureFlagKey}@@ -83,6 +90,7 @@ export const AGENT_ROSTER_GROUPS: AgentRosterGroup[] = [label: 'Support',watches: 'Problems customers raise in support',detail: 'Only open tickets are read.',+ steerable: true,docsUrl: 'https://posthog.com/docs/support',docsLabel: 'Support',},@@ -138,6 +146,7 @@ export const AGENT_ROSTER_GROUPS: AgentRosterGroup[] = [label: 'GitHub issues',watches: 'Issues filed in GitHub',detail: 'Reads the issues from the GitHub repositories you sync to the warehouse.',+ steerable: true,},{source: 'engineering_analytics',@@ -154,6 +163,7 @@ export const AGENT_ROSTER_GROUPS: AgentRosterGroup[] = [label: 'Linear',watches: 'Issues tracked in Linear',detail: 'Reads the issues from the Linear workspace you sync to the warehouse.',+ steerable: true,},{source: 'zendesk',@@ -161,6 +171,7 @@ export const AGENT_ROSTER_GROUPS: AgentRosterGroup[] = [label: 'Zendesk',watches: 'Incoming Zendesk tickets',detail: 'Reads the tickets from the Zendesk account you sync to the warehouse.',+ steerable: true,},{source: 'pganalyze',@@ -168,6 +179,7 @@ export const AGENT_ROSTER_GROUPS: AgentRosterGroup[] = [label: 'pganalyze',watches: 'Slow Postgres queries and bad indexes',detail: 'Reads the issues from the pganalyze account you sync to the warehouse.',+ steerable: true,},],},diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex a4806264d07b..d7b28d7b2751 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -31,6 +31,7 @@ export const INBOX_EVENTS = {SOURCE_CONNECTED: 'Signal source connected',SOURCE_DISABLED: 'Signal source disabled',SOURCE_INTEREST: 'signals source interest',+ SOURCE_STEERING_CHANGED: 'Signal source steering changed',// Scout-troop management. Names and property shapes match the desktop app one-for-one so both// clients union in one project; desktop sends no `inbox_client`, so its rows read as null.SCOUT_FLEET_VIEWED: 'Scout fleet viewed',@@ -434,6 +435,28 @@ export function captureSignalSourceInterest(source: string): void {captureInboxEvent(INBOX_EVENTS.SOURCE_INTEREST, { source })}+/**+ * A source's steering rules were saved. Carries only lengths and flags: the rules text names the+ * customer's own labels, projects, and workflows, so it never leaves their project. Fired once the+ * request settles, so `success` separates a saved change from a rejected one.+ */+export function captureSignalSourceSteeringChanged(params: {+ sourceProduct: string+ sourceType: string+ steeringLength: number+ defaultNotActionable: boolean+ success: boolean+}): void {+ captureInboxEvent(INBOX_EVENTS.SOURCE_STEERING_CHANGED, {+ source_product: params.sourceProduct,+ source_type: params.sourceType,+ steering_length: params.steeringLength,+ has_steering: params.steeringLength > 0,+ default_not_actionable: params.defaultNotActionable,+ success: params.success,+ })+}+/*** Outcome of a task-kickoff action, fired once the request settles. Pairs with the press event on* `report_id` + `action_type`. `blocked` means we never issued the request (no AI consent), which isdiff --git a/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.test.ts b/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.test.tsnew file mode 100644index 000000000000..0b04dead6102--- /dev/null+++ b/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.test.ts@@ -0,0 +1,132 @@+import { expectLogic } from 'kea-test-utils'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { signalSourcesLogic } from '../signalSourcesLogic'+import { SOURCE_STEERING_MAX_LENGTH, SignalSourceConfig, SignalSourceProduct, SignalSourceType } from '../types'+import { sourceSteeringModalLogic } from './sourceSteeringModalLogic'++const sourceConfig: SignalSourceConfig = {+ id: 'config-1',+ source_product: SignalSourceProduct.Conversations,+ source_type: SignalSourceType.Ticket,+ enabled: true,+ // A key steering does not own, to prove saves merge rather than clobber.+ config: { recording_filters: { events: [] }, steering: 'old rules' },+ created_at: '2026-08-01T00:00:00Z',+ updated_at: '2026-08-01T00:00:00Z',+ status: null,+}++describe('sourceSteeringModalLogic', () => {+ let logic: ReturnType<typeof sourceSteeringModalLogic.build>+ let patchBodies: Record<string, any>[]+ let onClose: jest.Mock+ let reloadFails: boolean++ beforeEach(() => {+ patchBodies = []+ reloadFails = false+ useMocks({+ get: {+ '/api/projects/:team_id/signals/source_configs/': () =>+ reloadFails+ ? [500, { detail: 'Internal server error' }]+ : [200, { results: [sourceConfig], count: 1, next: null, previous: null }],+ },+ patch: {+ '/api/projects/:team_id/signals/source_configs/:id/': async ({ request }) => {+ const body = (await request.json()) as Record<string, any>+ patchBodies.push(body)+ // The serializer recomputes the sync status on every response.+ return [200, { ...sourceConfig, ...body, status: 'completed' }]+ },+ },+ })+ initKeaTests()+ onClose = jest.fn()+ logic = sourceSteeringModalLogic({ sourceConfig, onClose })+ logic.mount()+ })++ afterEach(() => {+ logic?.unmount()+ })++ it('saves the whole config with trimmed steering keys merged in, keeping keys it does not own', async () => {+ expect(logic.values.sourceSteering).toEqual({ steering: 'old rules', defaultNotActionable: false })++ logic.actions.setSourceSteeringValue('steering', ' skip chores ')+ logic.actions.setSourceSteeringValue('defaultNotActionable', true)+ await expectLogic(logic, () => {+ logic.actions.submitSourceSteering()+ }).toDispatchActions(['submitSourceSteeringSuccess'])++ expect(patchBodies).toEqual([+ {+ config: {+ recording_filters: { events: [] },+ steering: 'skip chores',+ default_not_actionable: true,+ },+ },+ ])+ expect(onClose).toHaveBeenCalled()+ })++ it('merges onto the freshest cached config, not the open-time snapshot', async () => {+ // A reload landed while the modal was open and changed a key steering does not own.+ signalSourcesLogic.actions.loadSourceConfigsSuccess([+ { ...sourceConfig, config: { ...sourceConfig.config, recording_filters: { events: ['$pageview'] } } },+ ])++ logic.actions.setSourceSteeringValue('steering', 'new rules')+ await expectLogic(logic, () => {+ logic.actions.submitSourceSteering()+ }).toDispatchActions(['submitSourceSteeringSuccess'])++ expect(patchBodies[0].config.recording_filters).toEqual({ events: ['$pageview'] })+ })++ it('caches the saved config from the response even when the list reload fails', async () => {+ signalSourcesLogic.actions.loadSourceConfigsSuccess([sourceConfig])+ reloadFails = true++ logic.actions.setSourceSteeringValue('steering', 'fresh rules')+ await expectLogic(logic, () => {+ logic.actions.submitSourceSteering()+ }).toDispatchActions(['submitSourceSteeringSuccess'])+ await expectLogic(signalSourcesLogic).toDispatchActions(['loadSourceConfigsFailure'])++ expect(signalSourcesLogic.values.sourceConfigs?.[0]?.config).toEqual({+ recording_filters: { events: [] },+ steering: 'fresh rules',+ default_not_actionable: false,+ })+ expect(signalSourcesLogic.values.sourceConfigs?.[0]?.status).toEqual('completed')+ })++ it('shows the saved rules when the same source is reopened after a config reload', () => {+ logic.unmount()+ const reloaded = {+ ...sourceConfig,+ config: { ...sourceConfig.config, steering: 'saved rules', default_not_actionable: true },+ updated_at: '2026-08-02T00:00:00Z',+ }+ logic = sourceSteeringModalLogic({ sourceConfig: reloaded, onClose })+ logic.mount()++ expect(logic.values.sourceSteering).toEqual({ steering: 'saved rules', defaultNotActionable: true })+ })++ it('rejects rules over the server cap without issuing a request', async () => {+ logic.actions.setSourceSteeringValue('steering', 'x'.repeat(SOURCE_STEERING_MAX_LENGTH + 1))+ await expectLogic(logic, () => {+ logic.actions.submitSourceSteering()+ }).toDispatchActions(['submitSourceSteeringFailure'])++ expect(patchBodies).toEqual([])+ expect(onClose).not.toHaveBeenCalled()+ })+})diff --git a/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.ts b/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.tsnew file mode 100644index 000000000000..042d96c680e3--- /dev/null+++ b/products/signals/frontend/inbox/logics/sourceSteeringModalLogic.ts@@ -0,0 +1,199 @@+import { LogicWrapper, MakeLogicType, connect, kea, key, path, props } from 'kea'+import { forms } from 'kea-forms'+import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'++import { lemonToast } from '@posthog/lemon-ui'++import { ApiError } from 'lib/api-error'+import { teamLogic } from 'scenes/teamLogic'++import { signalsSourceConfigsPartialUpdate } from 'products/signals/frontend/generated/api'+import type { SignalSourceConfigApi } from 'products/signals/frontend/generated/api.schemas'++import { captureSignalSourceSteeringChanged } from '../inboxAnalytics'+import { signalSourcesLogic } from '../signalSourcesLogic'+import {+ SOURCE_DEFAULT_NOT_ACTIONABLE_KEY,+ SOURCE_STEERING_KEY,+ SOURCE_STEERING_MAX_LENGTH,+ SignalSourceConfig,+} from '../types'++export interface SourceSteeringFormValues {+ steering: string+ defaultNotActionable: boolean+}++export interface SourceSteeringModalLogicProps {+ sourceConfig: SignalSourceConfig+ onClose: () => void+}++/** Whether the team has any steering set on a source, for the roster's add-vs-edit affordance. */+export function sourceSteeringIsSet(config: SignalSourceConfig): boolean {+ const steering = config.config[SOURCE_STEERING_KEY]+ return (+ (typeof steering === 'string' && steering.trim().length > 0) ||+ config.config[SOURCE_DEFAULT_NOT_ACTIONABLE_KEY] === true+ )+}++// Type-checked reads: the config blob is an open object, so a non-string steering value+// (possible via the raw API before the serializer validation landed) must degrade to the+// defaults rather than break the form.+function steeringFormDefaults(sourceConfig: SignalSourceConfig): SourceSteeringFormValues {+ const steering = sourceConfig.config[SOURCE_STEERING_KEY]+ return {+ steering: typeof steering === 'string' ? steering : '',+ defaultNotActionable: sourceConfig.config[SOURCE_DEFAULT_NOT_ACTIONABLE_KEY] === true,+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface sourceSteeringModalLogicValues {+ sourceConfigs: SignalSourceConfig[] | null // signalSourcesLogic+ currentTeamId: number | null // teamLogic+ isSourceSteeringSubmitting: boolean+ isSourceSteeringValid: boolean+ showSourceSteeringErrors: boolean+ sourceSteering: SourceSteeringFormValues+ sourceSteeringAllErrors: Record<string, any>+ sourceSteeringChanged: boolean+ sourceSteeringErrors: DeepPartialMap<SourceSteeringFormValues, ValidationErrorType>+ sourceSteeringHasErrors: boolean+ sourceSteeringManualErrors: Record<string, any>+ sourceSteeringTouched: boolean+ sourceSteeringTouches: Record<string, boolean>+ sourceSteeringValidationErrors: DeepPartialMap<SourceSteeringFormValues, ValidationErrorType>+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface sourceSteeringModalLogicActions {+ loadSourceConfigs: () => any // signalSourcesLogic+ replaceSourceConfig: (config: SignalSourceConfig) => {+ config: SignalSourceConfig+ } // signalSourcesLogic+ resetSourceSteering: (values?: SourceSteeringFormValues) => {+ values?: SourceSteeringFormValues+ }+ setSourceSteeringManualErrors: (errors: Record<string, any>) => {+ errors: Record<string, any>+ }+ setSourceSteeringValue: (+ key: FieldName,+ value: any+ ) => {+ name: FieldName+ value: any+ }+ setSourceSteeringValues: (values: DeepPartial<SourceSteeringFormValues>) => {+ values: DeepPartial<SourceSteeringFormValues>+ }+ submitSourceSteering: () => {+ value: boolean+ }+ submitSourceSteeringFailure: (+ error: Error,+ errors: Record<string, any>+ ) => {+ error: Error+ errors: Record<string, any>+ }+ submitSourceSteeringRequest: (sourceSteering: SourceSteeringFormValues) => {+ sourceSteering: SourceSteeringFormValues+ }+ submitSourceSteeringSuccess: (sourceSteering: SourceSteeringFormValues) => {+ sourceSteering: SourceSteeringFormValues+ }+ touchSourceSteeringField: (key: string) => {+ key: string+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface sourceSteeringModalLogicMeta {+ key: string+}++export type sourceSteeringModalLogicType = MakeLogicType<+ sourceSteeringModalLogicValues,+ sourceSteeringModalLogicActions,+ SourceSteeringModalLogicProps,+ sourceSteeringModalLogicMeta+>++export const sourceSteeringModalLogic: LogicWrapper<sourceSteeringModalLogicType> = kea<sourceSteeringModalLogicType>([+ path(['scenes', 'inbox', 'logics', 'sourceSteeringModalLogic']),+ props({} as SourceSteeringModalLogicProps),+ key((logicProps) => logicProps.sourceConfig.id),+ connect(() => ({+ values: [teamLogic, ['currentTeamId'], signalSourcesLogic, ['sourceConfigs']],+ actions: [signalSourcesLogic, ['loadSourceConfigs', 'replaceSourceConfig']],+ })),+ forms(({ props: logicProps, actions, values }) => ({+ sourceSteering: {+ defaults: steeringFormDefaults(logicProps.sourceConfig),+ errors: ({ steering }: SourceSteeringFormValues) => ({+ steering:+ steering.length > SOURCE_STEERING_MAX_LENGTH+ ? `Rules must be ${SOURCE_STEERING_MAX_LENGTH} characters or fewer`+ : undefined,+ }),+ submit: async (formValues: SourceSteeringFormValues) => {+ if (values.currentTeamId === null) {+ lemonToast.error('Select a project before saving steering rules')+ throw new Error('No project selected')+ }+ const { sourceConfig } = logicProps+ const steering = formValues.steering.trim()+ // The endpoint replaces the config object wholesale, so the whole blob goes back+ // with the steering keys merged in; a partial object would clobber source-specific+ // keys like recording_filters. The merge base is the freshest cached row rather+ // than the open-time prop snapshot, so a config change that landed while the+ // modal was open (another card's toggle, an earlier save) survives. A concurrent+ // write from another client can still be lost until the endpoint merges+ // server-side.+ const baseConfig =+ values.sourceConfigs?.find((c: SignalSourceConfig) => c.id === sourceConfig.id)?.config ??+ sourceConfig.config+ const config = {+ ...baseConfig,+ [SOURCE_STEERING_KEY]: steering,+ [SOURCE_DEFAULT_NOT_ACTIONABLE_KEY]: formValues.defaultNotActionable,+ }+ const analyticsParams = {+ sourceProduct: sourceConfig.source_product,+ sourceType: sourceConfig.source_type,+ steeringLength: steering.length,+ defaultNotActionable: formValues.defaultNotActionable,+ }+ let updated: SignalSourceConfigApi+ try {+ updated = await signalsSourceConfigsPartialUpdate(String(values.currentTeamId), sourceConfig.id, {+ config,+ })+ } catch (error) {+ captureSignalSourceSteeringChanged({ ...analyticsParams, success: false })+ const apiError = error instanceof ApiError ? error : null+ lemonToast.error(apiError?.detail ?? "Couldn't save your steering rules. Please try again.")+ throw error+ }+ captureSignalSourceSteeringChanged({ ...analyticsParams, success: true })+ lemonToast.success('Steering rules saved. They apply from the next sync.')+ // Overlay the saved row onto the cached list before the reload: if the reload is+ // slow or fails, a reopened modal would otherwise derive its form from the stale+ // config and a second save could restore the obsolete rules.+ actions.replaceSourceConfig({+ ...sourceConfig,+ enabled: updated.enabled ?? sourceConfig.enabled,+ config: updated.config ?? config,+ updated_at: updated.updated_at,+ // The generated type widens the serializer's sync status to string | null.+ status: (updated.status ?? null) as SignalSourceConfig['status'],+ })+ actions.loadSourceConfigs()+ logicProps.onClose()+ },+ },+ })),+])diff --git a/products/signals/frontend/inbox/signalSourcesLogic.ts b/products/signals/frontend/inbox/signalSourcesLogic.tsindex 58253fe2f153..290378cca08b 100644--- a/products/signals/frontend/inbox/signalSourcesLogic.ts+++ b/products/signals/frontend/inbox/signalSourcesLogic.ts@@ -340,6 +340,9 @@ export interface signalSourcesLogicActions {openSourcesModal: () => {value: true}+ replaceSourceConfig: (config: SignalSourceConfig) => {+ config: SignalSourceConfig+ }setAllScannerSignals: (enabled: boolean) => {enabled: boolean}@@ -502,6 +505,7 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([toggleSignalSource: (params: ToggleSignalSourceParams) => ({ params }),toggleSignalSourceSuccess: (params: ToggleSignalSourceParams) => ({ params }),toggleSignalSourceFailure: (params: ToggleSignalSourceParams, error: string) => ({ params, error }),+ replaceSourceConfig: (config: SignalSourceConfig) => ({ config }),toggleErrorTracking: true,toggleErrorTrackingComplete: true,toggleErrorTrackingType: (sourceType: SignalSourceType) => ({ sourceType }),@@ -646,6 +650,10 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([},],sourceConfigs: {+ // A save endpoint returned the row: reflect it immediately so consumers don't read+ // stale config while the follow-up list reload is in flight (or after it failed).+ replaceSourceConfig: (state: SignalSourceConfig[] | null, { config }: { config: SignalSourceConfig }) =>+ state ? state.map((c) => (c.id === config.id ? config : c)) : state,toggleHealthChecks: (state: SignalSourceConfig[] | null) =>toggleSourceConfigState(state, SignalSourceProduct.HealthChecks, SignalSourceType.HealthIssue),toggleEvalReports: (state: SignalSourceConfig[] | null) =>diff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.tsindex b730810ee4bb..c7a3c5d344d7 100644--- a/products/signals/frontend/inbox/types.ts+++ b/products/signals/frontend/inbox/types.ts@@ -159,6 +159,14 @@ export enum SignalSourceConfigStatus {FAILED = 'failed',}+// `SignalSourceConfig.config` keys the emission actionability gate reads. Mirrors+// STEERING_KEY / DEFAULT_NOT_ACTIONABLE_KEY / STEERING_MAX_LENGTH in+// products/signals/backend/contracts.py; the generated config type is an open object,+// so the key names and cap only exist here and there.+export const SOURCE_STEERING_KEY = 'steering'+export const SOURCE_DEFAULT_NOT_ACTIONABLE_KEY = 'default_not_actionable'+export const SOURCE_STEERING_MAX_LENGTH = 2000+// ── Inbox 2.0 IA: tabs + scope ──────────────────────────────────────────────export type InboxTabKey = 'pulls' | 'reports' | 'not-actionable' | 'runs' | 'archived' | 'config'