Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(signals): lay out inbox autonomy settings as uniform rows (#101041)

Chris Volzerf66541133d79
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 00a86cac32fd..eb002783144d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8409,9 +8409,9 @@ snapshots:
scenes-app-inbox-scene--self-driving-verdict-pending--light:
hash: v1.k794b7964.96cdbec6c78e8daedb06be4a0134093efcd5838af69e6e7d1722a3892cf561b5.iJ2K0zNhOVgGAPY6JvduyhDBODMwk-CN7_mAdB8scOg
scenes-app-inbox-scene--settings--dark:
- hash: v1.k794b7964.14ed4a004e1c806fb9178be0020a0aa078874b1356db0e7c037afe48d4ecadef.0oQeLxKsUvzJDj72tiCFTC60gtvrbAeumQv-FGbJxZ4
+ hash: v1.k794b7964.dbc67b137d29e2640e1c9d7e87d0bb2dbb143e71697cf19baeac4293d9526fca.CpnlyG5rgG4kjSxgv27Sdt6i7OWxkkO_YT8eUfoXu-E
scenes-app-inbox-scene--settings--light:
- hash: v1.k794b7964.695c2ef4914cec3959aeeddc8fc6dbdf648ffaec4bb058b2850eb2949b0c47d3.OD7Wkopvw_-ByEzsDEWIdwPdFQDvi1sUO_CbG8YiAAk
+ hash: v1.k794b7964.7188c4058337baba350ae79845be3130992319fb259fb0cf5206c3d1d4c95ba8.eLzK8VGpzLgMkcryFCZBBTgomfWdfOb9SFua02Vi2ts
scenes-app-inbox-scene--triage--dark:
hash: v1.k794b7964.77e43b36fdcd81befecf4de80e489050f525840924ec6ddef37c23a9179dbe8a.B3qkZFYBncFaPn2EBg4cBoYu_LIwW29imNwBdLXF5eo
scenes-app-inbox-scene--triage--light:
@@ -8601,45 +8601,69 @@ snapshots:
scenes-app-inbox-scoutwritescopespicker--with-granted-scopes--light:
hash: v1.k794b7964.2dd74fab813b22724a00074e4b564fd131f976add8144d620670da70600b6511.ICZgVzVzMD7rdvIGfRR7HoKsMbp8uvKav294uYJlzuU
scenes-app-inbox-selfdrivingsection--daily-limit-reached--dark:
- hash: v1.k794b7964.833c25a9d3cc97054dedf6c847dbed5e950b691a4fb6f0112e680b799928165c.lxNgsUnOCDGZyrQ43gqNUDN8JyV7tXH5Wtvb4JnJTL0
+ hash: v1.k794b7964.027abdb918ea8b3e641afc489d0460febed2c8d926d03792d4ea2f978b5c341f.3b75XL4cuMhIgRwUMJzL4FN9jhVHQWsk_F-WvF39Xdc
scenes-app-inbox-selfdrivingsection--daily-limit-reached--light:
- hash: v1.k794b7964.1ccf27c19c602284500dffb1a267cae43fe429b3a0258a2a1a7f15e620f4aa99.4cj1fYQYYGq2dT853FqyQ17HcNUV2gWI08jt5Pf7zlA
+ hash: v1.k794b7964.96066f8faf0a5515db83dbea4fca1923335d0f85ca06b0c894f6648736e86ad2.zkYrBt2LECU_2MzXTySxMzlVJuXZZrwHGvyRSKw9zqk
scenes-app-inbox-selfdrivingsection--daily-limit-set--dark:
hash: v1.k794b7964.3fa4e975d9966a9bc3557d63ff5017a07d8b2428cec986c16f386c8d0f341022.UVEV2Z_N7DdU_THXbBI8uEURPwirfncvsbjodaYYmVY
scenes-app-inbox-selfdrivingsection--daily-limit-set--light:
hash: v1.k794b7964.219716b5c72f7c5fc968cd475c15536bf10734cff3200a34c89f162f3ab62b80.j-EMqzNiG7OjMvEVhhQkAYxwkbvWKi3iSsGmwaFN1I0
scenes-app-inbox-selfdrivingsection--disabled--dark:
- hash: v1.k794b7964.fe0b43978b5f6f9a34e4674503a972599fbaabe45ee4937b25e6a68067aa120a.Vh_Uto5i_c36XFOiFkp32jmxfz4luh-U3B7Lq49vxzQ
+ hash: v1.k794b7964.1c3b6d06e8b7cda2826f1dbed75c4302180b09e0ce10decb4a9165019db62266.3Z57xV-AXwoqOo3dwGg2ZnSIYcf2akzlGyVs3tN6eYw
scenes-app-inbox-selfdrivingsection--disabled--light:
- hash: v1.k794b7964.ee93e3b9bb5b4b372cffc1daa9e0b35c9a9e6dd7ec9339b07781e5ecce8a6a7b.FfOQBXsVG2nKZeMOAcQzvJuLRhrlnC63aqJdg6VI_1A
+ hash: v1.k794b7964.f26838ffbf5e310aca1591bc211ccd5aaf4c933c475eb40db24cba3b03546ab7.t5J-3dJfsGl6XzX6bf63x8TmFvidmJoAQV8CqWx2SE0
scenes-app-inbox-selfdrivingsection--git-hub-assignment-on--dark:
- hash: v1.k794b7964.75e207df5a376765346c96174f733fe59775363bb093edf12a99eb6ebf8c7c80.Uk3T1D8eNvCRwAZVhVLCWgutZQMrAaBSHW7PAhCXPy8
+ hash: v1.k794b7964.524c26488a77e4759db4d6e9783a3c3028c38d514e87fdfb321cef7a75410542.KRAp5JtNs-ir8F1Ds7QLfAkG03WCtdjFAkRaHWJZb5w
scenes-app-inbox-selfdrivingsection--git-hub-assignment-on--light:
- hash: v1.k794b7964.f97f75e75e8eee6b235827ac59ef866d7e221c221a2ec528a084c482fa4bc2b0._YfqT2hSPB1kQk3k_k4njuiC85uZO17eKgqGRRpOOSo
+ hash: v1.k794b7964.57af56f19994255413673d8fc12ec148ff9b033eb123e66e240635a23718cb46.LLSxjyWoQftRO_OMQoiI8Ks0T6S8ZuLWK6b9pWALJ7E
scenes-app-inbox-selfdrivingsection--issue-tracker-configured--dark:
- hash: v1.k794b7964.da38342117fa8ae6014c42db6911203a1d56699699afa960349864ba9d9f35c2.y9yF0mzBj5Gstzq-W1_jPo8-BuniKnj_VQX_0YaoAWo
+ hash: v1.k794b7964.0956d0f012b6da9877448cd1afd59bffec92f23fe568c76bbbb63ccd7f778da0.j1RolAIx5vnIu-hTCBxc-_sNok53fyvTFakq1kqWeOk
scenes-app-inbox-selfdrivingsection--issue-tracker-configured--light:
- hash: v1.k794b7964.f5ac0ad77c941dd05efcfa2c83c91b1118d6e03068490fe472145052c567c0f4.xWIldZymU4xR4_VdN39syM4-LtwTQ6aXZs73rPwPH_M
+ hash: v1.k794b7964.1a9038f9d2377dc4ceb76e7d132156e808d5af750bc8d9df1ec714bd6eb76ac0.oo-Os2qSOshYrCqT1P6KaM__RMUU4JNfQGj8tV96qaI
scenes-app-inbox-selfdrivingsection--issue-tracker-unavailable--dark:
- hash: v1.k794b7964.2e7891ab26dbae7e2510f44f413cff3b2a7eef5bad5f0d131a5c1035cb361655.VMAo4c9Z0HdS3gmByyTtYz-xgsL9wwLLGxcienPsIvg
+ hash: v1.k794b7964.6bfc4c4bf6e0dd7990584e903704b5f44f073a62e5c9ac8328a7cbef659f894b.X4le-xk7srup5exu5Pc5_Si2qfegExY70NvNhunda5Q
scenes-app-inbox-selfdrivingsection--issue-tracker-unavailable--light:
- hash: v1.k794b7964.24c86c24c804d234c72857d4bc91ede2424defcb84187669f7ace94cb05c9e97.iAvFq6Q1O6ImvKYAoOlzQe7x6vYex93FaI1GSSPOXgw
+ hash: v1.k794b7964.e6f7bb7efdb33b8d946315868e4fc665367e81f6358968df6fe0b2fd816b7f43.-RWkNykvwjmxBO1N0IJkZCypT-XX_4MgBR1GpsfuCQk
scenes-app-inbox-selfdrivingsection--no-daily-limit--dark:
hash: v1.k794b7964.3e355e2b561a2a3b3d38b00258e51531d6e9116d42129731a3c4b71bf6cb5e7e.VxAxGwO-zZ-B9OtgXOMp53Lvq5dOJjbs-qh60r-bT88
scenes-app-inbox-selfdrivingsection--no-daily-limit--light:
hash: v1.k794b7964.9837d5c2833b8def4c88c221e6ab65699e274a2515b210320b49f13ea0572a0a.hqgSLSsKWsmf3zXL3sEwl6kOe1jzwGeG-Fd0Zpoek70
scenes-app-inbox-selfdrivingsection--personal-default--dark:
- hash: v1.k794b7964.2e7891ab26dbae7e2510f44f413cff3b2a7eef5bad5f0d131a5c1035cb361655.aD8rm1FJVvybW_DKodX_bZg3igdI4lEnTlsShLMjqBo
+ hash: v1.k794b7964.6bfc4c4bf6e0dd7990584e903704b5f44f073a62e5c9ac8328a7cbef659f894b.mqG4VjYYqTJPbk7ZxvOgrMuzYO5hitL82lKfbxlTQhw
scenes-app-inbox-selfdrivingsection--personal-default--light:
- hash: v1.k794b7964.24c86c24c804d234c72857d4bc91ede2424defcb84187669f7ace94cb05c9e97.nqZZSGkteO2jVA-fkWwMp28FcKvdJwSHNTxtm-9UBCE
+ hash: v1.k794b7964.e6f7bb7efdb33b8d946315868e4fc665367e81f6358968df6fe0b2fd816b7f43.de-M1MiqSnjIleeHY7YwmVFJMZQeEHrgjXKJcCnJwRg
scenes-app-inbox-selfdrivingsection--personal-override--dark:
hash: v1.k794b7964.aa42dc763078e1431c621efad3dae9f298485890910510fccd861fb1bc9f7d77.Go-OjRKiACFptGQ39DNGs4H4H83nh48PwJQBaoW59CI
scenes-app-inbox-selfdrivingsection--personal-override--light:
hash: v1.k794b7964.11bb568d4acedc2c8471037b636ccceffd9d5132b2831c86911cb3c03dc0e761.Av0epOul8ebcU34b5lat7cvdImPzSkTHhwuYPkfV3WA
scenes-app-inbox-selfdrivingsection--pull-request-ready-for-review--dark:
- hash: v1.k794b7964.61d267c06579d429695694aeb8965b7baee948c49315afdb0ebfd88f85c6b4a7.WKG1q7jFy7Y5Wb_sQJE9gJ-YvFwnLHn7N24dC5Sz7uo
+ hash: v1.k794b7964.5c7016fb60829b29c82e9bf3f07d963d1e00eac9a629acca351639e8dfa4eee7.PK60jC-eLVVJyLASnginr-jH-kW4XeJ0kXcaHuhWHoE
scenes-app-inbox-selfdrivingsection--pull-request-ready-for-review--light:
- hash: v1.k794b7964.7a06f93ef8eb6ffb7a1f931221b77be7faf99d70f924e25972e2e1e2e808ea6e.gO-Z9ycEHRYf6X79K3HbXdmxAtcZ6fvgIAvAQ-3F_NQ
+ hash: v1.k794b7964.4413b7625076a075f7885a916773fcf57eaf431ab4022ddba2fad92fed45a8a5.S9dGHX6YN9sKL3WrxkT5rMtlc5ZN2IQDcFCWew1o1NE
+ scenes-app-inbox-selfdrivingsection--settings-tab--dark:
+ hash: v1.k794b7964.044e15a7e573425f0c482378b04343142fa8fe6bcaf2df3d35492b17861524b5.GpGngARPmeN9NYvgNs7PUw69AB_NZi8OZ_CPWOWlltw
+ scenes-app-inbox-selfdrivingsection--settings-tab--light:
+ hash: v1.k794b7964.88ac658607ec63989aa8d3354212f68ab053974296882d4e515d7bca5e100322.UgALD2SDOAEEffeuf8rwsR60RTGiA4VBDRIp2bqAis0
+ scenes-app-inbox-selfdrivingsection--settings-tab-base-branches--dark:
+ hash: v1.k794b7964.ca88af903008fea09ee8b8c1d354c148797006250b948da9043499b21c2272d4.zcdK-Ds3Kic7Q4WtleLQG1hWXxxOpwB_SoQH-mCSrq8
+ scenes-app-inbox-selfdrivingsection--settings-tab-base-branches--light:
+ hash: v1.k794b7964.2059311feb93424cf8acb48cacb174a5ab422213f972bfcf4395ac2292acc743.5cWpKb2yzNnfHv8fyusBvyR9m7JfPa6xJzT6iGtWAlU
+ scenes-app-inbox-selfdrivingsection--settings-tab-base-branches-without-git-hub--dark:
+ hash: v1.k794b7964.ec42adbf666a5d1c1e01359ef99fe30bb0ac15a440c868e39271f1c6cc5bc0a9.iR202ex1FvPA8l_vx2zZVMFi2dKKUFStDnzskUkunLQ
+ scenes-app-inbox-selfdrivingsection--settings-tab-base-branches-without-git-hub--light:
+ hash: v1.k794b7964.a3c4202c5a498c006f1ff88e755604e38574b4658a6539c0d5efa2fc87fad0e0.K2g-9o2erlGEfhbgAVP4oqDogZFCfrxqa8F1FAiiehA
+ scenes-app-inbox-selfdrivingsection--settings-tab-disabled--dark:
+ hash: v1.k794b7964.1ecf216757ce2db57fe852a49aac8e3285eddcffc533bb6d4d4bd64a893bf03a.BNXn4jfro34u7tfGlpvKw_BDJB3CWldR9ccgZ1ieFK4
+ scenes-app-inbox-selfdrivingsection--settings-tab-disabled--light:
+ hash: v1.k794b7964.965985d456fd402f5d56535a2c7b648c4fe489781520325dbb3a7fbad377d1ee.1zFknWFsS9hOaZV9CHfeK2FSWwXIcXaR18SdKn_suXc
+ scenes-app-inbox-selfdrivingsection--settings-tab-issue-tracker-jira--dark:
+ hash: v1.k794b7964.08bda87bf4c2a3a1bf6232f395b74d879fe3a025174a60e058e693cc25b085fe.SX7eUSB6gow5Oar38Pn-8EfIk4aTja9XvS937Zn54t8
+ scenes-app-inbox-selfdrivingsection--settings-tab-issue-tracker-jira--light:
+ hash: v1.k794b7964.799b981717d3ccd8c33a7b6dfdc15e8bfddf18f8fa957ab2702e6b440bac5c34.BcVp6QtB-QWj_Sp2fdEUlHxokd0SPlCU_d_oyq4S9Ss
+ scenes-app-inbox-selfdrivingsection--settings-tab-narrow--dark:
+ hash: v1.k794b7964.9aca38b1236ed16a464f94102f9474904f14937adcd17d419ccd6c6748498025.KorTthkm-gqbl1oile51fljznkrj4jr-Bc0D9neiQOg
+ scenes-app-inbox-selfdrivingsection--settings-tab-narrow--light:
+ hash: v1.k794b7964.bc690ec63fc78a5be3c81b9d3fff83716f69d0ffecaa7ec5b20318983808bc4e.S8Pbf4Hj1-mIxKF7R6_7lVDwWT5GpUE7zObcG1aMe5M
scenes-app-inbox-signal-cards--all-sources--dark:
hash: v1.k794b7964.8220c14a1dc6de9d9aa2fa2fa829bff1d19230cf7cdb947906b3fee3ead37d98.BBzXUXAId7C0u5sasTEYZBdaqZjXRU20paQFY6thp3s
scenes-app-inbox-signal-cards--all-sources--light:
diff --git a/products/signals/frontend/inbox/components/config/AutonomySettingGroup.tsx b/products/signals/frontend/inbox/components/config/AutonomySettingGroup.tsx
new file mode 100644
index 000000000000..d8751b66471c
--- /dev/null
+++ b/products/signals/frontend/inbox/components/config/AutonomySettingGroup.tsx
@@ -0,0 +1,25 @@
+import { ReactNode } from 'react'
+
+/**
+ * A run of Autonomy rows that share one scope, such as the project or the current user. The scope
+ * is stated once in the heading, so each row does not have to repeat who it applies to.
+ */
+export function AutonomySettingGroup({
+ title,
+ description,
+ children,
+}: {
+ title: string
+ description?: ReactNode
+ children: ReactNode
+}): JSX.Element {
+ return (
+ <div className="flex flex-col gap-1 py-4 first:pt-2 last:pb-0">
+ <div className="flex flex-col gap-0.5">
+ <h4 className="m-0 text-xs font-semibold uppercase tracking-wide text-tertiary">{title}</h4>
+ {description && <p className="m-0 text-xs leading-snug text-secondary">{description}</p>}
+ </div>
+ <div className="flex flex-col divide-y divide-primary [&>*:last-child]:pb-0">{children}</div>
+ </div>
+ )
+}
diff --git a/products/signals/frontend/inbox/components/config/AutonomySettingRow.tsx b/products/signals/frontend/inbox/components/config/AutonomySettingRow.tsx
new file mode 100644
index 000000000000..a8ba3fb92953
--- /dev/null
+++ b/products/signals/frontend/inbox/components/config/AutonomySettingRow.tsx
@@ -0,0 +1,38 @@
+import { ReactNode } from 'react'
+
+/**
+ * One setting in the Autonomy section: a title, one line of context, and one control. Every row
+ * has the same shape, so a reader scans the left column for the setting and the right column for
+ * its value. The control sits right of the text where the width allows and wraps below it in a
+ * narrow scene. Dependent settings that the control reveals render indented under the row.
+ */
+export function AutonomySettingRow({
+ title,
+ description,
+ control,
+ children,
+}: {
+ title: string
+ description?: ReactNode
+ control?: ReactNode
+ children?: ReactNode
+}): JSX.Element {
+ return (
+ <div className="flex flex-col gap-3 py-3">
+ {/* basis-48 leaves room for a switch beside the text in the 320px legacy rail. */}
+ <div className="flex flex-wrap items-start justify-between gap-x-4 gap-y-2">
+ <div className="flex min-w-0 flex-1 basis-48 flex-col gap-0.5">
+ <span className="text-sm font-medium text-default">{title}</span>
+ {description && <p className="m-0 text-xs leading-snug text-secondary">{description}</p>}
+ </div>
+ {/* max-w-full caps a control wider than the row, so a full-width segmented button compresses instead of overflowing. */}
+ {control && <div className="flex max-w-full shrink-0 items-center gap-1">{control}</div>}
+ </div>
+ {children && (
+ <div className="ml-0.5 flex flex-col divide-y divide-primary border-l-2 border-primary pl-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
+ {children}
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/products/signals/frontend/inbox/components/config/SelfDrivingSection.stories.tsx b/products/signals/frontend/inbox/components/config/SelfDrivingSection.stories.tsx
index dc5d421b5224..01f51c783985 100644
--- a/products/signals/frontend/inbox/components/config/SelfDrivingSection.stories.tsx
+++ b/products/signals/frontend/inbox/components/config/SelfDrivingSection.stories.tsx
@@ -1,12 +1,15 @@
import type { Meta, StoryObj } from '@storybook/react'
+import { FEATURE_FLAGS } from 'lib/constants'
+
import { useStorybookMocks } from '~/mocks/browser'
+import { SettingsSection } from '../tabs/SettingsSection'
import { SelfDrivingSection } from './SelfDrivingSection'
-// The "PR generation" card from the agents setup rail. It reads the team-wide config
-// (`signals/config`) and the current user's personal override (`users/@me/signal_autonomy`), so both
-// GETs are mocked per story to place the card in a given state.
+// The Autonomy settings. They read the team-wide config (`signals/config`) and the current user's
+// personal override (`users/@me/signal_autonomy`), so both GETs are mocked per story to place the
+// section in a given state.
interface CardState {
/** `autostart_enabled` on the team config – the master switch. */
@@ -15,6 +18,8 @@ interface CardState {
projectThreshold?: string
/** Personal override, or null to inherit the project threshold ("Default"). */
myThreshold?: string | null
+ /** Repositories that branch from somewhere other than their default branch. */
+ baseBranches?: Record<string, string>
dailyLimit?: number | null
reportsToday?: number
/** Personal opt-in to being added as a GitHub assignee on the implementation PR. */
@@ -32,10 +37,11 @@ interface CardState {
const GITHUB_INTEGRATION = { id: 1, kind: 'github', display_name: 'PostHog', config: {}, created_at: '2024-03-01' }
-function Card({
+function useAutonomyMocks({
enabled = true,
projectThreshold = 'P2',
myThreshold = null,
+ baseBranches = {},
dailyLimit = null,
reportsToday = 0,
githubAssign = false,
@@ -44,14 +50,14 @@ function Card({
integrations = [],
issueTrackingIntegration = null,
issueTrackingConfig = {},
-}: CardState): JSX.Element {
+}: CardState): void {
useStorybookMocks({
get: {
'/api/projects/:team_id/signals/config/': {
id: 'cfg-1',
autostart_enabled: enabled,
default_autostart_priority: projectThreshold,
- autostart_base_branches: {},
+ autostart_base_branches: baseBranches,
issue_tracking_integration: issueTrackingIntegration,
issue_tracking_config: issueTrackingConfig,
max_reports_per_day: dailyLimit,
@@ -70,7 +76,11 @@ function Card({
'/api/projects/:team_id/integrations/': { results: integrations },
},
})
- // Mimic the agents rail (`w-80` aside + the column's `px-4 py-3`) so the card lays out as in the scene.
+}
+
+/** The legacy agents rail: a `w-80` aside with the column's `px-4 py-3`, so the card lays out as in the scene. */
+function Card(state: CardState): JSX.Element {
+ useAutonomyMocks(state)
return (
<div className="w-80 px-4 py-3 bg-surface-secondary">
<SelfDrivingSection />
@@ -78,6 +88,22 @@ function Card({
)
}
+/** The Settings tab: the section inside its card, at the tab's `max-w-4xl` or pinned narrow. */
+function SettingsCard({ width, ...state }: CardState & { width: 'wide' | 'narrow' }): JSX.Element {
+ useAutonomyMocks(state)
+ // 32rem is about what a 1280px window leaves the scene with the side panel open.
+ return (
+ <div className={width === 'wide' ? 'w-[56rem] px-6 py-6' : 'w-[32rem] px-6 py-6'}>
+ <SettingsSection
+ title="Autonomy"
+ description="How much agents do on their own: opening pull requests, and how many reports arrive each day."
+ >
+ <SelfDrivingSection />
+ </SettingsSection>
+ </div>
+ )
+}
+
const meta: Meta = {
title: 'Scenes-App/Inbox/SelfDrivingSection',
component: SelfDrivingSection,
@@ -91,6 +117,59 @@ export default meta
type Story = StoryObj
+const REDESIGN = { featureFlags: [FEATURE_FLAGS.INBOX_REDESIGN] }
+
+// The Settings tab at full width: controls sit right of their labels.
+export const SettingsTab: Story = {
+ parameters: REDESIGN,
+ render: () => <SettingsCard width="wide" dailyLimit={10} reportsToday={3} />,
+}
+
+// The Settings tab in a narrow scene: wide controls wrap below their labels, nothing clips.
+export const SettingsTabNarrow: Story = {
+ parameters: REDESIGN,
+ render: () => <SettingsCard width="narrow" dailyLimit={10} reportsToday={3} />,
+}
+
+// A repository that branches from `develop`: the override list and the Add override button render under Base branches.
+export const SettingsTabBaseBranches: Story = {
+ parameters: REDESIGN,
+ render: () => (
+ <SettingsCard
+ width="wide"
+ integrations={[GITHUB_INTEGRATION]}
+ baseBranches={{ 'posthog/posthog.com': 'develop' }}
+ />
+ ),
+}
+
+// GitHub disconnected after an override was saved: the override stays readable and removable, the picker hides.
+export const SettingsTabBaseBranchesWithoutGitHub: Story = {
+ parameters: REDESIGN,
+ render: () => <SettingsCard width="wide" baseBranches={{ 'posthog/posthog.com': 'develop' }} />,
+}
+
+// A Jira tracker with a saved project: the target reads as text with a Change button, and no picker mounts.
+export const SettingsTabIssueTrackerJira: Story = {
+ parameters: REDESIGN,
+ render: () => (
+ <SettingsCard
+ width="wide"
+ integrations={[
+ { id: 2, kind: 'jira', display_name: 'example.atlassian.net', config: {}, created_at: '2024-03-01' },
+ ]}
+ issueTrackingIntegration={2}
+ issueTrackingConfig={{ project_key: 'ENG' }}
+ />
+ ),
+}
+
+// Master switch off in the Settings tab: the project threshold hides. Base branches and your own threshold stay.
+export const SettingsTabDisabled: Story = {
+ parameters: REDESIGN,
+ render: () => <SettingsCard width="wide" enabled={false} />,
+}
+
export const NoDailyLimit: Story = {
render: () => <Card />,
}
@@ -103,12 +182,12 @@ export const DailyLimitReached: Story = {
render: () => <Card dailyLimit={10} reportsToday={10} />,
}
-// Personal override set below the project default: "My threshold" reads P1+ while the project stays P2+.
+// Personal override set below the project default: the personal threshold reads P1+ while the project stays P2+.
export const PersonalOverride: Story = {
render: () => <Card myThreshold="P1" />,
}
-// No personal override: "My threshold" shows "Default" and inherits the project threshold.
+// No personal override: the personal threshold shows "Default" and inherits the project threshold.
export const PersonalDefault: Story = {
render: () => <Card myThreshold={null} />,
}
@@ -123,12 +202,12 @@ export const PullRequestReadyForReview: Story = {
render: () => <Card myPrReady />,
}
-// Master switch off: both thresholds are hidden and only the reassurance copy shows.
+// Master switch off: the project threshold hides, your own threshold stays because it applies to your other projects.
export const Disabled: Story = {
render: () => <Card enabled={false} />,
}
-// No tracker connected: the issue tracker row points at the integrations settings instead.
+// No tracker connected: the issue tracker row offers to connect one.
export const IssueTrackerUnavailable: Story = {
render: () => <Card />,
}
diff --git a/products/signals/frontend/inbox/components/config/SelfDrivingSection.tsx b/products/signals/frontend/inbox/components/config/SelfDrivingSection.tsx
index e2de7b7715a1..571c9b4e7d87 100644
--- a/products/signals/frontend/inbox/components/config/SelfDrivingSection.tsx
+++ b/products/signals/frontend/inbox/components/config/SelfDrivingSection.tsx
@@ -1,9 +1,8 @@
import { useActions, useValues } from 'kea'
-import { IconPlus, IconRocket, IconX } from '@posthog/icons'
+import { IconPlus, IconX } from '@posthog/icons'
import {
LemonButton,
- LemonCollapse,
LemonInput,
LemonSegmentedButton,
LemonSelect,
@@ -11,20 +10,6 @@ import {
LemonSwitch,
Link,
} from '@posthog/lemon-ui'
-import {
- Button,
- ButtonGroup,
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from '@posthog/quill'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { GitHubBranchCombobox } from 'lib/integrations/GitHubBranchCombobox'
@@ -39,6 +24,8 @@ import { IntegrationType } from '~/types'
import { signalTeamConfigLogic } from '../../logics/signalTeamConfigLogic'
import { userAutonomyLogic } from '../../logics/userAutonomyLogic'
import { PRIORITY_THRESHOLD_OPTIONS, SignalReportPriority } from '../../types'
+import { AutonomySettingGroup } from './AutonomySettingGroup'
+import { AutonomySettingRow } from './AutonomySettingRow'
/** Compact segmented-control label per priority. P4 (the lowest bar) reads as "All". */
const THRESHOLD_SEGMENT_LABELS: Record<SignalReportPriority, string> = {
@@ -64,7 +51,7 @@ const PR_STATE_SEGMENTS = [
const MY_PR_STATE_DEFAULT_VALUE = '__default__'
const MY_PR_STATE_SEGMENTS = [{ value: MY_PR_STATE_DEFAULT_VALUE, label: 'Default' }, ...PR_STATE_SEGMENTS]
-function BaseBranchOverrideRows(): JSX.Element | null {
+function BaseBranchOverrideList(): JSX.Element | null {
const { baseBranchOverrides, teamConfigUpdating } = useValues(signalTeamConfigLogic)
const { updateBaseBranchOverride, removeBaseBranchOverride } = useActions(signalTeamConfigLogic)
const { githubIntegrations } = useValues(integrationsLogic)
@@ -80,43 +67,45 @@ function BaseBranchOverrideRows(): JSX.Element | null {
)
return (
- <div className="flex flex-col gap-1">
+ <ul className="m-0 flex list-none flex-col gap-1 p-0">
{baseBranchOverrides.map(({ repo, branch }) => {
const integration = integrationsByOwner.get(repo.split('/')[0])
return (
- <div key={repo} className="flex items-center gap-1">
- <span className="text-xs text-default min-w-0 flex-1 truncate" title={repo}>
+ <li key={repo} className="flex flex-wrap items-center gap-2">
+ <span className="min-w-0 flex-1 basis-40 truncate text-sm text-default" title={repo}>
{repo}
</span>
- {integration ? (
- <GitHubBranchCombobox
- integrationId={integration.id}
- repo={repo}
- value={branch}
- allowCustomValues={false}
- disabled={teamConfigUpdating}
- onChange={(next) => {
- if (next) {
- updateBaseBranchOverride(repo, next)
- }
- }}
+ <div className="flex items-center gap-1">
+ {integration ? (
+ <GitHubBranchCombobox
+ integrationId={integration.id}
+ repo={repo}
+ value={branch}
+ allowCustomValues={false}
+ disabled={teamConfigUpdating}
+ onChange={(next) => {
+ if (next) {
+ updateBaseBranchOverride(repo, next)
+ }
+ }}
+ />
+ ) : (
+ <span className="text-xs text-secondary">{branch}</span>
+ )}
+ <LemonButton
+ type="tertiary"
+ size="small"
+ icon={<IconX />}
+ loading={teamConfigUpdating}
+ aria-label={`Remove base branch override for ${repo}`}
+ data-attr="signals-base-branch-override-remove"
+ onClick={() => removeBaseBranchOverride(repo)}
/>
- ) : (
- <span className="text-xs text-muted shrink-0">{branch}</span>
- )}
- <Button
- variant="outline"
- size="sm"
- loading={teamConfigUpdating}
- aria-label={`Remove base branch override for ${repo}`}
- onClick={() => removeBaseBranchOverride(repo)}
- >
- <IconX />
- </Button>
- </div>
+ </div>
+ </li>
)
})}
- </div>
+ </ul>
)
}
@@ -128,8 +117,13 @@ function BaseBranchOverridePicker(): JSX.Element {
addBaseBranchOverrideDisabledReason,
teamConfigUpdating,
} = useValues(signalTeamConfigLogic)
- const { setDraftBaseBranchIntegrationId, setDraftBaseBranchRepo, setDraftBaseBranchBranch, addBaseBranchOverride } =
- useActions(signalTeamConfigLogic)
+ const {
+ setDraftBaseBranchIntegrationId,
+ setDraftBaseBranchRepo,
+ setDraftBaseBranchBranch,
+ addBaseBranchOverride,
+ clearDraftBaseBranch,
+ } = useActions(signalTeamConfigLogic)
const { githubIntegrations } = useValues(integrationsLogic)
const integrationId = draftBaseBranchIntegrationId ?? githubIntegrations[0].id
@@ -137,112 +131,108 @@ function BaseBranchOverridePicker(): JSX.Element {
return (
<div className="flex flex-wrap items-center gap-1">
{githubIntegrations.length > 1 && (
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- variant="outline"
- size="sm"
- aria-label="GitHub organization"
- disabled={teamConfigUpdating}
- >
- <span className="min-w-0 truncate">
- {githubIntegrations.find((integration) => integration.id === integrationId)
- ?.display_name ?? 'GitHub'}
- </span>
- </Button>
- }
- />
- <DropdownMenuContent>
- {githubIntegrations.map((integration) => (
- <DropdownMenuItem
- key={integration.id}
- onClick={() => setDraftBaseBranchIntegrationId(integration.id)}
- >
- {integration.display_name}
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
+ <LemonSelect
+ size="small"
+ value={integrationId}
+ options={githubIntegrations.map((integration) => ({
+ value: integration.id,
+ label: integration.display_name,
+ }))}
+ disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
+ onChange={(next) => next != null && setDraftBaseBranchIntegrationId(next)}
+ aria-label="GitHub organization"
+ />
)}
- <ButtonGroup>
- <GitHubRepositoryCombobox
+ <GitHubRepositoryCombobox
+ integrationId={integrationId}
+ value={draftBaseBranchRepo}
+ disabled={teamConfigUpdating}
+ onChange={(repo) => setDraftBaseBranchRepo(repo ?? '')}
+ placeholder="Repository"
+ />
+ {draftBaseBranchRepo ? (
+ <GitHubBranchCombobox
integrationId={integrationId}
- value={draftBaseBranchRepo}
+ repo={draftBaseBranchRepo}
+ value={draftBaseBranchBranch}
+ allowCustomValues={false}
disabled={teamConfigUpdating}
- onChange={(repo) => setDraftBaseBranchRepo(repo ?? '')}
- placeholder="Repository"
- />
- {draftBaseBranchRepo ? (
- <GitHubBranchCombobox
- integrationId={integrationId}
- repo={draftBaseBranchRepo}
- value={draftBaseBranchBranch}
- allowCustomValues={false}
- disabled={teamConfigUpdating}
- onChange={(branch) => setDraftBaseBranchBranch(branch ?? '')}
- />
- ) : null}
- </ButtonGroup>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="outline"
- size="sm"
- disabled={!!addBaseBranchOverrideDisabledReason}
- loading={teamConfigUpdating}
- aria-label="Add base branch override"
- onClick={() => addBaseBranchOverride()}
- >
- <IconPlus />
- Add
- </Button>
- }
+ onChange={(branch) => setDraftBaseBranchBranch(branch ?? '')}
/>
- <TooltipContent>{addBaseBranchOverrideDisabledReason ?? 'Add base branch override'}</TooltipContent>
- </Tooltip>
+ ) : null}
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconPlus />}
+ disabledReason={addBaseBranchOverrideDisabledReason ?? undefined}
+ loading={teamConfigUpdating}
+ data-attr="signals-base-branch-override-add"
+ onClick={() => addBaseBranchOverride()}
+ >
+ Add
+ </LemonButton>
+ <LemonButton
+ type="tertiary"
+ size="small"
+ disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
+ onClick={() => clearDraftBaseBranch()}
+ >
+ Cancel
+ </LemonButton>
</div>
)
}
/**
- * Collapsed by default, because targeting anything but the repo's default branch is the exception.
- * Opens on its own when overrides exist, so a configured team isn't left to discover them behind a
- * chevron; the count keeps that state readable even once collapsed again.
+ * Where agents branch from, per repository. Renders regardless of the auto-start toggle, because the
+ * inbox "Create PR" button resolves the same overrides for a PR opened by hand. The list stays in
+ * view so a configured team can read its overrides without opening anything. The picker mounts on
+ * request, because the repository combobox loads the repository list as soon as it renders.
*/
-function BaseBranchOverrides(): JSX.Element {
- const { baseBranchOverrides } = useValues(signalTeamConfigLogic)
+function BaseBranchesRow(): JSX.Element {
const { githubIntegrations } = useValues(integrationsLogic)
+ const { baseBranchOverrides, baseBranchPickerOpen } = useValues(signalTeamConfigLogic)
+ const { setBaseBranchPickerOpen } = useActions(signalTeamConfigLogic)
- // The Collapsible root fills itself with --muted while open or hovered, which reads as an
- // off-color patch against the card. The trigger owns the hover instead.
return (
- <Collapsible defaultOpen={baseBranchOverrides.length > 0} className="bg-transparent hover:bg-transparent">
- {/* px-2.5/py-1.5 matches the Threshold row above; the Button's own fill is dropped so the
- row reads as a label, not a band, leaving only the hover as the affordance. */}
- <CollapsibleTrigger className="w-full h-auto px-2.5 py-1.5 text-xs text-secondary font-normal bg-transparent hover:bg-[var(--fill-hover)]">
- <span className="flex-1 text-left">Base branch overrides</span>
- {baseBranchOverrides.length > 0 && (
- <span className="text-tertiary tabular-nums">{baseBranchOverrides.length}</span>
- )}
- </CollapsibleTrigger>
- {/* Padding goes on the panel itself rather than a nested wrapper, which would stack with
- the panel's own inset. Same 10px/6px as the trigger and the Threshold row. */}
- <CollapsibleContent className="flex flex-col gap-1.5 px-2.5 pb-1.5">
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Otherwise, PRs use GitHub's default branch.
- </p>
- <BaseBranchOverrideRows />
- {githubIntegrations.length > 0 ? (
- <BaseBranchOverridePicker />
+ <AutonomySettingRow
+ title="Base branches"
+ description={
+ githubIntegrations.length > 0 ? (
+ 'PRs target the default branch of each repository. Add an override for a repository that needs a different branch.'
) : (
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Connect GitHub above to add an override.
- </p>
- )}
- </CollapsibleContent>
- </Collapsible>
+ // One element around the whole sentence, so the swap never removes a bare text
+ // node a translation extension replaced (frontend/src/AGENTS.md, rule 7).
+ <span>
+ PRs target the default branch of each repository.{' '}
+ <Link to={urls.settings('project-integrations')}>Connect GitHub</Link> to add an override.
+ </span>
+ )
+ }
+ >
+ {/* Stored overrides stay in view without an integration, so a team can still read and remove them. */}
+ {(githubIntegrations.length > 0 || baseBranchOverrides.length > 0) && (
+ <div className="flex flex-col gap-2 py-3">
+ <BaseBranchOverrideList />
+ {githubIntegrations.length > 0 &&
+ (baseBranchPickerOpen ? (
+ <BaseBranchOverridePicker />
+ ) : (
+ <div>
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconPlus />}
+ data-attr="signals-base-branch-override-open"
+ onClick={() => setBaseBranchPickerOpen(true)}
+ >
+ Add override
+ </LemonButton>
+ </div>
+ ))}
+ </div>
+ )}
+ </AutonomySettingRow>
)
}
@@ -306,7 +296,61 @@ function IssueTrackerTarget({
/>
)
}
- return <p className="text-[11px] text-tertiary leading-snug mb-0">Issues go to {integration.display_name}.</p>
+ return <p className="m-0 text-xs text-secondary">Issues go to {integration.display_name}.</p>
+}
+
+/** One sentence for a saved target, so the section reads it without mounting the picker. */
+function describeIssueTrackerTarget(integration: IntegrationType, target: Record<string, string>): string | null {
+ if (integration.kind === 'github' && target.repository) {
+ return `Issues go to ${integration.display_name}/${target.repository}.`
+ }
+ if (integration.kind === 'jira' && target.project_key) {
+ return `Issues go to project ${target.project_key}.`
+ }
+ // Linear stores only the team id, which means nothing to a reader. The picker shows the name.
+ if (integration.kind === 'linear' && target.team_id) {
+ return `Issues go to a team in ${integration.display_name}.`
+ }
+ return null
+}
+
+/**
+ * The saved target as text with a Change button, or the picker. The Linear and Jira pickers call
+ * the provider for their option lists as soon as they mount, so the picker only renders once a
+ * person asks to change the target, or when the chosen tracker has no target yet.
+ */
+function IssueTrackerTargetRow({
+ integration,
+ target,
+ disabled,
+ onSave,
+}: {
+ integration: IntegrationType
+ target: Record<string, string>
+ disabled: boolean
+ onSave: (config: Record<string, string>) => void
+}): JSX.Element | null {
+ const { issueTrackerTargetPickerOpen } = useValues(signalTeamConfigLogic)
+ const { setIssueTrackerTargetPickerOpen } = useActions(signalTeamConfigLogic)
+
+ const summary = describeIssueTrackerTarget(integration, target)
+ if (summary === null || issueTrackerTargetPickerOpen) {
+ return <IssueTrackerTarget integration={integration} target={target} disabled={disabled} onSave={onSave} />
+ }
+ return (
+ <div className="flex flex-wrap items-center gap-2">
+ <p className="m-0 text-xs text-secondary">{summary}</p>
+ <LemonButton
+ type="secondary"
+ size="small"
+ disabledReason={disabled ? 'Saving changes' : undefined}
+ data-attr="signals-issue-tracker-target-change"
+ onClick={() => setIssueTrackerTargetPickerOpen(true)}
+ >
+ Change
+ </LemonButton>
+ </div>
+ )
}
/**
@@ -314,7 +358,7 @@ function IssueTrackerTarget({
* only merge when a tracked work item points at it. Off unless a tracker is picked, so one field is
* both the switch and the target and the two can never disagree.
*/
-function IssueTracker(): JSX.Element {
+function IssueTrackerRow(): JSX.Element {
const { issueTrackerConfig, issueTrackerIntegrationId, selectedIssueTrackerIntegrationId, teamConfigUpdating } =
useValues(signalTeamConfigLogic)
const { patchTeamConfig, setDraftIssueTrackerIntegrationId } = useActions(signalTeamConfigLogic)
@@ -325,9 +369,6 @@ function IssueTracker(): JSX.Element {
const selected = trackers.find((integration) => integration.id === selectedIssueTrackerIntegrationId) ?? null
// A freshly picked provider has no target yet, so the stored one belongs to the old provider.
const target = selectedIssueTrackerIntegrationId === issueTrackerIntegrationId ? issueTrackerConfig : {}
- const saved = trackers.find((integration) => integration.id === issueTrackerIntegrationId) ?? null
- const summary =
- integrations === null ? 'Loading…' : saved ? (ISSUE_TRACKER_LABELS[saved.kind] ?? saved.kind) : 'Off'
const saveTarget = (config: Record<string, string>): void => {
if (selected) {
@@ -351,78 +392,71 @@ function IssueTracker(): JSX.Element {
}
}
- const content = (
- <div className="flex flex-col gap-1.5">
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Open an issue for every PR agents make, and link the two. Use this when a PR can only merge with a
- tracked work item behind it.
- </p>
- {integrations === null ? (
- integrationsLoading ? (
- <LemonSkeleton className="h-7 max-w-xs" />
- ) : (
- <div className="flex items-center gap-2">
- <span className="text-[11px] text-tertiary">Could not load integrations.</span>
- <LemonButton size="xsmall" type="secondary" onClick={() => loadIntegrations()}>
- Retry
- </LemonButton>
- </div>
- )
- ) : trackers.length > 0 ? (
- <>
- <LemonSelect
- size="xsmall"
- fullWidth
- className="max-w-xs"
- value={selectedIssueTrackerIntegrationId ?? ISSUE_TRACKER_OFF}
- options={[
- { value: ISSUE_TRACKER_OFF, label: 'Off' },
- ...trackers.map((integration) => ({
- value: integration.id,
- label: `${ISSUE_TRACKER_LABELS[integration.kind]} · ${integration.display_name}`,
- })),
- ]}
- disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
- onChange={chooseTracker}
+ let control: JSX.Element
+ if (integrations === null) {
+ control = integrationsLoading ? (
+ <LemonSkeleton className="h-8 w-40" />
+ ) : (
+ <LemonButton size="small" type="secondary" onClick={() => loadIntegrations()}>
+ Retry
+ </LemonButton>
+ )
+ } else if (trackers.length === 0) {
+ control = (
+ <LemonButton
+ size="small"
+ type="secondary"
+ to={urls.settings('project-integrations')}
+ data-attr="signals-issue-tracker-connect"
+ >
+ Connect a tracker
+ </LemonButton>
+ )
+ } else {
+ control = (
+ <LemonSelect
+ size="small"
+ value={selectedIssueTrackerIntegrationId ?? ISSUE_TRACKER_OFF}
+ options={[
+ { value: ISSUE_TRACKER_OFF, label: 'Off' },
+ ...trackers.map((integration) => ({
+ value: integration.id,
+ label: `${ISSUE_TRACKER_LABELS[integration.kind]} · ${integration.display_name}`,
+ })),
+ ]}
+ disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
+ onChange={chooseTracker}
+ aria-label="Issue tracker"
+ />
+ )
+ }
+
+ // One string rather than conditional text siblings, so the description keeps a sole text node
+ // that a translation extension cannot detach from React (frontend/src/AGENTS.md, rule 7).
+ let description =
+ 'Open an issue for every PR agents make, and link the two. Use this when a PR can only merge with a tracked work item behind it.'
+ if (integrations !== null && trackers.length === 0) {
+ description += ' Works with GitHub, GitLab, Linear, and Jira.'
+ } else if (integrations === null && !integrationsLoading) {
+ description += ' Could not load integrations.'
+ }
+
+ return (
+ <AutonomySettingRow title="Issue tracker" description={description} control={control}>
+ {selected && (
+ <div className="flex flex-col gap-2 py-3">
+ <IssueTrackerTargetRow
+ integration={selected}
+ target={target}
+ disabled={teamConfigUpdating}
+ onSave={saveTarget}
/>
- {selected && (
- <IssueTrackerTarget
- integration={selected}
- target={target}
- disabled={teamConfigUpdating}
- onSave={saveTarget}
- />
- )}
- <p className="text-[11px] text-tertiary leading-snug mb-0">
+ <p className="m-0 text-xs leading-snug text-secondary">
If the tracker fails, the PR still opens and the report shows that the issue is missing.
</p>
- </>
- ) : (
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- <Link to={urls.settings('project-integrations')}>Connect GitHub, GitLab, Linear, or Jira</Link> to
- track issues.
- </p>
+ </div>
)}
- </div>
- )
-
- return (
- <LemonCollapse
- embedded
- size="small"
- panels={[
- {
- key: 'issue-tracker',
- header: (
- <div className="flex flex-1 items-center justify-between gap-2">
- <span className="text-xs text-secondary">Issue tracker</span>
- <span className="text-xs text-tertiary">{summary}</span>
- </div>
- ),
- content,
- },
- ]}
- />
+ </AutonomySettingRow>
)
}
@@ -432,11 +466,9 @@ function IssueTracker(): JSX.Element {
* allow", and placing it next to plan usage read as if the two limits were one system. Renders
* regardless of the auto-start toggle, since the cap pauses report generation, not just PRs.
* The billing quota deliberately does not overwrite this row: it caps pull requests, not reports,
- * so stamping its pause here reported the wrong limit as the reason nothing arrived. Same
- * collapsed-by-default shape as Base branch overrides: the trigger's count keeps the state
- * readable without opening.
+ * so stamping its pause here reported the wrong limit as the reason nothing arrived.
*/
-function DailyReportLimit(): JSX.Element {
+function DailyReportLimitRow(): JSX.Element {
const {
maxReportsPerDay,
reportsGeneratedToday,
@@ -447,53 +479,59 @@ function DailyReportLimit(): JSX.Element {
} = useValues(signalTeamConfigLogic)
const { setDraftMaxReportsPerDay, saveDraftMaxReportsPerDay } = useActions(signalTeamConfigLogic)
- const summary =
+ const usage =
maxReportsPerDay != null
- ? `${Math.min(reportsGeneratedToday, maxReportsPerDay)} / ${maxReportsPerDay} today`
+ ? `${Math.min(reportsGeneratedToday, maxReportsPerDay)} of ${maxReportsPerDay} reports today.`
: null
return (
- <>
- <Collapsible className="bg-transparent hover:bg-transparent">
- <CollapsibleTrigger className="w-full h-auto px-2.5 py-1.5 text-xs text-secondary font-normal bg-transparent hover:bg-[var(--fill-hover)]">
- <span className="flex-1 text-left">Daily report limit</span>
- {summary && <span className="text-tertiary tabular-nums">{summary}</span>}
- </CollapsibleTrigger>
- <CollapsibleContent className="flex flex-col gap-1.5 px-2.5 pb-1.5">
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Pause new report generation after this many reports in a day. Leave empty for no limit.
- </p>
- <div className="flex items-center gap-1">
- <LemonInput
- type="number"
- min={1}
- step={1}
- size="small"
- placeholder="No limit"
- value={draftMaxReportsPerDay ?? undefined}
- onChange={(value) => setDraftMaxReportsPerDay(value ?? null)}
- onPressEnter={saveDraftMaxReportsPerDay}
- fullWidth
- />
- <LemonButton
- type="secondary"
- size="small"
- onClick={saveDraftMaxReportsPerDay}
- loading={teamConfigUpdating}
- disabledReason={saveMaxReportsPerDayDisabledReason ?? undefined}
- data-attr="signals-daily-report-limit-save"
- >
- Save
- </LemonButton>
- </div>
- </CollapsibleContent>
- </Collapsible>
- {dailyReportLimitReached && (
- <p className="text-xs font-medium text-danger mb-0 px-2.5 pb-1.5">
- Daily report limit reached. New reports resume at midnight in your project's timezone.
- </p>
- )}
- </>
+ <AutonomySettingRow
+ title="Daily report limit"
+ description={
+ <>
+ Pause new reports after this many in a day. Leave empty for no limit.
+ {usage && (
+ <>
+ {' '}
+ <span className="text-default tabular-nums" translate="no">
+ {usage}
+ </span>
+ </>
+ )}
+ {dailyReportLimitReached && (
+ <span className="block font-medium text-danger">
+ Daily report limit reached. New reports resume at midnight in your project's timezone.
+ </span>
+ )}
+ </>
+ }
+ control={
+ <>
+ <LemonInput
+ type="number"
+ min={1}
+ step={1}
+ size="small"
+ className="w-28"
+ placeholder="No limit"
+ value={draftMaxReportsPerDay ?? undefined}
+ onChange={(value) => setDraftMaxReportsPerDay(value ?? null)}
+ onPressEnter={saveDraftMaxReportsPerDay}
+ aria-label="Daily report limit"
+ />
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={saveDraftMaxReportsPerDay}
+ loading={teamConfigUpdating}
+ disabledReason={saveMaxReportsPerDayDisabledReason ?? undefined}
+ data-attr="signals-daily-report-limit-save"
+ >
+ Save
+ </LemonButton>
+ </>
+ }
+ />
)
}
@@ -507,22 +545,19 @@ function GitHubIssueWritebackRow(): JSX.Element {
const { patchTeamConfig } = useActions(signalTeamConfigLogic)
return (
- <div className="flex items-start justify-between gap-2 px-2.5 py-1.5">
- <div className="flex flex-col gap-0.5 min-w-0 flex-1">
- <span className="text-xs text-secondary">Comment back on GitHub issues</span>
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- When a GitHub issue creates a report, comment on that issue with a link to the report. Everybody
- watching the issue can see the comment.
- </p>
- </div>
- <LemonSwitch
- checked={githubIssueWritebackEnabled}
- loading={teamConfigUpdating}
- onChange={(enabled) => patchTeamConfig({ github_issue_writeback_enabled: enabled })}
- aria-label="Comment back on GitHub issues that create reports"
- data-attr="signals-github-issue-writeback"
- />
- </div>
+ <AutonomySettingRow
+ title="Comment back on GitHub issues"
+ description="When a GitHub issue creates a report, comment on that issue with a link to the report. Everybody watching the issue can see the comment."
+ control={
+ <LemonSwitch
+ checked={githubIssueWritebackEnabled}
+ loading={teamConfigUpdating}
+ onChange={(enabled) => patchTeamConfig({ github_issue_writeback_enabled: enabled })}
+ aria-label="Comment back on GitHub issues that create reports"
+ data-attr="signals-github-issue-writeback"
+ />
+ }
+ />
)
}
@@ -537,64 +572,66 @@ function GitHubAssignmentRow(): JSX.Element {
const { setGithubAssignOnPullRequest } = useActions(userAutonomyLogic)
return (
- <div className="flex items-start justify-between gap-2 px-2.5 py-1.5">
- <div className="flex flex-col gap-0.5 min-w-0 flex-1">
- <span className="text-xs text-secondary">Assign me on GitHub</span>
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Add you as an assignee on PRs for reports that suggest you as reviewer, across all your projects.
- </p>
- </div>
- <LemonSwitch
- checked={autonomyConfig?.github_assign_on_pull_request ?? false}
- loading={githubAssignUpdating}
- disabledReason={autonomyConfigLoading && autonomyConfig === null ? 'Loading settings' : undefined}
- onChange={setGithubAssignOnPullRequest}
- aria-label="Assign me on GitHub pull requests"
- data-attr="signals-github-assign-on-pull-request"
- />
- </div>
+ <AutonomySettingRow
+ title="Assign me on GitHub"
+ description="Add you as an assignee on the PRs agents open for your reports."
+ control={
+ <LemonSwitch
+ checked={autonomyConfig?.github_assign_on_pull_request ?? false}
+ loading={githubAssignUpdating}
+ disabledReason={autonomyConfigLoading && autonomyConfig === null ? 'Loading settings' : undefined}
+ onChange={setGithubAssignOnPullRequest}
+ aria-label="Assign me on GitHub pull requests"
+ data-attr="signals-github-assign-on-pull-request"
+ />
+ }
+ />
)
}
/**
* Whether self-driving PRs skip the draft state. Draft stays the default because a ready PR runs
- * the full CI matrix on every push, and the personal control overrides the project one because one
- * reviewer's workflow differs from their teammate's. Renders regardless of the auto-start toggle:
- * a PR opened by hand from the inbox goes through the same transition.
+ * the full CI matrix on every push. Renders regardless of the auto-start toggle: a PR opened by
+ * hand from the inbox goes through the same transition.
*/
-function PullRequestStateRows(): JSX.Element {
+function ProjectPullRequestStateRow(): JSX.Element {
const { defaultOpenPullRequestReady, teamConfigUpdating } = useValues(signalTeamConfigLogic)
const { patchTeamConfig } = useActions(signalTeamConfigLogic)
- const { autonomyConfig, autonomyConfigLoading, openPullRequestReadyUpdating } = useValues(userAutonomyLogic)
- const { setOpenPullRequestReady } = useActions(userAutonomyLogic)
-
- const mine = autonomyConfig?.github_open_pull_request_ready
- const myState = mine == null ? MY_PR_STATE_DEFAULT_VALUE : mine ? 'ready' : 'draft'
return (
- <div className="flex flex-col gap-2 px-2.5 py-1.5">
- <div className="flex flex-col gap-1">
- <span className="text-xs text-secondary">Self-driving PRs open as</span>
+ <AutonomySettingRow
+ title="Open PRs as"
+ description="Draft lets your team inspect the change first. Ready for review can run more checks and request reviews, as your repository settings allow."
+ control={
<LemonSegmentedButton
- size="xsmall"
+ size="small"
fullWidth
- className="max-w-xs"
value={defaultOpenPullRequestReady ? 'ready' : 'draft'}
options={PR_STATE_SEGMENTS}
disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
onChange={(next) => patchTeamConfig({ default_open_pull_request_ready: next === 'ready' })}
/>
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Ready for review can run more checks and request reviews. Your repository settings control these
- actions. Draft lets your team inspect the change first.
- </p>
- </div>
- <div className="flex flex-col gap-1">
- <span className="text-xs text-secondary">PRs for my review open as</span>
+ }
+ />
+ )
+}
+
+/** The personal counterpart: one reviewer's workflow differs from their teammate's, so it wins. */
+function MyPullRequestStateRow(): JSX.Element {
+ const { autonomyConfig, autonomyConfigLoading, openPullRequestReadyUpdating } = useValues(userAutonomyLogic)
+ const { setOpenPullRequestReady } = useActions(userAutonomyLogic)
+
+ const mine = autonomyConfig?.github_open_pull_request_ready
+ const myState = mine == null ? MY_PR_STATE_DEFAULT_VALUE : mine ? 'ready' : 'draft'
+
+ return (
+ <AutonomySettingRow
+ title="Open PRs as"
+ description="Default follows the project setting. A PR stays in draft if someone moves it back to draft."
+ control={
<LemonSegmentedButton
- size="xsmall"
+ size="small"
fullWidth
- className="max-w-xs"
value={myState}
options={MY_PR_STATE_SEGMENTS}
disabledReason={
@@ -608,33 +645,109 @@ function PullRequestStateRows(): JSX.Element {
setOpenPullRequestReady(next === MY_PR_STATE_DEFAULT_VALUE ? null : next === 'ready')
}
/>
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- This choice applies to all projects where reports suggest you as a reviewer. It overrides each
- project setting. A PR stays in draft if someone moves it back to draft.
- </p>
- </div>
- </div>
+ }
+ />
+ )
+}
+
+/** The team default; a teammate's personal threshold takes precedence for reports suggesting them. */
+function ProjectThresholdRow(): JSX.Element {
+ const { defaultAutostartPriority, teamConfigUpdating } = useValues(signalTeamConfigLogic)
+ const { patchTeamConfig } = useActions(signalTeamConfigLogic)
+
+ return (
+ <AutonomySettingRow
+ title="Priority threshold"
+ description="Agents open PRs for reports at this priority or higher."
+ control={
+ <LemonSegmentedButton
+ size="small"
+ fullWidth
+ value={defaultAutostartPriority}
+ options={THRESHOLD_SEGMENTS}
+ disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
+ onChange={(next) => patchTeamConfig({ default_autostart_priority: next })}
+ />
+ }
+ />
+ )
+}
+
+function MyThresholdRow(): JSX.Element {
+ const { autonomyConfig, autonomyConfigLoading, autostartPriorityUpdating } = useValues(userAutonomyLogic)
+ const { setAutostartPriority } = useActions(userAutonomyLogic)
+ const myThreshold = autonomyConfig?.autostart_priority ?? MY_THRESHOLD_DEFAULT_VALUE
+
+ return (
+ <AutonomySettingRow
+ title="Priority threshold"
+ description="Default follows the project threshold."
+ control={
+ <LemonSegmentedButton
+ size="small"
+ fullWidth
+ value={myThreshold}
+ options={MY_THRESHOLD_SEGMENTS}
+ disabledReason={
+ autostartPriorityUpdating
+ ? 'Saving changes'
+ : autonomyConfigLoading
+ ? 'Loading settings'
+ : undefined
+ }
+ onChange={(next) =>
+ setAutostartPriority(
+ next === MY_THRESHOLD_DEFAULT_VALUE ? null : (next as SignalReportPriority)
+ )
+ }
+ />
+ }
+ />
)
}
/**
* 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.
+ * on `signalTeamConfigLogic`. The switch is the master opt-out for autonomous inbox PRs; reports
+ * keep generating and notifying either way. The threshold only matters while it is on, so it nests
+ * under it.
+ */
+function PullRequestGenerationRow(): JSX.Element {
+ const { teamConfigUpdating, autostartEnabled } = useValues(signalTeamConfigLogic)
+ const { patchTeamConfig } = useActions(signalTeamConfigLogic)
+
+ return (
+ <AutonomySettingRow
+ title="PR generation"
+ description={
+ autostartEnabled
+ ? 'Agents open PRs for actionable reports.'
+ : 'Reports still arrive and notify your team. Turn this on to let agents open PRs for actionable reports.'
+ }
+ control={
+ <LemonSwitch
+ checked={autostartEnabled}
+ loading={teamConfigUpdating}
+ onChange={(enabled) => patchTeamConfig({ autostart_enabled: enabled })}
+ aria-label="Generate PRs for actionable reports automatically"
+ data-attr="signals-autostart-enabled"
+ />
+ }
+ >
+ {autostartEnabled && <ProjectThresholdRow />}
+ </AutonomySettingRow>
+ )
+}
+
+/**
+ * The Autonomy settings: what agents do on their own for this project, the current user's personal
+ * overrides, and the daily report cap. Rows group by scope so a setting does not have to say who it
+ * applies to, and every row shares one shape (`AutonomySettingRow`).
*/
export function SelfDrivingSection(): JSX.Element {
// The Settings tab wraps this in its own card; the legacy setup rail does not.
const redesign = useFeatureFlag('INBOX_REDESIGN')
- const { teamConfig, teamConfigLoading, teamConfigUpdating, autostartEnabled, defaultAutostartPriority } =
- useValues(signalTeamConfigLogic)
- const { patchTeamConfig } = useActions(signalTeamConfigLogic)
- const { autonomyConfig, autonomyConfigLoading, autostartPriorityUpdating } = useValues(userAutonomyLogic)
- const { setAutostartPriority } = useActions(userAutonomyLogic)
- const myThreshold = autonomyConfig?.autostart_priority ?? MY_THRESHOLD_DEFAULT_VALUE
+ const { teamConfig, teamConfigLoading } = useValues(signalTeamConfigLogic)
if (teamConfigLoading && teamConfig === null) {
return <LemonSkeleton className="h-20 w-full rounded" />
@@ -644,99 +757,28 @@ export function SelfDrivingSection(): JSX.Element {
<div
className={
redesign
- ? '-mx-2.5 flex flex-col'
- : 'flex flex-col rounded border border-primary bg-surface-primary overflow-hidden'
+ ? 'flex flex-col divide-y divide-primary'
+ : 'flex flex-col divide-y divide-primary rounded border border-primary bg-surface-primary px-3 py-3'
}
>
- <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}
- loading={teamConfigUpdating}
- 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={redesign ? 'border-t border-primary' : 'border-t border-primary bg-surface-secondary'}>
- {autostartEnabled ? (
- <>
- {/* Label above the control rather than beside it: the rail is narrow enough that a
- five- or six-segment row alongside a label overflows the card. `fullWidth` keeps the
- segments even, capped so the same markup doesn't stretch in the wide stacked layout. */}
- <div className="flex flex-col gap-2 px-2.5 py-1.5">
- <div className="flex flex-col gap-1">
- <span className="text-xs text-secondary">Project threshold</span>
- <LemonSegmentedButton
- size="xsmall"
- fullWidth
- className="max-w-xs"
- value={defaultAutostartPriority}
- options={THRESHOLD_SEGMENTS}
- disabledReason={teamConfigUpdating ? 'Saving changes' : undefined}
- onChange={(next) => patchTeamConfig({ default_autostart_priority: next })}
- />
- </div>
- <div className="flex flex-col gap-1">
- <span className="text-xs text-secondary">My threshold</span>
- <LemonSegmentedButton
- size="xsmall"
- fullWidth
- className="max-w-xs"
- value={myThreshold}
- options={MY_THRESHOLD_SEGMENTS}
- disabledReason={
- autostartPriorityUpdating
- ? 'Saving changes'
- : autonomyConfigLoading
- ? 'Loading settings'
- : undefined
- }
- onChange={(next) =>
- setAutostartPriority(
- next === MY_THRESHOLD_DEFAULT_VALUE ? null : (next as SignalReportPriority)
- )
- }
- />
- <p className="text-[11px] text-tertiary leading-snug mb-0">
- Overrides the project threshold for reports that suggest you as reviewer. It applies
- across all your projects.
- </p>
- </div>
- </div>
- <div className="border-t border-primary">
- <BaseBranchOverrides />
- </div>
- </>
- ) : (
- <p className="text-xs text-secondary mb-0 px-2.5 py-1.5">
- Reports still arrive and notify your team.
- </p>
- )}
- <div className="border-t border-primary">
- <PullRequestStateRows />
- </div>
- <div className="border-t border-primary">
- <GitHubIssueWritebackRow />
- </div>
- <div className="border-t border-primary">
- <GitHubAssignmentRow />
- </div>
- <div className="border-t border-primary">
- <IssueTracker />
- </div>
- <div className="border-t border-primary">
- <DailyReportLimit />
- </div>
- </div>
+ <AutonomySettingGroup title="Pull requests" description="Applies to everyone in this project.">
+ <PullRequestGenerationRow />
+ <BaseBranchesRow />
+ <ProjectPullRequestStateRow />
+ <GitHubIssueWritebackRow />
+ <IssueTrackerRow />
+ </AutonomySettingGroup>
+ <AutonomySettingGroup
+ title="Your overrides"
+ description="For reports that suggest you as reviewer, in every project you belong to. These override the project settings."
+ >
+ <MyThresholdRow />
+ <MyPullRequestStateRow />
+ <GitHubAssignmentRow />
+ </AutonomySettingGroup>
+ <AutonomySettingGroup title="Reports" description="Applies to everyone in this project.">
+ <DailyReportLimitRow />
+ </AutonomySettingGroup>
</div>
)
}
diff --git a/products/signals/frontend/inbox/logics/signalTeamConfigLogic.ts b/products/signals/frontend/inbox/logics/signalTeamConfigLogic.ts
index 045913be5b8d..75ccc8787217 100644
--- a/products/signals/frontend/inbox/logics/signalTeamConfigLogic.ts
+++ b/products/signals/frontend/inbox/logics/signalTeamConfigLogic.ts
@@ -27,6 +27,7 @@ export interface signalTeamConfigLogicValues {
addBaseBranchOverrideDisabledReason: string | null
autostartEnabled: boolean
baseBranchOverrides: BaseBranchOverride[]
+ baseBranchPickerOpen: boolean
dailyReportLimitReached: boolean
defaultAutostartPriority: SignalReportPriority
defaultOpenPullRequestReady: boolean
@@ -38,6 +39,7 @@ export interface signalTeamConfigLogicValues {
githubIssueWritebackEnabled: boolean
issueTrackerConfig: Record<string, string>
issueTrackerIntegrationId: number | null
+ issueTrackerTargetPickerOpen: boolean
maxReportsPerDay: number | null
patchesInFlight: number
reportsGeneratedToday: number
@@ -104,6 +106,9 @@ export interface signalTeamConfigLogicActions {
saveDraftMaxReportsPerDay: () => {
value: true
}
+ setBaseBranchPickerOpen: (open: boolean) => {
+ open: boolean
+ }
setDraftBaseBranchBranch: (branch: string) => {
branch: string
}
@@ -119,6 +124,9 @@ export interface signalTeamConfigLogicActions {
setDraftMaxReportsPerDay: (value: number | null) => {
value: number | null
}
+ setIssueTrackerTargetPickerOpen: (open: boolean) => {
+ open: boolean
+ }
updateBaseBranchOverride: (
repo: string,
branch: string
@@ -193,6 +201,8 @@ export const signalTeamConfigLogic = kea<signalTeamConfigLogicType>([
setDraftMaxReportsPerDay: (value: number | null) => ({ value }),
saveDraftMaxReportsPerDay: true,
setDraftIssueTrackerIntegrationId: (integrationId: number | null) => ({ integrationId }),
+ setBaseBranchPickerOpen: (open: boolean) => ({ open }),
+ setIssueTrackerTargetPickerOpen: (open: boolean) => ({ open }),
}),
loaders(() => {
// Every patch of `autostart_base_branches` sends the whole map, so two in flight at once let the
@@ -254,6 +264,25 @@ export const signalTeamConfigLogic = kea<signalTeamConfigLogicType>([
clearDraftBaseBranch: () => '',
},
],
+ // The pickers below fetch their option lists on mount, and Linear and Jira do so from the
+ // provider. They mount only after a person asks to add or change a value, so a view of
+ // the section costs no integration request. Closing also drops the base branch draft.
+ baseBranchPickerOpen: [
+ false,
+ {
+ setBaseBranchPickerOpen: (_, { open }) => open,
+ clearDraftBaseBranch: () => false,
+ },
+ ],
+ issueTrackerTargetPickerOpen: [
+ false,
+ {
+ setIssueTrackerTargetPickerOpen: (_, { open }) => open,
+ setDraftIssueTrackerIntegrationId: () => false,
+ patchTeamConfigSuccess: (state, { payload }) =>
+ payload?.patch && 'issue_tracking_config' in payload.patch ? false : state,
+ },
+ ],
// A save is in flight while this is above zero. Tracked explicitly rather than read off
// teamConfigLoading, because that flag also flips for the initial load and the background
// tab-return refresh (both plain GETs), neither of which should disable the save controls.