@@ -24,6 +24,7 @@ export const CodexConnectBanner = () => {
2424 const theme = useTheme ( )
2525 const [ flowState , setFlowState ] = useState < FlowState > ( 'checking' )
2626 const [ error , setError ] = useState < string | null > ( null )
27+ const [ manualUrl , setManualUrl ] = useState < string | null > ( null )
2728 const [ isDisconnectHovered , setIsDisconnectHovered ] = useState ( false )
2829 const [ isConnectHovered , setIsConnectHovered ] = useState ( false )
2930
@@ -41,6 +42,8 @@ export const CodexConnectBanner = () => {
4142 } else if ( callbackStatus === 'error' ) {
4243 setError ( message ?? 'Authorization failed' )
4344 setFlowState ( 'error' )
45+ } else if ( callbackStatus === 'waiting' && message ) {
46+ setManualUrl ( message )
4447 }
4548 } ) . catch ( ( err ) => {
4649 setError ( err instanceof Error ? err . message : 'Failed to start OAuth flow' )
@@ -57,12 +60,15 @@ export const CodexConnectBanner = () => {
5760 const handleConnect = async ( ) => {
5861 try {
5962 setFlowState ( 'waiting-for-code' )
63+ setManualUrl ( null )
6064 await startOAuthFlowWithCallback ( ( callbackStatus , message ) => {
6165 if ( callbackStatus === 'success' ) {
6266 setFlowState ( 'connected' )
6367 } else if ( callbackStatus === 'error' ) {
6468 setError ( message ?? 'Authorization failed' )
6569 setFlowState ( 'error' )
70+ } else if ( callbackStatus === 'waiting' && message ) {
71+ setManualUrl ( message )
6672 }
6773 } )
6874 } catch ( err ) {
@@ -128,10 +134,17 @@ export const CodexConnectBanner = () => {
128134 < BottomBanner borderColorKey = "info" onClose = { handleClose } >
129135 < box style = { { flexDirection : 'column' , gap : 0 , flexGrow : 1 } } >
130136 < text style = { { fg : theme . info } } > Waiting for authorization</ text >
131- < text style = { { fg : theme . muted , marginTop : 1 } } >
132- Sign in with your OpenAI account in the browser. The authorization
133- will complete automatically.
134- </ text >
137+ { manualUrl ? (
138+ < text style = { { fg : theme . muted , marginTop : 1 } } >
139+ Could not open browser. Open this URL manually:{ ' ' }
140+ { manualUrl }
141+ </ text >
142+ ) : (
143+ < text style = { { fg : theme . muted , marginTop : 1 } } >
144+ Sign in with your OpenAI account in the browser. The authorization
145+ will complete automatically.
146+ </ text >
147+ ) }
135148 </ box >
136149 </ BottomBanner >
137150 )
0 commit comments