MCPcopy Index your code
hub / github.com/Noumena-Network/code / executeUserInput

Function executeUserInput

src/utils/handlePromptSubmit.ts:400–617  ·  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

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

Callers 1

handlePromptSubmitFunction · 0.85

Calls 13

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
logForDebuggingFunction · 0.70

Tested by

no test coverage detected