MCPcopy
hub / github.com/cursor/cookbook / sendPrompt

Function sendPrompt

sdk/coding-agent-cli/src/tui/App.tsx:407–435  ·  view source on GitHub ↗
(prompt: string)

Source from the content-addressed store, hash-verified

405 }
406
407 const sendPrompt = async (prompt: string) => {
408 const session = sessionRef.current
409 if (!session) {
410 return
411 }
412
413 const assistantId = nextId()
414 setBusy(true)
415 setCancelRequested(false)
416 setScrollOffset(0)
417 setTranscript((items) => [
418 ...items,
419 { id: nextId(), kind: "user", label: "you", text: prompt },
420 ])
421
422 try {
423 await session.sendPrompt({
424 prompt,
425 onEvent: (event) => {
426 setTranscript((items) => applyAgentEvent(items, event, assistantId))
427 },
428 })
429 } catch (error) {
430 addEntry("error", "run", getErrorMessage(error))
431 } finally {
432 setBusy(false)
433 setCancelRequested(false)
434 }
435 }
436
437 const cancelActiveRun = async () => {
438 const session = sessionRef.current

Callers 1

submitInputFunction · 0.85

Calls 5

nextIdFunction · 0.85
applyAgentEventFunction · 0.85
addEntryFunction · 0.85
sendPromptMethod · 0.80
getErrorMessageFunction · 0.70

Tested by

no test coverage detected