samagotchi 0.171.0 → 0.172.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 (202) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -1
  3. data/bin/chi +6 -4
  4. data/docs/architecture.md +24 -7
  5. data/docs/bundles.md +4 -21
  6. data/docs/cli.md +50 -80
  7. data/docs/configuration.md +11 -13
  8. data/docs/context.md +5 -6
  9. data/docs/guardrails.md +57 -96
  10. data/docs/hooks.md +3 -4
  11. data/docs/internals/attached-context.md +6 -7
  12. data/docs/internals/background-tasks.md +4 -3
  13. data/docs/internals/bridge.md +29 -3
  14. data/docs/internals/engine.md +21 -9
  15. data/docs/internals/objectives.md +3 -5
  16. data/docs/internals/participants.md +118 -143
  17. data/docs/internals/prompt-caching.md +4 -5
  18. data/docs/internals/web-frontend.md +33 -14
  19. data/docs/internals/working-set.md +7 -5
  20. data/docs/memory.md +1 -1
  21. data/docs/plugins.md +2 -16
  22. data/docs/scheduling.md +1 -1
  23. data/docs/sessions.md +15 -49
  24. data/docs/sub-agent.md +2 -2
  25. data/docs/system-one.md +2 -2
  26. data/docs/testing.md +56 -7
  27. data/lib/samagotchi/bridge/card_store.rb +1 -0
  28. data/lib/samagotchi/bridge/sse_writer.rb +1 -0
  29. data/lib/samagotchi/bridge/turn_accumulator.rb +0 -1
  30. data/lib/samagotchi/bridge.rb +26 -9
  31. data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
  32. data/lib/samagotchi/bundle_command/test_run.rb +1 -0
  33. data/lib/samagotchi/bundle_command/try/run.rb +1 -0
  34. data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
  35. data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
  36. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
  37. data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
  38. data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
  39. data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
  40. data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
  41. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  42. data/lib/samagotchi/client_id.rb +126 -67
  43. data/lib/samagotchi/command_intake.rb +15 -3
  44. data/lib/samagotchi/compat.rb +6 -1
  45. data/lib/samagotchi/context_candidate_choice.rb +1 -3
  46. data/lib/samagotchi/context_candidates.rb +3 -4
  47. data/lib/samagotchi/continue_offer.rb +9 -2
  48. data/lib/samagotchi/delivery.rb +23 -12
  49. data/lib/samagotchi/empty_answer_error.rb +5 -0
  50. data/lib/samagotchi/engine/cards.rb +3 -0
  51. data/lib/samagotchi/engine/context_judge.rb +5 -3
  52. data/lib/samagotchi/engine/events.rb +4 -0
  53. data/lib/samagotchi/engine/hooks.rb +3 -0
  54. data/lib/samagotchi/engine/messages.rb +5 -0
  55. data/lib/samagotchi/engine/model_settings.rb +2 -0
  56. data/lib/samagotchi/engine/models.rb +10 -0
  57. data/lib/samagotchi/engine/objectives.rb +6 -0
  58. data/lib/samagotchi/engine/participants.rb +18 -14
  59. data/lib/samagotchi/engine/plugins.rb +8 -0
  60. data/lib/samagotchi/engine/questions.rb +3 -0
  61. data/lib/samagotchi/engine/recap.rb +1 -0
  62. data/lib/samagotchi/engine/session.rb +4 -0
  63. data/lib/samagotchi/engine/side_requests.rb +9 -0
  64. data/lib/samagotchi/engine/steering.rb +2 -0
  65. data/lib/samagotchi/engine/toolkit.rb +5 -0
  66. data/lib/samagotchi/engine/turn_end.rb +7 -0
  67. data/lib/samagotchi/engine/turn_helpers.rb +8 -0
  68. data/lib/samagotchi/engine/verify.rb +2 -0
  69. data/lib/samagotchi/engine.rb +3 -2
  70. data/lib/samagotchi/grants.rb +28 -22
  71. data/lib/samagotchi/guardrail_wiring.rb +23 -18
  72. data/lib/samagotchi/guardrails/approval_use.rb +59 -0
  73. data/lib/samagotchi/guardrails/approvals.rb +9 -11
  74. data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
  75. data/lib/samagotchi/guardrails/gate.rb +10 -5
  76. data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
  77. data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
  78. data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
  79. data/lib/samagotchi/guardrails/review_paths.rb +2 -3
  80. data/lib/samagotchi/guardrails.rb +1 -1
  81. data/lib/samagotchi/llm_context_strategy.rb +2 -0
  82. data/lib/samagotchi/objectives.rb +1 -4
  83. data/lib/samagotchi/objectives_audit.rb +1 -1
  84. data/lib/samagotchi/objectives_track.rb +1 -1
  85. data/lib/samagotchi/owner_prompt.rb +3 -6
  86. data/lib/samagotchi/parent_report.rb +1 -0
  87. data/lib/samagotchi/participant_messages.rb +9 -4
  88. data/lib/samagotchi/participant_turn_mode.rb +50 -0
  89. data/lib/samagotchi/participants.rb +21 -12
  90. data/lib/samagotchi/participants_watch.rb +2 -2
  91. data/lib/samagotchi/plugin/api.rb +2 -2
  92. data/lib/samagotchi/plugin/attached_context.rb +1 -1
  93. data/lib/samagotchi/plugin/context.rb +0 -4
  94. data/lib/samagotchi/plugin/sessions.rb +1 -25
  95. data/lib/samagotchi/run_options.rb +2 -3
  96. data/lib/samagotchi/send_command.rb +10 -10
  97. data/lib/samagotchi/session.rb +0 -3
  98. data/lib/samagotchi/session_access/contract.rb +1 -10
  99. data/lib/samagotchi/session_access/local.rb +10 -23
  100. data/lib/samagotchi/session_access/remote.rb +9 -20
  101. data/lib/samagotchi/session_access.rb +12 -16
  102. data/lib/samagotchi/session_chain.rb +4 -6
  103. data/lib/samagotchi/session_commands.rb +6 -3
  104. data/lib/samagotchi/session_continue.rb +1 -2
  105. data/lib/samagotchi/session_manager/delivery.rb +25 -5
  106. data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
  107. data/lib/samagotchi/session_manager/listing.rb +5 -0
  108. data/lib/samagotchi/session_manager/spawn.rb +2 -2
  109. data/lib/samagotchi/session_manager/worker_command.rb +9 -0
  110. data/lib/samagotchi/session_participants.rb +12 -8
  111. data/lib/samagotchi/session_review.rb +5 -7
  112. data/lib/samagotchi/session_stores.rb +3 -3
  113. data/lib/samagotchi/share_command.rb +10 -12
  114. data/lib/samagotchi/share_terms.rb +41 -0
  115. data/lib/samagotchi/steer.rb +8 -14
  116. data/lib/samagotchi/system_prompt.rb +16 -25
  117. data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
  118. data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
  119. data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
  120. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
  121. data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
  122. data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
  123. data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
  124. data/lib/samagotchi/terminal_ui.rb +1 -2
  125. data/lib/samagotchi/testing/sessions.rb +2 -10
  126. data/lib/samagotchi/tool_runner.rb +8 -9
  127. data/lib/samagotchi/toolkit.rb +4 -22
  128. data/lib/samagotchi/toolkit_suggest.rb +3 -3
  129. data/lib/samagotchi/tools/deferred_tools.rb +1 -0
  130. data/lib/samagotchi/tools/execute.rb +11 -45
  131. data/lib/samagotchi/tools/leftovers.rb +122 -0
  132. data/lib/samagotchi/tools/memory.rb +70 -26
  133. data/lib/samagotchi/tools/task_get.rb +1 -0
  134. data/lib/samagotchi/tools/task_list.rb +3 -2
  135. data/lib/samagotchi/tools/task_record.rb +6 -4
  136. data/lib/samagotchi/tools/task_runtime.rb +199 -20
  137. data/lib/samagotchi/tools/task_wait.rb +4 -3
  138. data/lib/samagotchi/turn_context.rb +1 -1
  139. data/lib/samagotchi/turn_origin.rb +1 -1
  140. data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
  141. data/lib/samagotchi/turn_stages/objectives.rb +2 -2
  142. data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
  143. data/lib/samagotchi/update_hint.rb +3 -1
  144. data/lib/samagotchi/verify_fresh.rb +1 -1
  145. data/lib/samagotchi/verify_fresh_origin.rb +13 -11
  146. data/lib/samagotchi/version.rb +1 -1
  147. data/lib/samagotchi/web/app.rb +3 -5
  148. data/lib/samagotchi/web/participant_access.rb +14 -18
  149. data/lib/samagotchi/web/participant_review.rb +3 -4
  150. data/lib/samagotchi/web/participant_show.rb +4 -3
  151. data/lib/samagotchi/web/participant_view.rb +3 -3
  152. data/lib/samagotchi/web/participants_admin.rb +21 -40
  153. data/lib/samagotchi/web/public/app.js +5 -47
  154. data/lib/samagotchi/web/public/data.js +2 -10
  155. data/lib/samagotchi/web/public/delivery_line.js +17 -60
  156. data/lib/samagotchi/web/public/index.html +10 -30
  157. data/lib/samagotchi/web/public/live_turn.js +1 -1
  158. data/lib/samagotchi/web/public/owner_claim.js +2 -2
  159. data/lib/samagotchi/web/public/participant_bar.js +4 -5
  160. data/lib/samagotchi/web/public/participant_names.js +14 -10
  161. data/lib/samagotchi/web/public/participants_panel.js +29 -62
  162. data/lib/samagotchi/web/public/reload_check.js +2 -3
  163. data/lib/samagotchi/web/public/send_turn.js +4 -23
  164. data/lib/samagotchi/web/public/session_actions.js +4 -45
  165. data/lib/samagotchi/web/public/session_fields.js +0 -1
  166. data/lib/samagotchi/web/public/session_state.js +0 -3
  167. data/lib/samagotchi/web/public/session_view.js +2 -3
  168. data/lib/samagotchi/web/public/settings_panel.js +4 -18
  169. data/lib/samagotchi/web/public/stage_answer.js +56 -0
  170. data/lib/samagotchi/web/public/stage_asking.js +1 -1
  171. data/lib/samagotchi/web/public/stage_cloud.js +93 -0
  172. data/lib/samagotchi/web/public/stage_dom.js +100 -0
  173. data/lib/samagotchi/web/public/stage_handoff.js +154 -0
  174. data/lib/samagotchi/web/public/stage_pager.js +59 -0
  175. data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
  176. data/lib/samagotchi/web/public/stage_view.js +90 -411
  177. data/lib/samagotchi/web/public/start_page.js +12 -33
  178. data/lib/samagotchi/web/public/start_settings.js +24 -78
  179. data/lib/samagotchi/web/public/start_toolkit.js +6 -10
  180. data/lib/samagotchi/web/public/stream_handlers.js +1 -9
  181. data/lib/samagotchi/web/public/turn_block.js +3 -7
  182. data/lib/samagotchi/web/public/turn_events.js +15 -6
  183. data/lib/samagotchi/web/public/turn_pieces.js +3 -4
  184. data/lib/samagotchi/web/public/viewer_self.js +8 -2
  185. data/lib/samagotchi/web/qr.rb +1 -1
  186. data/lib/samagotchi/web/session_control.rb +3 -1
  187. data/lib/samagotchi/web/session_create.rb +5 -71
  188. data/lib/samagotchi/web/session_summary.rb +1 -4
  189. data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
  190. data/lib/samagotchi/web/viewer.rb +3 -3
  191. data/lib/samagotchi/worker.rb +16 -14
  192. data/lib/samagotchi/worker_inbound.rb +4 -3
  193. data/lib/samagotchi/worker_link.rb +17 -0
  194. data/lib/samagotchi/working_set.rb +87 -28
  195. metadata +13 -8
  196. data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
  197. data/lib/samagotchi/participant_mode.rb +0 -86
  198. data/lib/samagotchi/review_apply.rb +0 -131
  199. data/lib/samagotchi/review_command.rb +0 -123
  200. data/lib/samagotchi/review_start.rb +0 -196
  201. data/lib/samagotchi/web/public/review_apply.js +0 -34
  202. data/lib/samagotchi/web/public/review_start.js +0 -55
@@ -11,7 +11,7 @@ require_relative "../session_inbox"
11
11
  require_relative "../session_metrics"
12
12
  require_relative "../parent_report"
13
13
  require_relative "../participant_messages"
14
- require_relative "../participant_mode"
14
+ require_relative "../worker_link"
15
15
  require_relative "../participant_revise"
16
16
  require_relative "../participants"
17
17
  require_relative "../session"
@@ -19,12 +19,13 @@ require_relative "../turn_checkpoint"
19
19
  require_relative "../turn_origin"
20
20
  require_relative "../verify_fresh"
21
21
  require_relative "../log"
22
+ require_relative "proxy_gate"
22
23
 
23
24
  module Samagotchi
24
25
  module Web
25
26
  # What a participant (a Grants token) may do in chi web, mixed into
26
27
  # App: the gate's lookup of their grant, the refusals that are theirs
27
- # (token_revoked, token_expired with its ended page, token_bound for a
28
+ # (token_revoked, token_expired, token_outdated with its ended page, token_bound for a
28
29
  # link bound to another account, another session's
29
30
  # 404, not_permitted by role), the trimmed answers of their own routes
30
31
  # (info, the session, resolve, a wait on their turn), their turns, and
@@ -44,7 +45,8 @@ module Samagotchi
44
45
 
45
46
  ENDED = {
46
47
  revoked: ["token_revoked", ParticipantMessages::TOKEN_REVOKED],
47
- expired: ["token_expired", ParticipantMessages::TOKEN_EXPIRED]
48
+ expired: ["token_expired", ParticipantMessages::TOKEN_EXPIRED],
49
+ outdated: ["token_outdated", ParticipantMessages::TOKEN_OUTDATED]
48
50
  }.freeze
49
51
  NOT_PERMITTED = ParticipantMessages::NOT_PERMITTED
50
52
 
@@ -139,7 +141,7 @@ module Samagotchi
139
141
  grant.with(revoked_at: @grants.now.utc.iso8601, revoked_by: by)
140
142
  end
141
143
 
142
- # 401 token_revoked / token_expired for an ended grant's token (the
144
+ # 401 token_revoked / token_expired / token_outdated for an ended grant's token (the
143
145
  # page's HTML says the same words), nil when none was presented.
144
146
  def grant_ended_response(req)
145
147
  grant, state = req.env[ENDED_GRANT_ENV]
@@ -240,13 +242,7 @@ module Samagotchi
240
242
  # first prompt's opening words: the conversation).
241
243
  def participant_title(session)
242
244
  title = session.title.to_s.strip
243
- return title unless title.empty?
244
-
245
- # A review session's subjects are what participants read anyway.
246
- subjects = session.review&.subjects || []
247
- return UNTITLED if subjects.empty?
248
-
249
- "review of #{subjects.first}#{" +#{subjects.size - 1}" if subjects.size > 1}"
245
+ title.empty? ? UNTITLED : title
250
246
  end
251
247
 
252
248
  UNTITLED = "an untitled session"
@@ -254,7 +250,7 @@ module Samagotchi
254
250
  def participant_names(id)
255
251
  now = @grants.now
256
252
  Participants.read(id, state_dir: default_state_dir).select { |entry| entry.active?(now) }
257
- .map { |entry| { id: entry.id, name: entry.name, kind: entry.kind, role: entry.role } }
253
+ .map { |entry| { id: entry.id, name: entry.name, role: entry.role } }
258
254
  end
259
255
 
260
256
  # POST …/cancel from a participant: only their own running turn, named
@@ -287,7 +283,7 @@ module Samagotchi
287
283
  # would stop whatever runs, the owner's next turn too.
288
284
  def cancels_by_turn_id?(id)
289
285
  session = @session_class.load(id, state_dir: default_state_dir)
290
- Array(ParticipantMode.live_features(session, default_state_dir)).include?(Delivery::CANCEL_TURN_ID_FEATURE)
286
+ Array(WorkerLink.live_features(session.id, state_dir: default_state_dir)).include?(Delivery::CANCEL_TURN_ID_FEATURE)
291
287
  end
292
288
 
293
289
  # 409 cancel_unavailable, audited; nothing is relayed.
@@ -310,7 +306,7 @@ module Samagotchi
310
306
  # POST /api/sessions/:id/turn from a participant: their turn (D6,
311
307
  # D10). Of the body only the prompt, the delivery and images they
312
308
  # uploaded count: the author and client id are the grant's
313
- # (review:<id>), no no_interrupt; the owner's prompt history never
309
+ # (participant:<id>), no no_interrupt; the owner's prompt history never
314
310
  # sees it. The delivery
315
311
  # is queue or next step (none: next step): the worker puts a next-step
316
312
  # message into a running turn only when that turn is theirs, else it
@@ -337,7 +333,7 @@ module Samagotchi
337
333
 
338
334
  # A Verify turn's claim, a Revise turn's draft of their own answer.
339
335
  delivery = Delivery.queue?(body["delivery"]) ? Delivery::QUEUE : Delivery::NEXT_STEP
340
- result = SessionManager.deliver_turn(id, prompt: prompt, client_id: ClientId.review(grant.id),
336
+ result = SessionManager.deliver_turn(id, prompt: prompt, client_id: ClientId.participant(grant.id),
341
337
  delivery: delivery, author: grant.author,
342
338
  **(images.empty? ? {} : { images: images }),
343
339
  anchors: anchors,
@@ -369,7 +365,7 @@ module Samagotchi
369
365
  return nil unless anchors.revises
370
366
 
371
367
  session = @session_class.load(id, state_dir: default_state_dir)
372
- features = ParticipantMode.live_features(session, default_state_dir)
368
+ features = WorkerLink.live_features(session.id, state_dir: default_state_dir)
373
369
  if features && !features.include?(ReviseAnchor::PARTICIPANT_FEATURE)
374
370
  return [409, "revise_unavailable", ParticipantMessages::REVISE_UNAVAILABLE]
375
371
  end
@@ -589,7 +585,7 @@ module Samagotchi
589
585
  <!doctype html>
590
586
  <html lang="en"><head><meta charset="utf-8">
591
587
  <meta name="viewport" content="width=device-width, initial-scale=1">
592
- <title>chi: review link ended</title>
588
+ <title>chi: link ended</title>
593
589
  <style>#{PAGE_STYLE}</style></head>
594
590
  <body>
595
591
  <h1>chi</h1>
@@ -611,7 +607,7 @@ module Samagotchi
611
607
  </script>
612
608
  </body></html>
613
609
  HTML
614
- BOUND_PAGE = ENDED_PAGE.sub("<title>chi: review link ended</title>", "<title>chi: review link for another account</title>")
610
+ BOUND_PAGE = ENDED_PAGE.sub("<title>chi: link ended</title>", "<title>chi: link for another account</title>")
615
611
  end
616
612
  end
617
613
  end
@@ -5,7 +5,6 @@ require_relative "token"
5
5
  require_relative "participant_stream_filter"
6
6
  require_relative "../participant_exposure"
7
7
  require_relative "../session_metrics"
8
- require_relative "../participant_mode"
9
8
  require_relative "../verify_fresh"
10
9
 
11
10
  module Samagotchi
@@ -80,9 +79,9 @@ module Samagotchi
80
79
  def review_viewer(req, id, session:, state:, queued:, viewer:)
81
80
  grant = principal(req).grant
82
81
  capped = !participant_cap_refusal(grant).nil?
83
- # Theirs: pair only when their grant was issued to act (ParticipantMode.live_for).
84
- mode = ParticipantMode.live_for(session, grant, state_dir: default_state_dir).to_s
85
- { kind: "participant", id: grant.id, name: grant.name, participant_kind: grant.kind, mode: mode, can_comment: !capped,
82
+ # Their turns act under the owner's rules (every active grant is pair).
83
+ mode = Grants::PAIR_MODE
84
+ { kind: "participant", id: grant.id, name: grant.name, mode: mode, can_comment: !capped,
86
85
  cap_reached: capped, session_id: id,
87
86
  usage: review_usage(grant, session: session, state: state, queued: queued, viewer: viewer) }
88
87
  end
@@ -4,9 +4,10 @@ require "json"
4
4
  require_relative "participant_view"
5
5
  require_relative "viewer"
6
6
  require_relative "../bridge/turn_accumulator"
7
- require_relative "../participant_mode"
7
+ require_relative "../worker_link"
8
8
  require_relative "../verify_anchor"
9
9
  require_relative "../verify_fresh"
10
+ require_relative "capabilities"
10
11
 
11
12
  module Samagotchi
12
13
  module Web
@@ -40,7 +41,7 @@ module Samagotchi
40
41
  session = reads.session
41
42
  viewer = participant_viewer(req, session)
42
43
  turn_snapshot = reads.turn_snapshot
43
- features = ParticipantMode.live_features(session, default_state_dir)
44
+ features = WorkerLink.live_features(session.id, state_dir: default_state_dir)
44
45
  timing = participant_timing(reads.id, live_metrics: reads.state && reads.state["metrics"])
45
46
  raw = visible_replies(reads.raw_messages)
46
47
  drawn = drawn_lines(reads.id, raw, timing: {}, entries: [], cwd: session.working_directory,
@@ -110,7 +111,7 @@ module Samagotchi
110
111
  session = reads.session
111
112
  review = review_viewer(req, reads.id, session: session, state: reads.state, queued: queued, viewer: viewer)
112
113
  Viewer.for(principal(req)).to_h.merge(
113
- review.slice(:participant_kind, :mode, :cap_reached, :usage),
114
+ review.slice(:mode, :cap_reached, :usage),
114
115
  session_stopped: session.status == Session::STATUS_STOPPED,
115
116
  waiting_for_owner: participant_waiting(reads.turn_snapshot)
116
117
  )
@@ -3,7 +3,6 @@
3
3
  require_relative "../output_formatter"
4
4
  require_relative "../steer"
5
5
  require_relative "../turn_origin"
6
- require_relative "../participant_mode"
7
6
  require_relative "../revise_anchor"
8
7
  require_relative "../verify_anchor"
9
8
  require_relative "../redact"
@@ -33,8 +32,9 @@ module Samagotchi
33
32
  # home folder), defence in depth only: the allowlist is the control.
34
33
  # Pure: no I/O; keys of what comes in may be strings (JSON) or symbols.
35
34
  module ParticipantView
36
- # A turn's participant_mode values the view passes on (ParticipantMode).
37
- PARTICIPANT_MODES = [ParticipantMode::REVIEW.to_s, ParticipantMode::PAIR.to_s].freeze
35
+ # A turn's participant_mode values the view passes on: "pair", and an
36
+ # older chi's "review" (its saved turns keep their stamp).
37
+ PARTICIPANT_MODES = %w[review pair].freeze
38
38
 
39
39
  # The stream's event types a participant gets, each rebuilt by the
40
40
  # method named. Every other type is dropped.
@@ -2,17 +2,16 @@
2
2
 
3
3
  require_relative "../grants"
4
4
  require_relative "qr"
5
- require_relative "../review_start"
6
- require_relative "../review_apply"
5
+ require_relative "../share_terms"
7
6
  require_relative "../session_metrics"
8
7
  require_relative "../participants"
9
8
  require_relative "../session"
9
+ require_relative "link_codes"
10
10
 
11
11
  module Samagotchi
12
12
  module Web
13
13
  # The owner's routes for a session's participants, mixed into App:
14
- # invite, list, revoke, a participant's cap, and the review Apply (the
15
- # owner's turn quoting a review turn's proposal). What a participant
14
+ # invite, list, revoke and a participant's cap. What a participant
16
15
  # may do themselves is ParticipantAccess's. See
17
16
  # docs/internals/participants.md.
18
17
  module ParticipantsAdmin
@@ -21,12 +20,11 @@ module Samagotchi
21
20
  # GET /api/sessions/:id/participants, GET /api/participants: the
22
21
  # grants (one session's, or every one), in every state, never a token
23
22
  # or digest. One session's also carries +warning+: the share warning
24
- # for a session that isn't a review session (ReviewStart.share_warning,
25
- # null for one), which the panel shows before its Invite; and
26
- # +identity_header+: the header this chi web's auth proxy names the
27
- # signed-in user in (null without one), for the Invite's email field;
28
- # +mode+: what a participant invited now gets, "pair" or "review"
29
- # (ReviewStart.share_terms), for the panel's words; +link_base+: where
23
+ # (ShareTerms#warning: what a participant's turns do there, or why no
24
+ # one can be invited until the session restarts), which the panel shows
25
+ # before its Invite; +identity_header+: the header this chi web's auth
26
+ # proxy names the signed-in user in (null without one), for the
27
+ # Invite's email field; and +link_base+: where
30
28
  # a participant's link opens (participant_base), for a claim link
31
29
  # (claim_link.js) the participant's browser opens with its cookie.
32
30
  def handle_participants_list(req, id = nil)
@@ -34,8 +32,8 @@ module Samagotchi
34
32
  grants = @grants.list(session_id: id).map { |grant| grant.public_h(now) }
35
33
  return json_response(200, { participants: grants }) unless id
36
34
 
37
- terms = ReviewStart.share_terms(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
38
- json_response(200, { participants: with_spend(id, grants), warning: terms.warning, mode: terms.mode.to_s,
35
+ terms = ShareTerms.of(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
36
+ json_response(200, { participants: with_spend(id, grants), warning: terms.warning,
39
37
  identity_header: @public_url&.identity_header, link_base: participant_base(req) })
40
38
  rescue Grants::Unwritable => e
41
39
  grants_unwritable(e)
@@ -57,12 +55,12 @@ module Samagotchi
57
55
  end
58
56
  end
59
57
 
60
- # POST /api/sessions/:id/participants {name, kind?, ttl? (seconds),
58
+ # POST /api/sessions/:id/participants {name, ttl? (seconds),
61
59
  # cap? (dollars), identity? (an email: the grant is bound to it, only
62
60
  # behind an auth proxy with an identity header)}: a new grant. The
63
61
  # answer carries the token and the link once (chi keeps only its
64
- # digest), and +warning+ for a session that isn't a review session
65
- # (ReviewStart.share_warning; null for one).
62
+ # digest), and +warning+ (ShareTerms#warning); 409 worker_too_old
63
+ # while the session's live worker would refuse their turns.
66
64
  def handle_participants_invite(req, id)
67
65
  body = body_hash(req) or return error_response(400, "invalid_json", "invalid JSON body")
68
66
  ttl = body["ttl"]
@@ -71,12 +69,14 @@ module Samagotchi
71
69
  cap = body["cap"]
72
70
  return error_response(400, "invalid_participant", Grants::CAP_RANGE) unless cap.nil? || Grants.cap?(cap)
73
71
 
74
- # The grant is stamped pair only when the warning that comes back says
75
- # their turns act (one read: ReviewStart.share_terms).
76
- terms = ReviewStart.share_terms(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
77
- issued = Participants.invite(@grants, session_id: id, name: body["name"], kind: (body["kind"] || "human").to_s,
78
- ttl: ttl, cap: cap, identity: body["identity"], public_url: @public_url,
79
- mode: terms.grant_mode, state_dir: default_state_dir)
72
+ # No link while the live worker would refuse every turn of theirs
73
+ # (one read: ShareTerms.of, the warning that comes back).
74
+ terms = ShareTerms.of(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
75
+ return error_response(409, "worker_too_old", terms.refusal) if terms.refusal
76
+
77
+ # An older chi --remote share --agent's kind is ignored.
78
+ issued = Participants.invite(@grants, session_id: id, name: body["name"], ttl: ttl, cap: cap, identity: body["identity"], public_url: @public_url,
79
+ state_dir: default_state_dir)
80
80
  link = participant_link(req, id, issued.token, expires_at: issued.grant.expires_at)
81
81
  json_response(201, { participant: issued.grant.public_h(@grants.now), token: issued.token,
82
82
  link: link, lan: !@lan.nil? || !@public_url.nil?, qr_svg: QR.svg(link), warning: terms.warning })
@@ -86,25 +86,6 @@ module Samagotchi
86
86
  grants_unwritable(e)
87
87
  end
88
88
 
89
- # GET /api/sessions/:id/apply[?turn=T] (owner): the owner's turn that
90
- # applies review turn T's proposal (ReviewApply: the reply quoted
91
- # under one line of the owner's), for the composer: never sent from
92
- # here. Without turn, the latest review turn with a reply. Read from
93
- # the live worker's messages, else the saved ones.
94
- # @return 200 {text, turn_id, author, author_name}; 404 not_found (no
95
- # such turn, or no review turn); 400 not_review_turn; 409 no_reply
96
- def handle_apply(req, id)
97
- session = @session_class.load(id, state_dir: default_state_dir)
98
- live = bridge_get_json(id, "snapshot")
99
- messages = live_or_saved(live && live["snapshot"], "messages") { session.messages }
100
- proposal = ReviewApply.find(messages, req.params["turn"])
101
- json_response(200, { text: ReviewApply.compose(proposal), turn_id: proposal.turn_id, author: proposal.author,
102
- author_name: proposal.author_name })
103
- rescue ReviewApply::Refused => e
104
- status = { not_found: 404, not_review_turn: 400, no_reply: 409 }.fetch(e.code)
105
- error_response(status, e.code.to_s, e.message)
106
- end
107
-
108
89
  # DELETE /api/sessions/:id/participants[?id=p_…], DELETE
109
90
  # /api/participants: revokes one participant, a session's or every
110
91
  # one's; their open streams end within a poll.
@@ -15,7 +15,6 @@ import {
15
15
  openEvents,
16
16
  createIdleSession,
17
17
  continueSession,
18
- startReview,
19
18
  uploadImage,
20
19
  listModels,
21
20
  fetchHistory,
@@ -47,7 +46,6 @@ import { createSessionStore } from "./session_store.js";
47
46
  import { createFeatureGates } from "./feature_gates.js";
48
47
  import { stillOn } from "./latest.js";
49
48
  import { normalize, cantText } from "./format.js";
50
- import { elementOf } from "./turn_html.js";
51
49
  import { createBubbles } from "./bubbles.js";
52
50
  import { createCardsPlace } from "./cards_place.js";
53
51
  import { createStageView } from "./stage_view.js";
@@ -63,7 +61,6 @@ import { openerFill, openTitle, restoredComposer } from "./chains.js";
63
61
  import { createTaskStopper } from "./task_stop.js";
64
62
  import { createSystemOneWrongAction } from "./system_one_wrong.js";
65
63
  import { appendQuote } from "./annotations.js";
66
- import { applyComposerText, applyRowTemplate, fetchApply } from "./review_apply.js";
67
64
  import { nameVerdictCards } from "./verdict_card.js";
68
65
  import { redrawFresh } from "./verdict_fresh.js";
69
66
  import { authorBadge, nameUnnamedBadges } from "./participant_names.js";
@@ -192,8 +189,6 @@ const participantsControl = viewer.can("participants_admin") ? createParticipant
192
189
  el: infoTextEl,
193
190
  session: () => store.selected,
194
191
  api: { list: listParticipants, invite: inviteParticipant, revoke: revokeParticipant, cap: setParticipantCap },
195
- startReview: (opts) => sessionActions.reviewSelected(opts),
196
- reviewing: () => sessionActions.reviewing.has(store.selected),
197
192
  // An older prompt drawn before the list came says "a participant": named now.
198
193
  onNames: () => {
199
194
  nameUnnamedBadges(document);
@@ -217,7 +212,6 @@ const startPage = createStartPage({
217
212
  settingsEl: $("#settingsNew"),
218
213
  llmContextEl: $("#llmContextNew"),
219
214
  thinkingEl: $("#thinkingNew"),
220
- reviewEl: $("#reviewNew"),
221
215
  toolkitBtnEl: $("#toolkitBtn"),
222
216
  toolkitEl: $("#toolkitNew"),
223
217
  selected: () => store.selected,
@@ -451,7 +445,6 @@ const deliveryControl = createDeliveryControl({
451
445
  composerEmpty: () => !composer.hasDraft(),
452
446
  history: viewer.can("prompt_history"),
453
447
  send: (delivery) => handleSendTurn({ delivery }),
454
- session: () => store.selected,
455
448
  });
456
449
 
457
450
  // This tab's id in the session's events: tells its own prompts from the
@@ -523,7 +516,6 @@ const sessionView = createSessionView({
523
516
  liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet, wsPreview, gapClock,
524
517
  bubbles, cards, markdown: markdownPlace,
525
518
  capabilities: () => pageCapabilities,
526
- can: viewer.can,
527
519
  page: {
528
520
  setReviseAnchor, renderInitRow, setMarkdownWarning, setCapabilities, findInTurnRoots, appendToHistory,
529
521
  setTurnRunning, mergeTurnTiming, applySessionPayload, turnEndStatus, replaceSelectedCard,
@@ -703,7 +695,7 @@ const sessionActions = createSessionActions({
703
695
  store,
704
696
  sessions: () => store.sessions,
705
697
  setSessions: (list) => store.update({ sessions: list }),
706
- api: { continueSession, startReview, archiveSession, unarchiveSession, deleteSession, stopSession,
698
+ api: { continueSession, archiveSession, unarchiveSession, deleteSession, stopSession,
707
699
  sessionHolds, stopSessionHolds },
708
700
  eventsLive: () => !!eventsControl,
709
701
  refresh,
@@ -910,11 +902,9 @@ function clearNotice() {
910
902
  }
911
903
  promptEl.addEventListener("input", clearNotice);
912
904
  promptEl.addEventListener("input", () => noteDraft());
913
- // An emptied composer lets go of its Apply turn, its Verify claim and its
914
- // Revise.
905
+ // An emptied composer lets go of its Verify claim and its Revise.
915
906
  promptEl.addEventListener("input", () => {
916
907
  if (promptEl.value.trim()) return;
917
- deliveryControl.release();
918
908
  ownerVerify.clear();
919
909
  setReviseAnchor(null);
920
910
  });
@@ -979,41 +969,11 @@ infoTextEl.addEventListener("click", async (e) => {
979
969
  showToast((await copyText(store.selected)) ? "Session id copied" : "Couldn't copy the session id");
980
970
  });
981
971
 
982
- // Apply (review_apply.js) under a participant's review turn that just
983
- // ended live ({turn_id, author, author_name}, from its turn_started), once:
984
- // a reload draws it from the history (turn_block.js).
985
- function placeApply(data) {
986
- const badge = authorBadge(data.author, data.author_name);
987
- if (!badge || historyEl.querySelector(`.review-apply[data-apply-turn="${CSS.escape(data.turn_id)}"]`)) return;
988
- appendToHistory(elementOf(applyRowTemplate(data.turn_id, badge)));
989
- }
990
-
991
972
  // The owner's Verify (owner_verify.js): verdict cards, Verify fresh, the claim.
992
973
  const ownerVerify = createOwnerVerify({
993
974
  historyEl, store, api, claim: ownerClaim, liveTurn, toast: (text) => showToast(text),
994
975
  });
995
976
 
996
- // Apply: the owner's Apply turn into the composer, after what is typed
997
- // there; never sent from here.
998
- if (viewer.can("apply")) historyEl.addEventListener("click", async (e) => {
999
- const button = e.target.closest(".review-apply-btn");
1000
- if (!button || !store.selected) return;
1001
- const id = store.selected;
1002
- button.disabled = true;
1003
- try {
1004
- const text = await fetchApply(id, button.dataset.applyTurn);
1005
- if (id === store.selected) {
1006
- fillComposer(applyComposerText(promptEl.value, text));
1007
- // The owner's own turn: queued after a running one, never steered in.
1008
- deliveryControl.hold();
1009
- }
1010
- } catch (err) {
1011
- showToast(err.message);
1012
- } finally {
1013
- button.disabled = false;
1014
- }
1015
- });
1016
-
1017
977
  // The session bar (info_bar_model.js sessionBar): its buttons, and the
1018
978
  // info line rendered by info_bar.js.
1019
979
  // The open session waits on the user: its card is up, or its summary says so
@@ -1185,7 +1145,6 @@ const streamHandlers = (participant ? participant.wrapHandlers : (handlers) => h
1185
1145
  contextChips,
1186
1146
  workingSet,
1187
1147
  participantsControl,
1188
- placeApply: viewer.can("apply") ? placeApply : null,
1189
1148
  placeVerdict: ownerVerify.placeVerdict,
1190
1149
  restoreVerify: (anchor) => ownerVerify.set(anchor),
1191
1150
  restoreRevise,
@@ -1332,15 +1291,14 @@ function runSessionCommand(line) {
1332
1291
 
1333
1292
  function clearComposer() {
1334
1293
  promptEl.value = "";
1335
- deliveryControl.release();
1336
1294
  fitPrompt();
1337
1295
  }
1338
1296
 
1339
- // A queue (Alt+Enter, or an Apply turn's Enter) to a worker that can't
1340
- // queue (it would steer): not sent, the text kept, a note says why.
1297
+ // A queue (Alt+Enter) to a worker that can't queue (it would steer): not
1298
+ // sent, the text kept, a note says why.
1341
1299
  function queueRefused(altKey) {
1342
1300
  if (!store.selected || !liveTurn.running || store.current.workerFeatures.includes("delivery")) return false;
1343
- if (!altKey && !deliveryControl.held()) return false;
1301
+ if (!altKey) return false;
1344
1302
  addCommandBubble({ label: null, line: promptEl.value.trim(), text: QUEUE_NEEDS_WORKER, failed: true });
1345
1303
  return true;
1346
1304
  }
@@ -60,11 +60,9 @@ export function listSessions(sort, order, { dir, ...opts } = {}) {
60
60
  // start page's ⚙ panel set some; thinking: its own level ("low"), when the
61
61
  // start page's ⚙ panel set one; toolkit: the kit it starts on, when the
62
62
  // start page's 🧰 list picked one (none: config's default, maybe suggested).
63
- // review: {subjects} makes it a review session (it starts idle; no preview).
64
63
  // The other fields are api()'s fetch options.
65
- export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit, review,
66
- ...opts } = {}) {
67
- const start = review ? { review } : { idle: true, ...(preview ? { preview } : {}) };
64
+ export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit, ...opts } = {}) {
65
+ const start = { idle: true, ...(preview ? { preview } : {}) };
68
66
  const body = { ...start, ...(dir ? { dir } : {}), ...(model ? { model } : {}),
69
67
  ...(llmContext ? { llm_context: llmContext } : {}), ...(thinking ? { thinking } : {}),
70
68
  ...(toolkit ? { toolkit } : {}) };
@@ -80,12 +78,6 @@ export function continueSession(id, opts = {}) {
80
78
  return api("/api/sessions", { method: "POST", body: JSON.stringify({ continues: id, idle: true }), ...opts });
81
79
  }
82
80
 
83
- // A review fork of +id+ (docs/sessions.md, Review sessions): a new session in
84
- // its folder, seeded with its recap, not its transcript; +id+ keeps running.
85
- export function startReview(id, opts = {}) {
86
- return api("/api/sessions", { method: "POST", body: JSON.stringify({ review: { from: id } }), ...opts });
87
- }
88
-
89
81
  // The models a new session can start on: {default, models: [{name, host, id}],
90
82
  // warning?} (a host that failed is in the warning, the list has the rest).
91
83
  export function listModels(opts = {}) {
@@ -5,8 +5,8 @@
5
5
  // and offers the other two deliveries as links (a phone has no row: idle
6
6
  // the line is gone; running it lies over the session bar's left, where
7
7
  // status, ctx and speed are, only while it matters: the text field focused
8
- // or holding text or images, a choice armed or an Apply turn held, the last
9
- // two written here as data-armed and data-held; index.html):
8
+ // or holding text or images, or a choice armed, the last written here as
9
+ // data-armed; index.html):
10
10
  //
11
11
  // ↳ goes in after this thinking step · 2:31 · 31k chars cut in now · queue for after the turn
12
12
  // ↳ goes in after this tool call (execute · 0:12) queue for after the turn
@@ -19,13 +19,7 @@
19
19
  // composer arms its choice for the next Enter; Esc or a second click
20
20
  // disarms it.
21
21
  //
22
- // An Apply turn (review_apply.js) in the composer is the owner's own turn,
23
- // never a steer into the running one (that may be a participant's
24
- // read-only review turn): while the composer holds it (hold(), till it is
25
- // sent, emptied or Esc'd) Enter queues it, and the line says so.
26
- //
27
- // While a participant's turn runs (a review turn, or a working session's
28
- // pair turn), the worker queues the owner's input behind it whatever it
22
+ // While a participant's turn runs, the worker queues the owner's input behind it whatever it
29
23
  // asks (never a steer or a cut into their turn): Enter queues, no cut is
30
24
  // offered, and the line says so.
31
25
  //
@@ -46,13 +40,7 @@ const CUT_SHORT = "cut in";
46
40
  // would steer it), the text kept, this said.
47
41
  export const QUEUE_NEEDS_WORKER = "Not sent: queueing needs a newer worker (it would steer the running turn). "
48
42
  + "Restart it (chi sessions restart ID, or the update badge), then send again.";
49
- // The line while the composer holds an Apply turn (Enter queues it).
50
- export const APPLY_QUEUES = "your Apply turn queues for after this turn · Esc to steer it in instead";
51
- export const APPLY_QUEUES_SHORT = "Apply: queued after the turn";
52
- // The same to a worker without the delivery feature: Enter refuses it.
53
- export const APPLY_CANT_QUEUE = "your Apply turn can't queue on this worker (restart it) · Esc to steer it in instead";
54
- // The line while a participant's turn runs (the worker queues), whichever
55
- // mode: review or pair.
43
+ // The line while a participant's turn runs (the worker queues).
56
44
  export const PARTICIPANT_TURN_QUEUES = "goes in as your own turn after this participant's turn";
57
45
  export const PARTICIPANT_TURN_QUEUES_SHORT = "after their turn";
58
46
  // A participant's line: their own turn, the owner's, another participant's.
@@ -116,8 +104,6 @@ function thinkingOnly(gen, serverGen) {
116
104
  // armed "cut" | "queue" | null: the choice the next Enter sends
117
105
  // canQueue the worker takes delivery: queue (its "delivery" feature)
118
106
  // model the session's model, for the cut-off reason
119
- // held the composer holds an Apply turn: Enter queues it (an armed
120
- // cut still wins)
121
107
  // participantTurn the running turn is a participant's: Enter queues,
122
108
  // no cut (the worker queues the owner's input behind it)
123
109
  // viewerTurn a participant looks: {own, steer, by} (their own turn, it
@@ -130,7 +116,7 @@ function thinkingOnly(gen, serverGen) {
130
116
  // cutting off the cut link goes (the text says why); without the
131
117
  // feature the queue link goes.
132
118
  export function deliveryLine({ phase = "thinking", gen = null, tool = null, cutAfter = null, serverGen = null, now = Date.now(),
133
- armed = null, canQueue = true, model = "", held = false, participantTurn = false, viewerTurn = null } = {}) {
119
+ armed = null, canQueue = true, model = "", participantTurn = false, viewerTurn = null } = {}) {
134
120
  if (viewerTurn) return viewerLine(viewerTurn);
135
121
  const cutOff = cutAfter === 0 || (cutAfter != null && cutAfter < 0);
136
122
  const thinking = phase === "thinking" && thinkingOnly(gen, serverGen);
@@ -164,16 +150,10 @@ export function deliveryLine({ phase = "thinking", gen = null, tool = null, cutA
164
150
  let wait = "";
165
151
  if (cutEnabled && cutAfter > 0 && age != null && age < cutAfter) wait = `cuts at about ${clockText(cutAfter)} if you choose ${CUT_LABEL}`;
166
152
  const effective = (armed === "cut" && cutEnabled) || (armed === "queue" && canQueue) ? armed : null;
167
- // An Apply turn queues unless a cut was armed for it.
168
- const applies = held && effective !== "cut";
169
- const enter = effective || (applies && canQueue ? "queue" : null);
170
- let parts = [cutOff ? reason : "", where, wait].filter(Boolean);
153
+ const enter = effective;
154
+ const parts = [cutOff ? reason : "", where, wait].filter(Boolean);
171
155
  // A phone's short row leaves it out: its ticked chip says it.
172
156
  if (effective) parts.push("Enter sends");
173
- if (applies) {
174
- parts = [canQueue ? APPLY_QUEUES : APPLY_CANT_QUEUE];
175
- if (canQueue) short = APPLY_QUEUES_SHORT;
176
- }
177
157
  if (participantTurn) {
178
158
  return {
179
159
  text: `\u21B3 ${PARTICIPANT_TURN_QUEUES}`,
@@ -230,17 +210,14 @@ function idleTemplate(hint = IDLE_HINT) {
230
210
  // phase, gen, tool, cutAfter, serverGen, canQueue, model)
231
211
  // composerEmpty() nothing typed and no image chips: a link arms
232
212
  // send(delivery) send the composer's line with +delivery+ ("cut", "queue")
233
- // session() the open session's id: an Apply hold is that session's
234
213
  const TICK_MS = 500;
235
214
 
236
215
  // +history+: the viewer walks a prompt history with ↑ (the idle hint says so).
237
- export function createDeliveryControl({ el, read, composerEmpty, send, session = () => null, now = () => Date.now(), history = true,
216
+ export function createDeliveryControl({ el, read, composerEmpty, send, now = () => Date.now(), history = true,
238
217
  setTimer = (fn, ms) => setInterval(fn, ms), clearTimer = (t) => clearInterval(t) }) {
239
218
  // "off" (no session: the row is gone), "idle" or "running".
240
219
  let mode = "off";
241
220
  let armed = null;
242
- // The session whose Apply turn the composer holds, or null.
243
- let heldFor = null;
244
221
  let timer = null;
245
222
  let line = null;
246
223
 
@@ -256,13 +233,11 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
256
233
  refresh();
257
234
  };
258
235
 
259
- // For a phone's CSS (index.html): whether a choice is armed or an Apply
260
- // turn held while the turn runs ("1" or ""): the line shows then. Not the
261
- // queue chip's pressed look: a participant's turn draws it with nothing
262
- // armed.
236
+ // For a phone's CSS (index.html): whether a choice is armed while the
237
+ // turn runs ("1" or ""): the line shows then. Not the queue chip's
238
+ // pressed look: a participant's turn draws it with nothing armed.
263
239
  const mark = () => {
264
240
  el.dataset.armed = mode === "running" && armed ? "1" : "";
265
- el.dataset.held = mode === "running" && held() ? "1" : "";
266
241
  };
267
242
 
268
243
  function refresh() {
@@ -271,15 +246,13 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
271
246
  if (mode === "idle") render(idleTemplate(history ? IDLE_HINT : IDLE_HINT_NO_HISTORY), el);
272
247
  return;
273
248
  }
274
- line = deliveryLine({ ...read(), now: now(), armed, held: held() });
249
+ line = deliveryLine({ ...read(), now: now(), armed });
275
250
  // A choice no longer possible (a tool started) disarms.
276
251
  armed = line.armed;
277
252
  mark();
278
253
  render(deliveryLineTemplate(line, { onCut: () => click("cut"), onQueue: () => click("queue") }), el);
279
254
  }
280
255
 
281
- const held = () => heldFor != null && heldFor === session();
282
-
283
256
  return {
284
257
  // +next+: "off", "idle" or "running".
285
258
  show(next) {
@@ -300,36 +273,20 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
300
273
  refresh,
301
274
  click,
302
275
  armed: () => armed,
303
- // The composer holds an Apply turn (of the open session): Enter queues it.
304
- hold() {
305
- heldFor = session();
306
- refresh();
307
- },
308
- held,
309
- // The composer let it go (emptied).
310
- release() {
311
- if (heldFor == null) return;
312
- heldFor = null;
313
- refresh();
314
- },
315
276
  // What this send goes in as while the turn runs ("cut", "queue" or
316
- // null), the armed choice and the Apply hold let go. The hold is the
317
- // line's word on it (it knows the worker can queue); idle, none.
277
+ // null), the armed choice let go; idle, none.
318
278
  take() {
319
279
  const was = mode === "running" && line ? line.enter : armed;
320
- if (armed || heldFor != null) {
280
+ if (armed) {
321
281
  armed = null;
322
- heldFor = null;
323
282
  refresh();
324
283
  }
325
284
  return was || null;
326
285
  },
327
- // Esc: the armed choice goes; else, while the turn runs, the Apply hold
328
- // (Enter then steers it in).
286
+ // Esc: the armed choice goes.
329
287
  disarm() {
330
- if (armed) armed = null;
331
- else if (mode === "running" && held()) heldFor = null;
332
- else return false;
288
+ if (!armed) return false;
289
+ armed = null;
333
290
  refresh();
334
291
  return true;
335
292
  },