()
| 535 | } |
| 536 | |
| 537 | function SimulatorPage() { |
| 538 | const [chunks, setChunks] = useState<Array<any>>([]) |
| 539 | const [input, setInput] = useState('') |
| 540 | |
| 541 | const { messages, sendMessage, isLoading, addToolApprovalResponse, stop } = |
| 542 | useChat({ |
| 543 | connection: fetchServerSentEvents('/api/simulator-chat'), |
| 544 | tools, |
| 545 | onChunk: (chunk: any) => { |
| 546 | setChunks((prev) => [...prev, chunk]) |
| 547 | }, |
| 548 | }) |
| 549 | |
| 550 | const clearChunks = () => setChunks([]) |
| 551 | |
| 552 | const handleInject = (template: string) => { |
| 553 | setInput((prev) => (prev ? `${prev}\n${template}` : template)) |
| 554 | } |
| 555 | |
| 556 | return ( |
| 557 | <div className="flex h-[calc(100vh-72px)] bg-gray-900"> |
| 558 | {/* Left side - Chat (1/2 width) */} |
| 559 | <div className="w-1/2 flex flex-col border-r border-purple-500/20"> |
| 560 | {/* Header bar */} |
| 561 | <div className="border-b border-purple-500/20 bg-gray-800 px-4 py-3"> |
| 562 | <div className="flex items-center gap-3"> |
| 563 | <div className="flex items-center gap-2"> |
| 564 | <FlaskConical className="w-5 h-5 text-purple-400" /> |
| 565 | <h1 className="text-white font-semibold">Tool Simulator</h1> |
| 566 | </div> |
| 567 | <span className="text-xs px-2 py-1 bg-purple-500/20 text-purple-400 rounded"> |
| 568 | Mock LLM |
| 569 | </span> |
| 570 | </div> |
| 571 | <p className="text-gray-400 text-xs mt-1"> |
| 572 | Test tool execution flows with a simulated LLM. Use the syntax:{' '} |
| 573 | <code className="bg-gray-700 px-1 rounded"> |
| 574 | toolName({'{ args }'}) |
| 575 | </code> |
| 576 | </p> |
| 577 | </div> |
| 578 | |
| 579 | <Messages |
| 580 | messages={messages} |
| 581 | addToolApprovalResponse={addToolApprovalResponse} |
| 582 | /> |
| 583 | |
| 584 | <ToolInjectionPanel onInject={handleInject} /> |
| 585 | |
| 586 | <ChatInputArea> |
| 587 | <div className="space-y-3"> |
| 588 | {isLoading && ( |
| 589 | <div className="flex items-center justify-center"> |
| 590 | <button |
| 591 | onClick={stop} |
| 592 | className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors flex items-center gap-2" |
| 593 | > |
| 594 | <Square className="w-4 h-4 fill-current" /> |
nothing calls this directly
no test coverage detected