Skip to content

Commit 2e59347

Browse files
brunobergherroomote-agentmrubensroomote[bot]
authored
Shows a pill with the base Roo Code Cloud URL when not pointing to pr… (#7555)
Co-authored-by: Roo Code <[email protected]> Co-authored-by: Matt Rubens <[email protected]> Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
1 parent fe2b612 commit 2e59347

File tree

20 files changed

+125
-19
lines changed

20 files changed

+125
-19
lines changed

webview-ui/src/components/cloud/CloudView.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { ToggleSwitch } from "@/components/ui/toggle-switch"
1111

1212
import { History, PiggyBank, SquareArrowOutUpRightIcon } from "lucide-react"
1313

14+
// Define the production URL constant locally to avoid importing from cloud package in tests
15+
const PRODUCTION_ROO_CODE_API_URL = "https://app.roocode.com"
16+
1417
type CloudViewProps = {
1518
userInfo: CloudUserInfo | null
1619
isAuthenticated: boolean
@@ -56,10 +59,16 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
5659
// Send telemetry for cloud website visit
5760
// NOTE: Using ACCOUNT_* telemetry events for backward compatibility with analytics
5861
telemetryClient.capture(TelemetryEventName.ACCOUNT_CONNECT_CLICKED)
59-
const cloudUrl = cloudApiUrl || "https://app.roocode.com"
62+
const cloudUrl = cloudApiUrl || PRODUCTION_ROO_CODE_API_URL
6063
vscode.postMessage({ type: "openExternal", url: cloudUrl })
6164
}
6265

66+
const handleOpenCloudUrl = () => {
67+
if (cloudApiUrl) {
68+
vscode.postMessage({ type: "openExternal", url: cloudApiUrl })
69+
}
70+
}
71+
6372
const handleRemoteControlToggle = () => {
6473
const newValue = !remoteControlEnabled
6574
setRemoteControlEnabled(newValue)
@@ -186,6 +195,18 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
186195
</div>
187196
</>
188197
)}
198+
{cloudApiUrl && cloudApiUrl !== PRODUCTION_ROO_CODE_API_URL && (
199+
<div className="mt-6 flex justify-center">
200+
<div className="inline-flex items-center px-3 py-1 gap-1 rounded-full bg-vscode-badge-background/50 text-vscode-badge-foreground text-xs">
201+
<span className="text-vscode-foreground/75">{t("cloud:cloudUrlPillLabel")}: </span>
202+
<button
203+
onClick={handleOpenCloudUrl}
204+
className="text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0">
205+
{cloudApiUrl}
206+
</button>
207+
</div>
208+
</div>
209+
)}
189210
</div>
190211
)
191212
}

webview-ui/src/components/cloud/__tests__/CloudView.spec.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ vi.mock("@src/i18n/TranslationContext", () => ({
2121
"cloud:remoteControlDescription":
2222
"Enable following and interacting with tasks in this workspace with Roo Code Cloud",
2323
"cloud:profilePicture": "Profile picture",
24+
"cloud:cloudUrlPillLabel": "Roo Code Cloud URL: ",
2425
}
2526
return translations[key] || key
2627
},
@@ -148,4 +149,70 @@ describe("CloudView", () => {
148149
expect(screen.queryByTestId("remote-control-toggle")).not.toBeInTheDocument()
149150
expect(screen.queryByText("Roomote Control")).not.toBeInTheDocument()
150151
})
152+
153+
it("should not display cloud URL pill when pointing to production", () => {
154+
const mockUserInfo = {
155+
name: "Test User",
156+
157+
}
158+
159+
render(
160+
<CloudView
161+
userInfo={mockUserInfo}
162+
isAuthenticated={true}
163+
cloudApiUrl="https://app.roocode.com"
164+
onDone={() => {}}
165+
/>,
166+
)
167+
168+
// Check that the cloud URL pill is NOT displayed for production URL
169+
expect(screen.queryByText(/Roo Code Cloud URL:/)).not.toBeInTheDocument()
170+
})
171+
172+
it("should display cloud URL pill when pointing to non-production environment", () => {
173+
const mockUserInfo = {
174+
name: "Test User",
175+
176+
}
177+
178+
render(
179+
<CloudView
180+
userInfo={mockUserInfo}
181+
isAuthenticated={true}
182+
cloudApiUrl="https://staging.roocode.com"
183+
onDone={() => {}}
184+
/>,
185+
)
186+
187+
// Check that the cloud URL pill is displayed with the staging URL
188+
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
189+
expect(screen.getByText("https://staging.roocode.com")).toBeInTheDocument()
190+
})
191+
192+
it("should display cloud URL pill for non-authenticated users when not pointing to production", () => {
193+
render(
194+
<CloudView
195+
userInfo={null}
196+
isAuthenticated={false}
197+
cloudApiUrl="https://dev.roocode.com"
198+
onDone={() => {}}
199+
/>,
200+
)
201+
202+
// Check that the cloud URL pill is displayed even when not authenticated
203+
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
204+
expect(screen.getByText("https://dev.roocode.com")).toBeInTheDocument()
205+
})
206+
207+
it("should not display cloud URL pill when cloudApiUrl is undefined", () => {
208+
const mockUserInfo = {
209+
name: "Test User",
210+
211+
}
212+
213+
render(<CloudView userInfo={mockUserInfo} isAuthenticated={true} onDone={() => {}} />)
214+
215+
// Check that the cloud URL pill is NOT displayed when cloudApiUrl is undefined
216+
expect(screen.queryByText(/Roo Code Cloud URL:/)).not.toBeInTheDocument()
217+
})
151218
})

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"cloudBenefitMetrics": "Get a holistic view of your token consumption",
1313
"visitCloudWebsite": "Visit Roo Code Cloud",
1414
"remoteControl": "Roomote Control",
15-
"remoteControlDescription": "Enable following and interacting with tasks in this workspace with Roo Code Cloud"
15+
"remoteControlDescription": "Enable following and interacting with tasks in this workspace with Roo Code Cloud",
16+
"cloudUrlPillLabel": "Roo Code Cloud URL"
1617
}

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/it/cloud.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)