From f4c3ee0d5699959d51e8a1ae33c242227cf0a8a3 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 8 Aug 2026 23:05:19 +0800 Subject: [PATCH] fix: clean AgentIO inputed bind, no project_form hook --- wwwroot/index.ui | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wwwroot/index.ui b/wwwroot/index.ui index b4407ca..f9c22a9 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -81,7 +81,7 @@ "event": "changed", "actiontype": "script", "target": "self", - "script": "var ai=bricks.getWidgetById('chat_input',bricks.app);console.log('HOOK: ai=',ai?'found':'null','inputw=',ai&&ai.inputw?'found':'null');if(ai&&ai.inputw&&!ai._hooked){ai._hooked=true;ai.inputw.unbind('inputed');ai.inputw.bind('inputed',function(e){console.log('HOOK inputed:',JSON.stringify(e.params));var p=e.params.prompt||'';var mid=e.params.model_id||'';ai.show_input(e.params);var chat=ai.msg_box;var mout=new bricks.AgentOutput({});chat.add_widget(mout);var xhr=new XMLHttpRequest();xhr.open('POST','/pipeline-sdlc/api/cockpit_chat.dspy');xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');var lastLen=0;xhr.onprogress=function(){var t=xhr.responseText;var d=t.substring(lastLen);lastLen=t.length;d.split(String.fromCharCode(10)).forEach(function(line){line=line.trim();if(!line)return;try{var obj=JSON.parse(line);if(obj.content){mout.update_data(obj)}}catch(e){console.log('err:',line.substring(0,40))}})};xhr.send('action=send_message&message_text='+encodeURIComponent(p)+'&model_id='+encodeURIComponent(mid))})};var v=this.getValue();var pid=(v||{}).project_id||'';if(!pid)return;fetch('/pipeline-sdlc/api/cockpit_context_update.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'project_id='+encodeURIComponent(pid)}).then(function(r){return r.json()}).then(function(r){if(r.success){var pl=bricks.getWidgetById('task_btn',bricks.app);if(pl&&pl.text_w)pl.text_w.set_text('\\u4efb\\u52a1');}})" + "script": "var v=this.getValue();var pid=(v||{}).project_id||'';if(!pid)return;fetch('/pipeline-sdlc/api/cockpit_context_update.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'project_id='+encodeURIComponent(pid)}).then(function(r){return r.json()}).then(function(r){if(r.success){var pl=bricks.getWidgetById('task_btn',bricks.app);if(pl&&pl.text_w)pl.text_w.set_text('任务');}})" } ] }, @@ -156,6 +156,15 @@ } ] } + ], + "binds": [ + { + "wid": "self", + "event": "inputed", + "actiontype": "script", + "target": "self", + "script": "console.log('AGENTIO inputed bind fired',JSON.stringify(params));var ai=this;if(ai.inputw&&!ai._done){ai._done=true;var orig=ai.user_inputed.bind(ai);ai.inputw.unbind('inputed');ai.inputw.bind('inputed',function(e){console.log('HOOKED:',e.params.prompt);orig(e);var p=e.params.prompt||'';var mid=e.params.model_id||'';var xhr=new XMLHttpRequest();xhr.open('POST',ai.opts.url);xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');var lastLen=0;xhr.onprogress=function(){var t=xhr.responseText;var d=t.substring(lastLen);lastLen=t.length;d.split(String.fromCharCode(10)).forEach(function(line){line=line.trim();if(!line)return;try{var obj=JSON.parse(line);console.log('STREAM:',line.substring(0,40))}catch(e){}})};xhr.onload=function(){console.log('DONE')};xhr.send('action=send_message&message_text='+encodeURIComponent(p)+'&model_id='+encodeURIComponent(mid))})}" + } ] }, {