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

Function executeUserInput

source code/utils/handlePromptSubmit.ts:398–612  ·  view source on GitHub ↗

* Core logic for executing user input without UI side effects. * * All commands arrive as `queuedCommands`. First command gets full treatment * (attachments, ideSelection, pastedContents with image resizing). Commands 2-N * get `skipAttachments` to avoid duplicating turn-level context.

(params: ExecuteUserInputParams)

Source from the content-addressed store, hash-verified

396 * get `skipAttachments` to avoid duplicating turn-level context.
397 */
398async function executeUserInput(params: ExecuteUserInputParams): Promise<void> {
399 const {
400 messages,
401 mainLoopModel,
402 ideSelection,
403 querySource,
404 queryGuard,
405 setToolJSX,
406 getToolUseContext,
407 setUserInputOnProcessing,
408 setAbortController,
409 onQuery,
410 setAppState,
411 onBeforeQuery,
412 resetHistory,
413 canUseTool,
414 queuedCommands,
415 } = params
416
417 // Note: paste references are already processed before calling this function
418 // (either in handlePromptSubmit before queuing, or before initial execution).
419 // Always create a fresh abort controller — queryGuard guarantees no concurrent
420 // executeUserInput call, so there's no prior controller to inherit.
421 const abortController = createAbortController()
422 setAbortController(abortController)
423
424 function makeContext(): ProcessUserInputContext {
425 return getToolUseContext(messages, [], abortController, mainLoopModel)
426 }
427
428 // Wrap in try-finally so the guard is released even if processUserInput
429 // throws or onQuery is skipped. onQuery's finally calls queryGuard.end(),
430 // which transitions running→idle; cancelReservation() below is a no-op in
431 // that case (only acts on dispatching state).
432 try {
433 // Reserve the guard BEFORE processUserInput — processBashCommand awaits
434 // BashTool.call() and processSlashCommand awaits getMessagesForSlashCommand,
435 // so the guard must be active during those awaits to ensure concurrent
436 // handlePromptSubmit calls queue (via the isActive check above) instead
437 // of starting a second executeUserInput. This call is a no-op if the
438 // guard is already in dispatching (legacy queue-processor path).
439 queryGuard.reserve()
440 queryCheckpoint('query_process_user_input_start')
441
442 const newMessages: Message[] = []
443 let shouldQuery = false
444 let allowedTools: string[] | undefined
445 let model: string | undefined
446 let effort: EffortValue | undefined
447 let nextInput: string | undefined
448 let submitNextInput: boolean | undefined
449
450 // Iterate all commands uniformly. First command gets attachments +
451 // ideSelection + pastedContents, rest skip attachments to avoid
452 // duplicating turn-level context (IDE selection, todos, diffs).
453 const commands = queuedCommands ?? []
454
455 // Compute the workload tag for this turn. queueProcessor can batch a

Callers 1

handlePromptSubmitFunction · 0.85

Calls 11

createAbortControllerFunction · 0.85
queryCheckpointFunction · 0.85
runWithWorkloadFunction · 0.85
processUserInputFunction · 0.85
makeContextFunction · 0.85
fileHistoryEnabledFunction · 0.85
fileHistoryMakeSnapshotFunction · 0.85
enqueueFunction · 0.85
reserveMethod · 0.80
cancelReservationMethod · 0.80

Tested by

no test coverage detected