From da938de219b151664ec49c4b9e154d956e901e55 Mon Sep 17 00:00:00 2001 From: Rassl Date: Mon, 27 Jul 2026 14:31:55 +0700 Subject: [PATCH] feat: show agent text response and fix composer typing lag --- .../admin/ontology/ontology-agent-panel.tsx | 118 ++++++++++++------ src/lib/graph-api.ts | 9 +- 2 files changed, 88 insertions(+), 39 deletions(-) diff --git a/src/app/admin/ontology/ontology-agent-panel.tsx b/src/app/admin/ontology/ontology-agent-panel.tsx index b0e41c2..4b5ccca 100644 --- a/src/app/admin/ontology/ontology-agent-panel.tsx +++ b/src/app/admin/ontology/ontology-agent-panel.tsx @@ -1,6 +1,6 @@ "use client" -import { useCallback, useEffect, useRef, useState } from "react" +import { memo, useCallback, useEffect, useRef, useState } from "react" import { Sparkles, X, ArrowUp, Loader2 } from "lucide-react" import { triggerOntologyAgent, @@ -21,6 +21,7 @@ interface AgentTurn { runRef?: string status: TurnStatus reviews: Review[] + response?: string error?: string } @@ -44,7 +45,6 @@ function mapRunStatus(status: StakworkRun["status"]): TurnStatus { export function OntologyAgentPanel({ onClose }: { onClose: () => void }) { const schemas = useSchemaStore((s) => s.schemas) const [turns, setTurns] = useState([]) - const [input, setInput] = useState("") const [busy, setBusy] = useState(false) const pollRef = useRef | null>(null) const scrollRef = useRef(null) @@ -94,7 +94,11 @@ export function OntologyAgentPanel({ onClose }: { onClose: () => void }) { return } const res = await listReviews({ run_ref_id: runRef, status: "pending" }) - patchAgentTurn(turnId, { status: "completed", reviews: res.reviews }) + patchAgentTurn(turnId, { + status: "completed", + reviews: res.reviews, + response: run?.response, + }) } catch { /* swallow — keep polling until a terminal state or unmount */ } @@ -103,11 +107,10 @@ export function OntologyAgentPanel({ onClose }: { onClose: () => void }) { [patchAgentTurn] ) - const handleSubmit = useCallback(async () => { - const instruction = input.trim() + const handleSubmit = useCallback(async (raw: string) => { + const instruction = raw.trim() if (!instruction || busy) return setBusy(true) - setInput("") const history: OntologyAgentMessage[] = turns.map((t) => t.role === "user" @@ -131,7 +134,7 @@ export function OntologyAgentPanel({ onClose }: { onClose: () => void }) { setBusy(false) patchAgentTurn(agentId, { status: "failed", error: "Could not start the ontology agent." }) } - }, [input, busy, turns, patchAgentTurn, startPoll]) + }, [busy, turns, patchAgentTurn, startPoll]) return (
@@ -183,43 +186,68 @@ export function OntologyAgentPanel({ onClose }: { onClose: () => void }) { )}
- {/* Composer */} -
-
-