Skip to content

Commit 6733ea4

Browse files
roomotedaniel-lxs
authored andcommitted
fix: incorporate PR feedback for cloud URL indicator
- Fixed href syntax error (removed quotes around curly braces) - Added translation support for "Roo Code Cloud URL:" label - Extracted production URL as a constant (PRODUCTION_CLOUD_URL) - Implemented proper link handling using vscode.postMessage - Updated tests to match new implementation
1 parent 0383611 commit 6733ea4

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type CloudViewProps = {
1818
onDone: () => void
1919
}
2020

21+
const PRODUCTION_CLOUD_URL = "https://app.roocode.com"
22+
2123
export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: CloudViewProps) => {
2224
const { t } = useAppTranslation()
2325
const { remoteControlEnabled, setRemoteControlEnabled } = useExtensionState()
@@ -56,10 +58,16 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
5658
// Send telemetry for cloud website visit
5759
// NOTE: Using ACCOUNT_* telemetry events for backward compatibility with analytics
5860
telemetryClient.capture(TelemetryEventName.ACCOUNT_CONNECT_CLICKED)
59-
const cloudUrl = cloudApiUrl || "https://app.roocode.com"
61+
const cloudUrl = cloudApiUrl || PRODUCTION_CLOUD_URL
6062
vscode.postMessage({ type: "openExternal", url: cloudUrl })
6163
}
6264

65+
const handleOpenCloudUrl = () => {
66+
if (cloudApiUrl) {
67+
vscode.postMessage({ type: "openExternal", url: cloudApiUrl })
68+
}
69+
}
70+
6371
const handleRemoteControlToggle = () => {
6472
const newValue = !remoteControlEnabled
6573
setRemoteControlEnabled(newValue)
@@ -186,11 +194,15 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
186194
</div>
187195
</>
188196
)}
189-
{cloudApiUrl && cloudApiUrl !== "https://app.roocode.com" && (
197+
{cloudApiUrl && cloudApiUrl !== PRODUCTION_CLOUD_URL && (
190198
<div className="mt-6 flex justify-center">
191199
<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">
192-
<span className="text-vscode-foreground/75">Roo Code Cloud URL: </span>
193-
<a href="{cloudApiUrl}">{cloudApiUrl}</a>
200+
<span className="text-vscode-foreground/75">{t("account:cloudUrlPillLabel")}</span>
201+
<button
202+
onClick={handleOpenCloudUrl}
203+
className="text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0">
204+
{cloudApiUrl}
205+
</button>
194206
</div>
195207
</div>
196208
)}

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

Lines changed: 9 additions & 6 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
},
@@ -156,7 +157,7 @@ describe("CloudView", () => {
156157
}
157158

158159
render(
159-
<AccountView
160+
<CloudView
160161
userInfo={mockUserInfo}
161162
isAuthenticated={true}
162163
cloudApiUrl="https://app.roocode.com"
@@ -175,7 +176,7 @@ describe("CloudView", () => {
175176
}
176177

177178
render(
178-
<AccountView
179+
<CloudView
179180
userInfo={mockUserInfo}
180181
isAuthenticated={true}
181182
cloudApiUrl="https://staging.roocode.com"
@@ -184,12 +185,13 @@ describe("CloudView", () => {
184185
)
185186

186187
// Check that the cloud URL pill is displayed with the staging URL
187-
expect(screen.getByText("Roo Code Cloud URL: https://staging.roocode.com")).toBeInTheDocument()
188+
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
189+
expect(screen.getByText("https://staging.roocode.com")).toBeInTheDocument()
188190
})
189191

190192
it("should display cloud URL pill for non-authenticated users when not pointing to production", () => {
191193
render(
192-
<AccountView
194+
<CloudView
193195
userInfo={null}
194196
isAuthenticated={false}
195197
cloudApiUrl="https://dev.roocode.com"
@@ -198,7 +200,8 @@ describe("CloudView", () => {
198200
)
199201

200202
// Check that the cloud URL pill is displayed even when not authenticated
201-
expect(screen.getByText("Roo Code Cloud URL: https://dev.roocode.com")).toBeInTheDocument()
203+
expect(screen.getByText(/Roo Code Cloud URL:/)).toBeInTheDocument()
204+
expect(screen.getByText("https://dev.roocode.com")).toBeInTheDocument()
202205
})
203206

204207
it("should not display cloud URL pill when cloudApiUrl is undefined", () => {
@@ -207,7 +210,7 @@ describe("CloudView", () => {
207210
208211
}
209212

210-
render(<AccountView userInfo={mockUserInfo} isAuthenticated={true} onDone={() => {}} />)
213+
render(<CloudView userInfo={mockUserInfo} isAuthenticated={true} onDone={() => {}} />)
211214

212215
// Check that the cloud URL pill is NOT displayed when cloudApiUrl is undefined
213216
expect(screen.queryByText(/Roo Code Cloud URL:/)).not.toBeInTheDocument()

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
}

0 commit comments

Comments
 (0)