MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / processKeysInBatch

Function processKeysInBatch

source code/ink/components/App.tsx:446–514  ·  view source on GitHub ↗
(app: App, items: ParsedInput[], _unused1: undefined, _unused2: undefined)

Source from the content-addressed store, hash-verified

444// Helper to process all keys within a single discrete update context.
445// discreteUpdates expects (fn, a, b, c, d) -> fn(a, b, c, d)
446function processKeysInBatch(app: App, items: ParsedInput[], _unused1: undefined, _unused2: undefined): void {
447 // Update interaction time for notification timeout tracking.
448 // This is called from the central input handler to avoid having multiple
449 // stdin listeners that can cause race conditions and dropped input.
450 // Terminal responses (kind: 'response') are automated, not user input.
451 // Mode-1003 no-button motion is also excluded — passive cursor drift is
452 // not engagement (would suppress idle notifications + defer housekeeping).
453 if (items.some(i => i.kind === 'key' || i.kind === 'mouse' && !((i.button & 0x20) !== 0 && (i.button & 0x03) === 3))) {
454 updateLastInteractionTime();
455 }
456 for (const item of items) {
457 // Terminal responses (DECRPM, DA1, OSC replies, etc.) are not user
458 // input — route them to the querier to resolve pending promises.
459 if (item.kind === 'response') {
460 app.querier.onResponse(item.response);
461 continue;
462 }
463
464 // Mouse click/drag events update selection state (fullscreen only).
465 // Terminal sends 1-indexed col/row; convert to 0-indexed for the
466 // screen buffer. Button bit 0x20 = drag (motion while button held).
467 if (item.kind === 'mouse') {
468 handleMouseEvent(app, item);
469 continue;
470 }
471 const sequence = item.sequence;
472
473 // Handle terminal focus events (DECSET 1004)
474 if (sequence === FOCUS_IN) {
475 app.handleTerminalFocus(true);
476 const event = new TerminalFocusEvent('terminalfocus');
477 app.internal_eventEmitter.emit('terminalfocus', event);
478 continue;
479 }
480 if (sequence === FOCUS_OUT) {
481 app.handleTerminalFocus(false);
482 // Defensive: if we lost the release event (mouse released outside
483 // terminal window — some emulators drop it rather than capturing the
484 // pointer), focus-out is the next observable signal that the drag is
485 // over. Without this, drag-to-scroll's timer runs until the scroll
486 // boundary is hit.
487 if (app.props.selection.isDragging) {
488 finishSelection(app.props.selection);
489 app.props.onSelectionChange();
490 }
491 const event = new TerminalFocusEvent('terminalblur');
492 app.internal_eventEmitter.emit('terminalblur', event);
493 continue;
494 }
495
496 // Failsafe: if we receive input, the terminal must be focused
497 if (!getTerminalFocused()) {
498 setTerminalFocused(true);
499 }
500
501 // Handle Ctrl+Z (suspend) using parsed key to support both raw (\x1a) and
502 // CSI u format (\x1b[122;5u) from Kitty keyboard protocol terminals
503 if (item.name === 'z' && item.ctrl && SUPPORTS_SUSPEND) {

Callers

nothing calls this directly

Calls 8

handleMouseEventFunction · 0.85
finishSelectionFunction · 0.85
getTerminalFocusedFunction · 0.85
setTerminalFocusedFunction · 0.85
onResponseMethod · 0.80
emitMethod · 0.80
dispatchKeyboardEventMethod · 0.80

Tested by

no test coverage detected