diff --git a/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx b/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx index 227c6fc6..685fe618 100644 --- a/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx +++ b/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx @@ -56,6 +56,25 @@ export const CONTINUE_MENU_OPTIONS: { label: string; value: string }[] = [ { label: 'Cancel', value: 'cancel' }, ]; +/** + * Suffix for the Framework detection row. Auto-detect gets "(detected)"; a + * manual pick from either picker must not — otherwise a failed detection + * still claims success (#944). + */ +export function frameworkRowSuffix({ + manuallySelected, + beta, +}: { + manuallySelected: boolean; + beta?: boolean; +}): string | undefined { + const suffixParts: string[] = []; + if (!manuallySelected) suffixParts.push('(detected)'); + // Some frameworks may be marked as beta/early-access in their config. + // If so, show a [BETA] tag to set expectations for users. + return suffixParts.join(' ') || undefined; +} + /** * A blank, unselectable row. Navigation skips disabled options, so this is a * margin the menu can hold rather than one the layout has to special-case. @@ -172,7 +191,10 @@ export const PostHogIntegrationIntroScreen = ({ setPickingFramework(false)} + onComplete={() => { + setManuallySelected(true); + setPickingFramework(false); + }} /> ); @@ -180,7 +202,10 @@ export const PostHogIntegrationIntroScreen = ({ body = ( setPickingFramework(false)} + onComplete={() => { + setManuallySelected(true); + setPickingFramework(false); + }} /> ); } else if (view === 'more-info') { @@ -230,16 +255,13 @@ export const PostHogIntegrationIntroScreen = ({ const detectionRows: DetectionRow[] = []; if (frameworkLabel) { - const suffixParts: string[] = []; - if (!manuallySelected) suffixParts.push('(detected)'); - // Dead path today — every framework went GA. Kept for re-activation - // when the next beta framework lands (set `beta: true` on its config). - if (config?.metadata.beta) suffixParts.push('[BETA]'); - detectionRows.push({ label: 'Framework', value: frameworkLabel, - suffix: suffixParts.join(' ') || undefined, + suffix: frameworkRowSuffix({ + manuallySelected, + beta: config?.metadata.beta, + }), }); } diff --git a/src/ui/tui/screens/__tests__/PostHogIntegrationIntroScreen.test.ts b/src/ui/tui/screens/__tests__/PostHogIntegrationIntroScreen.test.ts index 301b84ec..4a7e993f 100644 --- a/src/ui/tui/screens/__tests__/PostHogIntegrationIntroScreen.test.ts +++ b/src/ui/tui/screens/__tests__/PostHogIntegrationIntroScreen.test.ts @@ -8,6 +8,7 @@ import { CONTINUE_MENU_OPTIONS, + frameworkRowSuffix, sharingOptions, } from '@ui/tui/screens/PostHogIntegrationIntroScreen'; @@ -72,3 +73,24 @@ describe('the sharing choice', () => { expect(spacer?.label).toBe(''); }); }); + +describe('frameworkRowSuffix', () => { + it('shows (detected) after auto-detection', () => { + expect(frameworkRowSuffix({ manuallySelected: false })).toBe('(detected)'); + }); + + it('omits (detected) after a manual pick', () => { + // Fallback picker after failed detection, or Change framework — both set + // manuallySelected so the intro does not claim detection succeeded (#944). + expect(frameworkRowSuffix({ manuallySelected: true })).toBeUndefined(); + }); + + it('keeps [BETA] when present, with or without (detected)', () => { + expect(frameworkRowSuffix({ manuallySelected: false, beta: true })).toBe( + '(detected) [BETA]', + ); + expect(frameworkRowSuffix({ manuallySelected: true, beta: true })).toBe( + '[BETA]', + ); + }); +});