From b2314fd3b24781774e9ecaed0a2d9ee0d4da9989 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 31 Jul 2026 16:14:19 +0800 Subject: [PATCH] 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. --- wwwroot/index.ui | 4 ++-- wwwroot/sd_cockpit/index.ui | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wwwroot/index.ui b/wwwroot/index.ui index c72a427..2b8a993 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -24,7 +24,7 @@ "options": { "name": "refresh", "label": "刷新", "css": "small" }, "binds": [{ "wid": "self", "event": "click", "actiontype": "script", "target": "self", - "script": "var c=bricks.getWidgetById('chat_scroll');if(c)c.render({});var s=bricks.getWidgetById('stats_row');if(s)s.render({});" + "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({});" }] } ] @@ -98,7 +98,7 @@ "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');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');if(c)c.render({});}});" + "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({});}});" } ] } diff --git a/wwwroot/sd_cockpit/index.ui b/wwwroot/sd_cockpit/index.ui index c72a427..2b8a993 100644 --- a/wwwroot/sd_cockpit/index.ui +++ b/wwwroot/sd_cockpit/index.ui @@ -24,7 +24,7 @@ "options": { "name": "refresh", "label": "刷新", "css": "small" }, "binds": [{ "wid": "self", "event": "click", "actiontype": "script", "target": "self", - "script": "var c=bricks.getWidgetById('chat_scroll');if(c)c.render({});var s=bricks.getWidgetById('stats_row');if(s)s.render({});" + "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({});" }] } ] @@ -98,7 +98,7 @@ "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');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');if(c)c.render({});}});" + "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({});}});" } ] }