1- import { useCallback , useState } from "react"
1+ import { useCallback , useState , useEffect } from "react"
22import knuthShuffle from "knuth-shuffle-seeded"
33import { Trans } from "react-i18next"
44import { VSCodeButton , VSCodeLink } from "@vscode/webview-ui-toolkit/react"
5+ import posthog from "posthog-js"
56
67import type { ProviderSettings } from "@roo-code/types"
8+ import { TelemetryEventName } from "@roo-code/types"
79
810import { useExtensionState } from "@src/context/ExtensionStateContext"
911import { validateApiConfiguration } from "@src/utils/validate"
1012import { vscode } from "@src/utils/vscode"
1113import { useAppTranslation } from "@src/i18n/TranslationContext"
1214import { getRequestyAuthUrl , getOpenRouterAuthUrl } from "@src/oauth/urls"
15+ import { telemetryClient } from "@src/utils/TelemetryClient"
1316
1417import ApiOptions from "../settings/ApiOptions"
1518import { Tab , TabContent } from "../common/Tab"
@@ -20,6 +23,14 @@ const WelcomeView = () => {
2023 const { apiConfiguration, currentApiConfigName, setApiConfiguration, uriScheme, machineId } = useExtensionState ( )
2124 const { t } = useAppTranslation ( )
2225 const [ errorMessage , setErrorMessage ] = useState < string | undefined > ( undefined )
26+ const [ showRooProvider , setShowRooProvider ] = useState ( false )
27+
28+ // Check PostHog feature flag for Roo provider
29+ useEffect ( ( ) => {
30+ posthog . onFeatureFlags ( function ( ) {
31+ setShowRooProvider ( posthog ?. getFeatureFlag ( "roo-provider-featured" ) === "test" )
32+ } )
33+ } , [ ] )
2334
2435 // Memoize the setApiConfigurationField function to pass to ApiOptions
2536 const setApiConfigurationFieldForApiOptions = useCallback (
@@ -69,7 +80,7 @@ const WelcomeView = () => {
6980 { /* Define the providers */ }
7081 { ( ( ) => {
7182 // Provider card configuration
72- const providers = [
83+ const baseProviders = [
7384 {
7485 slug : "requesty" ,
7586 name : "Requesty" ,
@@ -85,6 +96,20 @@ const WelcomeView = () => {
8596 } ,
8697 ]
8798
99+ // Conditionally add Roo provider based on feature flag
100+ const providers = showRooProvider
101+ ? [
102+ ...baseProviders ,
103+ {
104+ slug : "roo" ,
105+ name : "Roo Code Cloud" ,
106+ description : t ( "welcome:routers.roo.description" ) ,
107+ incentive : t ( "welcome:routers.roo.incentive" ) ,
108+ authUrl : "#" , // Placeholder since onClick handler will prevent default
109+ } ,
110+ ]
111+ : baseProviders
112+
88113 // Shuffle providers based on machine ID (will be consistent for the same machine)
89114 const orderedProviders = [ ...providers ]
90115 knuthShuffle ( orderedProviders , ( machineId as any ) || Date . now ( ) )
@@ -94,9 +119,41 @@ const WelcomeView = () => {
94119 < a
95120 key = { index }
96121 href = { provider . authUrl }
97- className = "flex-1 border border-vscode-panel-border hover:bg-secondary rounded-md py-3 px-4 mb-2 flex flex-row gap-3 cursor-pointer transition-all no-underline text-inherit"
122+ className = "relative flex-1 border border-vscode-panel-border hover:bg-secondary rounded-md py-3 px-4 mb-2 flex flex-row gap-3 cursor-pointer transition-all no-underline text-inherit"
98123 target = "_blank"
99- rel = "noopener noreferrer" >
124+ rel = "noopener noreferrer"
125+ onClick = { ( e ) => {
126+ // Track telemetry for featured provider click
127+ telemetryClient . capture ( TelemetryEventName . FEATURED_PROVIDER_CLICKED , {
128+ provider : provider . slug ,
129+ } )
130+
131+ // Special handling for Roo provider
132+ if ( provider . slug === "roo" ) {
133+ e . preventDefault ( )
134+
135+ // Set the Roo provider configuration
136+ const rooConfig : ProviderSettings = {
137+ apiProvider : "roo" ,
138+ }
139+
140+ // Save the Roo provider configuration
141+ vscode . postMessage ( {
142+ type : "upsertApiConfiguration" ,
143+ text : currentApiConfigName ,
144+ apiConfiguration : rooConfig ,
145+ } )
146+
147+ // Then trigger cloud sign-in
148+ vscode . postMessage ( { type : "rooCloudSignIn" } )
149+ }
150+ // For other providers, let the default link behavior work
151+ } } >
152+ { provider . incentive && (
153+ < div className = "absolute top-0 right-0 text-[10px] text-vscode-badge-foreground bg-vscode-badge-background px-2 py-0.5 rounded-bl rounded-tr-md" >
154+ { provider . incentive }
155+ </ div >
156+ ) }
100157 < div className = "w-8 h-8 flex-shrink-0" >
101158 < img
102159 src = { `${ imagesBaseUri } /${ provider . slug } .png` }
@@ -108,13 +165,8 @@ const WelcomeView = () => {
108165 < div className = "text-sm font-medium text-vscode-foreground" >
109166 { provider . name }
110167 </ div >
111- < div >
112- < div className = "text-xs text-vscode-descriptionForeground" >
113- { provider . description }
114- </ div >
115- { provider . incentive && (
116- < div className = "text-xs mt-1" > { provider . incentive } </ div >
117- ) }
168+ < div className = "text-xs text-vscode-descriptionForeground" >
169+ { provider . description }
118170 </ div >
119171 </ div >
120172 </ a >
0 commit comments