11import { 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"
33
44import { type CloudUserInfo , TelemetryEventName } from "@roo-code/types"
55
@@ -26,6 +26,7 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
2626 const { remoteControlEnabled, setRemoteControlEnabled } = useExtensionState ( )
2727 const wasAuthenticatedRef = useRef ( false )
2828 const timeoutRef = useRef < NodeJS . Timeout | null > ( null )
29+ const manualUrlInputRef = useRef < HTMLInputElement | null > ( null )
2930
3031 // Manual URL entry state
3132 const [ authInProgress , setAuthInProgress ] = useState ( false )
@@ -54,6 +55,16 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
5455 }
5556 } , [ isAuthenticated ] )
5657
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+
5768 // Cleanup timeout on unmount
5869 useEffect ( ( ) => {
5970 return ( ) => {
@@ -98,6 +109,12 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
98109 setShowManualEntry ( true )
99110 }
100111
112+ const handleReset = ( ) => {
113+ setAuthInProgress ( false )
114+ setShowManualEntry ( false )
115+ setManualUrl ( "" )
116+ }
117+
101118 const handleLogoutClick = ( ) => {
102119 // Send telemetry for cloud logout action
103120 // NOTE: Using ACCOUNT_* telemetry events for backward compatibility with analytics
@@ -239,39 +256,50 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone }: Cl
239256 </ div >
240257
241258 < 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+ ) }
245264
246265 { /* Manual entry section */ }
247266 { authInProgress && ! showManualEntry && (
248267 // 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" />
251271 { t ( "cloud:authWaiting" ) }
252272 </ 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+ ) }
258280 </ div >
259281 ) }
260282
261283 { showManualEntry && (
262284 // 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" >
265287 { t ( "cloud:pasteCallbackUrl" ) }
266- </ div >
288+ </ p >
267289 < VSCodeTextField
290+ ref = { manualUrlInputRef as any }
268291 value = { manualUrl }
269292 onChange = { handleManualUrlChange }
270293 onKeyDown = { handleKeyDown }
271294 placeholder = "vscode://RooVeterinaryInc.roo-cline/auth/clerk/callback?state=..."
272- className = "w-1/2 "
295+ className = "w-full "
273296 />
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 >
275303 ) }
276304 </ div >
277305 </ >
0 commit comments