(prompt: string)
| 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 |
no test coverage detected