Skip to content

Commit dc88f70

Browse files
yannbfstorybook-bot
authored andcommitted
Merge pull request #35053 from storybookjs/sidnioulz/double-gate-ai-optin
Core: Rework AI checklist feature gate (cherry picked from commit 23bcfb9)
1 parent 5adebe7 commit dc88f70

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎code/core/src/shared/utils/ai-checklist-flags.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ describe('ai-checklist-flags', () => {
2929
});
3030

3131
describe('hasAiInitOptIn', () => {
32-
it('returns true when nothing is cached', async () => {
32+
it('returns false when nothing is cached', async () => {
3333
const { hasAiInitOptIn } = await import('./ai-checklist-flags.ts');
34-
expect(await hasAiInitOptIn('/some/project/.storybook')).toBe(true);
34+
expect(await hasAiInitOptIn('/some/project/.storybook')).toBe(false);
3535
});
3636

37-
it('returns true when the cached configDir is for a different project', async () => {
37+
it('returns false when the cached configDir is for a different project', async () => {
3838
mockCacheStore.set('ai-init-opt-in', {
3939
timestamp: Date.now(),
4040
configDir: resolve('/repo/apps/web/.storybook'),
4141
});
4242
const { hasAiInitOptIn } = await import('./ai-checklist-flags.ts');
43-
expect(await hasAiInitOptIn('/repo/packages/ui/.storybook')).toBe(true);
43+
expect(await hasAiInitOptIn('/repo/packages/ui/.storybook')).toBe(false);
4444
});
4545

46-
it('returns true when the cached entry lacks a configDir field', async () => {
46+
it('returns false when the cached entry lacks a configDir field', async () => {
4747
// Defensive — should never happen in practice because the CLI always
4848
// writes configDir, but a corrupted cache shouldn't unlock this flag.
4949
mockCacheStore.set('ai-init-opt-in', { timestamp: Date.now() });
5050
const { hasAiInitOptIn } = await import('./ai-checklist-flags.ts');
51-
expect(await hasAiInitOptIn('/any/project/.storybook')).toBe(true);
51+
expect(await hasAiInitOptIn('/any/project/.storybook')).toBe(false);
5252
});
5353

5454
it('returns true when the cached configDir matches the resolved input', async () => {

‎code/core/src/shared/utils/ai-checklist-flags.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ async function readProjectScopedFlag(
4949
} catch {}
5050
}
5151

52-
/** Written by `storybook init` when the user accepted the AI feature and in legacy inits where the question was not asked. */
52+
/** Written by `storybook init` when the user accepted the AI feature and in legacy inits where the question was not asked.
53+
* Due to regressions with unsupported frameworks, and the computational complexity of plugging framework feature support
54+
* into this part of the app, we've decided to revert the flag to treat the user as opting out from init when the flag
55+
* isn't found.
56+
*/
5357
export async function hasAiInitOptIn(configDir: string): Promise<boolean> {
5458
const flag = await readProjectScopedFlag('ai-init-opt-in', configDir);
55-
return flag?.answer !== false;
59+
return flag?.answer === true;
5660
}
5761

5862
/** Written by `storybook ai setup` when the prompt CLI ran in this project. */

0 commit comments

Comments
 (0)