1
1
import { useEffect , useRef , useState } from "react"
2
- import { VSCodeButton , VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
2
+ import { VSCodeButton , VSCodeProgressRing , VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
3
3
4
4
import { type CloudUserInfo , TelemetryEventName } from "@roo-code/types"
5
5
@@ -26,6 +26,7 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
26
26
const { remoteControlEnabled, setRemoteControlEnabled } = useExtensionState ( )
27
27
const wasAuthenticatedRef = useRef ( false )
28
28
const timeoutRef = useRef < NodeJS . Timeout | null > ( null )
29
+ const manualUrlInputRef = useRef < HTMLInputElement | null > ( null )
29
30
30
31
// Manual URL entry state
31
32
const [ authInProgress , setAuthInProgress ] = useState ( false )
@@ -54,6 +55,16 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
54
55
}
55
56
} , [ isAuthenticated ] )
56
57
58
+ // Focus the manual URL input when it becomes visible
59
+ useEffect ( ( ) => {
60
+ if ( showManualEntry && manualUrlInputRef . current ) {
61
+ // Small delay to ensure the DOM is ready
62
+ setTimeout ( ( ) => {
63
+ manualUrlInputRef . current ?. focus ( )
64
+ } , 50 )
65
+ }
66
+ } , [ showManualEntry ] )
67
+
57
68
// Cleanup timeout on unmount
58
69
useEffect ( ( ) => {
59
70
return ( ) => {
@@ -98,6 +109,12 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
98
109
setShowManualEntry ( true )
99
110
}
100
111
112
+ const handleReset = ( ) => {
113
+ setAuthInProgress ( false )
114
+ setShowManualEntry ( false )
115
+ setManualUrl ( "" )
116
+ }
117
+
101
118
const handleLogoutClick = ( ) => {
102
119
// Send telemetry for cloud logout action
103
120
// NOTE: Using ACCOUNT_* telemetry events for backward compatibility with analytics
@@ -239,39 +256,50 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
239
256
</ div >
240
257
241
258
< div className = "flex flex-col items-center gap-4" >
242
- < VSCodeButton appearance = "primary" onClick = { handleConnectClick } className = "w-1/2" >
243
- { t ( "cloud:connect" ) }
244
- </ VSCodeButton >
259
+ { ! authInProgress && (
260
+ < VSCodeButton appearance = "primary" onClick = { handleConnectClick } className = "w-1/2" >
261
+ { t ( "cloud:connect" ) }
262
+ </ VSCodeButton >
263
+ ) }
245
264
246
265
{ /* Manual entry section */ }
247
266
{ authInProgress && ! showManualEntry && (
248
267
// Timeout message with "Having trouble?" link
249
- < div className = "flex flex-col items-center gap-2" >
250
- < div className = "text-sm text-vscode-descriptionForeground" >
268
+ < div className = "flex flex-col items-center gap-1" >
269
+ < div className = "flex items-center gap-2 text-sm text-vscode-descriptionForeground" >
270
+ < VSCodeProgressRing className = "size-3 text-vscode-foreground" />
251
271
{ t ( "cloud:authWaiting" ) }
252
272
</ div >
253
- < button
254
- onClick = { handleShowManualEntry }
255
- className = "text-sm text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0" >
256
- { t ( "cloud:havingTrouble" ) }
257
- </ button >
273
+ { ! showManualEntry && (
274
+ < button
275
+ onClick = { handleShowManualEntry }
276
+ className = "text-sm text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0" >
277
+ { t ( "cloud:havingTrouble" ) }
278
+ </ button >
279
+ ) }
258
280
</ div >
259
281
) }
260
282
261
283
{ showManualEntry && (
262
284
// Manual URL entry form
263
- < >
264
- < div className = "text-xs text-vscode-descriptionForeground" >
285
+ < div className = "space-y-2 text-center border-border/50 border-t px-2 pt-8 mt-3" >
286
+ < p className = "text-xs text-vscode-descriptionForeground" >
265
287
{ t ( "cloud:pasteCallbackUrl" ) }
266
- </ div >
288
+ </ p >
267
289
< VSCodeTextField
290
+ ref = { manualUrlInputRef as any }
268
291
value = { manualUrl }
269
292
onChange = { handleManualUrlChange }
270
293
onKeyDown = { handleKeyDown }
271
294
placeholder = "vscode://RooVeterinaryInc.roo-cline/auth/clerk/callback?state=..."
272
- className = "w-1/2 "
295
+ className = "w-full "
273
296
/>
274
- </ >
297
+ < button
298
+ onClick = { handleReset }
299
+ className = "text-sm text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground underline cursor-pointer bg-transparent border-none p-0" >
300
+ { t ( "cloud:startOver" ) }
301
+ </ button >
302
+ </ div >
275
303
) }
276
304
</ div >
277
305
</ >
0 commit comments