@@ -1205,6 +1205,9 @@ function M:handle_chat_content_received(params)
12051205 if content .state == " finished" then
12061206 self :_finalize_streaming_response ()
12071207 self :_update_input_display ()
1208+ elseif content .text == " Waiting for tool call approval" then
1209+ -- Handle implicit approval flow when toolCallPrepare was already received
1210+ self :render_tool_call (content , chat_id )
12081211 end
12091212 elseif content .type == " toolCallPrepare" then
12101213 self :_finalize_streaming_response ()
@@ -1375,13 +1378,45 @@ function M:handle_chat_content_received(params)
13751378end
13761379
13771380function M :render_tool_call (tool_content , chat_id )
1381+ -- Handle explicit manual approval (toolCallRun with manualApproval flag)
13781382 if tool_content .type == " toolCallRun" and tool_content .manualApproval then
13791383 return require (" eca.approve" ).approve_tool_call (tool_content , function ()
13801384 self .mediator :send (" chat/toolCallApprove" , { chatId = chat_id , toolCallId = tool_content .id }, nil )
13811385 end , function ()
13821386 self .mediator :send (" chat/toolCallReject" , { chatId = chat_id , toolCallId = tool_content .id }, nil )
13831387 end )
13841388 end
1389+
1390+ -- Handle implicit approval flow: progress message "Waiting for tool call approval"
1391+ -- with a previously prepared tool call (toolCallPrepare stored in _current_tool_call)
1392+ if tool_content .type == " progress"
1393+ and tool_content .text == " Waiting for tool call approval"
1394+ and self ._current_tool_call
1395+ and self ._current_tool_call .id
1396+ and not self ._current_tool_call .approval_shown then
1397+ -- Mark as shown to avoid duplicate approval dialogs
1398+ self ._current_tool_call .approval_shown = true
1399+
1400+ -- Store the tool call id in a local variable to avoid closure issues
1401+ local tool_call_id = self ._current_tool_call .id
1402+
1403+ -- Build tool content from the prepared tool call for the approval dialog
1404+ -- Using field names expected by approve.lua
1405+ local prepared_tool_call = {
1406+ id = tool_call_id ,
1407+ name = self ._current_tool_call .name or " Tool call" ,
1408+ summary = self ._current_tool_call .summary ,
1409+ arguments = self ._current_tool_call .arguments or " " ,
1410+ origin = " eca" , -- default origin for implicit approval
1411+ details = self ._current_tool_call .details ,
1412+ }
1413+
1414+ return require (" eca.approve" ).approve_tool_call (prepared_tool_call , function ()
1415+ self .mediator :send (" chat/toolCallApprove" , { chatId = chat_id , toolCallId = tool_call_id }, nil )
1416+ end , function ()
1417+ self .mediator :send (" chat/toolCallReject" , { chatId = chat_id , toolCallId = tool_call_id }, nil )
1418+ end )
1419+ end
13851420end
13861421
13871422--- @param text string
@@ -1811,6 +1846,7 @@ function M:_handle_tool_call_prepare(content)
18111846 arguments = " " ,
18121847 details = {},
18131848 outputs = " " ,
1849+ approval_shown = false ,
18141850 }
18151851 end
18161852
0 commit comments