MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / executeUserInput

Function executeUserInput

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

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