Skip to content

Commit fc86f03

Browse files
bidahclaude
andcommitted
🚩 refactor(template): replace TEMPLATE_OVERRIDE env var with vercel/flags templateFlag
Use the flags SDK to control template selection (expo-testing vs react-native-expo) instead of NEXT_PUBLIC_TEMPLATE environment variable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dddbfa5 commit fc86f03

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { opencodeEnabled } from '@/flags'
1+
import { opencodeEnabled, templateFlag } from '@/flags'
22
import { ProjectPageWrapper } from './project-page-wrapper'
33

44
export default async function Page() {
55
const showOpencode = await opencodeEnabled()
6+
const template = await templateFlag()
67

7-
return <ProjectPageWrapper opencodeEnabled={!!showOpencode} />
8+
return <ProjectPageWrapper opencodeEnabled={!!showOpencode} template={template as 'expo-testing' | 'react-native-expo'} />
89
}

‎apps/web/app/(app)/p/[id]/project-page-wrapper.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ const ProjectPage = dynamic(
88
{ ssr: false, loading: () => <Loading /> },
99
)
1010

11-
export function ProjectPageWrapper({ opencodeEnabled }: { opencodeEnabled: boolean }) {
12-
return <ProjectPage opencodeEnabled={opencodeEnabled} />
11+
export function ProjectPageWrapper({ opencodeEnabled, template }: { opencodeEnabled: boolean; template: 'expo-testing' | 'react-native-expo' }) {
12+
return <ProjectPage opencodeEnabled={opencodeEnabled} template={template} />
1313
}

‎apps/web/app/(app)/p/[id]/project-page.tsx‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ import { useIsMobile } from '@/hooks/use-mobile'
5050
import { AppSidebar } from '@/components/app-sidebar'
5151
import Loading from './loading'
5252

53-
export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabled?: boolean }) {
54-
// Toggle to true to force expo-testing template during development
55-
const EXPO_TESTING = false
53+
export function ProjectPageInternal({ opencodeEnabled = false, template: templateOverride }: { opencodeEnabled?: boolean; template?: 'expo-testing' | 'react-native-expo' }) {
5654

5755
const params = useParams()
5856
const projectID = params?.id as string
@@ -80,7 +78,7 @@ export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabl
8078
})
8179
}, [])
8280
const [selectedTemplate, setSelectedTemplate] = useState<'auto' | TemplateId>(
83-
EXPO_TESTING ? 'expo-testing' : 'react-native-expo',
81+
templateOverride || 'react-native-expo',
8482
)
8583
const [languageModel, setLanguageModel] = useCookieStorage<LLMModelConfig>(
8684
'languageModel',
@@ -1824,7 +1822,7 @@ export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabl
18241822
console.log('Creating new project with:', {
18251823
id: projectId,
18261824
title: 'Generating project name...',
1827-
template: EXPO_TESTING ? 'expo-testing' : (templateFromUrl || selectedTemplate || 'react-native-expo'),
1825+
template: templateOverride || templateFromUrl || selectedTemplate || 'react-native-expo',
18281826
userID: session?.user?.id,
18291827
})
18301828

@@ -1837,7 +1835,7 @@ export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabl
18371835
body: JSON.stringify({
18381836
id: projectId,
18391837
title: 'Generating project name...',
1840-
template: EXPO_TESTING ? 'expo-testing' : (templateFromUrl || selectedTemplate || 'react-native-expo'),
1838+
template: templateOverride || templateFromUrl || selectedTemplate || 'react-native-expo',
18411839
userID: session?.user?.id,
18421840
}),
18431841
})
@@ -1969,7 +1967,7 @@ export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabl
19691967
projectId: project.id,
19701968
userID: session?.user?.id,
19711969
teamID: userTeam?.id,
1972-
chooseTemplate: EXPO_TESTING ? 'expo-testing' : 'expo',
1970+
chooseTemplate: templateOverride || 'expo',
19731971
firstMessage: firstMessage ? { role: 'user', content: firstMessage } : undefined, // Pass first message for title generation
19741972
}),
19751973
})
@@ -2055,7 +2053,7 @@ export function ProjectPageInternal({ opencodeEnabled = false }: { opencodeEnabl
20552053
sbxId: result.sandboxId,
20562054
projectId: result.projectId,
20572055
projectTitle: result.projectTitle,
2058-
template: EXPO_TESTING ? 'expo-testing' : (project.template || 'react-native-expo'),
2056+
template: templateOverride || project.template || 'react-native-expo',
20592057
recreated: result.recreated,
20602058
})
20612059

‎apps/web/flags.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ export const tunnelMode = flag<string>({
1616
? { adapter: vercelAdapter() }
1717
: { decide: () => 'ngrok-patch' }),
1818
})
19+
20+
export const templateFlag = flag<string>({
21+
key: 'template',
22+
defaultValue: 'react-native-expo',
23+
...(process.env.FLAGS
24+
? { adapter: vercelAdapter() }
25+
: { decide: () => 'react-native-expo' }),
26+
})

0 commit comments

Comments
 (0)