Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -172,15 +191,21 @@ export const PostHogIntegrationIntroScreen = ({
</Box>
<FrameworkPicker
store={store}
onComplete={() => setPickingFramework(false)}
onComplete={() => {
setManuallySelected(true);
setPickingFramework(false);
}}
/>
</>
);
} else if (pickingFramework) {
body = (
<FrameworkPicker
store={store}
onComplete={() => setPickingFramework(false)}
onComplete={() => {
setManuallySelected(true);
setPickingFramework(false);
}}
/>
);
} else if (view === 'more-info') {
Expand Down Expand Up @@ -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,
}),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import {
CONTINUE_MENU_OPTIONS,
frameworkRowSuffix,
sharingOptions,
} from '@ui/tui/screens/PostHogIntegrationIntroScreen';

Expand Down Expand Up @@ -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]',
);
});
});