()
| 20 | | 'error' |
| 21 | |
| 22 | export const ChatGptConnectBanner = () => { |
| 23 | const theme = useTheme() |
| 24 | const setInputMode = useChatStore((state) => state.setInputMode) |
| 25 | const [flowState, setFlowState] = useState<FlowState>('checking') |
| 26 | const [error, setError] = useState<string | null>(null) |
| 27 | const [authUrl, setAuthUrl] = useState<string | null>(null) |
| 28 | const [hovered, setHovered] = useState(false) |
| 29 | const [isCloseHovered, setIsCloseHovered] = useState(false) |
| 30 | |
| 31 | useEffect(() => { |
| 32 | const status = getChatGptOAuthStatus() |
| 33 | if (!status.connected) { |
| 34 | setFlowState('waiting-for-code') |
| 35 | const result = connectChatGptOAuth() |
| 36 | setAuthUrl(result.authUrl) |
| 37 | result.credentials |
| 38 | .then(() => { |
| 39 | setFlowState('connected') |
| 40 | }) |
| 41 | .catch((err) => { |
| 42 | setError(err instanceof Error ? err.message : 'Failed to connect') |
| 43 | setFlowState('error') |
| 44 | }) |
| 45 | } else { |
| 46 | setFlowState('connected') |
| 47 | } |
| 48 | |
| 49 | return () => { |
| 50 | stopChatGptOAuthServer() |
| 51 | } |
| 52 | }, []) |
| 53 | |
| 54 | const handleConnect = () => { |
| 55 | setFlowState('waiting-for-code') |
| 56 | const result = connectChatGptOAuth() |
| 57 | setAuthUrl(result.authUrl) |
| 58 | result.credentials |
| 59 | .then(() => { |
| 60 | setFlowState('connected') |
| 61 | }) |
| 62 | .catch((err) => { |
| 63 | setError(err instanceof Error ? err.message : 'Failed to connect') |
| 64 | setFlowState('error') |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | const handleDisconnect = () => { |
| 69 | disconnectChatGptOAuth() |
| 70 | setFlowState('not-connected') |
| 71 | } |
| 72 | |
| 73 | const panelStyle = { |
| 74 | width: '100%' as const, |
| 75 | borderStyle: 'single' as const, |
| 76 | borderColor: theme.border, |
| 77 | customBorderChars: BORDER_CHARS, |
| 78 | paddingLeft: 1, |
| 79 | paddingRight: 1, |
nothing calls this directly
no test coverage detected