Agent 提问弹窗 — Popup + TextInput + Enter 提交。
触发流程
- Agent 发出
{:ask_user, session_id, question, options, ref}事件 EventRouter创建 ask_map(含新建 TextInput ref)存入state.pending_askApp.render检测到pending_ask != nil时叠加渲染此 DialogKeyHandler优先检测弹窗状态:- 普通字符 → 转发给 TextInput
Enter→ 提交回答:向 Agent EventBus 发送{:ask_user_response, ref, answer}Esc→ 提交空字符串(取消)- 其余 → 转发给 TextInput
带选项的提问
如果 options 非空,则在问题下方显示选项列表(1. option1 2. option2…),
用户可直接输入对应数字快速选择。
回答回传方式
通过 GenServer.cast(session_agent_pid, {:ask_user_reply, ref, answer})
直接回调 Agent(session 持有对 CMDC Agent 进程的引用)。
实际调用 CMDC 公共 API 或 fallback 到 EventBus 回传。
Summary
Functions
@spec new_ask_map(String.t(), String.t(), [map()], String.t()) :: CmdcTui.State.ask_map()
从事件参数创建 ask_map,包含新建的 TextInput ref。
@spec render(CmdcTui.State.t(), ExRatatui.Layout.Rect.t()) :: [ {ExRatatui.widget(), ExRatatui.Layout.Rect.t()} ]
渲染提问弹窗。