yumoqing b2314fd3b2 fix: add bricks.app as second arg to getWidgetById calls in cockpit scripts
The new bricks.js getWidgetById (line 2680) no longer has a default from_widget fallback.
When called without a second argument, from_widget is undefined and get_by_id crashes at
line 2691: Cannot read properties of undefined (reading 'dom_element').

Fixed both in refresh button click handler and TextFiles inputed handler.
2026-07-31 16:14:19 +08:00

109 lines
4.7 KiB
XML

{
"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": "Button",
"options": { "name": "refresh", "label": "刷新", "css": "small" },
"binds": [{
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
"script": "var c=bricks.getWidgetById('chat_scroll',bricks.app);if(c)c.render({});var s=bricks.getWidgetById('stats_row',bricks.app);if(s)s.render({});"
}]
}
]
},
{
"widgettype": "HBox",
"options": {
"width": "100%",
"padding": "8px 24px 8px 24px",
"cheight": 4,
"gap": "16px"
},
"subwidgets": [
{
"widgettype": "urlwidget",
"id": "stats_row",
"options": {
"url": "{{entire_url('/pipeline-sdlc/api/cockpit_stats.dspy')}}",
"method": "GET"
}
}
]
},
{
"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": "TextFiles",
"id": "chat_input",
"options": {
"bgcolor": "#fff",
"border": "1px solid #e2e8f0",
"borderTop": "none",
"borderRadius": "0 0 8px 8px",
"padding": "10px 14px 10px 14px"
},
"binds": [
{
"wid": "self",
"event": "inputed",
"actiontype": "script",
"target": "self",
"script": "var prompt=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 body='message_text='+encodeURIComponent(prompt)+'&iteration_id='+encodeURIComponent(iid)+'&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||r.error){var c=bricks.getWidgetById('chat_scroll',bricks.app);if(c)c.render({});}});"
}
]
}
]
}
]
}