From d852a48b4601e5945c8bebc2a4f35602408f3c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=98=E5=8F=B6?= Date: Sun, 15 Nov 2026 19:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E7=B1=BB=E5=9E=8B=E5=8C=96=20listener?= =?UTF-8?q?=20=E9=80=82=E9=85=8D=20msg-buffer=20=E7=9A=84=20on-fill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 app.schema/typed-listener:解码器处理一次事件,handler 直接接收 FillEvent 与 DispatchOp 回调。on-fill 不再手写 RespoListener 的开放 handler 字段,未知事件仍被忽略。 同步质量预算中 typed-listener 的 intentional-open Dynamic 上限。 --- calcit.cirru | 40 +++++++++++++++++++++++++++----------- config/calcit-quality.json | 3 +++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/calcit.cirru b/calcit.cirru index 5477fdf..4f47c5b 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -1591,20 +1591,18 @@ :tags $ #{} :regression :unit 'on-fill $ %{} 'CodeEntry (:doc |) :code $ quote $ defn on-fill (cursor state on-submit) - %{} respo.schema/RespoListener (:name :on-fill) - :handler $ fn (event dispatch!) + app.schema/typed-listener :on-fill + fn (event) (try-decode-map-as event 'app.schema/FillEvent) + fn (checked dispatch!) hint-fn $ Fn app.schema/FillEvent Fn DispatchOp $ -> Unit -> Unit - match (try-decode-map-as event 'app.schema/FillEvent) - (:ok checked) - match checked $ - :fill-text text submit? - do - dispatch! $ DispatchOp :widget-state cursor $ assoc state :content text - when submit? $ on-submit text (:search? state) (:think? state) dispatch! - , &unit - (:err _) &unit + match checked $ + :fill-text text submit? + do + dispatch! $ DispatchOp :widget-state cursor $ assoc state :content text + when submit? $ on-submit text (:search? state) (:think? state) dispatch! + , &unit :examples $ [] :schema $ quote $ Fn (List respo.schema/CoordKey) MessageBoxState Fn String Bool Bool @@ -2655,6 +2653,26 @@ , :sessions ([]) :current-session-id None :model None :archived-count 0 :examples $ [] :schema $ quote Store + 'typed-listener $ %{} 'CodeEntry + :doc "|Build a RespoListener from an event decoder and a typed handler; the only Dynamic event boundary stays inside this adapter, and unknown events are ignored." + :code $ quote $ defn typed-listener (name decode handler) + respo.schema/RespoListener :name name :handler $ fn (event dispatch!) + match (decode event) + (:ok value) + handler value $ fn (op) + hint-fn $ Fn DispatchOp $ -> Unit + dispatch! op + , &unit + (:err _message) &unit + :examples $ [] + :schema $ quote $ Fn Tag + Fn Dynamic $ -> $ Result T String + Fn T + Fn DispatchOp $ -> Unit + -> Unit + -> respo.schema/RespoListener + :generics T + :open :decode :ns $ %{} 'NsEntry (:doc |) :code $ quote $ ns app.schema :require $ calcit.test :refer $ is diff --git a/config/calcit-quality.json b/config/calcit-quality.json index f0506d6..e470402 100644 --- a/config/calcit-quality.json +++ b/config/calcit-quality.json @@ -33,6 +33,9 @@ }, "app.schema/encode-store": { "code-nil/unresolved": 2 + }, + "app.schema/typed-listener": { + "schema-dynamic/intentional-open": 1 } } }