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:
Tim Wang
2026-06-28 21:57:57 +08:00
committed by yzc
parent 212429bf9d
commit f0f10b6092
18 changed files with 330 additions and 196 deletions

View File

@@ -65,8 +65,8 @@ def _load_bot_api(monkeypatch, *, accessible, calls):
calls["completion"] = True
async def _gen():
if False:
yield ""
yield 'data: {"event":"message","data":{"content":"ok"}}\n\n'
yield 'data: {"event":"message_end","data":{"content":"ok"}}\n\n'
return _gen()
_stub(monkeypatch, "quart", Response=lambda *a, **k: SimpleNamespace(headers=SimpleNamespace(add_header=lambda *aa, **kk: None)), request=SimpleNamespace())
@@ -83,7 +83,12 @@ def _load_bot_api(monkeypatch, *, accessible, calls):
_stub(monkeypatch, "api.db.services.llm_service", LLMBundle=SimpleNamespace())
_stub(monkeypatch, "common.metadata_utils", apply_meta_data_filter=lambda *_a, **_k: None)
_stub(monkeypatch, "api.db.services.search_service", SearchService=SimpleNamespace())
_stub(monkeypatch, "api.db.services.user_service", UserTenantService=SimpleNamespace())
_stub(
monkeypatch,
"api.db.services.user_service",
TenantService=SimpleNamespace(),
UserTenantService=SimpleNamespace(),
)
_stub(monkeypatch, "api.db.joint_services.tenant_model_service", get_tenant_default_model_by_type=lambda *_a, **_k: None, get_model_config_from_provider_instance=lambda *_a, **_k: None)
_stub(monkeypatch, "common.misc_utils", get_uuid=lambda: "uuid", thread_pool_exec=_passthrough_thread_pool_exec)
_stub(
@@ -118,7 +123,7 @@ def _load_bot_api(monkeypatch, *, accessible, calls):
async def _async_empty_json():
return {}
return {"stream": False}
@pytest.mark.p1