: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(settings): rename agent settings and show who they affect under today-rail-nav (#110217)
Shy Altere40cafef7f11
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e5bf56aa402b..35bed2d437f8 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2297,9 +2297,9 @@ snapshots:components-search--product-recents-and-starred--light:hash: v1.k794b7964.45213063c3c767175033b9c3ff72d94df2e3ffc9ffe46398bc78c45c3708f1b5.X_mXo_erMw09YXsaZY6-sc_9vQx8VtriGVHZgr_wJmwcomponents-search--searching--dark:- hash: v1.k794b7964.85544bea3a92150db0074577d58f437b5b09f93dfa82c7dcd9a27d5e38cd3256.9qyAZf2smivxTKXy7X55f5ZzMoiqvWZSa3HPQeTEGA4+ hash: v1.k794b7964.ae247836fac71b1e28116bee6c32d31a85e2f07a561743305c93e4f28cad2e4f.r6uSoLw68XcOix7fWb6Xhow6od6DG9PCD6Gb7avZyDEcomponents-search--searching--light:- hash: v1.k794b7964.4e738196907c56187af644a3ce2054b81628979093a0fb7071cbddc0b828969d.EaYKI7WplrZEWvFuoC4FLC6Jyv-YcAxrsFyAxq96jrI+ hash: v1.k794b7964.23b1f5e5c02f9929a895879ffb3e9a6d97f62fa1b1c23c9b150464e117bfa330.2gya8sUFXKlDzwVigII5a7IOAqnR-O1jXBrpiJF42m8components-sentencelist--full-sentence--dark:hash: v1.k794b7964.7e8e5dd2e09d246cc3668f362f2391fe67618bd1143aa393832297f5dc30e558.yptEWKc5RAUY613Fwd5cQ0VIinMvpdoI6cuKgagAGxkcomponents-sentencelist--full-sentence--light:diff --git a/frontend/src/lib/components/Search/searchLogic.test.ts b/frontend/src/lib/components/Search/searchLogic.test.tsindex d6cd48a1898d..e1d01d9aaeaf 100644--- a/frontend/src/lib/components/Search/searchLogic.test.ts+++ b/frontend/src/lib/components/Search/searchLogic.test.ts@@ -90,6 +90,52 @@ describe('searchLogic', () => {expect(terminalDockLogic.values.dockOpen).toBe(false)})+ it.each([+ ['off', false, 'Model preferences', false],+ ['on', true, 'Agent preferences', true],+ ])(+ 'shows one copy of a section gated on a flag and its negation, with the flag %s',+ (_state, flagOn, expectedName, expectsGatedKeyword) => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TODAY_RAIL_NAV]: flagOn })+ const settings = [+ {+ id: 'task-agent-my-preference',+ hasTitle: true,+ titleString: 'My default model',+ descriptionString: null,+ },+ {+ id: 'task-comments-slack-dm',+ hasTitle: true,+ titleString: 'Gated setting',+ descriptionString: null,+ keywords: ['zebra'],+ flag: 'TODAY_RAIL_NAV' as const,+ },+ ]+ logic.actions.setSettingsSections([+ {+ id: 'environment-task-agents',+ level: 'environment',+ titleString: 'Agent preferences',+ flag: 'TODAY_RAIL_NAV',+ settings,+ },+ {+ id: 'environment-task-agents',+ level: 'environment',+ titleString: 'Model preferences',+ flag: '!TODAY_RAIL_NAV',+ settings,+ },+ ])++ const items = logic.values.settingsItems.filter((item) => item.id === 'settings-project-task-agents')+ expect(items.map((item) => item.displayName)).toEqual([expectedName])+ expect(items[0].name.includes('zebra')).toBe(expectsGatedKeyword)+ }+ )+it('aborts and cancels the in-flight person search when the term is cleared', async () => {neverResolvingPersonSearch()diff --git a/frontend/src/lib/components/Search/searchLogic.tsx b/frontend/src/lib/components/Search/searchLogic.tsxindex 36068a92b42a..5640c1e3305e 100644--- a/frontend/src/lib/components/Search/searchLogic.tsx+++ b/frontend/src/lib/components/Search/searchLogic.tsx@@ -194,6 +194,7 @@ export interface SettingsSectionSummary {titleString: string | nulldescriptionString: string | nullkeywords?: string[]+ flag?: SettingSection['flag']}[]}@@ -1406,12 +1407,6 @@ export const searchLogic = kea<searchLogicType>([section.level === 'environment' ? section.id.replace('environment-', 'project-') : section.id) as SettingSectionId- // Skip duplicate project sections (environment sections take priority)- if (seenSectionIds.has(effectiveSectionId)) {- continue- }- seenSectionIds.add(effectiveSectionId)-// Filter by feature flag if requiredif (section.flag) {if (!checkFlag(section.flag as Pick<Setting, 'flag'>['flag'])) {@@ -1419,13 +1414,19 @@ export const searchLogic = kea<searchLogicType>([}}+ // Skip duplicate project sections (environment sections take priority)+ if (seenSectionIds.has(effectiveSectionId)) {+ continue+ }+ seenSectionIds.add(effectiveSectionId)+// Create a search item for each settings sectionconst levelPrefix = toSentenceCase(effectiveLevel)const searchTerms = [...(section.keywords ?? []),...section.settings- .filter((setting) => setting.hasTitle)+ .filter((setting) => setting.hasTitle && checkFlag(setting.flag)).flatMap((setting) => [toSentenceCase(setting.id.replace(/[-]/g, ' ')),...(setting.titleString ? [setting.titleString] : []),@@ -1935,6 +1936,7 @@ export const searchLogic = kea<searchLogicType>([setting.searchDescription ??(typeof setting.description === 'string' ? setting.description : null),keywords: setting.keywords,+ flag: setting.flag,})),})))diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsxindex 2f75cd69668d..d5fd8ecc33f6 100644--- a/frontend/src/scenes/settings/SettingsMap.tsx+++ b/frontend/src/scenes/settings/SettingsMap.tsx@@ -83,6 +83,7 @@ import { WorkflowsEngagementEventsSettings } from 'products/workflows/frontend/simport { WorkflowsTaskLimitsSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsTaskLimitsSettings'import { IntegrationsList } from '../../lib/integrations/IntegrationsList'+import { SettingScopeTag } from './components/SettingScopeTag'import {ActivityLogNotifications,ActivityLogOrgLevelSettings,@@ -383,11 +384,50 @@ export const SETTINGS_MAP: SettingSection[] = [},],},+ {+ level: 'environment',+ id: 'environment-task-agents',+ title: 'Agent preferences',+ group: 'AI',+ flag: 'TODAY_RAIL_NAV',+ keywords: ['model preferences', 'personalization', 'desktop'],+ settings: [+ {+ id: 'task-agent-project-default',+ title: (+ <>+ Project default model+ <SettingScopeTag scope="project" />+ </>+ ),+ searchTerm: 'Project default model',+ description:+ 'The model agent runs launch with when nobody picks one. Everyone on this project inherits it in the new PostHog AI view, in Slack, and in PostHog Desktop.',+ component: <TaskAgentProjectDefaultSettings />,+ keywords: ['ai', 'model', 'claude', 'codex', 'agent', 'tasks', 'default', 'slack', 'desktop'],+ },+ {+ id: 'task-agent-my-preference',+ title: (+ <>+ My default model+ <SettingScopeTag scope="user" />+ </>+ ),+ searchTerm: 'My default model',+ description:+ 'The model your own runs launch with, overriding the project default. Applies in the new PostHog AI view, in Slack, and in PostHog Desktop.',+ component: <TaskAgentMyPreferenceSettings />,+ keywords: ['ai', 'model', 'claude', 'codex', 'agent', 'tasks', 'preference', 'slack', 'desktop'],+ },+ ],+ },{level: 'environment',id: 'environment-task-agents',title: 'Model preferences',group: 'AI',+ flag: '!TODAY_RAIL_NAV',settings: [{id: 'task-agent-project-default',@@ -407,12 +447,36 @@ export const SETTINGS_MAP: SettingSection[] = [},],},+ {+ level: 'environment',+ id: 'environment-ai-subscriptions',+ title: 'Bring your own subscription',+ group: 'AI',+ flag: ['POSTHOG_CODE_CODEX_OWN_SUBSCRIPTION_CLOUD', 'TODAY_RAIL_NAV'],+ keywords: ['subscriptions', 'byos', 'plan & usage'],+ settings: [+ {+ id: 'ai-subscription-codex',+ title: (+ <>+ Codex+ <SettingScopeTag scope="user" />+ </>+ ),+ searchTerm: 'Codex',+ description:+ 'Connect your ChatGPT account so your Codex cloud tasks can run on your own ChatGPT plan. The connection is yours and applies in every project.',+ component: <PersonalCodexIntegration />,+ keywords: ['codex', 'chatgpt', 'openai', 'subscription', 'plan', 'billing', 'cloud', 'personal'],+ },+ ],+ },{level: 'environment',id: 'environment-ai-subscriptions',title: 'Subscriptions',group: 'AI',- flag: 'POSTHOG_CODE_CODEX_OWN_SUBSCRIPTION_CLOUD',+ flag: ['POSTHOG_CODE_CODEX_OWN_SUBSCRIPTION_CLOUD', '!TODAY_RAIL_NAV'],settings: [{id: 'ai-subscription-codex',diff --git a/frontend/src/scenes/settings/components/SettingScopeTag.tsx b/frontend/src/scenes/settings/components/SettingScopeTag.tsxnew file mode 100644index 000000000000..db9ec5f8e50e--- /dev/null+++ b/frontend/src/scenes/settings/components/SettingScopeTag.tsx@@ -0,0 +1,22 @@+import { LemonTag, Tooltip } from '@posthog/lemon-ui'++export type SettingScope = 'user' | 'project'++const SCOPE_COPY: Record<SettingScope, { label: string; tooltip: string }> = {+ user: { label: 'Only you', tooltip: 'This setting changes only your own agent runs.' },+ project: {+ label: 'Everyone in this project',+ tooltip: 'This setting changes agent runs for everyone in this project.',+ },+}++export function SettingScopeTag({ scope }: { scope: SettingScope }): JSX.Element {+ const { label, tooltip } = SCOPE_COPY[scope]+ return (+ <Tooltip title={tooltip}>+ <LemonTag size="small" type={scope === 'project' ? 'warning' : 'muted'} className="ml-2 align-middle">+ {label}+ </LemonTag>+ </Tooltip>+ )+}diff --git a/frontend/src/scenes/settings/settingsSearch.test.tsx b/frontend/src/scenes/settings/settingsSearch.test.tsxindex 687af5d13b20..f7d3d5e255e4 100644--- a/frontend/src/scenes/settings/settingsSearch.test.tsx+++ b/frontend/src/scenes/settings/settingsSearch.test.tsx@@ -1,3 +1,5 @@+import { FEATURE_FLAGS } from 'lib/constants'+import { matchesFlagDefinition } from './flagGating'import { SETTINGS_MAP } from './SettingsMap'import { buildSettingsSearchIndex, createSettingsSearchFuse, searchSettingsIndex } from './settingsSearch'@@ -121,4 +123,35 @@ describe('settingsSearch', () => {expect(searchSettingsIndex(fuse, term)[0]?.settingId).toBe('variables')})+ // The today-rail-nav redesign renames some sections by keeping their id and gating two copies on+ // the flag and its negation. Both copies visible at once would render the section twice.+ test.each([+ ['on', { [FEATURE_FLAGS.TODAY_RAIL_NAV]: true }],+ ['off', {}],+ ])('shows each section once with today-rail-nav %s', (_state, flags) => {+ const allOtherFlags = Object.fromEntries(+ Object.values(FEATURE_FLAGS)+ .filter((flag) => flag !== FEATURE_FLAGS.TODAY_RAIL_NAV)+ .map((flag) => [flag, true])+ )+ const visibleIds = SETTINGS_MAP.filter((section) =>+ matchesFlagDefinition(section.flag, { ...allOtherFlags, ...flags })+ ).map((section) => section.id)++ expect(visibleIds.length).toBe(new Set(visibleIds).size)+ })++ test.each([+ ['model preferences', 'task-agent-my-preference'],+ ['subscriptions', 'ai-subscription-codex'],+ ])('finds a renamed section by its old name "%s" with today-rail-nav on', (term, expectedSettingId) => {+ const flags = {+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: true,+ [FEATURE_FLAGS.POSTHOG_CODE_CODEX_OWN_SUBSCRIPTION_CLOUD]: true,+ }+ const visible = (definition: Pick<Setting, 'flag'>): boolean => matchesFlagDefinition(definition.flag, flags)+ const fuse = createSettingsSearchFuse(buildSettingsSearchIndex(SETTINGS_MAP.filter(visible), visible))++ expect(searchSettingsIndex(fuse, term).map((entry) => entry.settingId)).toContain(expectedSettingId)+ })})