samagotchi 0.181.0 → 0.182.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/bin/chi +1 -0
  4. data/docs/architecture.md +1 -1
  5. data/docs/cli.md +30 -4
  6. data/docs/configuration.md +1 -0
  7. data/docs/internals/block-renderers.md +114 -0
  8. data/docs/internals/bridge.md +10 -0
  9. data/docs/internals/engine.md +11 -0
  10. data/docs/internals/inline-widgets.md +3 -1
  11. data/docs/internals/prompt-caching.md +9 -1
  12. data/docs/internals/remote-sessions.md +14 -2
  13. data/docs/internals/web-frontend.md +33 -3
  14. data/docs/sessions.md +7 -4
  15. data/lib/samagotchi/answer_display.rb +3 -2
  16. data/lib/samagotchi/block_fix/stamp.rb +49 -0
  17. data/lib/samagotchi/block_fix.rb +220 -0
  18. data/lib/samagotchi/bridge/block_fix_route.rb +30 -0
  19. data/lib/samagotchi/bridge/turn_drawings.rb +19 -0
  20. data/lib/samagotchi/bridge.rb +11 -2
  21. data/lib/samagotchi/bridge_client.rb +9 -0
  22. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  23. data/lib/samagotchi/config.rb +3 -0
  24. data/lib/samagotchi/continue_intent.rb +8 -0
  25. data/lib/samagotchi/engine/block_fix.rb +332 -0
  26. data/lib/samagotchi/engine/side_requests.rb +7 -5
  27. data/lib/samagotchi/engine.rb +4 -0
  28. data/lib/samagotchi/events.rb +1 -0
  29. data/lib/samagotchi/idle_client.rb +10 -6
  30. data/lib/samagotchi/inline_widgets.rb +12 -0
  31. data/lib/samagotchi/kernel_loop.rb +7 -5
  32. data/lib/samagotchi/llm/chat_loop.rb +2 -0
  33. data/lib/samagotchi/markdown_parser.rb +28 -0
  34. data/lib/samagotchi/session_access/contract.rb +3 -0
  35. data/lib/samagotchi/session_access/delete_plan.rb +77 -0
  36. data/lib/samagotchi/session_access/local.rb +13 -0
  37. data/lib/samagotchi/session_access/remote.rb +19 -1
  38. data/lib/samagotchi/session_access.rb +1 -0
  39. data/lib/samagotchi/session_chain/delete.rb +39 -81
  40. data/lib/samagotchi/session_chain/delete_preview.rb +55 -19
  41. data/lib/samagotchi/session_delete_command.rb +129 -3
  42. data/lib/samagotchi/session_manager/delegate_rule.rb +86 -0
  43. data/lib/samagotchi/session_manager/listing.rb +4 -4
  44. data/lib/samagotchi/session_manager/removal.rb +38 -12
  45. data/lib/samagotchi/session_manager/running_tasks.rb +50 -23
  46. data/lib/samagotchi/session_manager.rb +1 -0
  47. data/lib/samagotchi/version.rb +1 -1
  48. data/lib/samagotchi/web/app.rb +13 -1
  49. data/lib/samagotchi/web/block_fix_routes.rb +39 -0
  50. data/lib/samagotchi/web/markdown_renderer.rb +24 -9
  51. data/lib/samagotchi/web/message_display.rb +6 -1
  52. data/lib/samagotchi/web/participant_view.rb +1 -1
  53. data/lib/samagotchi/web/public/app.js +5 -5
  54. data/lib/samagotchi/web/public/block_fix.js +270 -0
  55. data/lib/samagotchi/web/public/block_fix_note.js +104 -0
  56. data/lib/samagotchi/web/public/block_frame.js +6 -3
  57. data/lib/samagotchi/web/public/block_host.js +1 -1
  58. data/lib/samagotchi/web/public/block_renderers.css +12 -0
  59. data/lib/samagotchi/web/public/block_watch.js +16 -2
  60. data/lib/samagotchi/web/public/inline_widgets.js +1 -1
  61. data/lib/samagotchi/web/public/stream_handlers.js +5 -1
  62. data/lib/samagotchi/web/public/turn_block.js +5 -2
  63. data/lib/samagotchi/web/server.rb +6 -4
  64. data/lib/samagotchi/web/session_control.rb +53 -21
  65. data/lib/samagotchi/worker/block_fixes.rb +22 -0
  66. data/lib/samagotchi/worker.rb +10 -3
  67. metadata +12 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef194e6af0d4be30d6b98a61f1995582670d7d5823d684733b0f75175b58857a
4
- data.tar.gz: 94467de696fd0223e72755c109f7fc0dd2c2ae6edf6fa3014ff8bde4f86748cc
3
+ metadata.gz: 39e6d208e1727e50fcb10c903c2c8cfc2bcb5c659f769de03916a52a527fc216
4
+ data.tar.gz: d9b8cca3456163bcec4c133e9559a7ef6e87a60eb6bcbd18537016e4afb4927a
5
5
  SHA512:
6
- metadata.gz: 2a019f5cddf59cf801f080f96c8b8d4579504f3f7a712f8d20a9b6010e7ac4d9218f9650c6d7f7630351329b9dadfeb3896a6a52d1b2c95782cd93514f180639
7
- data.tar.gz: fc52dd4dda346a56abddac22161b42c65014b8bf9cd4dee5196c0412c1a751aab116d4def340f774bde911f7ff7c6e7d6249012804d90edcd67fdf8929bbdd86
6
+ metadata.gz: 5737d57d34e0a8b8c49e776f1a771354a1f5abb2afaff856cc29b73fe0adf6c1740048c3b32df19087a23580d38b6532b5203b286de4fe96c84022a5b684eef9
7
+ data.tar.gz: 92dd02c054a4353dfd7ce245b3c6c11ceecbf571922704af64b0cffcde5fc95615309f96165242dac203d05f6b3c6372d372226fcc5afd92ff0a1686edde8619
data/CHANGELOG.md CHANGED
@@ -8,6 +8,30 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.182.0] - 2026-11-21
12
+
13
+ ### Added
14
+
15
+ - In the web, a fenced block chi can't draw in the newest answer (a `chi-ui` picks or walk, a Mermaid diagram) is
16
+ asked for again once, on the side: no message is sent and no turn runs. The fixed block draws with "Drawn after a
17
+ fix" under it, and the saved answer holds it. A fix that didn't help, or an older answer's block, gets an "Ask in
18
+ chat" button that fills the composer. `web.block_fix: off` turns it off.
19
+ - `chi sessions delete --dry-run ID...` prints what the delete would do and deletes nothing: what goes, what is
20
+ stopped first and what stays (the web's delete sheet in the terminal), and which of `--force` / `--stop-tasks` it
21
+ needs; with `--chain`, the chain's. It exits 1 when the delete would be refused. With `--remote` it needs a chi
22
+ web of this version.
23
+
24
+ ### Changed
25
+
26
+ - Deleting a session (the web, `chi sessions delete`, `/exit --delete`) now deletes its stopped delegates with it; a
27
+ running delegate keeps running on its own. With `--remote`, an older chi web still leaves them.
28
+
29
+ ### Fixed
30
+
31
+ - A remote archive refusal keeps the hidden session count and names every worker stopped before its task check.
32
+
33
+ Update with `chi update`.
34
+
11
35
  ## [0.181.0] - 2026-11-21
12
36
 
13
37
  ### Added
@@ -6620,7 +6644,8 @@ and long-lived sessions.
6620
6644
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
6621
6645
  hotkey panel that send selected text or the clipboard to your sessions.
6622
6646
 
6623
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.181.0...HEAD
6647
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.182.0...HEAD
6648
+ [0.182.0]: https://github.com/dm1try/samagotchi/compare/v0.181.0...v0.182.0
6624
6649
  [0.181.0]: https://github.com/dm1try/samagotchi/compare/v0.180.0...v0.181.0
6625
6650
  [0.180.0]: https://github.com/dm1try/samagotchi/compare/v0.179.0...v0.180.0
6626
6651
  [0.179.0]: https://github.com/dm1try/samagotchi/compare/v0.178.0...v0.179.0
data/bin/chi CHANGED
@@ -273,6 +273,7 @@ if options[:web]
273
273
  working_set: Samagotchi::Config.get("web.working_set"),
274
274
  stage_collapsed: Samagotchi::Config.get("web.stage_collapsed"),
275
275
  reload_check: Samagotchi::Config.get("web.reload_check"),
276
+ block_fix: Samagotchi::Config.get("web.block_fix"),
276
277
  annotate_presets: Samagotchi::Config.get("web.annotate_presets"),
277
278
  editor: Samagotchi::Config.get("web.editor"),
278
279
  start_dir: options[:start_dir] || Samagotchi::Config.get("web.start_dir"),
data/docs/architecture.md CHANGED
@@ -652,7 +652,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
652
652
 
653
653
  | Component | Main file(s) | What it is |
654
654
  |---|---|---|
655
- | Worker | `worker.rb` (`worker_boot.rb`, `worker_idle_exit.rb`, `worker_inbound.rb`, `worker_signals.rb`, `worker_wakes.rb`, `worker_task_wakes.rb`, `task_watch.rb`, `worker_participant_gate.rb`, `worker_exit_claim.rb`) | A session's background process: builds the `Engine` and `Bridge`, runs queued turns and the wake turns nobody typed (delegate reports, a background task that finished unseen: [Finish wake](internals/background-tasks.md#finish-wake), attached context), exits when idle. A spawned one traps TERM, HUP and INT (`WorkerSignals`, installed by `WorkerBoot.run_session_loop` when `SAMAGOTCHI_WORKER_PROCESS=1`): the running turn stops as a Stop with reason `signal`, is saved, and the worker leaves (`:signal`, exit 0; a new worker only for input already queued). A running turn is checkpointed at its iteration boundaries (`TurnCheckpoint`, the `interrupted_turn` mark), and the next worker settles a turn its predecessor died in (`TurnCheckpoint.settle`). The session is saved from the turn's thread, Bridge threads and a signal's thread; `Session#save` takes a per-session lock around its snapshot and write, so an older snapshot never lands over a newer one. `WorkerParticipantGate` is the one seat for "may this participant act" (a queued turn as it starts, the drain, the mid-turn stop, the Continue: [internals/participants.md](internals/participants.md)); `WorkerExitClaim` is the exit claim (`POST /exit`): one lock for the kind being taken and the exit taken. Threads: the gate is loop-thread only (a turn runs on the loop; no lock), the claim is safe from any thread (its own mutex, taken after the event lock). The concerns are `include`d parts in `lib/samagotchi/worker/` (`Worker::LeavePart`: exit and leave; `Worker::WakeTurnsPart`: the turns nobody typed; `Worker::StartupPart`: the start-up settle; `Worker::SignalGracePart`: a signal's grace; `Worker::ScratchPart`: a scratch worker whose terminal left; `Worker::ChildSidePart`: a delegate child's rings, Verify fresh verdicts; `Worker::CommandQueuePart`: session commands between turns). `worker.rb` keeps the loop, the wiring, the prompt turns and the drain. They share Worker's ivars, and each header says what it writes and reads. |
655
+ | Worker | `worker.rb` (`worker_boot.rb`, `worker_idle_exit.rb`, `worker_inbound.rb`, `worker_signals.rb`, `worker_wakes.rb`, `worker_task_wakes.rb`, `task_watch.rb`, `worker_participant_gate.rb`, `worker_exit_claim.rb`) | A session's background process: builds the `Engine` and `Bridge`, runs queued turns and the wake turns nobody typed (delegate reports, a background task that finished unseen: [Finish wake](internals/background-tasks.md#finish-wake), attached context), exits when idle. A spawned one traps TERM, HUP and INT (`WorkerSignals`, installed by `WorkerBoot.run_session_loop` when `SAMAGOTCHI_WORKER_PROCESS=1`): the running turn stops as a Stop with reason `signal`, is saved, and the worker leaves (`:signal`, exit 0; a new worker only for input already queued). A running turn is checkpointed at its iteration boundaries (`TurnCheckpoint`, the `interrupted_turn` mark), and the next worker settles a turn its predecessor died in (`TurnCheckpoint.settle`). The session is saved from the turn's thread, Bridge threads and a signal's thread; `Session#save` takes a per-session lock around its snapshot and write, so an older snapshot never lands over a newer one. `WorkerParticipantGate` is the one seat for "may this participant act" (a queued turn as it starts, the drain, the mid-turn stop, the Continue: [internals/participants.md](internals/participants.md)); `WorkerExitClaim` is the exit claim (`POST /exit`): one lock for the kind being taken and the exit taken. Threads: the gate is loop-thread only (a turn runs on the loop; no lock), the claim is safe from any thread (its own mutex, taken after the event lock). The concerns are `include`d parts in `lib/samagotchi/worker/` (`Worker::LeavePart`: exit and leave; `Worker::WakeTurnsPart`: the turns nobody typed; `Worker::StartupPart`: the start-up settle; `Worker::SignalGracePart`: a signal's grace; `Worker::ScratchPart`: a scratch worker whose terminal left; `Worker::ChildSidePart`: a delegate child's rings, Verify fresh verdicts; `Worker::CommandQueuePart`: session commands between turns; `Worker::BlockFixesPart`: a failed block's fix, written between turns). `worker.rb` keeps the loop, the wiring, the prompt turns and the drain. They share Worker's ivars, and each header says what it writes and reads. |
656
656
  | Session lifecycle | `session_manager/`, `worker_boot.rb`, the session sidecar files | Marker writers, derived states, lock order, crash repair and the known open windows are mapped in [Session lifecycle](internals/session-lifecycle.md). |
657
657
  | Config | `config.rb`, `config/restart_watch.rb` | Every setting as an `Entry`: env, config.yml and CLI layers ([configuration.md](configuration.md)); the notice a worker or chi web gets when config.yml changes a setting it reads only at its start. With `log.rb` it is the bottom layer: nothing it references reaches back to it, so `hosts:` and `models:` entries parse next to their types (`HostConfig.all`, `ModelSettings.all`). |
658
658
  | Paths | `paths.rb` (`Paths`) | The XDG base dirs chi's files live under, read from the env on every call: `Paths.state_home` (`$XDG_STATE_HOME`, else `~/.local/state`) and `Paths.config_home` (`$XDG_CONFIG_HOME`, else `~/.config`), both defaults under `Dir.home`; a blank variable counts as unset, a relative one is made absolute from the current directory. `Paths.tilde` shows a path with `~` for the home folder. `SessionManager` hands a spawned worker the spawner's `XDG_STATE_HOME` / `XDG_CONFIG_HOME`, when set, made absolute, so a relative one isn't read from the session's folder. |
data/docs/cli.md CHANGED
@@ -774,7 +774,7 @@ worker; stopped 1 background task)`). `/archive` says the same and names
774
774
  `chi sessions archive --stop-tasks ID`; the web asks a second confirm. See
775
775
  [Sessions](sessions.md#archiving-a-session).
776
776
 
777
- `chi sessions delete [--force] [--chain] [--stop-tasks] ID...` deletes sessions for good: the
777
+ `chi sessions delete [--force] [--chain] [--stop-tasks] [--dry-run] ID...` deletes sessions for good: the
778
778
  session file and its whole directory (notes, images, queued input). Each id
779
779
  (or unique prefix) gets one line: `deleted`, or `refused` with the reason.
780
780
  Deleting a chain's newest link undoes its continue and says so (`… deleted;
@@ -782,8 +782,12 @@ the previous link 1a2b3c4d is back in the lists`): the previous link comes
782
782
  back, not started, with the delegates and notes that had moved on. `--chain`
783
783
  deletes every link of the session's chain with their delegates (a running
784
784
  delegate is left running), one line per link and a `chain: …` summary; a
785
- schedule on the chain refuses it. See docs/sessions.md (Session chains →
786
- Deleting a link). A
785
+ schedule on the chain refuses it. A plain delete takes the session's stopped
786
+ delegates with it too (archived ones as well) and says how many (`… deleted;
787
+ 2 delegates deleted with it; 1 left running: 9d0e1f2a`); a running delegate
788
+ keeps running on its own, with its subtree. A delegate that would go and is a
789
+ schedule's target, or in a one-turn run, refuses the delete. See
790
+ docs/sessions.md (Session chains → Deleting a link). A
787
791
  session whose worker runs is refused unless `--force` stops the worker first;
788
792
  one a `--non-interactive` run has is always refused ("in use by a one-turn chi
789
793
  --non-interactive run or an older chi's terminal; let it finish first"). A
@@ -797,7 +801,25 @@ running)`). `--stop-tasks` is not `--force`: a live worker is still refused
797
801
  without it. `/exit --delete` refuses the same way and names `chi sessions
798
802
  delete --stop-tasks ID`. Exit
799
803
  status: 0 when all are gone, 1 when any was refused or unknown, 2 on a usage
800
- error. The Web UI deletes too: `delete` in the info bar, or the ✕ on a card in
804
+ error.
805
+
806
+ `--dry-run` prints what the delete would do and deletes nothing: the rows the
807
+ web's delete sheet shows (`back`: the previous link an undo brings back;
808
+ `goes`: the links and stopped delegates; `stopped first`: its worker or running
809
+ turn, the background tasks, another session's with its id in front; `stays`:
810
+ the running delegates, and the tasks chi can't verify), each only when it
811
+ applies, and which of `--force` / `--stop-tasks` the real delete needs. With `--chain` it prints the chain's choice. `--force` and `--stop-tasks` are ignored in the print-only plan; it reports
812
+ which real-delete flags would be needed instead. An unknown id or an id that cannot be resolved exits 1 as a would-be
813
+ refusal too. A plan that would be refused prints `would be refused: <why>` instead and exits 1; otherwise it exits 0:
814
+
815
+ ```text
816
+ $ chi sessions delete --dry-run ab12cd34
817
+ ab12cd34 would delete "fix the flaky spec"
818
+ goes: 2 stopped delegates (9d0e1f2a, 77aa0b1c)
819
+ stopped first: its worker; 2 background tasks (npm run dev, rspec) — needs --force, --stop-tasks
820
+ stays: 1 running delegate (5c1b22e0), without a parent
821
+ ```
822
+ The Web UI deletes too: `delete` in the info bar, or the ✕ on a card in
801
823
  All sessions; it asks first and stops a live worker, and asks again, naming
802
824
  them, when background tasks still run (OK stops them).
803
825
 
@@ -1684,6 +1706,10 @@ CHI_REMOTE=studio chi context push claude-outbox ab12 < answer.json
1684
1706
  an older one deletes or archives as it always did. A new chi web answers an
1685
1707
  older CLI's delete or archive of a session whose tasks run with 409
1686
1708
  `tasks_running`, which that CLI prints as a failure.
1709
+ - `sessions delete --dry-run` needs a chi web there that lists the
1710
+ `delete_plan_all` feature; an older one is refused before anything is asked
1711
+ (update and restart chi web there), since its plan would leave out a plain
1712
+ session's delegates.
1687
1713
  - A remote that can't be reached names itself and why (`chi send: remote
1688
1714
  studio (http://192.168.1.29:4567): connection refused`, exit 1; with
1689
1715
  `--format json` an `error` object).
@@ -2405,6 +2405,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2405
2405
  | `web.working_set` | `true` | yes | The stage view's working set: the files, memories and URLs a turn brought into the model's context, in a rail in the stage, a footprint as each finished turn's block summary and a `set N` chip in place of the mem chip; `false` brings the mem chip back. `?working_set=1` or `?working_set=0` on the page URL overrides it for that page load. See [CLI: the working set](cli.md#the-working-set). |
2406
2406
  | `web.stage_collapsed` | `false` | yes | Every session's stage in `chi web` starts folded to its status row (the running turn's prompt, steps and cloud behind ▴), a participant's page too. A session you fold or unfold by hand keeps its own fold in that browser (`chi_stage_collapsed:<session>`), whatever this says; one never touched follows it. Read when `chi web` starts: restart it after a change. |
2407
2407
  | `web.reload_check` | `false` | yes | Opt-in: once each finished turn has moved into the history, the page reads the session again (one full read per turn end), draws that turn as a reload would and compares the two, strictly: a known divergence counts as a mismatch too. `chi web` logs one `reload_checked` line per check and a `reload_mismatch` line naming the kinds that differed, `excused` (the known divergences, `history_shape.js` `ACCEPTED`, that would explain them) and `explained` (all of them had one), with `turn_id`, `drawn` (the turn came back from its drawing, so a mismatch with `drawn: true` is a drawing bug), `undrawn` (how many of the reload's rows came without their turn's drawing, the page's plain fallback: 0 unless chi web missed a turn) and the worker's version: counts only, never content. The count is `grep -c reload_mismatch` over `grep -c reload_checked` in chi web's log, split by `excused`. The turn's own cards and questions are compared as data, apart from the history: what the page's stream said (`card_registry.js`) against what the read lists (CardStore), each card or question of this turn (`of_turn`) by its id, its kind, its status (answered, cancelled, still asking) and its summary line (a card's title); a difference counts as `card` or `question`. Bodies, buttons, folds, the tag a card is drawn in and where it sits are ignored (the history's compare leaves cards and questions out on both sides; their place is the specs'). A read that lists CardStore's cap of cards and questions may have lost an older one: a card the page has and such a read doesn't is no difference. A question the read gives no turn and no opening stamp for (an older worker) leaves the questions out. A page whose `app.js` is older than its `reload_check.js` (a mixed cache) compares no cards: its `reload_checked` line says `cards_compared: false`. Between-turn cards and notices stay with the e2e reload checks. Every open owner tab runs the check; `chi web` logs a turn's first report only, and starts over when it restarts. |
2408
+ | `web.block_fix` | `auto` | | `auto`: a fenced block the owner's page can't draw in the newest answer (a `chi-ui` picks or walk, a bundle's diagram such as Mermaid) is asked for again, once, as a side request (no turn, no message; it shows as `block-fix` in `/stats`' side line). The fixed block draws in place, with "Drawn after a fix" under it, and the saved answer holds it, so the model's next turn sees it too (or only the page, when a turn started meanwhile). A fix that doesn't draw either, an older answer, and the third block of an answer get an "Ask in chat" button that fills the composer. `off`: the block stays source under its error line, as before, and `POST /api/sessions/:id/blocks/fix` answers `404`. Read when `chi web` starts. See [block-renderers.md](internals/block-renderers.md#a-failed-block-is-asked-for-again). |
2408
2409
  | `web.annotate_presets` | `Agreed\|Could you please elaborate?` | yes | Quick replies next to Annotate in `chi web`, `\|`-separated (a YAML list works too); `""` in the file or on the CLI leaves only Annotate (an empty env value means the default). See [CLI](cli.md#web-annotate-presets). |
2409
2410
  | `web.editor` | `vscode` | yes | What a file ref in `chi web` (a file tool row's title, a diff line) opens, for a viewer on this machine: a preset (`vscode`, `vscode-insiders`, `cursor`, `zed`) or a URL template with `{path}` and an optional `{line}`; `none` turns refs off. See [Opening files from chi web](#opening-files-from-chi-web). |
2410
2411
  | `web.start_dir` | the folder `chi web` runs in | | The folder `chi web` starts in (`chi web --start-dir DIR` for one run): its page (the printed link, a bare `/`, the LAN link and QR code, the Home Screen app) opens on that folder's project, outside a project (no repository or marked folder) on every session, and a new session from the all view starts there; the header's project picker switches projects. `~` and a relative path (resolved from your home folder) work; one that isn't a folder stops `chi web` from starting. `chi web` never changes its own folder. See [CLI](cli.md). |
@@ -63,6 +63,120 @@ model. The TUI is untouched: it shows a fence as source.
63
63
  `max-height` says the same number, a backstop whatever the parsing gets wrong. The decode is bounded too
64
64
  (15 s, the mark on until it ends). A very wide picture stays at least 120 px tall and scrolls sideways instead of a sliver.
65
65
 
66
+ ## A failed block is asked for again
67
+
68
+ One mechanism for every drawn block, a `chi-ui` picks or walk (core's drawer) and a bundle's renderer (chi-mermaid's
69
+ `mermaid`): a block the owner's page can't draw **in the newest answer**, for a reason that is the model's (a refused
70
+ `chi-ui` block, a renderer's own `error`), is asked for once more as a side request, and the answer is patched. No
71
+ message is sent and no turn runs. `web.block_fix: off` ([configuration.md](../configuration.md)) is the page as before:
72
+ the web route answers `404` instead of relaying a block fix.
73
+
74
+ ```
75
+ page: a drawer fails a block in the newest answer, marked fixable
76
+ └─ POST /api/sessions/:id/blocks/fix {turn_id, lang, source, reason} (chi web, :owner: Web::BlockFixRoutes)
77
+ → Bridge POST /session/:id/blocks/fix (Bridge::BlockFixRoute) → Engine#fix_block
78
+ ├─ the answer's stamp knows this block → 200 {state: "fixed" | "failed"}
79
+ └─ else 202 {state: "running"}; a side thread asks the model, checks the answer,
80
+ queues the result and wakes the worker's loop
81
+ worker loop, between turns (before any queued prompt): Engine#apply_block_fixes
82
+ └─ patches the answer (its text, or its display), stamps it, saves, announces :block_fix
83
+ page: on :block_fix → re-reads that answer; the patched block draws as any block
84
+ reload: the answer is the patched text; the render marks the block from the stamp
85
+ ```
86
+
87
+ **The request** (`BlockFix.request`, `Engine::BlockFixPart`): `ask_side_model`, as `/btw` and ctx.ask_model, on the
88
+ session's model: the conversation up to and including the answer as the side transcript (`Plugin::SideQuestion`, its
89
+ last 32,000 characters; display-only keys gone), then the failed block, its language and its error (cut to 300
90
+ characters, in the user part only). `BlockFix::SYSTEM` asks for the corrected block only, in one fence; for `chi-ui` the
91
+ schemas follow (`InlineWidgets::FIX_RULES`: core can't read the inline-widgets bundle's prompt sections). No tools,
92
+ thinking off, 25 s, 6,000 tokens out. It shows as `block-fix` in `/stats`' side line, always the owner's.
93
+ `BlockFix.extract` takes the first fence of the answer (else the whole answer); it is refused when the answer was cut
94
+ off at its limit, empty, the same block, or over 16 KB, and a `chi-ui` fix must parse (`BlockFix.check`). Any other
95
+ language passes: only the page can draw it.
96
+
97
+ **Where the block is** (`BlockFix.locate`, `locate_all`, `replace`, `replace_all`): commonmarker, the page's render's
98
+ parser (`MarkdownParser` loads it for the render and the worker), walks the `code_block` nodes; each in that language
99
+ whose normalised source is the block's is a copy of it (an answer may repeat a block: a fix patches every copy, so none
100
+ is left to fail and be asked for again), and its `source_position` gives its body's lines. `replace` keeps the fence lines and gives each
101
+ new line the old body's indent (a list item's) and the text's own line ends. A block in a blockquote isn't fixed (its
102
+ lines carry `> `). A block's identity is `BlockFix.key`: SHA-256 of the language and the normalised source, 32 hex
103
+ characters.
104
+
105
+ **The route's answers** (`Engine#fix_block`): 409 `fix_unavailable` (no session, a scratch one, no commonmarker), 413
106
+ `block_too_large` (over 16 KB), then the turn's answer (`AnswerTail.find` by turn id; none: 409 `block_not_found`) and
107
+ **its stamp before its text**: 200 with the stamp's state when the stamp knows the block, even when the block is no
108
+ longer in the answer (a page that drew the answer before its fix, a second tab: `fixed`, and it reads the answer
109
+ again); a block that is a fix and fails again, or a `fixed` block still in the shown text (a copy no fix reached),
110
+ answers `failed`, never `fixed`, so a page can't redraw and ask again. Then 409 `block_not_found` (the source isn't a
111
+ block of the answer), 202 `running` while that answer's block is asked (in flight per answer and block: the same block
112
+ in a newer answer is that answer's own ask), 429 `fix_limit` past 2 blocks of one answer (`BlockFix::PER_ANSWER`: its
113
+ stamp and its asks in flight or waiting, so a reload's page can't ask for a third), 429 `fix_busy` past 2 in flight
114
+ (`MAX_RUNNING`). The answer is resolved once, there: the result carries its **anchor** (its index in the conversation, its digest as `Bridge::TurnDrawings`
115
+ computes one, and the turn counter: `Engine#turn_messages` counts each turn).
116
+
117
+ **The write: on the worker's loop, between turns, never from the request's thread.** A running turn holds its own copy
118
+ of the conversation and writes it back at its end. `Worker::BlockFixesPart#apply_block_fixes` runs in each pass that
119
+ runs the queued commands, after them and before the notes and the next prompt (the idle pass and each input file's
120
+ step); the result's thread wakes the loop (`Engine#block_fix_ready=`, `Waker#wake`). Under the event lock, four
121
+ outcomes:
122
+
123
+ - **No turn started since the ask, and the answer is still the newest** (`AnswerTail.find`; notes, a `!cmd` line and
124
+ `/continue no` land after an answer without a request, so "the last message" isn't the test): its `content` is
125
+ patched, its `display` too when a hook set one, and on `api: anthropic` its saved blocks (`anthropic_content`, which
126
+ `AnthropicWire#assistant_blocks` sends as they are): the text block that holds the block whole, else the blocks are
127
+ dropped and the answer goes as its text. A thinking block is never touched (with the blocks dropped, the answer's
128
+ thinking blocks go with them: the `thinking` text stays on the message, a final answer with no `tool_use` is valid
129
+ without them, and `ReasoningHistory.earlier_thought?` reads `thinking` too). The next turn sends the patched answer.
130
+ A fix asked as its own turn ends (the page asks on the end event, before the turn's hooks are done) counts as no turn
131
+ since.
132
+ - **A turn started since** (or was running at the ask): only `display` (`AnswerDisplay::KEY`, what the page renders in
133
+ place of `content`; never sent to a model). No message a model has been sent is rewritten, so no prompt cache is
134
+ invalidated.
135
+ - **The answer is still there but the fix can't land** (the block left its shown text, say a hook's new display; or the
136
+ patched display would pass `AnswerDisplay::MAX_CHARS`, on either path): the block is stamped `failed` with the
137
+ reason ("the answer changed", "the fix is too long"), so a reload doesn't ask again.
138
+ - **The answer is gone** (its digest changed: a rollback, a new text; the turn id now names another answer: a reminder
139
+ turn's id names no prompt, so it falls back to the newest answer): the fix is dropped (`state: "dropped"`), no stamp.
140
+
141
+ A fix in an answer's text moves its digest; the engine keeps the move (`@block_fix_moved`), so the answer's other
142
+ block, asked before that fix landed, still finds its answer (and its event's `was_digest` is the digest it patched).
143
+ The move map is capped at `MOVED_DIGEST_LIMIT = 64`: the oldest move is evicted, so a fix landed after 64 later
144
+ text-changing moves no longer finds and patches the older answer.
145
+
146
+ A failed ask stamps the answer only. Each outcome is one `Log.info(:model, "block_fix_<state>", lang:, key:, bytes:, ms:,
147
+ landed:, reason:)` line (never the source) and one `:block_fix` event (`turn_id`, `key`, `lang`, `state`, `landed`,
148
+ `reason`, and the answer's digest before and after: `was_digest`, `digest`). A participant never gets it
149
+ (`ParticipantView::DROPPED`). A pending result doesn't keep a worker alive: an idle exit or a stop loses it, and the
150
+ page's give-up shows "Ask in chat".
151
+
152
+ **The stamp** (`BlockFix::STAMP`, `block_fixes` on the answer's model message: `{key, fixed_key, state, reason, at}`
153
+ per block asked) is display only (`AnswerDisplay::DISPLAY_ONLY`) and rides both loops' allowlists (`ChatLoop#plain`,
154
+ `KernelLoop#sanitize_history`). It is why nothing is asked twice: a reload, a second tab and a re-rendered bubble get the
155
+ stamp's answer. `Web::MarkdownRenderer#render(block_fixes:)`, from `MessageDisplay`'s answer render only, marks a block
156
+ that is a fix `data-block-fixed` and one whose fix failed `data-block-fix-failed`; an unstamped answer's HTML is as
157
+ before.
158
+
159
+ **The page** (`block_fix.js`, `block_fix_note.js`; [web-frontend.md](web-frontend.md#a-failed-block-asked-for-again)):
160
+ a block failed by the model's input (a refused `chi-ui` block, a renderer's own `error`: `FrameError.renderer`) is
161
+ marked fixable; a failure that isn't the model's (the renderer didn't load, a hang, a timeout, over 64 KB, a picture
162
+ too large) keeps today's line, with no button. In the newest answer the line reads "· asking for a fix…" with a
163
+ pulsing dot; the fixed block draws as any block, with "Drawn after a fix" under it. A fix that didn't help says so
164
+ with an **Ask in chat** button (it fills the composer with "The X block in your answer didn't draw: reason. Please
165
+ send it again, corrected."; never sends), as does an older answer's failed block and an answer's third. A live worker
166
+ without the feature (`workerPredates`, with the store's `bridgeUp`): "· restart this session to fix"; a worker that
167
+ isn't up is asked, and chi web's 503 `not_live` gives the plain line. An answer is read again at most once per block
168
+ for the page's life, so a copy still failing after the redraw says a fix didn't help. The terminal and a participant's page show nothing new.
169
+
170
+ **The turn's drawing.** A patched `content` changes the digest the turn's drawing line ends on (`TurnDrawings#holds?`),
171
+ so the Bridge's `TurnDrawings` (an observer of `:block_fix` with `landed: "answer"`) writes that turn's line again with
172
+ the new end digest, when the old one ended on the answer as it was (`was_digest`). A `display` patch keeps the digest.
173
+
174
+ **What a content patch costs**: nothing on a remote prefix cache or on Anthropic's Messages API (the cached prefix ends
175
+ before the answer); on llama.cpp the slot re-evaluates from the patched block, a few hundred tokens, and the turn-end
176
+ warm-up's gain is lost for that one turn ([prompt-caching.md](prompt-caching.md#the-turn-end-warm-up)). A `!rollback` or
177
+ a canceled Continue can restore a checkpoint from before the patch: the answer comes back unpatched and unstamped and may
178
+ be asked for once more.
179
+
66
180
  ## Security model
67
181
 
68
182
  The bundle's JS is trusted (installing a bundle already means trusting it, [plugins.md](../plugins.md#trust)). **Its input
@@ -426,6 +426,15 @@ The Bridge exposes:
426
426
  `200`, or `409` when it is no longer pending.
427
427
  - `POST /session/:id/guardrails/wrong` — `{id}`: label this session's System 1 auto-allow as
428
428
  one it should have asked about; `200`, `404` for an unknown judgment, `409` if already labelled.
429
+ - `POST /session/:id/blocks/fix` — `{turn_id, lang, source, reason}`: ask again, once, for a block the owner's page
430
+ couldn't draw in that turn's answer (`Bridge::BlockFixRoute` → `Engine#fix_block`; web route `POST
431
+ /api/sessions/:id/blocks/fix`, `Web::BlockFixRoutes`). `400 missing_fields` without a turn id, a fence language
432
+ (`BlockRenderers::LANG`) or a source, or `400 invalid_json` for a non-object body; `200 {state: "fixed" | "failed",
433
+ reason?}` when the answer's stamp knows the block, `202 {state: "running"}` while it is asked,
434
+ `404` for a worker or web route whose `block_fix` feature is off, `409 fix_unavailable` / `block_not_found`,
435
+ `413 block_too_large`, `429 fix_limit` / `fix_busy`. The result lands between turns and is announced as `:block_fix` (a `state` event; never a
436
+ participant's); a fix that patched the answer's text writes its turn's drawing line again with the new end digest
437
+ (`TurnDrawings#call`). See [block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again).
429
438
  - `POST /session/:id/holds/stop` — stop those holds without the worker leaving; `200 {status: "stopped",
430
439
  session_id, stopped}` or `501 holds_unavailable`.
431
440
  - `POST /session/:id/tasks/stop` — `{task_id}`: stop a background task as the user
@@ -666,6 +675,7 @@ compatibility from its version. `Bridge::FEATURES` advertises:
666
675
  | `cancel_turn_id` | `POST /session/:id/cancel` can stop only the named turn. |
667
676
  | `participant_revise` | chi web can pass a participant's Revise draft for worker-side validation. |
668
677
  | `participant_client_id` | chi web can identify a participant as `participant:<id>` instead of using the legacy `review:<id>`. |
678
+ | `block_fix` | `POST /session/:id/blocks/fix` asks again for a block the page couldn't draw; the owner's page without it says "restart this session to fix". |
669
679
  | `working_set_item` | `GET /session/:id/working_set/item` answers one item's timeline (the running turn's mid-turn), so chi web asks for it instead of the whole snapshot. |
670
680
 
671
681
  `chi web`'s `GET /api/sessions/:id/stream` proxies this bridge
@@ -465,6 +465,17 @@ ask it (`Engine#cut_for_steer`, `#input_epoch`, `#generation_snapshot`), the str
465
465
  - `WaitingSteer`: a cut that came too early. It waits until the thinking passes the cut wait (rechecked on each
466
466
  thinking chunk), until a drain hands it to the model at a boundary, or until the turn ends.
467
467
 
468
+ ### A block fix: written between turns
469
+
470
+ `Engine::BlockFixPart` (`engine/block_fix.rb`) is the one writer of the conversation outside a turn that a side
471
+ thread feeds. `#fix_block` (the Bridge's route) resolves the answer once, takes its anchor (index, digest, the turn
472
+ counter `#turn_messages` bumps for every turn) and asks on `SideJudgments#aside`; the result waits in
473
+ `@block_fix_ready` and wakes the worker. `#apply_block_fixes` runs only on the worker's loop between turns
474
+ (`Worker::BlockFixesPart`, after the queued commands and before the notes and the next prompt) and never while a turn
475
+ runs: under the event lock it replaces the session's messages (`replace_session_messages`) with a copy of the answer
476
+ whose text (no turn since, still the newest answer) or display (a turn since) holds the fix, or drops the fix when
477
+ the anchor no longer matches. See [block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again).
478
+
468
479
  ## Events
469
480
 
470
481
  ### The turn's sink (`on_event`) and the observers
@@ -113,7 +113,9 @@ session switch, a turn's end, Revise's clones, the stage's hand-off to `#history
113
113
  listeners. A widget's position and picks live in the widget, so a clone or a rewrite starts over (accepted for v1).
114
114
  - **A refused block** (`data-widget-error`) stays source under `failBlock`'s muted `.block-note` ("Couldn't draw this
115
115
  chi-ui block: …", an attribute CSS shows, a click copies it). Bad JSON or an unknown `type` fails the same way, from
116
- the watcher. A `chi-ui` `<pre>` with neither attribute (an older server) is left alone.
116
+ the watcher. A `chi-ui` `<pre>` with neither attribute (an older server) is left alone. In the newest answer a
117
+ refused block is asked for again, once (the schemas go with the request: `InlineWidgets::FIX_RULES`, and the fix
118
+ must parse before it is used; [block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again)).
117
119
  - **walk** (`widget_walk.js`): the swimlane (one column per actor, one row per step; the current, seen and a hovered
118
120
  case's target marked; a click jumps), the step card (actor, `does`, "You see", the dashed "Behind it"), a fork's
119
121
  "Which case?" buttons, Back / Next / Start over, the path taken, and ← → while the widget has the focus
@@ -192,7 +192,15 @@ user message starts (`KernelLoop#warmup_prompt`) and sends it in a thread (`Clie
192
192
  server has since cleared skips its prompt cache and prefills everything (measured 0.5 s → 12 s). For the same
193
193
  reason `id_slot` is a reserved sampling key.
194
194
  - What breaks it (the warm-up simply misses): a system-prompt rebuild (`/thinking`, `/model`, a tool change),
195
- the image cut moving a batch, `!rollback`.
195
+ the image cut moving a batch, `!rollback`, a block fix that patched the last answer.
196
+
197
+ **A block fix patches the last answer before a turn sends it.** A block the page couldn't draw in the newest answer
198
+ is asked for again on the side, and when it comes back before the next turn starts the answer's text holds the fix
199
+ ([block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again)): that is the one change to an earlier
200
+ message a turn's request sees. The cached prefix ends before the answer on a remote prefix cache and on Anthropic's
201
+ Messages API (nothing lost); on llama.cpp the slot re-evaluates from the patched block (a few hundred tokens), and a
202
+ warm-up already sent loses its gain for that turn (measured 0.73 s against 0.11 s on a hybrid model). A fix that comes
203
+ back after the next turn started lands in the answer's `display` only, never sent to a model.
196
204
 
197
205
  ## The image window
198
206
 
@@ -134,9 +134,12 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
134
134
  `SessionManager::OwnedByTUI` / `DeleteRefused` / `ArchiveRefused` / `RestartRefused`, `SessionContinue::Refused`,
135
135
  and `ModelProfile::MissingModel` for `invalid_model` (no model there, or `--model`'s host unknown there: "could not
136
136
  start a session: …", exit 1, as here). A delete's or archive's `409 tasks_running` carries `op` (`delete` or
137
- `archive`), `tasks` (`{running, unverified, unreadable}`), `worker_stopped`, `stopped_worker` (whose; an older chi web sends only the Boolean) and a chain's `links`: `raise_refusal`
137
+ `archive`), `tasks` (`{running, unverified, unreadable}`), `worker_stopped`, `stopped_worker` (whose; an older chi web
138
+ sends only the Boolean), `stopped_workers` (the archive tree's stopped worker ids), and `sessions` (the archive's
139
+ hidden session count), plus a chain's `links`: `raise_refusal`
138
140
  rebuilds `DeleteRefused` or `ArchiveRefused` by `op`, with the `RunningTasks::Listing`, and makes the words here
139
- (`RunningTasks.words`), not from chi web's `message`. Its own code, not archive's `busy`: an older client prints
141
+ (`RunningTasks.words`, plus `RunningTasks.worker_words`: "its worker was stopped", "9d0e1f2a's worker was stopped",
142
+ or "N workers were stopped: its own, 9d0e1f2a"), not from chi web's `message`. Its own code, not archive's `busy`: an older client prints
140
143
  `RemoteFailed "… answered 409 tasks_running: …"` rather than "a turn is running". `--stop-tasks` asks for the
141
144
  `stop_tasks` feature first (`RemoteTooOld` without it).
142
145
  Checks the client would make locally come back as `SessionAccess::Refused` (`parent_answers_refused`,
@@ -191,6 +194,15 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
191
194
  `unarchived`/`moved_back` (read as `[]`). The delete refusals reach the CLI with their own reason and message
192
195
  (`continuing`, `delegate_unmovable`, `scheduled`, `chain_scheduled`, `worker_running`, `still_stopping`:
193
196
  `Remote#raise_refusal` raises `DeleteRefused` with `ids` and `schedule_id`).
197
+ - **A route that answers more.** `GET /api/sessions/:id/delete_plan` answering for every session (`{chained: false,
198
+ session_id, link}` for one in no chain, and a file-less folder), together with a plain delete that takes the
199
+ session's stopped delegates, is `delete_plan_all` (`App::DELETE_PLAN_FEATURE`). Its first caller is the CLI's
200
+ remote `sessions delete --dry-run` (`Remote#delete_plan`; `SessionAccess::DeletePlan.read` reads its JSON and
201
+ `Local#delete_plan`'s symbol-keyed preview into the same value objects), which requires it first: an older chi web answers a session in no chain with
202
+ `{chained: false}` alone and still leaves a plain session's delegates, so its plan would be wrong. A plain remote
203
+ delete needs no feature: against an older chi web it leaves the delegates, and the CLI prints what the result
204
+ says. The deletes' `tasks=` and archive's `tasks` (the sheet's named tasks) need none either: an older chi web
205
+ ignores them and stops what runs, which is what a CLI without them asks for.
194
206
 
195
207
  ## Which checks run where
196
208
 
@@ -389,9 +389,11 @@ links too). In ⋯'s menu, Delete doesn't click `#infoDeleteBtn` for a chained s
389
389
  card (`createDeleteSheet`, on `chip_popover.js`: a bottom sheet on a phone). Both shells keep one live host: a
390
390
  `host(anchor, id)` (the card's, with the session it opened for) or a Delete in ⋯ makes a new one, and a flow whose host
391
391
  is no longer the live one (a ✕ on another card while the first plan was read) draws and acts on nothing. What the sheet says comes from
392
- `GET /api/sessions/:id/delete_plan`, fetched as it opens and only for a chained session: the server's own plan and
393
- refusals (`SessionChain::Delete::Preview`, the code the delete runs), so the sheet and the delete can't disagree; its
394
- cost is one session listing walk per open. `deleteChoices` (pure) turns it into the two choices, a schedule's banner
392
+ `GET /api/sessions/:id/delete_plan`, fetched as it opens for every session: the server's own plan and refusals
393
+ (`SessionChain::Delete::Preview`, the code the delete runs), so the sheet and the delete can't disagree. Plain
394
+ sessions have a server-side link plan; the page still uses the plain confirm until the delete-sheet phase sends plans
395
+ for it. The preview shares one `session_rows` snapshot across the link and chain choices, while Links performs its own
396
+ listing. `deleteChoices` (pure) turns it into the two choices, a schedule's banner
395
397
  and each refusal's "Not while …"; a plan that says no chain (a link alone past a gap) falls back to the confirm. The
396
398
  confirm sends the shown choice's `digest` (`expect=`, `data.js deleteSession`/`deleteChain` keep it out of `fetch`);
397
399
  a `409 plan_changed` re-reads the plan and redraws the sheet with "What this deletes changed; check again" (a link no
@@ -463,6 +465,34 @@ kept: every open starts fitted.
463
465
  (solid `--bg-panel` under `body.no-glass` and reduced transparency), by `--safe-*`, and the standalone phone
464
466
  app's ✕ is 12px lower, below iOS 26's band under the clock.
465
467
 
468
+ ## A failed block asked for again
469
+
470
+ Two modules, owner page only ([block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again) has the
471
+ mechanism): `block_fix.js` (`wireBlockFix`, one call in app.js: the owner's page, `viewer.can("block_renderers")`,
472
+ with `<body data-block-fix="auto">`, else null; `createBlockFix`) and `block_fix_note.js` (the line's states, DOM
473
+ only). A drawer that fails a block because of the model's input marks it (`block_watch.js failBlock(..., {fixable})`,
474
+ `pre.dataset.blockFixable`, the reason kept in `pre.dataset.blockReason`, a bubbling `block-failed` event): a refused
475
+ `chi-ui` block (`inline_widgets.js`) and a renderer's own `error` (`block_frame.js` `FrameError.renderer`). `block_fix.js`
476
+ listens for that event and scans added nodes (a Revise clone arrives failed) in the turn roots, and decides from the DOM
477
+ alone: the newest answer's first 2 such blocks are posted (`POST /api/sessions/:id/blocks/fix`, `postFix`); the worker
478
+ also enforces the 2-per-answer limit and remains the authority (`fix_limit`, even if the page or a second tab posts).
479
+ A block
480
+ that is a fix (`data-block-fixed`) or whose fix failed (`data-block-fix-failed`), an older answer, a third block and a
481
+ live worker without the `block_fix` feature (`worker_features.js workerPredates`, with `bridgeUp`) get their line
482
+ instead. Nothing is kept across a re-render: a block failing again is posted again, and the worker answers it runs (or
483
+ how it went); only the redraw is counted: an answer is read again at most once per turn and block for the page's life
484
+ (the route's 200 `fixed` or the event's), and a block failing after it says a fix didn't help. The stream's `block_fix` handler
485
+ (`stream_handlers.js`, dep `blockFix`) hands the worker's word over: `fixed` re-reads that turn's answer (`getSession(id,
486
+ {tail, turnId})`) and writes the bubble as `applyFinalAnswer` writes it, which can't find it by its old text; `failed`
487
+ and `dropped` say a fix didn't help. A block is marked asked (`data-block-fix-asked`) before its POST, since the word can
488
+ come before the 202 (a quick side answer); a 202 after it starts no give-up. No word within 60 s of a 202: the line
489
+ gives up (today's words and Ask in chat);
490
+ a session switch drops the timers. The line's words are `data-text` (CSS), Ask in chat a button whose label is CSS
491
+ (`data-label`) with an `aria-label`, one delegated click listener per root; it fills the composer after the draft
492
+ (`widget_picks.js withDraft`), never sends. "Drawn after a fix" (`.block-note.fixed`) follows a `data-block-fixed`
493
+ block once its figure is placed; a click on it copies nothing (a failed block's line copies its error). A reload's drawn turn takes the saved answer when `block_fixed` is on its item (what
494
+ streamed is the block before the fix: `turn_block.js savedAnswer`).
495
+
466
496
  ## The stage's modules
467
497
 
468
498
  `stage_view.js` wires the stage: its `refresh`, the lifecycle (`turnStarted` … the hand-off) and the event API app.js