@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
22
33import { Button } from './button'
44import { useTheme } from '../hooks/use-theme'
5+ import { useChatStore } from '../state/chat-store'
56import {
67 connectChatGptOAuth ,
78 disconnectChatGptOAuth ,
@@ -20,10 +21,12 @@ type FlowState =
2021
2122export const ChatGptConnectBanner = ( ) => {
2223 const theme = useTheme ( )
24+ const setInputMode = useChatStore ( ( state ) => state . setInputMode )
2325 const [ flowState , setFlowState ] = useState < FlowState > ( 'checking' )
2426 const [ error , setError ] = useState < string | null > ( null )
2527 const [ authUrl , setAuthUrl ] = useState < string | null > ( null )
2628 const [ hovered , setHovered ] = useState ( false )
29+ const [ isCloseHovered , setIsCloseHovered ] = useState ( false )
2730
2831 useEffect ( ( ) => {
2932 const status = getChatGptOAuthStatus ( )
@@ -86,8 +89,20 @@ export const ChatGptConnectBanner = () => {
8689 customBorderChars : BORDER_CHARS ,
8790 }
8891
89- const escHint = (
90- < text style = { { fg : theme . muted } } > esc</ text >
92+ const handleClose = ( ) => {
93+ setInputMode ( 'default' )
94+ }
95+
96+ const closeButton = (
97+ < Button
98+ onClick = { handleClose }
99+ onMouseOver = { ( ) => setIsCloseHovered ( true ) }
100+ onMouseOut = { ( ) => setIsCloseHovered ( false ) }
101+ >
102+ < text style = { { fg : isCloseHovered ? theme . error : theme . muted } } >
103+ x
104+ </ text >
105+ </ Button >
91106 )
92107
93108 if ( flowState === 'connected' ) {
@@ -105,7 +120,7 @@ export const ChatGptConnectBanner = () => {
105120 < span fg = { theme . muted } > Disconnect</ span >
106121 </ text >
107122 </ Button >
108- { escHint }
123+ { closeButton }
109124 </ box >
110125 </ box >
111126 )
@@ -128,7 +143,7 @@ export const ChatGptConnectBanner = () => {
128143 < span fg = { theme . foreground } > Retry</ span >
129144 </ text >
130145 </ Button >
131- { escHint }
146+ { closeButton }
132147 </ box >
133148 </ box >
134149 )
@@ -139,7 +154,7 @@ export const ChatGptConnectBanner = () => {
139154 < box style = { { ...panelStyle , flexDirection : 'column' } } >
140155 < box style = { { flexDirection : 'row' , justifyContent : 'space-between' , alignItems : 'center' } } >
141156 < text style = { { fg : theme . foreground } } > Connecting to ChatGPT...</ text >
142- { escHint }
157+ { closeButton }
143158 </ box >
144159 < text style = { { fg : theme . muted } } >
145160 Sign in via your browser to connect.
@@ -166,7 +181,7 @@ export const ChatGptConnectBanner = () => {
166181 < span fg = { theme . link } > Connect to ChatGPT</ span >
167182 </ text >
168183 </ Button >
169- { escHint }
184+ { closeButton }
170185 </ box >
171186 )
172187 }
0 commit comments