refactor: 模型选择器移到输入区上方 — 去顶部model_selector

- index_cockpit.ui & index.ui: 移除顶部 HBox 中的 model_selector Form + 模型配置 Button
- 在 TextFiles 输入区上方新增模型选择行:🤖 下拉 + 模型配置按钮
- chat_input 脚本改为从 input_model_selector 读取 model_id (getValue)
- 修复脚本中 Unicode 转义损坏
This commit is contained in:
yumoqing 2026-08-05 19:20:05 +08:00
parent 9a3ed5fa7a
commit 0aad9561b0
2 changed files with 135 additions and 89 deletions

View File

@ -32,47 +32,6 @@
},
{
"widgettype": "Filler"
},
{
"widgettype": "Form",
"id": "model_selector",
"options": {
"name": "model_selector",
"cols": 1,
"fields": [
{
"name": "model_id",
"uitype": "code",
"label": "",
"placeholder": "选择模型",
"cwidth": 12,
"dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy",
"valueField": "model_id",
"textField": "model_id_text",
"params": {
"valueField": "model_id",
"textField": "model_id_text"
}
}
]
}
},
{
"widgettype": "Button",
"options": {
"name": "model_config",
"label": "模型配置",
"css": "small"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var pw=new bricks.PopupWindow({title:'模型配置',cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline_core/llm/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
}
]
},
@ -92,7 +51,7 @@
"widgettype": "Button",
"id": "project_label",
"options": {
"label": "\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a\u52a0\u8f7d\u4e2d...",
"label": "📁 当前项目:加载中...",
"css": "link",
"action": "click"
},
@ -110,7 +69,7 @@
"widgettype": "Button",
"id": "iteration_label",
"options": {
"label": "\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a\u52a0\u8f7d\u4e2d...",
"label": "🔄 当前迭代:加载中...",
"css": "link",
"action": "click"
},
@ -187,6 +146,70 @@
}
]
},
{
"widgettype": "HBox",
"options": {
"width": "100%",
"padding": "6px 14px 6px 14px",
"gap": "8px",
"alignItems": "center",
"bgcolor": "#f8fafc",
"border": "1px solid #e2e8f0",
"borderTop": "none"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": "🤖",
"cfontsize": 0.9
}
},
{
"widgettype": "Form",
"id": "input_model_selector",
"options": {
"name": "input_model_selector",
"cols": 1,
"fields": [
{
"name": "model_id",
"uitype": "code",
"label": "",
"placeholder": "选择模型",
"cwidth": 14,
"dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy",
"valueField": "model_id",
"textField": "model_id_text",
"params": {
"valueField": "model_id",
"textField": "model_id_text"
}
}
]
}
},
{
"widgettype": "Filler"
},
{
"widgettype": "Button",
"options": {
"label": "模型配置",
"css": "small"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var pw=new bricks.PopupWindow({title:'模型配置',cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline_core/llm/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
}
]
},
{
"widgettype": "TextFiles",
"id": "chat_input",
@ -203,7 +226,7 @@
"event": "inputed",
"actiontype": "script",
"target": "self",
"script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var el=document.querySelector('#model_selector select')||document.querySelector('select');if(el)mid=el.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:'\\u4f60',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:'\\u6b63\\u5728\\u5206\\u6790\\u9700\\u6c42...',cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'});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||'\\u5df2\\u5904\\u7406');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('\\u9519\\u8bef: '+(r.error||'\\u672a\\u77e5\\u9519\\u8bef'));}});"
"script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var el=bricks.getWidgetById('input_model_selector',bricks.app).getValue();if(el)mid=el.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:'\\u4f60',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:'\\u6b63\\u5728\\u5206\\u6790\\u9700\\u6c42...',cfontsize:0.95,color:'#1e293b',whiteSpace:'pre-wrap'});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||'\\u5df2\\u5904\\u7406');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('\\u9519\\u8bef: '+(r.error||'\\u672a\\u77e5\\u9519\\u8bef'));}});"
}
]
}

View File

@ -32,47 +32,6 @@
},
{
"widgettype": "Filler"
},
{
"widgettype": "Form",
"id": "model_selector",
"options": {
"name": "model_selector",
"cols": 1,
"fields": [
{
"name": "model_id",
"uitype": "code",
"label": "",
"placeholder": "选择模型",
"cwidth": 12,
"dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy",
"valueField": "model_id",
"textField": "model_id_text",
"params": {
"valueField": "model_id",
"textField": "model_id_text"
}
}
]
}
},
{
"widgettype": "Button",
"options": {
"name": "model_config",
"label": "模型配置",
"css": "small"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var pw=new bricks.PopupWindow({title:'模型配置',cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline_core/llm/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
}
]
},
@ -111,7 +70,7 @@
"widgettype": "Button",
"id": "project_label",
"options": {
"label": "\ud83d\udcc1 \u5f53\u524d\u9879\u76ee\uff1a\u52a0\u8f7d\u4e2d...",
"label": "📁 当前项目:加载中...",
"css": "link",
"action": "click"
},
@ -129,7 +88,7 @@
"widgettype": "Button",
"id": "iteration_label",
"options": {
"label": "\ud83d\udd04 \u5f53\u524d\u8fed\u4ee3\uff1a\u52a0\u8f7d\u4e2d...",
"label": "🔄 当前迭代:加载中...",
"css": "link",
"action": "click"
},
@ -149,7 +108,7 @@
"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);var pn=d.project_name||'';if(pl){pl.setText(pn?'\\ud83d\\udcc1 \\u5f53\\u524d\\u9879\\u76ee\\uff1a'+pn:'\\ud83d\\udcc1 \\u5f53\\u524d\\u9879\\u76ee\\uff1a--');}if(il){il.setText(d.iteration_name?(d.iteration_name.length>15?d.iteration_name.slice(0,15)+'...':d.iteration_name):'\\ud83d\\udd04 \\u5f53\\u524d\\u8fed\\u4ee3\\uff1a--');il.setText('\\ud83d\\udd04 \\u5f53\\u524d\\u8fed\\u4ee3\\uff1a'+(d.iteration_name||'--'));}return d;})"
"datascript": "(function(d){var d=d||{};var pl=bricks.getWidgetById('project_label',bricks.app);var il=bricks.getWidgetById('iteration_label',bricks.app);var pn=d.project_name||'';if(pl){pl.setText(pn?'📁 当前项目:'+pn:'📁 当前项目:--');}if(il){il.setText(d.iteration_name?(d.iteration_name.length>15?d.iteration_name.slice(0,15)+'...':d.iteration_name):'🔄 当前迭代:--');il.setText('🔄 当前迭代:'+(d.iteration_name||'--'));}return d;})"
}
}
]
@ -206,6 +165,70 @@
}
]
},
{
"widgettype": "HBox",
"options": {
"width": "100%",
"padding": "6px 14px 6px 14px",
"gap": "8px",
"alignItems": "center",
"bgcolor": "#f8fafc",
"border": "1px solid #e2e8f0",
"borderTop": "none"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": "🤖",
"cfontsize": 0.9
}
},
{
"widgettype": "Form",
"id": "input_model_selector",
"options": {
"name": "input_model_selector",
"cols": 1,
"fields": [
{
"name": "model_id",
"uitype": "code",
"label": "",
"placeholder": "选择模型",
"cwidth": 14,
"dataurl": "/pipeline-sdlc/api/cockpit_model_options.dspy",
"valueField": "model_id",
"textField": "model_id_text",
"params": {
"valueField": "model_id",
"textField": "model_id_text"
}
}
]
}
},
{
"widgettype": "Filler"
},
{
"widgettype": "Button",
"options": {
"label": "模型配置",
"css": "small"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var pw=new bricks.PopupWindow({title:'模型配置',cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline_core/llm/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
}
]
},
{
"widgettype": "TextFiles",
"id": "chat_input",
@ -222,7 +245,7 @@
"event": "inputed",
"actiontype": "script",
"target": "self",
"script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var el=document.querySelector('#model_selector select')||document.querySelector('select');if(el)mid=el.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:'\\u4f60',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:'\\u6b63\\u5728\\u5206\\u6790\\u9700\\u6c42...',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||'\\u5df2\\u5904\\u7406');var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});}else{if(at)at.set_text('\\u9519\\u8bef: '+(r.error||'\\u672a\\u77e5\\u9519\\u8bef'));}});"
"script": "var p=params.prompt;var files=params.add_files||[];var iid='';try{var iter=bricks.getWidgetById('current_iteration_id',bricks.app);if(iter)iid=iter.options.value||'';}catch(e){}var mid='';try{var ms=bricks.getWidgetById('input_model_selector',bricks.app);if(ms){var v=ms.getValue();mid=(v||{}).model_id||'';}}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..."
}
]
}