MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / ChatGptConnectBanner

Function ChatGptConnectBanner

cli/src/components/chatgpt-connect-banner.tsx:22–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20 | 'error'
21
22export 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,

Callers

nothing calls this directly

Calls 5

useThemeFunction · 0.90
getChatGptOAuthStatusFunction · 0.90
connectChatGptOAuthFunction · 0.90
stopChatGptOAuthServerFunction · 0.90
setErrorFunction · 0.85

Tested by

no test coverage detected