samagotchi 0.192.0 → 0.194.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 (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +128 -1
  3. data/docs/architecture.md +3 -3
  4. data/docs/bundle-authoring.md +1 -1
  5. data/docs/bundles.md +82 -40
  6. data/docs/cli.md +47 -17
  7. data/docs/configuration.md +75 -8
  8. data/docs/context.md +8 -5
  9. data/docs/desktop.md +3 -0
  10. data/docs/guardrails.md +20 -5
  11. data/docs/hooks.md +1 -0
  12. data/docs/internals/bridge.md +3 -1
  13. data/docs/internals/bundles.md +2 -2
  14. data/docs/internals/engine.md +46 -3
  15. data/docs/internals/pages.md +4 -4
  16. data/docs/internals/panes.md +66 -0
  17. data/docs/internals/participants.md +5 -3
  18. data/docs/internals/peers.md +176 -27
  19. data/docs/internals/prompt-caching.md +6 -1
  20. data/docs/internals/remote-sessions.md +6 -0
  21. data/docs/internals/session-lifecycle.md +12 -4
  22. data/docs/internals/web-frontend.md +106 -22
  23. data/docs/internals/working-set.md +5 -1
  24. data/docs/peers.md +150 -27
  25. data/docs/plugins.md +48 -7
  26. data/docs/releasing.md +30 -2
  27. data/docs/scheduling.md +3 -2
  28. data/docs/sessions.md +16 -7
  29. data/docs/sub-agent.md +6 -4
  30. data/docs/system-one.md +4 -0
  31. data/docs/testing.md +38 -3
  32. data/docs/thin-clients.md +27 -11
  33. data/lib/samagotchi/bridge/card_store.rb +1 -1
  34. data/lib/samagotchi/broadcast/triage_model.rb +17 -0
  35. data/lib/samagotchi/bundles/claude-peer/manifest.yml +8 -5
  36. data/lib/samagotchi/bundles/claude-peer/plugin.rb +24 -5
  37. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +61 -24
  38. data/lib/samagotchi/bundles/claude-peer/scripts/pair +31 -8
  39. data/lib/samagotchi/bundles/codex-peer/manifest.yml +8 -5
  40. data/lib/samagotchi/bundles/codex-peer/plugin.rb +62 -6
  41. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +57 -19
  42. data/lib/samagotchi/bundles/codex-peer/scripts/pair +28 -7
  43. data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
  44. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
  45. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  46. data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
  47. data/lib/samagotchi/bundles/mcp/plugin.rb +0 -7
  48. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  49. data/lib/samagotchi/chi_invocation.rb +7 -0
  50. data/lib/samagotchi/client.rb +18 -0
  51. data/lib/samagotchi/codex_rollout.rb +93 -0
  52. data/lib/samagotchi/compat.rb +8 -1
  53. data/lib/samagotchi/config.rb +19 -6
  54. data/lib/samagotchi/continue_offer.rb +13 -1
  55. data/lib/samagotchi/delivery.rb +2 -2
  56. data/lib/samagotchi/effective_model.rb +28 -2
  57. data/lib/samagotchi/engine/cards.rb +9 -4
  58. data/lib/samagotchi/engine/hooks.rb +8 -0
  59. data/lib/samagotchi/engine/models.rb +197 -7
  60. data/lib/samagotchi/engine/plugins.rb +2 -0
  61. data/lib/samagotchi/engine/side_requests.rb +72 -13
  62. data/lib/samagotchi/engine/toolkit.rb +1 -1
  63. data/lib/samagotchi/engine/turn_helpers.rb +1 -1
  64. data/lib/samagotchi/engine.rb +11 -8
  65. data/lib/samagotchi/engine_snapshots.rb +16 -3
  66. data/lib/samagotchi/events.rb +1 -0
  67. data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
  68. data/lib/samagotchi/hooks.rb +3 -1
  69. data/lib/samagotchi/host_registry.rb +146 -16
  70. data/lib/samagotchi/idle_client.rb +13 -2
  71. data/lib/samagotchi/idle_recap.rb +33 -3
  72. data/lib/samagotchi/idle_target.rb +27 -7
  73. data/lib/samagotchi/jsonl_store.rb +13 -2
  74. data/lib/samagotchi/llm/adapter_common.rb +4 -2
  75. data/lib/samagotchi/llm/anthropic_messages.rb +14 -2
  76. data/lib/samagotchi/llm/errors.rb +35 -4
  77. data/lib/samagotchi/llm/model_listing.rb +19 -0
  78. data/lib/samagotchi/llm/openai_chat.rb +8 -2
  79. data/lib/samagotchi/llm/prompt_cache.rb +5 -0
  80. data/lib/samagotchi/model_binding.rb +46 -4
  81. data/lib/samagotchi/model_catalog.rb +68 -8
  82. data/lib/samagotchi/model_profile.rb +35 -0
  83. data/lib/samagotchi/models_command.rb +8 -4
  84. data/lib/samagotchi/pages/launch.rb +1 -1
  85. data/lib/samagotchi/panes/kitty.rb +122 -0
  86. data/lib/samagotchi/panes.rb +185 -0
  87. data/lib/samagotchi/peer_announce.rb +245 -0
  88. data/lib/samagotchi/peer_cold.rb +92 -0
  89. data/lib/samagotchi/peer_command.rb +121 -20
  90. data/lib/samagotchi/peer_continue.rb +42 -16
  91. data/lib/samagotchi/peer_exchanges.rb +7 -0
  92. data/lib/samagotchi/peer_mailbox.rb +50 -10
  93. data/lib/samagotchi/peer_pair_here.rb +149 -0
  94. data/lib/samagotchi/peer_presence.rb +434 -0
  95. data/lib/samagotchi/peer_receipts.rb +33 -6
  96. data/lib/samagotchi/peer_say.rb +46 -21
  97. data/lib/samagotchi/peer_wait_expiry.rb +47 -0
  98. data/lib/samagotchi/plugin/api.rb +13 -1
  99. data/lib/samagotchi/plugin/card.rb +68 -11
  100. data/lib/samagotchi/plugin/context.rb +33 -2
  101. data/lib/samagotchi/plugin/panes.rb +54 -0
  102. data/lib/samagotchi/plugin/peer.rb +170 -63
  103. data/lib/samagotchi/plugin/peer_pairing.rb +290 -0
  104. data/lib/samagotchi/plugin/peer_start.rb +301 -0
  105. data/lib/samagotchi/plugin/peer_start_hook.rb +207 -0
  106. data/lib/samagotchi/plugin/peers.rb +89 -9
  107. data/lib/samagotchi/recap_setup.rb +40 -3
  108. data/lib/samagotchi/self_report.rb +25 -6
  109. data/lib/samagotchi/send_command.rb +6 -6
  110. data/lib/samagotchi/served_lookup.rb +225 -0
  111. data/lib/samagotchi/served_ref.rb +41 -0
  112. data/lib/samagotchi/session_access/contract.rb +6 -0
  113. data/lib/samagotchi/session_access/local.rb +149 -40
  114. data/lib/samagotchi/session_access/remote.rb +4 -4
  115. data/lib/samagotchi/session_access/remote_peers.rb +8 -5
  116. data/lib/samagotchi/session_chain/links.rb +8 -3
  117. data/lib/samagotchi/session_commands.rb +40 -8
  118. data/lib/samagotchi/session_continue.rb +11 -6
  119. data/lib/samagotchi/session_lifecycle/allowed.rb +4 -2
  120. data/lib/samagotchi/session_manager/delivery.rb +5 -0
  121. data/lib/samagotchi/session_manager/lifecycle.rb +58 -7
  122. data/lib/samagotchi/session_manager/removal.rb +3 -0
  123. data/lib/samagotchi/session_manager/spawn.rb +6 -1
  124. data/lib/samagotchi/session_model_settings.rb +7 -3
  125. data/lib/samagotchi/session_stores.rb +25 -11
  126. data/lib/samagotchi/sessions_command.rb +16 -3
  127. data/lib/samagotchi/system_one/http_backend.rb +111 -10
  128. data/lib/samagotchi/system_one/runs.rb +5 -2
  129. data/lib/samagotchi/system_prompt.rb +11 -4
  130. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -1
  131. data/lib/samagotchi/terminal_ui/formatting.rb +26 -12
  132. data/lib/samagotchi/terminal_ui/status_row.rb +20 -3
  133. data/lib/samagotchi/terminal_ui.rb +1 -1
  134. data/lib/samagotchi/testing/boundary.rb +0 -1
  135. data/lib/samagotchi/testing/bundle.rb +6 -2
  136. data/lib/samagotchi/testing/host.rb +1 -0
  137. data/lib/samagotchi/testing/recorder.rb +3 -0
  138. data/lib/samagotchi/turn_endings.rb +6 -2
  139. data/lib/samagotchi/user_typed.rb +29 -0
  140. data/lib/samagotchi/version.rb +1 -1
  141. data/lib/samagotchi/web/app.rb +8 -20
  142. data/lib/samagotchi/web/participant_review.rb +1 -1
  143. data/lib/samagotchi/web/participant_view.rb +1 -1
  144. data/lib/samagotchi/web/peer_routes.rb +40 -15
  145. data/lib/samagotchi/web/public/agent_rows.js +206 -0
  146. data/lib/samagotchi/web/public/agent_runs.js +595 -0
  147. data/lib/samagotchi/web/public/answer_fold.js +41 -44
  148. data/lib/samagotchi/web/public/app.js +4 -4
  149. data/lib/samagotchi/web/public/block_fix.js +1 -1
  150. data/lib/samagotchi/web/public/card.js +26 -10
  151. data/lib/samagotchi/web/public/cards_place.js +6 -4
  152. data/lib/samagotchi/web/public/context_chips.js +24 -2
  153. data/lib/samagotchi/web/public/copy.js +8 -2
  154. data/lib/samagotchi/web/public/data.js +2 -1
  155. data/lib/samagotchi/web/public/format.js +9 -1
  156. data/lib/samagotchi/web/public/history_reveal.js +5 -2
  157. data/lib/samagotchi/web/public/index.html +56 -2
  158. data/lib/samagotchi/web/public/info_bar_model.js +1 -1
  159. data/lib/samagotchi/web/public/model_pick.js +18 -5
  160. data/lib/samagotchi/web/public/model_picker.js +1 -1
  161. data/lib/samagotchi/web/public/page_view.js +1 -1
  162. data/lib/samagotchi/web/public/pages.css +1 -7
  163. data/lib/samagotchi/web/public/peer_chip.js +15 -5
  164. data/lib/samagotchi/web/public/peer_data.js +4 -2
  165. data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
  166. data/lib/samagotchi/web/public/peer_note.js +4 -2
  167. data/lib/samagotchi/web/public/peer_row.js +37 -0
  168. data/lib/samagotchi/web/public/peer_wait.js +36 -0
  169. data/lib/samagotchi/web/public/quiet_notes.js +12 -1
  170. data/lib/samagotchi/web/public/revise_stack.js +5 -2
  171. data/lib/samagotchi/web/public/send_turn.js +11 -3
  172. data/lib/samagotchi/web/public/served_ref.js +9 -0
  173. data/lib/samagotchi/web/public/session_fields.js +1 -0
  174. data/lib/samagotchi/web/public/session_state.js +4 -0
  175. data/lib/samagotchi/web/public/stage_missing.js +23 -6
  176. data/lib/samagotchi/web/public/stream_handlers.js +16 -0
  177. data/lib/samagotchi/web/public/turn_block.js +4 -0
  178. data/lib/samagotchi/web/public/version_notices.js +7 -1
  179. data/lib/samagotchi/web/session_control.rb +19 -10
  180. data/lib/samagotchi/web/session_show.rb +20 -0
  181. data/lib/samagotchi/web/update_ops.rb +2 -2
  182. data/lib/samagotchi/worker/command_queue.rb +3 -0
  183. data/lib/samagotchi/worker/mail.rb +24 -1
  184. data/lib/samagotchi/worker.rb +8 -5
  185. data/lib/samagotchi/worker_inbound/mail.rb +34 -6
  186. data/lib/samagotchi/worker_inbound.rb +11 -3
  187. data/lib/samagotchi/worker_link.rb +13 -1
  188. data/lib/samagotchi/worker_wakes.rb +33 -5
  189. metadata +22 -2
  190. data/lib/samagotchi/web/public/pages_group.js +0 -67
@@ -35,9 +35,16 @@ the next release (its baseline refresh) for the same reason, marked as kept for
35
35
  sheet still keeps `isChained` and `format.js deleteConfirmText` that way; and `ws_peek.js`'s `PEEK_WIDTH`, which 0.183.0's
36
36
  `working_set_view.js` imports though the view is 520 wide always now: `ws_part_peek_mixed_cache.test.js` loads this view
37
37
  with 0.183.0's `ws_reader.js` and `ws_peek.js`, and 0.183.0's view with this `ws_reader.js`, from
38
- `spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `details_motion.js`,
38
+ `spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `agent_rows.js` (a delegate report's and a
39
+ peer answer's row: its element and words; `answer_fold.js` re-exports its `reportLabel`, an import cycle neither side
40
+ uses at its top level, `agent_rows.test.js` loads both orders), `agent_runs.js` (the one owner of reports, peer
41
+ answers and notes: The notes rows and the run line, below; it imports only names the last release's `answer_fold.js`
42
+ and `quiet_notes.js` exported, and `quiet_notes.js installQuietNotes` stays for an older cached `app.js`), `details_motion.js`,
39
43
  `turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
40
- `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while it is open, a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js), `pages_group.js` (All sessions' former group, kept for an older cached app.js until after 0.189.0) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
44
+ `session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while a view owns the URL (`keepSessionHash`), a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js` (its `showPending` calls the injected `keepSessionHash`, following `views.js`'s rule not to write the session hash while a view owns the URL), `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js`, `peer_row.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `peer_wait.js` (the chip of a peer
45
+ the session waits for, its popover and Cancel: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `served_ref.js`
46
+ (`isServedRef`, which the stream's `generation_completed` reads, beside a `modelServed` already set, for a served
47
+ model's `modelServed`), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
41
48
 
42
49
  ## One page, every viewer
43
50
 
@@ -60,7 +67,7 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
60
67
  | **`store.current`** (`session_state.js`: `emptySessionState` / `sessionStateFrom`; per field: `session_fields.js FIELDS`) | the open session's fields, about 40 (info bar, chips, verdicts, timing, worker, stream cursor) | `store.update` / `setStatus` from app.js, `stream_handlers.js`, `session_sync.js`, `session_view.js`, `send_turn.js` (`firstPreview`, `owner`), `session_actions.js` (`status`), `owner_verify.js` (`verdicts`, `verifyFresh`); `forgetSession`'s `replaceCurrent` (`session_view.js`). Two writers in place, on purpose (D8 in `FIELDS`): live_timing.js's `activeTurn`, verdict_fresh.js's running list | the store runs the field's redraws (`FIELDS[key].redraws`) |
61
68
  | **`store.sessions`** (the hub's projection) | every card | `store.update({sessions})` from app.js: `openSessionEvents` (`applySessionEvent`), `refresh` (the list fallback), `addCreatedSession`, `views.js applyView` (re-sorted), `replaceSelectedCard` (`setLiveStatus` through `setStatus`, `readTurnEnd`, `setUsedMemories`), the stream's close (`withoutWorker`); `session_actions.js` (`setSessions`) | the store: `lists` and `infoBar`. **Always a new array**; an entry is replaced, never changed in place. `followSelectedSession` copies the open one's owner and worker (`fieldsFromCard`) and, when not streaming, its status (`setStatus(…, "hub")`) into `store.current` |
62
69
  | **Factory closures**: the `create*` factories (popovers, panels, views) | each component's own state: open-for, busy, error, its own fetched list | the factory | an `onChange` hook back into app.js, or a getter the factory reads at draw time |
63
- | **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers and long prompts (`.folded`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `quiet_notes.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js`, `quiet_notes.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
70
+ | **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers, long prompts, delegate reports and peer answers (`.folded`, each behind its `.answer-fold` row; a report's and a peer answer's `.answer-fold.agent-row`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored) and the run lines over a run with a report, a peer answer or a finished steps block in it (`.quiet-notes.agent-line`, its open segment its `data-open`, the closed segments' rows and items `.quiet-hidden`, a block under its line `.in-line`; never stored), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `agent_runs.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js`, `agent_runs.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
64
71
  | **A drawn turn** (`turn_drawings` of the full read) | every finished turn, as live drew it: `turnGroups` groups by the stamps only, a turn's stamped items (`drawn: <turn_id>`) one group, and `turnHistoryNodes` draws it by feeding its drawing's events to a live turn block offscreen (`turn_block.js drawnTurnNodes`: the block's own handlers, as the stage's), the stage's extras (a reminder, merged lines, a card that waited when it arrived, an answered question) in the order live left them for the history (`turn_settle.js settleOrder`, pure: from the drawing's `part_settled` and question events, whether the turn was opened, and whether a question had a lead-in) and the end as live, then the answer, the merged lines and the steps' texts from their saved items (markdown, refs). Each of its top-level elements carries `data-drawn`: `cards_place.js` leaves that turn's in-turn CardStore entries (`of_turn`) to it, and a kept reminder bubble of that turn (`data-turn-id`) stays out after a resync. chi web sends a drawing for every finished turn (one made from its messages where live wrote none): `drawnGroup` pairs the record the end names (`end.record_id`, by place for a turn saved before turn ids), else by the turn's id, and the answer's `data-answer-turn` is the end's own `turn_id` only (a made-up id, `m…` or `…~N`, keys none: no Revise). Nothing is rebuilt from messages: an item that comes unstamped is a `plain` group drawn as a plain row of its text (its prompt or answer bubble, no steps), the running turn's as expected (`runningTurnId`, the show's `current_turn`: it has no line yet), any other a miss, marked `data-undrawn`, logged once per render (`console.warn`) and counted by the reload check (`undrawn`), never a throw; a drawing with no parts (a minimal line) draws its prompt, answer and end | chi web (the show) | `renderHistory`, the reload check's render |
65
72
  | **The cards as data** (`card_registry.js`; app.js `cardRegistry`) | every question, continue offer and plugin card of the open session, keyed as `stage_waiting.js` keys them (`q:<id>`, `c:<id>`, `continue`): its kind and folded text (`card_kinds.js`), status (pending, answered, cancelled; resolved or dropped for the continue offer; asks or shown for a plugin card), `of_turn`, `opening_id`, step, `relayed_to` | `observeCards` around the stream handlers (outside the participant wrap: the page's handler first, then `apply`), so a read's replay feeds it too; `session_view.js renderSessionView` seeds it from the read right before the replay (`seed`: CardStore's listing, the pending question, the continue offer; it replaces), `forgetSession` resets it. Idempotent: a merge per key, a final status never back to pending, the first `of_turn`/`opening_id`/step kept, so seed then replay is what live holds. A question still pending at its turn's end is cancelled (the page cancels the card, no event comes) | an observer: nothing on the page draws from it; its one reader is the opt-in reload check (`reload_check.js`: this turn's entries against a registry seeded from a fresh read). `stage_cuts_parity.test.js` checks it against the stage's waiting cards at each cut, `card_registry.test.js` the events against each cut's seed and replay |
66
73
  | **What was opened of a running turn** (`stage_view_memory.js`, in `session_view.js`) | per session, for this tab: the cloud open, the steps opened in it, the working set's reader on an item; a Map of at most 20 sessions, nothing stored or sent (the peek isn't kept: it closes with its popover) | `session_view.js leaveSession`, from `session_sync.js select` and from `forgetSession` itself for the session it drew last (so the start page, `clearSelection`, keeps it too) before its reset (`captureView`); dropped by `endTurnView` | `renderSessionView`, once the read is drawn: put back (`applyView`) only when the read's running turn (`current_turn.turn_id`) is the one saved; taken either way |
@@ -68,20 +75,71 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
68
75
  | **localStorage** (`storage.js` `readStored`/`writeStored`, guarded) | per-browser choices only; a session's view settings per session (`session_prefs.js`) | the module that owns the choice | read at start, a session's view settings again when its view is drawn (see Storage keys) |
69
76
  | **SSE** | see Streams | the server | events go into the DOM directly (a participant's through `participant_main.js wrapHandlers` first) |
70
77
 
71
- **The notes rows** (`quiet_notes.js`): what nobody says in the conversation folds, so a phone shows the prompt and
72
- the answer, not the background under them. A stretch is a run of `#history` children that match `QUIET` (a
73
- `.bubble.hook-notice` but the empty-answer line, a `.bubble.note` that is neither a wake's opening `.turn-start` nor a
74
- `.peer-answer`, so objectives lines too, and a `.bubble.steer-row`); the `.turn-timing` line passes through it, and
75
- anything else ends it (a prompt, an answer, a card, a peer's answer, a time divider, another fold's row). Each stretch
76
- gets one `<button class="quiet-notes">` before its first item, closed, and its items get `.quiet-hidden`. The row is a
77
- sibling tied to its first item (WeakMaps, as `answer_fold.js`'s), not a wrapper: the bubbles stay direct children of
78
+ **The notes rows and the run line** (`agent_runs.js`, the one owner; the notes' words are `quiet_notes.js`'s): text
79
+ written for the user starts open, text agents write to each other starts closed, so a phone shows the prompt and the
80
+ answer, not the background under them. Three levels of the same content (the design: the fold-levels mock-up,
81
+ https://claude.ai/artifact/6Pe1GXxBX4qMmdUsZH2FEp): a segment in a shared line, a row, the full text.
82
+ - A delegate report and a peer's answer in `#history`, finished and keyed (`answer_fold.js answerKey`; a live merged
83
+ report has none until a reload: it stays open with no row and ends a run), get a row before their bubble
84
+ (`agent_rows.js` draws it; `.answer-fold.agent-row`), closed by default, opened by hand kept in the fold store's
85
+ `open` list (Storage keys); a tap opens or closes it, its height animated unless the viewer prefers no motion.
86
+ - A run is those items and the quiet items (`QUIET`: a `.bubble.hook-notice` but the empty-answer line, a
87
+ `.bubble.note` that is neither a wake's opening `.turn-start` nor a `.peer-answer`, so objectives lines too, and a
88
+ `.bubble.steer-row`) side by side among `#history`'s children; the `.turn-timing` line and an objectives line after
89
+ a block (`.obj-moves`, `.obj-nomove`: they stay on view) pass through it, anything
90
+ else ends it (a typed prompt, an answer, a card, a time divider, another fold's row). A run of quiet items only gets
91
+ the notes row: `<button class="quiet-notes">` before its first item, "▸ 3 notes · names ⚠ 1", closed, its items
92
+ `.quiet-hidden`. A run of one report or one peer answer only keeps its row. Anything else gets the run line: a
93
+ `<div class="quiet-notes agent-line">` of segment buttons (`.qn-seg`, `data-seg`: `report`, `peer:<name>`, `calls`,
94
+ `notes`), `segments`' words ("N reports", "<peer>: <verdict>", "<peer> answered" with no verdict, "<peer> ×N" for
95
+ several, "N calls", "N notes" with its "⚠ N"), in the mock-up's order (reports, peers, calls, notes; the owner: order
96
+ doesn't matter). The kinds are one table (`KINDS`: per kind its selector, whether one takes part, its segment key and
97
+ words, and whether its row under the line is a row of its own, a note's compact row or the item itself); the same
98
+ table feeds the runs, the segments, the jump's reveal and the observer. One
99
+ segment is open at a time (the line's `data-open`): its rows show under the line (`.in-line`, indented), each closed
100
+ or open as its bubble is. Under a line every row is the mock-up's compact panel row (`.answer-fold.compact`): a peer
101
+ answer's, a report's (`.report-row`: "child <id6>", its first line, its length; alone it is Build 1's `.report` row
102
+ again, `agent_rows.js drawAgentRow` with `inLine`) and one per note (`.note-row`: its name and text, `noteRowWords`;
103
+ a tap shows the note under it, never stored). A settle redraws an item's row only when its open state, its place in
104
+ a line or its text (the observer's) changed. The line is `role="group"` ("agent run"); a tap on a segment that hides
105
+ the focused row moves the focus to that segment. A segment is per peer by the name it shows (`peerName`). One line at every width: CSS shrinks the notes segment first,
106
+ then the calls', then the reports', then the peers', strictly: their `flex-shrink` is 1e15, 1e10, 1e5 and 1, so a
107
+ higher rank gives up nothing (under 1/64 px) until the ranks below are at their padding (a proportional ladder cut
108
+ every segment a little); on a phone the line is 44px tall, a segment's tap area is, and a segment's side padding is
109
+ 6px so the mock-up's "1 report · Claude: changes · 2 calls · 2 notes" fits at 390 px.
110
+ - A finished turn's steps block (`STEPS`: `.turn-work.done[data-end="completed"]`, with a call in its `data-calls`,
111
+ which `turn_block.js turnEnded` stamps live and on a reload, so no label parses the summary's words) in a run that
112
+ holds a report or a peer answer is the segment "N calls" (the calls of the run's blocks on view summed: one a
113
+ folded Revise version hides doesn't count). Under the line the block is its own row (`.in-line`, indented): today's
114
+ block, open or closed as it was last left, its summary line with the working set's footprint and its count, a tap
115
+ on it opens or closes the steps. So a footprint in a line is one tap deeper (the owner; [working-set.md](working-set.md)).
116
+ A block alone, or beside notes or a steer row only (a typed turn: owner decision (b)), keeps today's look and cuts
117
+ the notes into a notes row on each side; a cancelled or failed block ends a run and stays visible. A running block
118
+ stays out: the stage's joins at the hand-off; one opened in the history mid-turn (`stage_asking.js openTurn`, its
119
+ `data-opened-turn`) is done at its turn's end but joins only when `stage_handoff.js` drops that mark, the hand-off
120
+ that comes after the end. A block an older cached `turn_block.js` drew has no `data-calls` and stays out.
121
+ - A run inside a superseded Revise version folded to its stub (`revise_stack.js`: every item `.stack-hidden`): its
122
+ line or notes row is hidden with them (`.quiet-hidden`; a segment that had the focus gives it to the stub), and back
123
+ when the stub opens (a jump into it opens the stub first). `revise_stack.js`'s divider walk passes over it as over a
124
+ folded item.
125
+ - A notes row that a report or a peer answer joins becomes the line (a button becomes a div): its open state goes to
126
+ the notes segment, and its focus.
127
+ - Never stored: a reload draws every line and notes row closed; a row opened by hand inside a line shows open once its
128
+ segment is.
129
+ Every row and line is a sibling tied to its first item (WeakMaps), not a wrapper: the bubbles stay direct children of
78
130
  `#history`, where every walker (`turn_range.js`, `cards_place.js`, the stage's hand-off, the reload check) and the
79
- other observers expect them; a row something was placed after goes back before its item and keeps its open class.
80
- A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). Its one
81
- observer watches `#history`'s own children, and a settle writes only what changed (the copy, answer-fold,
82
- Revise and objectives observers see class and subtree writes). `revise_stack.js historyTurns`, `history_shape.js
83
- childItems` and `bubbles.js showRecap`'s walk skip the rows, and `history_reveal.js revealInHistory` opens one over a
84
- jump's target.
131
+ other observers expect them; the line has the notes row's class and the item rows `answer_fold.js`'s, so what passes
132
+ over those passes over them (`revise_stack.js historyTurns`, `history_shape.js childItems`, `bubbles.js showRecap`'s
133
+ walk, `cards_place.js afterTurnEnd`). A row or line something was placed after goes back before its item and keeps its
134
+ state. A hidden item's arrival (`ts-arrive`) plays on its row or line. Its one observer watches `#history` (children,
135
+ and class or key changes on them that aren't its own), and a settle writes only what changed (the copy, answer-fold,
136
+ Revise and objectives observers see class and subtree writes). `history_reveal.js revealInHistory` opens a line's
137
+ segment over a jump's target (`agent_runs.js revealRun`) before a notes row's (`quiet_notes.js revealQuiet`).
138
+ A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). A
139
+ between-turn card is not: live it sits where it arrived, after a reload just before the next turn's opening
140
+ (`placeSnapshotCards`), so a card that came before a run lands inside it on a reload and the one line live draws is
141
+ two there (measured: "1 report · Claude ×2 · 3 notes ⚠ 1" live, "Claude ×2 · 2 notes" and "1 report · 1 note ⚠ 1"
142
+ after a reload; the row order drifted the same way before the line).
85
143
 
86
144
  The objectives' strip keeps the list in its own closure (`objectives_strip.js`, seeded by `renderSessionView`, reset by
87
145
  `forgetSession`, updated by `objectives_updated`): [objectives.md](objectives.md#the-page).
@@ -626,7 +684,9 @@ row. It also marks the stage `data-stage-missing`: `"1"` when it holds no turn,
626
684
  its status row's rect is off the window or below the composer card's top edge (the user's own tall or folded
627
685
  composer: reported, not fixed), and warns once per visit with counts only — `live_read`, whether `current_turn`
628
686
  came, the replay's event types with their counts, the last replayed end event's turn id beside the running turn's,
629
- the stage's and the composer's rects and the composer's saved floor and fold. The show's `live_read`
687
+ the stage's and the composer's rects and the composer's saved floor and fold. The line waits for the task's own work
688
+ (a microtask): a re-read resets the turn view and draws its read in one task (`session_sync.js resync`), so the
689
+ reset's check sees the stage before the read filled it, and the render's check clears that mark before any line. The show's `live_read`
630
690
  (`SessionShow#live_snapshot`: "ok", "none", "failed") says whether the snapshot read that fills the page came from
631
691
  a live worker; chi web logs the why and the elapsed ms when it did not (bridge.md, The show). The e2e stage check
632
692
  (`spec/e2e/support/fixtures.js`) reads the mark.
@@ -879,10 +939,16 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
879
939
  is the peer chip's only feed, so the page reads it for every session it opens (`hasPeer: () => true`).
880
940
  Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
881
941
  `context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
882
- focus, and a 60 s tick while an exchange waits; a `turn_completed` redraws without a fetch (`touch()`) (one interval, cleared with the session: `forgetSession` →
942
+ focus, a peer bundle's `card` (`source` claude-peer or codex-peer) or `hook_notice` (its hook `… (bundle
943
+ claude-peer)`: a wait that ran out), and a 60 s tick while an exchange waits or the session waits for a peer
944
+ (`waiting` on its row: the chip turns paired, or goes, on a phone with no focus event); a `turn_completed` redraws without a fetch (`touch()`) (one interval, cleared with the session: `forgetSession` →
883
945
  `peerLinks.reset()`). The peer chips read the same model: its `onChange` also calls `contextChips.peersChanged()`, and
884
946
  the chips' own load (a session opened) calls `peers.refresh({ reuse: true })`. A pairing made from the peer's side
885
947
  sends the page nothing: the chip appears at the next read (a focus, a peer note, a send).
948
+ - `peer_wait.js` (pure): `waitingChipModel` ("Claude · waiting 8 min", state `awaiting`, apart from a send's
949
+ `waiting`), `waitingPopoverTemplate` (the wait, the minutes left, Cancel: `context_chips.js cancelWait`, the
950
+ Unpair route with no confirm), `waitMinutesLeft`. `peer_chip.js peerGroups` admits a row with `paired_at` or
951
+ `waiting`; a waited-for one is drawn by these.
886
952
  - `peer_mailbox_api.js` (state): `getPeerMessage(id, name, serial)` (a message's text: View latest answer, a
887
953
  mailbox note's "Read the full answer") and `unpairPeer(id, name)` (`DELETE …/peers/NAME`).
888
954
  - `peer_exchange.js` (pure): `peerRef(row)`, `stateText` (long and the phone's short words, both drawn; CSS picks),
@@ -898,6 +964,22 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
898
964
  agent" fold shows the content without the block, and the bubble carries `data-peer-inline`. Without it (an older
899
965
  session, a message over the cap) the bubble draws as before. A mailbox message's note (its hash has `box`) carries
900
966
  `data-peer-box` and no source; an older context answer's keeps its `<peer>-outbox` source as `data-peer-source`.
967
+ - **The answer's row** (`agent_runs.js`, drawn by `agent_rows.js`; its key `answer_fold.js answerKey`): every peer answer
968
+ in `#history`, short too, starts closed as one row before its bubble, `<name> <verdict> <summary> N lines` in a plain
969
+ panel box with no chevron (`.answer-fold.peer`; the verdict in the text colour whatever it says). `peer_row.js`
970
+ (pure) gives the words: the verdict as `verdictWord`'s lower-case word, none without one; the summary the peer sent
971
+ without the verdict mark it wrote into it (`summaryWithoutVerdict`: the last `VERDICT X` when X is the server's
972
+ verdict, the punctuation it leaves tidied), else (`.note-text` marked `data-fallback` by `peer_note.js`) the first
973
+ line of the peer's text; N the lines of the peer's own text (`.peer-text`'s `data-peer-md`), never the bubble's copy
974
+ text, and no length without a body. A tap opens the bubble under the same line (the box's top edge; the bubble's
975
+ `.under-row` class drops its own head, verdict and summary, which the row says, keeping the ↑ to the send), a
976
+ second closes it; opened by hand is kept with the reports' in the fold store's `open` list, keyed
977
+ `peer:<name>#<serial>`, else `peer@<opening id>`; with neither, no row and the bubble stays open. A jump into it (the
978
+ send pill's ↓, a claim link) opens it through `history_reveal.js`, not saved. An answer that arrives while a turn
979
+ runs sits in the stage, open (`stage_place.js`), and gets its row at the hand-off; the arrival motion
980
+ (`ts-arrive`) plays on the row, never on the hidden bubble. `revise_stack.js historyTurns` takes the row as its
981
+ note's head, and `cards_place.js afterTurnEnd` walks over it as over the notes. Next to a report, another answer or a
982
+ note it joins their run line (The notes rows and the run line).
901
983
  - `peer_text.js` (pure): `peerBlock(content)` cuts the text out between the first `[PEER MESSAGE from …]` line and the
902
984
  last `[END PEER MESSAGE]` line and undoes the `PeerNote.block` mark on forged frame lines
903
985
  (`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `PeerNote::FORGED_OPENINGS` and `FORGED_LINES`, and the same line breaks and leads
@@ -927,7 +1009,8 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
927
1009
  document would close it).
928
1010
  - `peer_chip.js` (pure): a paired peer in the session bar. `peerGroups(peers)` gives one group per peer of the
929
1011
  model that is paired (`paired_at`; an unpaired one keeps its messages but has no chip): `{key: "peer:<name>", name,
930
- label, peer}`. `peerChipModel` is the chip, the first state that applies: answers only (`can_send` false: a pairing
1012
+ label, peer}`. `peerChipModel` is the chip, the first state that applies: ended (the server's `ended`: a paired peer's inbox socket
1013
+ is gone, `PeerMailbox.socket_gone?`, and `can_send` false with it; no kitty call and no bundle state read in chi web), answers only (`can_send` false: a pairing
931
1014
  with no address), can't send (the newest send `failed` and the pairing not renewed since, `paired_at` past the failed
932
1015
  send's time ends it, `cantSend`), waiting (the newest validate/question `waiting`, its age the send's), answered
933
1016
  (its newest message unread: no receipt, `held` or `noted`; with the dot), paired. A peer the read doesn't name, an
@@ -987,8 +1070,9 @@ session's id), `unqueue.js` (`putBackTo(text, id)`: into the draft of the sessio
987
1070
  (synchronous). A gone session (`session_actions.js leaveGoneSession`, the one place: a send's `not_found`, a re-read's
988
1071
  404, the hub's `session_gone`) moves its draft to the start page's before the start page opens, unless a delete from
989
1072
  this tab is taking it (the `deleting` set, filled when the sheet's request starts: the open link of a chain deleted
990
- whole too); `afterDelete` drops the deleted ids' drafts after its `clearSelection`. A gone session that isn't open
991
- keeps its draft until the sweep.
1073
+ whole too); `afterDelete` drops the deleted ids' drafts after its `clearSelection`. If a send's `not_found` belongs to
1074
+ a session that isn't open, `send_turn.js` moves that sent line to the start-page draft and shows a toast naming the
1075
+ gone session instead of leaving it in the gone session's swept draft key.
992
1076
 
993
1077
  **Continue →** (`session_actions.js continueSelected`): right after the 201 (`addCreatedSession`), before it looks at
994
1078
  which session is open, `handOverDraft(id, next, created)` = `drafts.handOver(A, A', openerText(created))`: a draft
@@ -1088,7 +1172,7 @@ reach another device or the server.
1088
1172
  | `chi_notify`, `chi_push_device` | `notifications.js` (an injected storage) | the bell's state, this device's push id |
1089
1173
  | `chi_composer_draft:<session>` | `drafts.js` (through `session_prefs.js`; the key is `draft_keys.js COMPOSER_DRAFT`) | the session's composer draft's text (none while empty; its images are never stored) |
1090
1174
  | `chi_start_draft` | `drafts.js` (`draft_keys.js START_DRAFT`) | the start page's draft's text, one per browser; outside the sweep |
1091
- | `chi_answer_fold:<session>` | `answer_fold.js`, `revise_stack.js` | the answers and long prompts (`<turn id>:prompt`) folded by hand, and the Revise stubs unfolded by hand (`stub:<turn id>`) (swept with the session list) |
1175
+ | `chi_answer_fold:<session>` | `answer_fold.js`, `agent_runs.js` (the `open` list), `revise_stack.js` | the answers and long prompts (`<turn id>:prompt`) folded by hand, the delegate reports and peer answers (`peer:<name>#<serial>`, else `peer@<opening id>`) opened by hand (its `open` list), and the Revise stubs unfolded by hand (`stub:<turn id>`) (swept with the session list) |
1092
1176
 
1093
1177
  **A session's view settings** (`session_prefs.js`): the five `<key>:<session>` view keys above and the composer's
1094
1178
  draft (the fifth's name is defined in `ws_sections.js`, the draft's in `draft_keys.js`, new modules, so
@@ -369,7 +369,11 @@ passes `working_set_updated` to it, and does nothing when the flag is off. A new
369
369
  unchanged one). A footprint is a `<span>` in its block's summary line, `.turn-work > summary > .tw-sum`, before the
370
370
  steps' `.turn-steps`: drawn in the reload's template (`turnHistoryNodes`; a drawn turn's from its drawing's rows, `turnGroups`' steps), prepended at the hand-off
371
371
  (`stage_view.js handOff`, while the stage still hides the summary). A click there must not toggle the block:
372
- `details_motion.js` skips `.ws-foot`, and `footClick` cancels the click;
372
+ `details_motion.js` skips `.ws-foot`, and `footClick` cancels the click. A finished block in a run line
373
+ (`agent_runs.js`, [web-frontend.md](web-frontend.md), The notes rows and the run line) is hidden behind the line's
374
+ "N calls" segment, its footprint with it: one tap deeper, the same node in the same summary line (never drawn in
375
+ the line). The chip, the rail and the lens are as without a line, and a step tag's jump (`refs.js showRow`,
376
+ `history_reveal.js`) opens the calls segment before it lands on the row;
373
377
  - the rail (`onServer`, the stage's `scheduleRefresh`).
374
378
 
375
379
  **The list's lens.** The expanded list is always the session's set (`sessionSet()`), seen through a lens: `null`
data/docs/peers.md CHANGED
@@ -8,20 +8,96 @@ peer chip. How it is built: [internals/peers.md](internals/peers.md).
8
8
 
9
9
  ## Pairing
10
10
 
11
- The peer pairs from its side, with its `chi-peer` skill (`/claude install-skill` or `/codex install-skill`
12
- installs it). Its pair script runs one command:
11
+ There are two ways in, and neither needs a session id copied by hand:
12
+
13
+ - **In chi: `/claude pair`.** With exactly one Claude Code session open in this project it pairs at once. With
14
+ none, the session waits 10 minutes: the next Claude you start in the project pairs on its own, and its start
15
+ context says `paired with chi 3f2a9c1e (<title>)`. With several, the session waits and a card lists them, a row
16
+ each (its kitty window's title, folder and age) with **Show** (brings that window to the front) and **Pair**.
17
+ `/claude` alone shows the same list, or that none is open, or the wait. `/claude unpair` (or the chip's Unpair,
18
+ or the waiting chip's Cancel) ends the pairing or the wait. When a wait runs out, one line says so: "No Claude
19
+ Code session came in 10 min; /claude pair to wait again." On a session already paired, `/claude pair` refuses
20
+ ("unpair first"), unless that Claude is gone (its inbox socket missing): then the pairing ends, the reply says so,
21
+ and it pairs or waits as above. `/codex pair` only waits: Codex doesn't list itself, and its pairing is never gone.
22
+ - **In the peer: "pair with chi".** Its `chi-peer` skill (`/claude install-skill` or `/codex install-skill`
23
+ installs it) runs its pair script with no id, `chi peer pair claude --here …`: it pairs with the session that
24
+ waits in this project, else the chi session of this project that runs now and is paired with this peer already
25
+ (it says paired: codex-peer's start hook paired it), else the one chi session of this project that runs now, else
26
+ it lists them and the peer asks you which. A session paired with another Claude already is refused ("/claude unpair there first"), never
27
+ replaced, unless that Claude is gone (its inbox socket missing): then the pairing ends, as `/claude pair` ends it,
28
+ and it says so; one another pairing is taking right now is refused too ("try again"). With an id it pairs that session
29
+ (replacing its pairing):
13
30
 
14
31
  ```sh
15
- chi peer pair claude <session id> --address <where chi sends> --from "<who paired>"
32
+ chi peer pair claude <session id> --address <where chi sends> --from "<who paired>" [--peer-session <its id>]
16
33
  ```
17
34
 
18
35
  - `--address` is where chi's sends go: Claude Code's inbox socket, Codex's thread id. A pairing without one
19
36
  answers only: the peer can say, chi can't send to it (a peer on another machine with no forwarded socket).
20
- - Pairing again only replaces the address (a Claude Code restart gives it a new socket).
37
+ - Pairing again with an id replaces the pairing whole: its address, who paired (`--from`) and its peer session
38
+ (dropped when not passed). `--peer-session` names the peer's own session (Claude's pair script
39
+ passes `CLAUDE_CODE_SESSION_ID`): it is how a restart finds its pairing.
40
+
41
+ **Claude's start hook.** A Claude Code session lists itself here only with claude-peer's start hook: the
42
+ `/claude install-skill` card's **Add the start hook…** shows the exact line and the merged settings as a diff,
43
+ and that card's **Add the start hook** merges it into Claude Code's settings.json, on your tap only. It runs `chi peer announce claude` when an interactive Claude starts (never a
44
+ headless `claude -p`; subagents start no session). With it a Claude restart (`claude --resume`) keeps its pairing
45
+ (its start context says `chi <id8>: pairing refreshed`), and a `/clear` keeps it too. Without it, `/claude pair`
46
+ finds no Claude, and the peer pairs again with "pair with chi" after a restart. The line names the chi of your chi
47
+ home (`ChiShim.path`): run without one (a checkout's `bin/chi`, a state with no chi home) it can point at a chi that
48
+ isn't there, and its `2>/dev/null || true` (a failing hook would show "hook failed" in Claude) hides that; the status
49
+ card says when the line points at a chi that is gone.
50
+
51
+ **Codex's start hook.** codex-peer has one too: the `/codex install-skill` card's **Add the start hook…** shows the
52
+ exact line (`<chi> peer announce codex 2>/dev/null || true`) and the merged `$CODEX_HOME/hooks.json` (else
53
+ `~/.codex/hooks.json`) as a diff, and its card's **Add the start hook** appends it there on your tap: the one file it
54
+ writes, never `config.toml`, every other hook kept in its place (Codex keys a hook's trust by its place). With it, a
55
+ new Codex in this project pairs with a session that waits (`/codex pair`, `/codex start`) at its **first message**,
56
+ whatever it says ("look at the failing spec"), so no turn goes to "pair with chi"; its start context says `paired with
57
+ chi <id8> (<title>): …`. Codex fires the hook with the first message, never while it sits idle, so a Codex already open
58
+ still pairs with "pair with chi". A `codex exec` (a Codex builder, a review run), an `exec resume` and a `codex resume`
59
+ never take the wait: chi reads the first line of the session's rollout file and pairs only a fresh interactive Codex
60
+ (checked on Codex 0.172.0). A Codex subagent should not take it either (untested: the check fails closed unless its
61
+ `thread_source` and `originator` match an interactive Codex's). A `/new` in a Codex window starts a new thread, which
62
+ likely takes the wait, as a new window does. There is no list of Codex sessions in `/codex pair` (a Codex can't be told alive, nor
63
+ shown).
64
+ - **Review it in Codex.** Codex asks you to review a new or changed hook the next time it starts ("Hooks need
65
+ review": choose Review hooks, or `/hooks` later, and trust it); until then it skips the hook, silently. chi never
66
+ writes Codex's trust and never passes a trust-bypass flag. A Codex started by `/codex start` stops on that screen
67
+ in its background tab the first time: its opened line says so; Show the tab and answer it.
68
+ - A line pointing at a chi that is gone (a moved chi home) shows on the status card; adding it again changes the hook,
69
+ so Codex asks for the review again.
70
+ - Codex runs an interactive session's hooks in its app-server daemon, with the env of the Codex that started the
71
+ daemon: a `CHI_REMOTE` there makes chi exit before the announce, and `2>/dev/null || true` hides it (nothing pairs,
72
+ nothing shows). The card reads only `$CODEX_HOME/hooks.json`: an announce line you put in `config.toml`'s `[hooks]`
73
+ or a project's `.codex/hooks.json` isn't seen (the card offers to add it).
74
+
75
+ **Start one in kitty: `/claude start`.** chi makes the session wait, then opens a background kitty tab titled
76
+ `claude · chi <id8>` in the session's folder, running `claude` through your login shell (the setting
77
+ `bundles: claude-peer: start_command:` replaces it, a shell line, so you can add flags; read when the session's worker
78
+ starts, as every bundle setting is, so restart the session after changing it); the Claude there pairs on its
79
+ own when it starts, through the start hook. The tab opens in the kitty whose window has the focus, else the one
80
+ started last, and never takes the focus. `/claude` then says **Paired · started by chi** with the tab's title and
81
+ **Show** (`/claude show`, which brings the tab to the front); once the tab is closed it says so, with **Start one in
82
+ kitty**. It needs kitty with remote control (`kitty.listen_on`, [configuration.md](configuration.md#desktop-helper-agents-in-kitty-and-tmux)):
83
+ without it, "kitty isn't running or `kitty.listen_on` isn't set", and nothing waits. It refuses on a session already
84
+ paired, and without the start hook ("install the start hook first"). From the phone it works the same while kitty runs
85
+ on the working machine. `/codex start` opens Codex the same way (`bundles: codex-peer: start_command:`, default
86
+ `codex`) with the first prompt "pair with chi", which runs the skill's pair and so spends one Codex turn; it needs no
87
+ hook (with Codex's start hook, the hook pairs at that first message and the skill's pair says paired). Start, Show and pasting into a tab run only from your typing or tap: no tool call, `chi send`, agent, participant,
88
+ schedule or delegate reaches them. A second Start while the first tab is still starting is refused, two at the same
89
+ moment included (they take turns). A tab that closes at once (its command isn't found in the login shell's PATH: it
90
+ runs as `$SHELL -l -c "exec <start_command>"`) is said so, and leaves no wait; after its Claude ended, the status card's
91
+ title reads `claude-peer: ended` and the chip `Claude · ended`.
92
+
93
+ Who is here is a folder any local process can write (it sits in the mailbox root): a row shows nothing a forger
94
+ can't set, and your Pair is what trusts it, as the pair and say commands are unauthenticated already.
21
95
  - `chi peer unpair claude <id>` ends the pairing. Its messages stay, and chi still reads those it hasn't. The
22
96
  peer chip's **Unpair** does the same.
23
- - `chi peer pair` refuses a session whose live worker is older than the mailbox ("restart the session"), and a
24
- session that was continued (it names the new id).
97
+ - `chi peer pair` refuses a session whose live worker is older than the mailbox ("restart the session"). Pairing a
98
+ session that was continued pairs its chain's live link and names it (`3f2a9c1e paired with Claude (session
99
+ 1a2b3c4d continued as 3f2a9c1e)`); `unpair` of one ends the old link's pairing and the live link's, and `ls` lists
100
+ the live link's peers, naming it.
25
101
 
26
102
  Which agents are peers is the bundles' to say (`chi.peer NAME` in plugin code), never a file's. A message from
27
103
  a name no loaded bundle declared is refused with "no bundle in that session declares peer NAME".
@@ -29,11 +105,13 @@ a name no loaded bundle declared is refused with "no bundle in that session decl
29
105
  ## Saying something: `chi peer say`
30
106
 
31
107
  ```sh
32
- chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8 <<'EOF'
33
- <the full answer>
34
- EOF
108
+ chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8 < answer.md
35
109
  ```
36
110
 
111
+ The skills write the answer to a file first (`$TMPDIR/chi-peer/answer-<ref>.md`) and say it from there, so a say
112
+ refused with "try again in a moment" is run again as it is, without writing the answer twice. They never run it
113
+ again after a `#N received` line or a failure with no line: nothing stops a second write of the same message.
114
+
37
115
  - `--wake` or `--nowake` is required: `--wake` asks chi to run a turn for it (a validate's answer, a question's,
38
116
  a message chi should act on now); `--nowake` leaves it as a note for chi's next turn.
39
117
  - `--re` names the send it answers (the `ref:` line of chi's message); leave it out for a message the peer starts.
@@ -45,19 +123,21 @@ It prints one line, which the skills tell the agent to quote to its user:
45
123
  | What chi did | The line |
46
124
  |---|---|
47
125
  | started a turn | `#12 received · woke chi` |
48
- | held it | `#12 received · held: 3 peer turns in a row (peer.turns) · waits for the user's next message` |
126
+ | held it | `#12 received · held: 3 peer turns in a row (peer.turns) · waits for the user's next message`, `held: chi's cache is cold · waits for the user's next message` |
49
127
  | took it as background | `#12 received · noted` |
50
- | can't say yet | `#12 received · chi is in a turn: it reads this when the turn ends`, `chi is stopped: …`, `this session is archived: …`, `chi's worker isn't running and couldn't be started from here: …` |
128
+ | can't say yet | `#12 received · chi is in a turn: it reads this when the turn ends`, `chi is stopped: it reads this when its user starts it (chi --resume 1a2b3c4d)` (a peer's say never starts a stopped session), `this session is archived: …`, `chi's worker isn't running and couldn't be started from here: …` |
51
129
  | nothing within the wait | `#12 received · no answer from chi yet` |
52
130
  | refused | `refused: no bundle in that session declares peer claude` (exit 1) |
53
131
 
54
- Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A held message is not
132
+ Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A say to a session that was
133
+ continued goes to its chain's live link (below), and its line ends `· session continued as 3f2a9c1e: answer there`. A held message is not
55
134
  lost: it is a note, and the user's next message lets chi read it. The skills say not to send it again, and not to
56
135
  `chi send` past it.
57
136
 
58
- A say is refused, with nothing written, for: no such session; a session being deleted; a continued one (`this
59
- session was continued as <id>: say it there`); one being continued right now (`this session is being continued as
60
- <id>: say it there in a moment`: its new link is not saved yet); one busy with another change (`this session is busy
137
+ A say is refused, with nothing written, for: no such session; a session being deleted; a continued one whose live
138
+ link isn't paired (a chain an older chi continued: `this session was continued as <id>: say it there`, naming that
139
+ link); one being continued right now (`this session is being continued as
140
+ <id>: say it again in a moment`: its new link is not saved yet); one busy with another change (`this session is busy
61
141
  with another change; try again in a moment`); not paired (`not paired: run the pair script`); an older worker
62
142
  (`restart the session`); 200 messages chi hasn't read yet.
63
143
 
@@ -71,8 +151,8 @@ The worker takes the peer's messages in order, between turns, and writes one rec
71
151
  - then `read` once a turn starts with it in the conversation, and `completed`, `failed` or `stopped` when that
72
152
  turn ends.
73
153
 
74
- Held reasons: `off` (`peer.turns` is 0), `paused` (after a failed wake turn), `continue` (a continue offer waits),
75
- `max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
154
+ Held reasons: `off` (`peer.turns` is 0), `cold` (chi's cache is cold: below), `paused` (after a failed wake turn),
155
+ `continue` (a continue offer waits), `max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
76
156
 
77
157
  `chi peer ls <id>` lists each peer, its pairing and its newest messages with their receipts; the peer chip's list
78
158
  shows the same words (`held · peer turns`, `read`, `completed`).
@@ -83,7 +163,42 @@ A peer's messages may wake chi `peer.turns` times in a row (default 3) with noth
83
163
  `session.max_wakes`. Past it they wait as notes, the say's line says so, and the TUI and the web say it once. A
84
164
  message whose summary ends its round with `VERDICT OK` wakes chi once more to close it, held only by
85
165
  `session.max_wakes`. Only input typed in the web or a TUI resets the count: `chi send` does not, since a peer can
86
- run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` is attached context's only.
166
+ run it. The count outlives the worker (an idle exit, a restart), so a peer that speaks every 40 minutes is held after
167
+ `peer.turns` wakes as one that speaks every minute is. `peer.turns: 0` means a peer's message never wakes chi.
168
+ `context.wake` is attached context's only.
169
+
170
+ ## A cold cache
171
+
172
+ A turn on a cold prompt cache reads the whole conversation again at the write price, where a warm one pays a tenth of
173
+ it. So a message the peer starts on its own (no `--re` naming one of chi's sends) and a `VERDICT OK` closer don't wake
174
+ chi while its cache is cold: they wait as notes for the user's next message (`held: chi's cache is cold`, the chip's
175
+ `held · cold`, and the TUI and the web say it once). "Cold" is all of:
176
+
177
+ - chi's model is a Claude model on a remote host, whose requests carry cache breakpoints, so the host keeps a cache
178
+ with a TTL (through an OpenAI-style host such as OpenRouter, or a remote `api: anthropic` host whose dialect sends
179
+ them); a local model has no remote TTL and is never held, whatever its API;
180
+ - the last turn ended longer ago than `cache.ttl` (5 minutes, or an hour with `1h`);
181
+ - the conversation is over 20,000 tokens (the size the last turn saved); a smaller one is cheap to read again.
182
+
183
+ An answer chi asked for (its `--re` names a send chi made to that peer, in this session or the one it continues,
184
+ that no earlier message answered) wakes chi cold or warm, and so does a batch holding one. Anything chi can't tell (no turn yet, no saved size) counts
185
+ as warm.
186
+
187
+ ## Quiet pairings
188
+
189
+ When chi's model sends to a peer it hasn't exchanged anything with for `peer.quiet_minutes` (30 by default; 0 turns
190
+ this off), the peer's own session may have gone cold too, so you decide. "Exchanged" is the pairing, a send to it, or
191
+ a message from it, also in the session this one continues. Then:
192
+
193
+ - in a turn you started from the web or a TUI, you get a question: "Claude last heard from chi 2 h ago: its session
194
+ may be cold. Send?" (Send / Don't send; a parent agent can't answer Send). Don't send holds for the rest of that
195
+ turn, so the model trying again doesn't ask again;
196
+ - in any other turn (a schedule's, a delegate's, a wake turn, `chi send`'s) nobody is there to answer: the send is
197
+ refused at once and the model is told you decide;
198
+ - a `/claude …` or `/codex …` you type never asks.
199
+
200
+ The pairing stays paired; `/claude` (or `/codex`) shows `quiet 2 h: a send from the model asks first`. The timer
201
+ also asks when the peer was busy with its own work and is warm: it can't see the peer's cache.
87
202
 
88
203
  `peer.turns` replaced `context.peer_turns` (no alias): rename it in config.yml.
89
204
 
@@ -95,19 +210,27 @@ run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` i
95
210
  (`serial`, `offset`, `limit`), which pages it.
96
211
  - 200 messages chi hasn't read: further says are refused until it reads them.
97
212
  - The mailbox keeps every message chi hasn't taken, and the newest 50 it has.
98
- - A continued message is cut at 4 KiB in the new link; run `chi peer ls <previous id>` to read the rest.
99
- - A `chi peer say` sent at the very moment of a continue may stay with the previous session; run
100
- `chi peer ls <previous id>` to read it there.
213
+ - A continued message is cut at 4 KiB in the new link; the rest stays in the previous session's mailbox, and the
214
+ cut says how chi reads it whole: `claude_read(serial: N, box: "<previous id8>")` (`codex_read` for Codex), which
215
+ reads from the session this one continues.
216
+ - A `chi peer say` at the moment of a continue is refused (`being continued as <id>: say it again in a moment`, or
217
+ busy), nothing written, rather than landing in a mailbox the carry already read (the say holds the session's
218
+ transition lock shared); the peer runs it again.
101
219
 
102
220
  ## Continuing a session
103
221
 
104
- A continue leaves the pairing and the mailbox with the previous link:
222
+ The pairing follows the chain, and the peer does nothing:
223
+
224
+ - a continue copies each pairing to the new link as it is (the address, who paired, when), so chi's next send goes
225
+ to the same Claude or Codex session, with the new id in its header;
226
+ - a say, pair, unpair or `ls` to the old id runs on the chain's live link, and the say's line says so
227
+ (`session continued as <id8>: answer there`); a pairing the continue couldn't copy (a chain an older chi
228
+ continued) is refused as before, naming the live link, and the skill pairs again there;
229
+ - the messages stay with the previous link, and those it hadn't read (never taken, or held or noted and not yet
230
+ read by a turn) reach the new link as **one** note, each text in its peer block.
105
231
 
106
- - the new link's `/claude` init task posts the peer a `moved` message with the new id, and the peer pairs again
107
- with it, the way it paired before (its skill knows how);
108
- - a say to the old id is refused, naming the new id;
109
- - the messages the previous link hadn't read (never taken, or held or noted and not yet read by a turn) reach the
110
- new link as **one** note, each text in its peer block.
232
+ An answer chi asked for that reaches a new link before its first turn waits as a note, held `before a turn`, as it
233
+ does for any link with no turn yet (a Continue with no prompt): the user's first message lets chi read it.
111
234
 
112
235
  ## Codex's sandbox
113
236