From e07e6a49429a4c14e0a680471b9b92f10cc8e314 Mon Sep 17 00:00:00 2001 From: tiye Date: Mon, 24 Aug 2026 01:26:47 +0800 Subject: [PATCH 1/3] fix: normalize streamed markdown text --- calcit.cirru | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/calcit.cirru b/calcit.cirru index 3fa05a7..6320b39 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -123,7 +123,7 @@ if (option:none? content-opt) do (println |content-is-nil) (recur xss) let - content $ option:unwrap-or content-opt | + content $ stream-text (option:unwrap-or content-opt |) do (swap! *text str content) d! (:: :states-merge cursor state) {} (:answer @*text) (:loading? false) (:done? false) @@ -316,7 +316,7 @@ prompt-feedback $ unsafe-coerce (.-promptFeedback chunk-data) 'Dynamic fallback-text $ if (js-present-dynamic? prompt-feedback) (.-blockReason prompt-feedback) js/undefined text0 $ if (js-present-dynamic? primary-text) primary-text fallback-text - text $ if (js-present-dynamic? text0) (unsafe-coerce text0 'String) | + text $ if (js-present-dynamic? text0) (stream-text text0) | if is-thinking? (swap! *thinking-text str text) (swap! *text str text) d! $ :: :states-merge cursor state {} (:answer @*text) (:thinking @*thinking-text) (:loading? false) (:done? false) @@ -462,9 +462,9 @@ choice0 $ unsafe-coerce (.-0 choices) 'Dynamic choice $ unsafe-coerce (.-delta choice0) 'Dynamic reason0 $ .-reasoning_content choice - reason $ if (js-present-dynamic? reason0) (unsafe-coerce reason0 'String) | + reason $ if (js-present-dynamic? reason0) (stream-text reason0) | text0 $ .-content choice - text $ if (js-present-dynamic? text0) (unsafe-coerce text0 'String) | + text $ if (js-present-dynamic? text0) (stream-text text0) | if not $ blank? reason swap! *thinking-text str reason @@ -642,8 +642,8 @@ :args $ [] 'Number 'app.schema/ChatMessage [] idx $ let role $ :role msg - content $ :content msg - thinking $ :thinking msg + content $ stream-text (:content msg) + thinking $ stream-text (:thinking msg) div {} $ :class-name str-spaced style-message-item $ if (= role :assistant) style-message-assistant style-message-user @@ -767,8 +767,8 @@ :args $ [] 'Number 'app.schema/ChatMessage [] idx $ let role $ :role msg - content $ :content msg - thinking $ :thinking msg + content $ stream-text (:content msg) + thinking $ stream-text (:thinking msg) div {} $ :class-name str-spaced style-message-item $ if (= role :assistant) style-message-assistant style-message-user @@ -1411,6 +1411,12 @@ :schema $ :: 'Fn {} (:return 'app.schema/Store) :args $ [] 'app.schema/Store 'app.schema/ChatState + |stream-text $ %{} 'CodeEntry (:doc |) + :code $ quote + defn stream-text (value) + if (string? value) value $ do (js/console.warn "|msg-buffer: ignored non-string streaming text" value) | + :examples $ [] + :schema $ :: 'Dynamic |style-a-toggler $ %{} 'CodeEntry (:doc |) :code $ quote defstyle style-a-toggler $ {} From 311be5d239d0b8fd1c960d2b0eb21ba5b9057e49 Mon Sep 17 00:00:00 2001 From: tiye Date: Mon, 24 Aug 2026 01:31:10 +0800 Subject: [PATCH 2/3] fix: type stream text boundary --- calcit.cirru | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/calcit.cirru b/calcit.cirru index 6320b39..cac3bac 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -1414,9 +1414,18 @@ |stream-text $ %{} 'CodeEntry (:doc |) :code $ quote defn stream-text (value) + hint-fn $ {} + :generics $ [] 'T + :args $ [] 'T + :return 'String + :features $ #{} :js-ffi if (string? value) value $ do (js/console.warn "|msg-buffer: ignored non-string streaming text" value) | :examples $ [] - :schema $ :: 'Dynamic + :schema $ :: 'Fn + {} (:return 'String) + :args $ [] 'T + :features $ #{} :js-ffi + :generics $ [] 'T |style-a-toggler $ %{} 'CodeEntry (:doc |) :code $ quote defstyle style-a-toggler $ {} From 8c18d63ac58ec8d920c644f056e6bc14739c362e Mon Sep 17 00:00:00 2001 From: tiye Date: Mon, 24 Aug 2026 02:03:52 +0800 Subject: [PATCH 3/3] chore: use respo-markdown 0.4.24 --- deps.cirru | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.cirru b/deps.cirru index 7445f61..fb0cb1d 100644 --- a/deps.cirru +++ b/deps.cirru @@ -4,6 +4,6 @@ :dependencies $ {} (|Respo/alerts.calcit |0.10.19) |Respo/reel.calcit |0.6.7 |Respo/respo-feather.calcit |0.4.4 - |Respo/respo-markdown.calcit |0.4.23 + |Respo/respo-markdown.calcit |0.4.24 |Respo/respo-ui.calcit |0.7.10 |Respo/respo.calcit |0.16.83