mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-28 20:44:50 +02:00
[eric] tool-ui: expired respond is 200+gone not a red 404, the orphaned state stays
This commit is contained in:
+3
-3
@@ -938,9 +938,9 @@ async def ui_request_respond(request: Request):
|
||||
return JSONResponse({"error": "session_id, component_id and response object are required"}, status_code=400)
|
||||
from backend.apps.agents.ui_request_bridge import respond_to_ui_request
|
||||
delivered = respond_to_ui_request(session_id, component_id, response)
|
||||
if not delivered:
|
||||
return JSONResponse({"error": "no pending request for that component"}, status_code=404)
|
||||
return JSONResponse({"ok": True})
|
||||
# A consumed/expired request is a normal outcome (replayed transcript, agent moved on), not an
|
||||
# error; 200 + gone keeps Chromium's console free of red 404 noise while the UI shows its orphaned state.
|
||||
return JSONResponse({"ok": delivered, "gone": not delivered})
|
||||
|
||||
|
||||
@app.post("/api/invoke-agent/run")
|
||||
|
||||
@@ -60,8 +60,9 @@ function AskUiBubble({ pair, sessionId, isPending, suppressReveal }: AskUiBubble
|
||||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getAuthToken()}` },
|
||||
body: JSON.stringify({ session_id: sessionId, component_id: componentId, response }),
|
||||
})
|
||||
.then((r) => {
|
||||
if (!r.ok) {
|
||||
.then(async (r) => {
|
||||
const body = r.ok ? await r.json().catch(() => null) : null;
|
||||
if (!r.ok || (body && body.gone)) {
|
||||
// Nothing parked server-side (agent gone or this is a replayed transcript): say so instead of silently swallowing the click.
|
||||
setSubmitted(false);
|
||||
setLocalChoice(undefined);
|
||||
|
||||
Reference in New Issue
Block a user