MCPcopy Create free account
hub / github.com/arctic-cli/interface / handleStdinData

Function handleStdinData

packages/arctic/src/cli/cmd/tui/app.tsx:234–265  ·  view source on GitHub ↗
(data: Buffer)

Source from the content-addressed store, hash-verified

232 // Focus-in events trigger a repaint to fix rendering issues
233 let savedFocus: any = null
234 const handleStdinData = (data: Buffer) => {
235 const str = data.toString()
236 // Check for focus-out escape sequence (\x1b[O)
237 if (str.includes("\x1b[O")) {
238 savedFocus = renderer.currentFocusedRenderable
239 }
240 // Check for focus-in escape sequence (\x1b[I)
241 if (str.includes("\x1b[I")) {
242 renderer.currentRenderBuffer.clear()
243 renderer.requestRender()
244 // restore focus to the previously focused element after render completes
245 // try multiple times with increasing delays to work around opentui 0.1.77 focus tracking bug
246 const restoreFocus = () => {
247 const target = savedFocus || promptRef.current
248 if (target && typeof target.focus === "function") {
249 try {
250 if (typeof target.blur === "function") {
251 target.blur()
252 }
253 target.focus()
254 } catch {}
255 }
256 }
257 restoreFocus()
258 // retry after one frame
259 setTimeout(restoreFocus, 16)
260 // retry after renderer has settled
261 setTimeout(restoreFocus, 50)
262 // final retry with longer delay
263 setTimeout(restoreFocus, 150)
264 }
265 }
266
267 process.stdin.on("data", handleStdinData)
268

Callers

nothing calls this directly

Calls 2

restoreFocusFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected