From a8d8b235460e7e09719e9bf55bd82ad01c4a515c Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 10 Oct 2024 17:52:24 -0500 Subject: [PATCH] Close #4. chat_append() now waits for flush before sending message stream --- R/chat.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/chat.R b/R/chat.R index 1de47bf..30ee2ab 100644 --- a/R/chat.R +++ b/R/chat.R @@ -76,7 +76,10 @@ chat_append <- function(id, response, session = getDefaultReactiveDomain()) { # Already a generator (sync or async) stream <- response } - chat_append_stream(id, stream, session = session) + do_stream <- function() { + chat_append_stream(id, stream, session = session) + } + session$onFlushed(do_stream) } #' Low-level function to append a message to a chat control