yumoqing 0a6baa0d52 feat: AgentInput控件 — TextFiles+UiCode模型选择一体化
- 新增 agent_input.js: bricks.AgentInput extends VBox
  - 内部结构: UiFile + DynamicColumn + UiText + [add_btn | model_selector(UiCode) | filler | submit_btn]
  - options: model_dataurl(模型列表API), model_cwidth, placeholder
  - event inputed: {prompt, add_files, model_id}
  - 自动注册 bricks.Factory.register('AgentInput', ...)
- index.ui/index_cockpit.ui: chat_input 改用 widgettype=AgentInput
- 利用 bricks 的 jsfiles() 机制自动加载 agent_input.js
2026-08-06 13:43:11 +08:00

182 lines
10 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"widgettype": "VBox",
"options": {
"width": "100%",
"height": "100%",
"padding": "0"
},
"subwidgets": [
{
"widgettype": "HBox",
"options": {
"width": "100%",
"alignItems": "center",
"padding": "16px 24px 8px 24px",
"cheight": 6,
"gap": "12px"
},
"subwidgets": [
{
"widgettype": "Title2",
"options": {
"text": "开发产线驾驶舱"
}
},
{
"widgettype": "Text",
"options": {
"text": "AI驱动的对话式开发",
"cfontsize": 0.9,
"color": "#94a3b8"
}
},
{
"widgettype": "Filler"
}
]
},
{
"widgettype": "HBox",
"id": "context_bar",
"options": {
"width": "100%",
"padding": "4px 24px 4px 24px",
"cheight": 2.5,
"gap": "12px",
"alignItems": "center",
"bgcolor": "#e8f0fe"
},
"subwidgets": [
{
"widgettype": "Button",
"id": "project_label",
"options": {
"label": "📁 当前项目:加载中...",
"css": "link",
"action": "click"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var pid=d.project_id||'';if(!pid){bricks.showError('请先选择项目');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'项目名称:'+(d.project_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'项目ID'+pid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'工作目录:'+(d.workspace_dir||'/d/pipeline/workspaces/'+pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'项目详情',cwidth:36,cheight:16,auto_open:true});pw.content_w.add_widget(box);"
}
]
},
{
"widgettype": "Button",
"id": "iteration_label",
"options": {
"label": "🔄 当前迭代:加载中...",
"css": "link",
"action": "click"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var ctx=bricks.getWidgetById('context_data',bricks.app);var d=ctx?ctx.getValue():{};var iid=d.iteration_id||'';var pid=d.project_id||'';if(!iid){bricks.showError('请先选择迭代');return;}var box=new bricks.VBox();box.add_widget(new bricks.Text({text:'迭代名称:'+(d.iteration_name||'--'),cfontsize:1.1,fontWeight:'bold',marginBottom:'8px'}));box.add_widget(new bricks.Text({text:'迭代ID'+iid,cfontsize:0.85,color:'#64748b',marginBottom:'4px'}));box.add_widget(new bricks.Text({text:'所属项目:'+(d.project_name||pid),cfontsize:0.85,color:'#64748b'}));var pw=new bricks.PopupWindow({title:'迭代详情',cwidth:36,cheight:14,auto_open:true});pw.content_w.add_widget(box);"
}
]
},
{
"widgettype": "datawidget",
"id": "context_data",
"options": {
"dataurl": "/pipeline-sdlc/api/cockpit_context.dspy",
"method": "GET",
"datascript": "(function(d){var d=d||{};var pl=bricks.getWidgetById('project_label',bricks.app);var il=bricks.getWidgetById('iteration_label',bricks.app);if(pl){pl.setText(d.project_name?'\\ud83d\\udcc1 \\u5f53\\u524d\\u9879\\u76ee\\uff1a'+d.project_name:'\\ud83d\\udcc1 \\u5f53\\u524d\\u9879\\u76ee\\uff1a--');}if(il){il.setText('\\ud83d\\udd04 \\u5f53\\u524d\\u8fed\\u4ee3\\uff1a'+(d.iteration_name||'--'));}return d;})"
}
}
]
},
{
"widgettype": "VBox",
"options": {
"css": "filler",
"width": "100%",
"height": "100%",
"padding": "0 24px 0 24px",
"gap": "0"
},
"subwidgets": [
{
"widgettype": "VScrollPanel",
"id": "chat_scroll",
"options": {
"css": "filler",
"width": "100%",
"height": "100%",
"bgcolor": "#f8fafc",
"border": "1px solid #e2e8f0",
"borderBottom": "none",
"borderRadius": "8px 8px 0 0",
"padding": "16px"
},
"subwidgets": [
{
"widgettype": "VBox",
"options": {
"alignItems": "center",
"padding": "40px 0",
"gap": "12px"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": "选择一个迭代后,在下方输入你的需求。",
"cfontsize": 1,
"color": "#64748b"
}
},
{
"widgettype": "Text",
"options": {
"text": "Agent 将自动分析需求、生成设计、驱动产线执行。",
"cfontsize": 0.85,
"color": "#94a3b8"
}
}
]
}
]
},
{
"widgettype": "VBox",
"options": {
"bgcolor": "#fff",
"border": "1px solid #e2e8f0",
"borderTop": "none",
"borderRadius": "0 0 8px 8px",
"padding": "0"
},
"subwidgets": [
{
"widgettype": "AgentInput",
"id": "chat_input",
"options": {
"placeholder": "输入你的需求...",
"model_dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy",
"model_cwidth": 14
},
"binds": [
{
"wid": "self",
"event": "inputed",
"actiontype": "script",
"target": "self",
"script": "var p=params.prompt;var files=params.add_files||[];var mid=params.model_id||'';var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var chat=bricks.getWidgetById('chat_scroll',bricks.app);var at=null;if(chat){var ub=new bricks.HBox({width:'100%'});var um=new bricks.VBox({width:'85%',alignSelf:'flex-end',bgcolor:'#dbeafe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});um.add_widget(new bricks.Text({text:'你',cfontsize:0.75,color:'#2563eb',fontWeight:'bold'}));um.add_widget(new bricks.Text({text:p,cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'}));ub.add_widget(new bricks.VBox({css:'filler'}));ub.add_widget(um);ub.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/chat-user.svg')}));chat.add_widget(ub);var ab=new bricks.HBox({width:'100%'});var am=new bricks.VBox({width:'85%',alignSelf:'flex-start',bgcolor:'#e8f0fe',borderRadius:'12px',padding:'12px 16px',marginBottom:'10px',gap:'4px'});am.add_widget(new bricks.Text({text:'Agent',cfontsize:0.75,color:'#3b82f6',fontWeight:'bold'}));at=new bricks.Text({text:'正在分析需求...',cfontsize:0.85,color:'#64748b'});am.add_widget(at);ab.add_widget(new bricks.Svg({rate:2,url:bricks_resource('imgs/llm.svg')}));ab.add_widget(am);ab.add_widget(new bricks.VBox({css:'filler'}));chat.add_widget(ab);}var body='message_text='+encodeURIComponent(p)+'&iteration_id='+encodeURIComponent(iid)+'&model_id='+encodeURIComponent(mid)+'&action=send_message&file_paths='+encodeURIComponent(JSON.stringify(files.map(function(f){return f.name||f})));fetch('/pipeline-sdlc/api/cockpit_chat.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(r){if(r.success){if(at)at.set_text(r.agent_reply||'已处理');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('错误: '+(r.error||'未知错误'));}});"
}
]
}
]
}
]
}
]
}