Skip to content

Commit 8485548

Browse files
authored
Show the Roo provider on the welcome screen (#8317)
1 parent a0d6a4b commit 8485548

File tree

21 files changed

+138
-11
lines changed

21 files changed

+138
-11
lines changed

packages/types/src/telemetry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export enum TelemetryEventName {
6161
ACCOUNT_LOGOUT_CLICKED = "Account Logout Clicked",
6262
ACCOUNT_LOGOUT_SUCCESS = "Account Logout Success",
6363

64+
FEATURED_PROVIDER_CLICKED = "Featured Provider Clicked",
65+
6466
UPSELL_DISMISSED = "Upsell Dismissed",
6567
UPSELL_CLICKED = "Upsell Clicked",
6668

@@ -184,6 +186,7 @@ export const rooCodeTelemetryEventSchema = z.discriminatedUnion("type", [
184186
TelemetryEventName.ACCOUNT_CONNECT_SUCCESS,
185187
TelemetryEventName.ACCOUNT_LOGOUT_CLICKED,
186188
TelemetryEventName.ACCOUNT_LOGOUT_SUCCESS,
189+
TelemetryEventName.FEATURED_PROVIDER_CLICKED,
187190
TelemetryEventName.UPSELL_DISMISSED,
188191
TelemetryEventName.UPSELL_CLICKED,
189192
TelemetryEventName.SCHEMA_VALIDATION_ERROR,

src/assets/images/roo.png

3.95 KB
Loading

webview-ui/src/components/welcome/WelcomeView.tsx

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { useCallback, useState } from "react"
1+
import { useCallback, useState, useEffect } from "react"
22
import knuthShuffle from "knuth-shuffle-seeded"
33
import { Trans } from "react-i18next"
44
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
5+
import posthog from "posthog-js"
56

67
import type { ProviderSettings } from "@roo-code/types"
8+
import { TelemetryEventName } from "@roo-code/types"
79

810
import { useExtensionState } from "@src/context/ExtensionStateContext"
911
import { validateApiConfiguration } from "@src/utils/validate"
1012
import { vscode } from "@src/utils/vscode"
1113
import { useAppTranslation } from "@src/i18n/TranslationContext"
1214
import { getRequestyAuthUrl, getOpenRouterAuthUrl } from "@src/oauth/urls"
15+
import { telemetryClient } from "@src/utils/TelemetryClient"
1316

1417
import ApiOptions from "../settings/ApiOptions"
1518
import { 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>

webview-ui/src/i18n/locales/ca/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/welcome.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
},
1111
"openrouter": {
1212
"description": "A unified interface for LLMs"
13+
},
14+
"roo": {
15+
"description": "The best free models to get started",
16+
"incentive": "Try Roo out for free"
1317
}
1418
},
1519
"chooseProvider": "To do its magic, Roo needs an API key.",

webview-ui/src/i18n/locales/es/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/id/welcome.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)