mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-25 17:42:24 +08:00
Fix: UserFillUp interactive forms not working in agent explore mode (#14589)
## Summary - **Backend**: `_iter_session_completion_events` in `agent_api.py` was filtering out `user_inputs` and `workflow_finished` SSE events, causing agents with UserFillUp components to silently fail in explore mode — the interactive form never appeared, while the same agent worked correctly in run (editor) mode. - **Frontend**: `SessionChat` component in explore mode was missing `DebugContent` children rendering inside `MessageItem`, so even if the backend forwarded the events, the form UI would not render. Added `DebugContent`, `MarkdownContent`, `useAwaitCompentData` hook, and input-disabling logic to match the run mode's `chat/box.tsx` behavior. ## What was changed ### Backend (`api/apps/restful_apis/agent_api.py`) - Line 266: Added `"user_inputs"` and `"workflow_finished"` to the allowed event filter in `_iter_session_completion_events` ### Frontend (`web/src/pages/agent/explore/components/session-chat.tsx`) - Added imports: `DebugContent`, `MarkdownContent`, `useAwaitCompentData`, `useParams` - Added `sendFormMessage` from `useSendSessionMessage()` hook - Added `useAwaitCompentData` hook for form state management - Added `DebugContent` as `MessageItem` children for the latest assistant message (renders UserFillUp form) - Added `MarkdownContent` + submitted values display for previous assistant messages - Updated `NextMessageInput` disabled states to respect `isWaitting` (form submission in progress) ## Test plan - [x] Agent with UserFillUp component (e.g., email draft with send/edit/cancel options) shows interactive form in **explore mode** - [x] Same agent continues to work correctly in **run (editor) mode** - [x] Form submission sends data back to the agent and workflow continues - [x] Input field is disabled while waiting for form submission - [ ] Agents without UserFillUp components are unaffected in explore mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Zhichang Yu <yuzhichang@gmail.com>
This commit is contained in:
@@ -575,7 +575,14 @@ async def _iter_session_completion_events(tenant_id, agent_id, req, return_trace
|
||||
yield ans
|
||||
continue
|
||||
|
||||
if event in ["message", "message_end"]:
|
||||
if event in ["message", "message_end", "user_inputs", "workflow_finished"]:
|
||||
if event in ["user_inputs", "workflow_finished"]:
|
||||
logging.debug(
|
||||
"Forwarding session completion event: tenant_id=%s agent_id=%s event=%s",
|
||||
tenant_id,
|
||||
agent_id,
|
||||
event,
|
||||
)
|
||||
yield ans
|
||||
|
||||
|
||||
@@ -1564,7 +1571,10 @@ async def agent_chat_completion(tenant_id, agent_id=None):
|
||||
"trace": [copy.deepcopy(data)],
|
||||
}
|
||||
)
|
||||
final_ans = ans
|
||||
if ans.get("event") == "message_end":
|
||||
final_ans = ans
|
||||
elif ans.get("event") == "user_inputs" and not final_ans:
|
||||
final_ans = ans
|
||||
except Exception as exc:
|
||||
return get_result(data=f"**ERROR**: {str(exc)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user