Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion webview-ui/src/components/cloud/CloudView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { ToggleSwitch } from "@/components/ui/toggle-switch"

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

// Define the production URL constant locally to avoid importing from cloud package in tests
const PRODUCTION_ROO_CODE_API_URL = "https://app.roocode.com"

type CloudViewProps = {
userInfo: CloudUserInfo | null
isAuthenticated: boolean
Expand Down Expand Up @@ -56,10 +59,16 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
// Send telemetry for cloud website visit
// NOTE: Using ACCOUNT_* telemetry events for backward compatibility with analytics
telemetryClient.capture(TelemetryEventName.ACCOUNT_CONNECT_CLICKED)
const cloudUrl = cloudApiUrl || "https://app.roocode.com"
const cloudUrl = cloudApiUrl || PRODUCTION_ROO_CODE_API_URL
vscode.postMessage({ type: "openExternal", url: cloudUrl })
}

const handleOpenCloudUrl = () => {
if (cloudApiUrl) {
vscode.postMessage({ type: "openExternal", url: cloudApiUrl })
}
}

const handleRemoteControlToggle = () => {
const newValue = !remoteControlEnabled
setRemoteControlEnabled(newValue)
Expand Down Expand Up @@ -186,6 +195,18 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
</div>
</>
)}
{cloudApiUrl && cloudApiUrl !== PRODUCTION_ROO_CODE_API_URL && (
<div className="mt-6 flex justify-center">
<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">
<span className="text-vscode-foreground/75">{t("cloud:cloudUrlPillLabel")}: </span>
<button
onClick={handleOpenCloudUrl}
className="text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0">
{cloudApiUrl}
</button>
</div>
</div>
)}
</div>
)
}
67 changes: 67 additions & 0 deletions webview-ui/src/components/cloud/__tests__/CloudView.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ vi.mock("@src/i18n/TranslationContext", () => ({
"cloud:remoteControlDescription":
"Enable following and interacting with tasks in this workspace with Roo Code Cloud",
"cloud:profilePicture": "Profile picture",
"cloud:cloudUrlPillLabel": "Roo Code Cloud URL: ",
}
return translations[key] || key
},
Expand Down Expand Up @@ -148,4 +149,70 @@ describe("CloudView", () => {
expect(screen.queryByTestId("remote-control-toggle")).not.toBeInTheDocument()
expect(screen.queryByText("Roomote Control")).not.toBeInTheDocument()
})

it("should not display cloud URL pill when pointing to production", () => {
const mockUserInfo = {
name: "Test User",
email: "[email protected]",
}

render(
<CloudView
userInfo={mockUserInfo}
isAuthenticated={true}
cloudApiUrl="https://app.roocode.com"
onDone={() => {}}
/>,
)

// Check that the cloud URL pill is NOT displayed for production URL
expect(screen.queryByText(/Roo Code Cloud URL:/)).not.toBeInTheDocument()
})

it("should display cloud URL pill when pointing to non-production environment", () => {
const mockUserInfo = {
name: "Test User",
email: "[email protected]",
}

render(
<CloudView
userInfo={mockUserInfo}
isAuthenticated={true}
cloudApiUrl="https://staging.roocode.com"
onDone={() => {}}
/>,
)

// Check that the cloud URL pill is displayed with the staging URL
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
expect(screen.getByText("https://staging.roocode.com")).toBeInTheDocument()
})

it("should display cloud URL pill for non-authenticated users when not pointing to production", () => {
render(
<CloudView
userInfo={null}
isAuthenticated={false}
cloudApiUrl="https://dev.roocode.com"
onDone={() => {}}
/>,
)

// Check that the cloud URL pill is displayed even when not authenticated
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
expect(screen.getByText("https://dev.roocode.com")).toBeInTheDocument()
})

it("should not display cloud URL pill when cloudApiUrl is undefined", () => {
const mockUserInfo = {
name: "Test User",
email: "[email protected]",
}

render(<CloudView userInfo={mockUserInfo} isAuthenticated={true} onDone={() => {}} />)

// Check that the cloud URL pill is NOT displayed when cloudApiUrl is undefined
expect(screen.queryByText(/Roo Code Cloud URL:/)).not.toBeInTheDocument()
})
})
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ca/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/de/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/en/cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"cloudBenefitMetrics": "Get a holistic view of your token consumption",
"visitCloudWebsite": "Visit Roo Code Cloud",
"remoteControl": "Roomote Control",
"remoteControlDescription": "Enable following and interacting with tasks in this workspace with Roo Code Cloud"
"remoteControlDescription": "Enable following and interacting with tasks in this workspace with Roo Code Cloud",
"cloudUrlPillLabel": "Roo Code Cloud URL"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/es/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/fr/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/hi/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/id/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/it/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ja/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ko/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/nl/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pl/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pt-BR/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ru/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/tr/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/vi/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-CN/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-TW/cloud.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading