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

Function TakeoverPrompt

cli/src/components/waiting-room-screen.tsx:139–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137}
138
139const TakeoverPrompt: React.FC = () => {
140 const theme = useTheme()
141 const [pending, setPending] = useState(false)
142 const [focusedIndex, setFocusedIndex] = useState(0) // 0 = Take over, 1 = Exit
143
144 const handleTakeover = useCallback(() => {
145 if (pending) return
146 setPending(true)
147 takeOverFreebuffSession().finally(() => setPending(false))
148 }, [pending])
149
150 useKeyboard(
151 useCallback(
152 (key: KeyEvent) => {
153 const name = key.name ?? ''
154 const isConfirm = name === 'return' || name === 'enter'
155 const isExit = name === 'escape' || name === 'esc'
156 const isTab = name === 'tab'
157 const isShiftTab = key.shift === true && isTab
158 const isRight = name === 'right'
159 const isLeft = name === 'left'
160
161 if (isExit) {
162 key.preventDefault?.()
163 exitFreebuffCleanly()
164 return
165 }
166
167 if (isConfirm) {
168 key.preventDefault?.()
169 if (focusedIndex === 0) {
170 handleTakeover()
171 } else {
172 exitFreebuffCleanly()
173 }
174 return
175 }
176
177 if (isRight || isTab) {
178 key.preventDefault?.()
179 setFocusedIndex((prev) => (prev + 1) % 2)
180 return
181 }
182
183 if (isLeft || isShiftTab) {
184 key.preventDefault?.()
185 setFocusedIndex((prev) => (prev - 1 + 2) % 2)
186 return
187 }
188 },
189 [focusedIndex, handleTakeover],
190 ),
191 )
192
193 const isTakeoverFocused = focusedIndex === 0
194 const isExitFocused = focusedIndex === 1
195
196 return (

Callers

nothing calls this directly

Calls 3

useThemeFunction · 0.90
takeOverFreebuffSessionFunction · 0.90
exitFreebuffCleanlyFunction · 0.90

Tested by

no test coverage detected