: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(aio): toggle signal sources from the self-driving tab (#83176)
Radu Raicea1b509d64afb9
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 94c1c2a030c1..79b05089453e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5444,6 +5444,26 @@ snapshots:hash: v1.k794b7964.5cdaae6b72efa77261704903c3b14197bd4996f9db290718a4a585758aaa6cf2.xbF6ujFL2OI5SqKxuBM4wYp4MT4t2IC_HjI5-9mkT4cscenes-app-ai-observability-prompts--prompts-list--light:hash: v1.k794b7964.f4a3e9e0c94c327fbf41ea4698bb4d9cb92b5112848b3ee7f31c57466f0075b2.MoyySImBvALTiYl2FHqO1UG4XLCdcaJJzoUG56t_7gI+ scenes-app-ai-observability-self-driving-signal-source-toggle--load-failed--dark:+ hash: v1.k794b7964.594419147aefa58da5dddcb6b52c77c2f0c89f4830115a85cb93be8a719cfcc3.-0XtR5ua7OLwsi_LNT4ez5y9XsLqX4eQLrRsOX25y9U+ scenes-app-ai-observability-self-driving-signal-source-toggle--load-failed--light:+ hash: v1.k794b7964.666b8ed873bf7556fcbc614b1eff5d35be355cf20ae802d17a4296a7c28f4695.EhTofW4HGRg0NTr6BzBVSYLZtX7cj6H1r6u3Y06eICY+ scenes-app-ai-observability-self-driving-signal-source-toggle--loading--dark:+ hash: v1.k794b7964.4ccfbd9c7bc2fd77e7921b99926ca649cf2d278f3f52ad6aeef4a833877a0763.TIxsDf72HoX3oaW_c3Y1Vgauvkm8r_BMkiTnk-JqaC8+ scenes-app-ai-observability-self-driving-signal-source-toggle--loading--light:+ hash: v1.k794b7964.e4c2dbbde9aa9afcf7be121e5d357173a7da8cb243aac62f78a62dc4d63f198b.dWlu0w4h48kprw6oJpUUnFhruNVseXvmk7tgOexgGr8+ scenes-app-ai-observability-self-driving-signal-source-toggle--off--dark:+ hash: v1.k794b7964.8b44e85a56d3b162b3768808a1b3792d090a04eb2eeb24570ccde26757774aa0.KQZsisW5PcYcBbSNnuePRg1HErLXOhvMd7PTkDsCQXg+ scenes-app-ai-observability-self-driving-signal-source-toggle--off--light:+ hash: v1.k794b7964.32444d7760fdd3fe980414e14d0c29510dbcc79e53ac2e68480547ee798cf4b2.lWBrIzdl1fKU_qkGaN2mD1PdBRfYv1rGKzxWoXVmoSo+ scenes-app-ai-observability-self-driving-signal-source-toggle--on--dark:+ hash: v1.k794b7964.0947900b570417a054728ab484ebd682d108bbee215c93ad3c778c37a802c9e9.s-j4c2rVP1u58Lccoz68vFvzfVcN9VZAC5p0MeFhqSE+ scenes-app-ai-observability-self-driving-signal-source-toggle--on--light:+ hash: v1.k794b7964.65507eafae6b5eaf562fe40465076636506836ecdd66d27a4b99b381dbfb81ef.tRa6_ayTerymDxICixAGiw5Ps1nRLfxpXHrp3cyenfk+ scenes-app-ai-observability-self-driving-signal-source-toggle--toggling--dark:+ hash: v1.k794b7964.698da88937d031d692634a6f51af5cd6a45073adb0ececbe2c4f5ccee21c1390.lOPHKqkKlf_TQsmBTx5c2EyzsNDp2MeNqX_D8mjtguI+ scenes-app-ai-observability-self-driving-signal-source-toggle--toggling--light:+ hash: v1.k794b7964.c965506f3fa35369674cf3940c90a5c2de5776e3d8ed68db83089ec1480ed7d5.uBDe4ORwPrZR2iyF9JYRLhLzi5-pwke4LrzIicgf4aEscenes-app-ai-observability-sentiment--bar-full-width--dark:hash: v1.k794b7964.c85f4138877bf5f706d5675ad8ebca39a87300e45359ba3f5325551815fb5885.E-9wb0W7JxbRPXtj3-swTXq2QVbMKq-BpfDn-PXxcfUscenes-app-ai-observability-sentiment--bar-full-width--light:diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsxindex dafdbc2326ef..e3a67fda6d8a 100644--- a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx@@ -1,14 +1,17 @@import '@testing-library/jest-dom'-import { cleanup, render, screen, within } from '@testing-library/react'+import { cleanup, render, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { Provider } from 'kea'import type { ReactNode } from 'react'+import { lemonToast } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { newInternalTab } from 'lib/utils/newInternalTab'+import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'@@ -38,9 +41,28 @@ jest.mock('products/signals/frontend/inbox/components/config/scouts/ScoutCreateBScoutCreateButton: ({ children }: { children: ReactNode }) => <button>{children}</button>,}))+const EVAL_REPORTS_SOURCE_CONFIG = {+ id: 'source-config-eval-reports',+ source_product: 'llm_analytics',+ source_type: 'evaluation_report',+ enabled: true,+ config: {},+}++const ANOMALY_INVESTIGATION_SOURCE_CONFIG = {+ id: 'source-config-anomaly-investigation',+ source_product: 'analytics',+ source_type: 'anomaly_investigation',+ enabled: false,+ config: {},+}+describe('AIObservabilitySelfDriving', () => {+ let patchedSourceConfigs: { id: string; enabled: boolean }[]+beforeEach(() => {localStorage.clear()+ patchedSourceConfigs = []useMocks({get: {'/api/environments/:teamId/llm_analytics/provider_keys/': { results: [] },@@ -49,6 +71,26 @@ describe('AIObservabilitySelfDriving', () => {created_at: '2024-01-01T00:00:00Z',updated_at: '2024-01-01T00:00:00Z',},+ '/api/projects/:team_id/signals/source_configs/': () => [+ 200,+ {+ results: [EVAL_REPORTS_SOURCE_CONFIG, ANOMALY_INVESTIGATION_SOURCE_CONFIG],+ count: 2,+ next: null,+ previous: null,+ },+ ],+ },+ patch: {+ '/api/projects/:team_id/signals/source_configs/:id/': async ({ request, params }) => {+ const body = (await request.json()) as { enabled: boolean }+ patchedSourceConfigs.push({ id: params.id as string, enabled: body.enabled })+ const sourceConfig =+ params.id === ANOMALY_INVESTIGATION_SOURCE_CONFIG.id+ ? ANOMALY_INVESTIGATION_SOURCE_CONFIG+ : EVAL_REPORTS_SOURCE_CONFIG+ return [200, { ...sourceConfig, enabled: body.enabled }]+ },},})initKeaTests()@@ -319,6 +361,91 @@ describe('AIObservabilitySelfDriving', () => {expect(newInternalTab).toHaveBeenLastCalledWith('/alerts?alert_type=insights&alert_id=alert-investigated')})+ // Both sections render the same switch, so a section wired to the other section's signal+ // source would still look right. This pins each switch to the config it reads and writes.+ it('reads and writes each section signal source', async () => {+ const successToast = jest.spyOn(lemonToast, 'success').mockReturnValue('signal-source-toggle')++ render(+ <Provider>+ <AIObservabilitySelfDriving />+ </Provider>+ )++ const evalReportsSwitch = await screen.findByTestId('self-driving-eval-reports-signal-source')+ const anomalySwitch = screen.getByTestId('self-driving-anomaly-investigation-signal-source')+ expect(evalReportsSwitch).toHaveAttribute('aria-checked', 'true')+ expect(anomalySwitch).toHaveAttribute('aria-checked', 'false')++ await userEvent.click(screen.getByText('AI observability signal source'))+ expect(patchedSourceConfigs).toEqual([])+ expect(evalReportsSwitch).toHaveAttribute('aria-checked', 'true')++ await userEvent.click(anomalySwitch)+ await waitFor(() =>+ expect(patchedSourceConfigs).toEqual([{ id: 'source-config-anomaly-investigation', enabled: true }])+ )+ expect(successToast).toHaveBeenCalledWith('Product analytics signal source enabled')+ await waitFor(() => expect(anomalySwitch).not.toBeDisabled())++ await userEvent.click(evalReportsSwitch)+ await waitFor(() =>+ expect(patchedSourceConfigs).toEqual([+ { id: 'source-config-anomaly-investigation', enabled: true },+ { id: 'source-config-eval-reports', enabled: false },+ ])+ )+ expect(successToast).toHaveBeenCalledWith('AI observability signal source disabled')+ successToast.mockRestore()+ })++ it('offers a retry when signal source configs fail to load', async () => {+ let sourceConfigRequests = 0+ useMocks({+ get: {+ '/api/projects/:team_id/signals/source_configs/': () => {+ sourceConfigRequests += 1+ if (sourceConfigRequests === 1) {+ return [500, { detail: 'Failed to load signal source settings' }]+ }+ return [+ 200,+ {+ results: [EVAL_REPORTS_SOURCE_CONFIG, ANOMALY_INVESTIGATION_SOURCE_CONFIG],+ count: 2,+ next: null,+ previous: null,+ },+ ]+ },+ },+ })+ silenceKeaLoadersErrors()++ try {+ render(+ <Provider>+ <AIObservabilitySelfDriving />+ </Provider>+ )++ const loadErrors = await screen.findAllByText(+ "We couldn't load signal source settings. Try again in a moment."+ )+ expect(loadErrors).toHaveLength(2)++ await userEvent.click(screen.getAllByText('Try again')[0])++ expect(await screen.findByTestId('self-driving-eval-reports-signal-source')).toHaveAttribute(+ 'aria-checked',+ 'true'+ )+ expect(sourceConfigRequests).toBe(2)+ } finally {+ resumeKeaLoadersErrors()+ }+ })+it('sorts eval and anomaly alert columns', async () => {render(<Provider>diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsxindex ee2aacafa466..60be839a0b75 100644--- a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx@@ -31,6 +31,7 @@ import type { AlertApi } from 'products/alerts/frontend/generated/api.schemas'import { ScoutCreateButton } from 'products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton'import { ScoutRowCard } from 'products/signals/frontend/inbox/components/config/scouts/ScoutRowCard'import { scoutFleetLogic } from 'products/signals/frontend/inbox/logics/scoutFleetLogic'+import { signalSourcesLogic } from 'products/signals/frontend/inbox/signalSourcesLogic'import { llmEvaluationsLogic } from '../evaluations/llmEvaluationsLogic'import type { EvaluationConfig } from '../evaluations/types'@@ -45,6 +46,7 @@ import {type AIObservabilitySelfDrivingSection,aiObservabilitySelfDrivingLogic,} from './aiObservabilitySelfDrivingLogic'+import { SelfDrivingSignalSourceToggle } from './SelfDrivingSignalSourceToggle'const SCOUTS_DOCS_URL = 'https://posthog.com/docs/ai-observability/self-driving'const SELF_DRIVING_DOCS_URL = 'https://posthog.com/docs/self-driving'@@ -200,6 +202,15 @@ export function AIObservabilitySelfDriving(): JSX.Element {const { loadAnomalyAlertInvestigations, loadSelfDrivingEvaluationReports, setExpandedSections } = useActions(aiObservabilitySelfDrivingLogic)+ const {+ anomalyInvestigationConfig,+ evalReportsConfig,+ isAnomalyInvestigationToggling,+ isEvalReportsToggling,+ sourceConfigs,+ sourceConfigsLoadFailed,+ } = useValues(signalSourcesLogic)+ const { loadSourceConfigs, toggleAnomalyInvestigation, toggleEvalReports } = useActions(signalSourcesLogic)const aiObservabilityScouts = scoutConfigs?.filter(isAIObservabilityScout) ?? []const reportFor = (evaluation: EvaluationConfig): EvaluationReportApi | null =>@@ -411,6 +422,16 @@ export function AIObservabilitySelfDriving(): JSX.Element {Learn more</Link></p>+ <SelfDrivingSignalSourceToggle+ sourceName="AI observability"+ signalNoun="evaluation report"+ enabled={sourceConfigs === null ? null : !!evalReportsConfig?.enabled}+ loadFailed={sourceConfigsLoadFailed}+ toggling={isEvalReportsToggling}+ onChange={toggleEvalReports}+ onRetry={loadSourceConfigs}+ data-attr="self-driving-eval-reports-signal-source"+ />{!evaluationsLoadFailed &&!evaluationsLoading &&evaluations.length > 0 &&@@ -504,6 +525,16 @@ export function AIObservabilitySelfDriving(): JSX.Element {Learn more</Link></p>+ <SelfDrivingSignalSourceToggle+ sourceName="Product analytics"+ signalNoun="anomaly investigation"+ enabled={sourceConfigs === null ? null : !!anomalyInvestigationConfig?.enabled}+ loadFailed={sourceConfigsLoadFailed}+ toggling={isAnomalyInvestigationToggling}+ onChange={toggleAnomalyInvestigation}+ onRetry={loadSourceConfigs}+ data-attr="self-driving-anomaly-investigation-signal-source"+ />{anomalyAlertInvestigationsLoading && anomalyAlertInvestigations === null ? (<div className="flex flex-col gap-2"><LemonSkeleton className="h-10 w-full rounded" />diff --git a/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.stories.tsx b/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.stories.tsxnew file mode 100644index 000000000000..a09e1e1eea8c--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.stories.tsx@@ -0,0 +1,55 @@+import type { Meta, StoryObj } from '@storybook/react'++import { SelfDrivingSignalSourceToggle, SelfDrivingSignalSourceToggleProps } from './SelfDrivingSignalSourceToggle'++const meta: Meta = {+ title: 'Scenes-App/AI observability/Self-driving signal source toggle',+}+export default meta++const render = (args: SelfDrivingSignalSourceToggleProps): JSX.Element => <SelfDrivingSignalSourceToggle {...args} />++const evalReportsArgs: SelfDrivingSignalSourceToggleProps = {+ sourceName: 'AI observability',+ signalNoun: 'evaluation report',+ enabled: true,+ loadFailed: false,+ toggling: false,+ onChange: () => {},+ onRetry: () => {},+ 'data-attr': 'self-driving-signal-source-story',+}++export const On: StoryObj<SelfDrivingSignalSourceToggleProps> = {+ render,+ args: evalReportsArgs,+}++export const Off: StoryObj<SelfDrivingSignalSourceToggleProps> = {+ render,+ args: {+ ...evalReportsArgs,+ sourceName: 'Product analytics',+ signalNoun: 'anomaly investigation',+ enabled: false,+ },+}++export const Toggling: StoryObj<SelfDrivingSignalSourceToggleProps> = {+ render,+ args: { ...evalReportsArgs, toggling: true },+ // The switch keeps a spinner while the write is in flight, which never settles in a story.+ parameters: { testOptions: { waitForLoadersToDisappear: false } },+}++export const Loading: StoryObj<SelfDrivingSignalSourceToggleProps> = {+ render,+ args: { ...evalReportsArgs, enabled: null },+ // Same for the skeleton the switch shows until the signal source configs resolve.+ parameters: { testOptions: { waitForLoadersToDisappear: false } },+}++export const LoadFailed: StoryObj<SelfDrivingSignalSourceToggleProps> = {+ render,+ args: { ...evalReportsArgs, enabled: null, loadFailed: true },+}diff --git a/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.tsx b/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.tsxnew file mode 100644index 000000000000..26454f604964--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/SelfDrivingSignalSourceToggle.tsx@@ -0,0 +1,55 @@+import { LemonBanner, LemonCard, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'++export interface SelfDrivingSignalSourceToggleProps {+ /** Signal source product, named as it is in the inbox signal sources modal. */+ sourceName: string+ /** What this source emits, e.g. "evaluation report". */+ signalNoun: string+ /** `null` until the signal source configs resolve. */+ enabled: boolean | null+ loadFailed: boolean+ toggling: boolean+ onChange: () => void+ onRetry: () => void+ 'data-attr': string+}++export function SelfDrivingSignalSourceToggle({+ sourceName,+ signalNoun,+ enabled,+ loadFailed,+ toggling,+ onChange,+ onRetry,+ 'data-attr': dataAttr,+}: SelfDrivingSignalSourceToggleProps): JSX.Element {+ if (enabled === null) {+ if (loadFailed) {+ return (+ <LemonBanner type="error" action={{ children: 'Try again', onClick: onRetry }}>+ We couldn't load signal source settings. Try again in a moment.+ </LemonBanner>+ )+ }++ return <LemonSkeleton className="h-5 w-72 rounded" />+ }++ return (+ <LemonCard hoverEffect={false} className="flex items-center justify-between gap-3 p-3">+ <div className="flex flex-wrap items-baseline gap-1">+ <span className="font-medium">{sourceName} signal source</span>+ <span className="text-xs font-normal text-muted">Must be on to accept {signalNoun} signals.</span>+ </div>+ <LemonSwitch+ size="small"+ checked={enabled}+ onChange={onChange}+ loading={toggling}+ aria-label={`${sourceName} signal source`}+ data-attr={dataAttr}+ />+ </LemonCard>+ )+}diff --git a/products/ai_observability/frontend/selfDriving/aiObservabilitySelfDrivingLogic.ts b/products/ai_observability/frontend/selfDriving/aiObservabilitySelfDrivingLogic.tsindex c9dccff1e638..74291a768594 100644--- a/products/ai_observability/frontend/selfDriving/aiObservabilitySelfDrivingLogic.ts+++ b/products/ai_observability/frontend/selfDriving/aiObservabilitySelfDrivingLogic.ts@@ -1,10 +1,12 @@-import { MakeLogicType, actions, afterMount, kea, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'import { teamLogic } from 'scenes/teamLogic'import * as alertsApi from 'products/alerts/frontend/generated/api'import type { AlertApi } from 'products/alerts/frontend/generated/api.schemas'+import { signalSourcesLogic } from 'products/signals/frontend/inbox/signalSourcesLogic'+import type { SignalSourceConfig } from 'products/signals/frontend/inbox/types'import { listAllEvaluationReports } from '../evaluations/evaluationsApi'import type { EvaluationReportApi } from '../generated/api.schemas'@@ -41,6 +43,8 @@ async function listAllAnomalyAlertInvestigations(projectId: string): Promise<Ale// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface aiObservabilitySelfDrivingLogicValues {+ sourceConfigs: SignalSourceConfig[] | null // signalSourcesLogic+ sourceConfigsLoading: boolean // signalSourcesLogicanomalyAlertInvestigations: AlertApi[] | nullanomalyAlertInvestigationsLoading: booleanevaluationReports: EvaluationReportApi[] | null@@ -51,6 +55,7 @@ export interface aiObservabilitySelfDrivingLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface aiObservabilitySelfDrivingLogicActions {+ loadSourceConfigs: () => any // signalSourcesLogicloadAnomalyAlertInvestigations: () => anyloadAnomalyAlertInvestigationsFailure: (error: string,@@ -105,6 +110,11 @@ export type aiObservabilitySelfDrivingLogicType = MakeLogicType<export const aiObservabilitySelfDrivingLogic = kea<aiObservabilitySelfDrivingLogicType>([path(['products', 'ai_observability', 'selfDriving', 'aiObservabilitySelfDrivingLogic']),+ connect(() => ({+ values: [signalSourcesLogic, ['sourceConfigs', 'sourceConfigsLoading']],+ actions: [signalSourcesLogic, ['loadSourceConfigs']],+ })),+actions({setExpandedSections: (expandedSections: AIObservabilitySelfDrivingSection[]) => ({ expandedSections }),}),@@ -152,8 +162,13 @@ export const aiObservabilitySelfDrivingLogic = kea<aiObservabilitySelfDrivingLog],}),- afterMount(({ actions }) => {+ afterMount(({ actions, values }) => {actions.loadAnomalyAlertInvestigations()actions.loadSelfDrivingEvaluationReports()+ // signalSourcesLogic only loads these behind the inbox's own flag, and the signal source+ // switches in this tab need the rows either way.+ if (values.sourceConfigs === null && !values.sourceConfigsLoading) {+ actions.loadSourceConfigs()+ }}),])diff --git a/products/signals/frontend/inbox/signalSourcesLogic.ts b/products/signals/frontend/inbox/signalSourcesLogic.tsindex ba4cec1d4b45..58253fe2f153 100644--- a/products/signals/frontend/inbox/signalSourcesLogic.ts+++ b/products/signals/frontend/inbox/signalSourcesLogic.ts@@ -235,6 +235,7 @@ export interface signalSourcesLogicValues {linearIssuesConfig: SignalSourceConfig | nullpgAnalyzeIssuesConfig: SignalSourceConfig | nullsourceConfigs: SignalSourceConfig[] | null+ sourceConfigsLoadFailed: booleansourceConfigsLoading: booleansourcesModalOpen: booleantogglingSourceKeys: Set<string>@@ -636,6 +637,14 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([loadToolDataEventsFailure: () => true,},],+ sourceConfigsLoadFailed: [+ false,+ {+ loadSourceConfigs: () => false,+ loadSourceConfigsSuccess: () => false,+ loadSourceConfigsFailure: () => true,+ },+ ],sourceConfigs: {toggleHealthChecks: (state: SignalSourceConfig[] | null) =>toggleSourceConfigState(state, SignalSourceProduct.HealthChecks, SignalSourceType.HealthIssue),@@ -1083,6 +1092,17 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([}breakpoint()actions.toggleSignalSourceSuccess(params)+ if (+ sourceProduct === SignalSourceProduct.LlmAnalytics &&+ sourceType === SignalSourceType.EvaluationReport+ ) {+ lemonToast.success(`AI observability signal source ${enabled ? 'enabled' : 'disabled'}`)+ } else if (+ sourceProduct === SignalSourceProduct.Analytics &&+ sourceType === SignalSourceType.AnomalyInvestigation+ ) {+ lemonToast.success(`Product analytics signal source ${enabled ? 'enabled' : 'disabled'}`)+ }// Only a successful enable counts as a connection. First-time when there was no// persisted (non-placeholder) config for this product/type before the toggle.if (enabled) {