sendToolApprovalStream method
Answers pendingToolApproval with decision and resumes the run,
streaming the continuation of the response text.
Implementation
@override
Stream<String> sendToolApprovalStream(ToolApprovalDecision decision) {
final request = _pendingApprovalContent;
if (request == null) return const Stream.empty();
_pendingApprovalContent = null;
// Continue the response in the last assistant bubble when there is one,
// so an approval pause does not split the reply and the transcript keeps
// its user/llm pairing; only start a bubble in the degenerate case.
var llmMessage = _history.isNotEmpty && _history.last.origin.isLlm
? _history.last
: null;
if (llmMessage == null) {
llmMessage = ChatMessage.llm();
_history.add(llmMessage);
}
if (!_disposed) notifyListeners();
return _appendResponseTo(
llmMessage,
_toApprovalMessage(request, decision),
resuming: true,
);
}