Fix empty code blocks: rename ~docs/code param, fix batched IO dispatch
Two bugs caused code blocks to render empty across the site: 1. ~docs/code component had parameter named `code` which collided with the HTML <code> tag name. Renamed to `src` and updated all 57 callers. Added font-mono class for explicit monospace. 2. Batched IO dispatch in ocaml_bridge.py only skipped one leading number (batch ID) but the format has two (epoch + ID): (io-request EPOCH ID "name" args...). Changed to skip all leading numbers so the string name is correctly found. This fixes highlight and other batchable helpers returning empty results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -143,7 +143,7 @@
|
||||
(li (strong "Subscribe") " — register the captured continuation as a signal subscriber")
|
||||
(li (strong "Return") " — flow the current signal value through the rest of the expression"))
|
||||
(p "When the signal changes, the captured continuation is re-invoked with the new value. The " (code "update-fn") " on the ReactiveResetFrame mutates the DOM. No explicit " (code "effect()") " wrapping needed.")
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
";; User writes:\n(div :class (str \"count-\" (deref counter))\n (str \"Value: \" (deref counter)))\n\n;; CEK sees (deref counter) → signal? → reactive-reset on stack?\n;; Yes: capture (str \"count-\" [HOLE]) as continuation\n;; Register as subscriber. Return current value.\n;; When counter changes: re-invoke continuation → update DOM."
|
||||
"lisp")))))
|
||||
|
||||
@@ -567,11 +567,11 @@
|
||||
|
||||
(~docs/section :title "Freeze" :id "freeze"
|
||||
(p "Take a computation mid-flight and freeze it:")
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
"(let ((expr (sx-parse \"(+ 1 (* 2 3))\"))\n (state (make-cek-state (first expr) (make-env) (list))))\n ;; Step 4 times\n (set! state (cek-step (cek-step (cek-step (cek-step state)))))\n ;; Freeze to SX\n (cek-freeze state))"
|
||||
"lisp"))
|
||||
(p "The frozen state is pure SX:")
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
"{:phase \"continue\"\n :control nil\n :value 1\n :env {}\n :kont ({:type \"arg\"\n :f (primitive \"+\")\n :evaled ()\n :remaining ((* 2 3))\n :env {}})}"
|
||||
"lisp"))
|
||||
(p "Everything is data. The continuation frame says: \u201cI was adding 1 to something, "
|
||||
@@ -579,7 +579,7 @@
|
||||
|
||||
(~docs/section :title "Thaw and resume" :id "thaw"
|
||||
(p "Parse the frozen SX back. Thaw it. Resume:")
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
"(let ((frozen (sx-parse frozen-text))\n (state (cek-thaw (first frozen))))\n (cek-run state))\n;; => 7"
|
||||
"lisp"))
|
||||
(p "Native functions like " (code "+") " serialize as " (code "(primitive \"+\")")
|
||||
@@ -595,7 +595,7 @@
|
||||
(~docs/section :title "Content addressing" :id "content-addressing"
|
||||
(p "Hash the frozen SX " (code "\u2192") " content identifier. "
|
||||
"Same state always produces the same CID. Store by CID, retrieve by CID, verify by CID.")
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
"(freeze-to-cid \"widget\")\n;; => \"d9eea67b\"\n\n(thaw-from-cid \"d9eea67b\")\n;; Signals restored. Same CID = same state."
|
||||
"lisp"))
|
||||
(p "Try it: change the values, click Content-address. Copy the CID. "
|
||||
@@ -729,7 +729,7 @@
|
||||
"The address IS the content."))
|
||||
|
||||
(~docs/section :title "How it works" :id "how"
|
||||
(~docs/code :code (highlight
|
||||
(~docs/code :src (highlight
|
||||
";; Freeze a scope \u2192 hash \u2192 CID\n(freeze-to-cid \"widget\")\n;; => \"d9eea67b\"\n\n;; The frozen SX is stored by CID\n(content-get \"d9eea67b\")\n;; => {:name \"widget\" :signals {:count 42 :name \"hello\"}}\n\n;; Thaw from CID \u2192 signals restored\n(thaw-from-cid \"d9eea67b\")\n;; Signals reset to frozen values"
|
||||
"lisp"))
|
||||
(p "The hash is djb2 for now \u2014 deterministic and fast. "
|
||||
@@ -783,36 +783,36 @@
|
||||
(p "The CEK machine is pure data\u2192data. Each step takes a state dict and returns a new one. "
|
||||
"Type an expression, click Step to advance one CEK transition.")
|
||||
(~geography/cek/demo-stepper :initial-expr "(let ((x 10)) (+ x (* 2 3)))")
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-stepper") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-stepper") "lisp")))
|
||||
|
||||
(~docs/section :title "Render stepper" :id "render-stepper"
|
||||
(p "Watch a component render itself. The CEK evaluates the expression — "
|
||||
"when it encounters " (code "(div ...)") ", the render adapter produces HTML in one step. "
|
||||
"Click Run to see the rendered output appear in the preview.")
|
||||
(~geography/cek/demo-render-stepper)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-render-stepper") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-render-stepper") "lisp")))
|
||||
|
||||
(~docs/section :title "1. Counter" :id "demo-counter"
|
||||
(p (code "(deref count)") " in text position creates a reactive text node. " (code "(deref doubled)") " is a computed that updates when count changes.")
|
||||
(~geography/cek/demo-counter :initial 0)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-counter") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-counter") "lisp")))
|
||||
|
||||
(~docs/section :title "2. Computed chain" :id "demo-chain"
|
||||
(p "Three levels of computed: base -> doubled -> quadrupled. Change base, all propagate.")
|
||||
(~geography/cek/demo-chain)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-chain") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-chain") "lisp")))
|
||||
|
||||
(~docs/section :title "3. Reactive attributes" :id "demo-attr"
|
||||
(p (code "(deref sig)") " in " (code ":class") " position. The CEK evaluates the " (code "str") " expression, and when the signal changes, the continuation re-evaluates and updates the attribute.")
|
||||
(~geography/cek/demo-reactive-attr)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-reactive-attr") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-reactive-attr") "lisp")))
|
||||
|
||||
(~docs/section :title "4. Effect + cleanup" :id "demo-stopwatch"
|
||||
(p "Effects still work through CEK. This stopwatch uses " (code "effect") " with cleanup — toggling the signal clears the interval.")
|
||||
(~geography/cek/demo-stopwatch)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-stopwatch") "lisp")))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-stopwatch") "lisp")))
|
||||
|
||||
(~docs/section :title "5. Batch coalescing" :id "demo-batch"
|
||||
(p "Two signals updated in " (code "batch") " — one notification cycle. Compare render counts between batch and no-batch.")
|
||||
(~geography/cek/demo-batch)
|
||||
(~docs/code :code (highlight (component-source "~geography/cek/demo-batch") "lisp")))))
|
||||
(~docs/code :src (highlight (component-source "~geography/cek/demo-batch") "lisp")))))
|
||||
|
||||
Reference in New Issue
Block a user