samagotchi 0.194.0 → 0.196.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +80 -1
- data/docs/architecture.md +2 -1
- data/docs/bundle-authoring.md +23 -23
- data/docs/bundles.md +201 -7
- data/docs/cli.md +5 -1
- data/docs/configuration.md +25 -4
- data/docs/context.md +13 -3
- data/docs/guardrails.md +6 -4
- data/docs/hooks.md +3 -1
- data/docs/internals/attached-context.md +2 -0
- data/docs/internals/block-renderers.md +4 -1
- data/docs/internals/bridge.md +4 -0
- data/docs/internals/engine.md +15 -2
- data/docs/internals/knowledge.md +215 -0
- data/docs/internals/pages.md +17 -9
- data/docs/internals/panes.md +51 -13
- data/docs/internals/participants.md +15 -3
- data/docs/internals/peers.md +14 -9
- data/docs/internals/session-lifecycle.md +26 -12
- data/docs/internals/web-frontend.md +64 -27
- data/docs/memory.md +4 -2
- data/docs/pages.md +72 -1
- data/docs/peers.md +25 -14
- data/docs/plugins.md +132 -6
- data/docs/releasing.md +1 -1
- data/docs/scheduling.md +4 -0
- data/docs/sessions.md +9 -2
- data/docs/system-one.md +3 -1
- data/docs/testing.md +3 -1
- data/lib/samagotchi/bundle_manifest.rb +30 -5
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +8 -5
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +2 -2
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +8 -5
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +3 -3
- data/lib/samagotchi/bundles/coordinator/manifest.yml +7 -4
- data/lib/samagotchi/bundles/coordinator/plugin.rb +15 -5
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +10 -0
- data/lib/samagotchi/bundles/core/manifest.yml +2 -2
- data/lib/samagotchi/bundles/cost-cap/manifest.yml +4 -4
- data/lib/samagotchi/bundles/cost-cap/plugin.rb +54 -3
- data/lib/samagotchi/bundles/dev/manifest.yml +3 -2
- data/lib/samagotchi/bundles/github-pr/manifest.yml +4 -2
- data/lib/samagotchi/bundles/knowledge/adapters.rb +205 -0
- data/lib/samagotchi/bundles/knowledge/catalog.rb +151 -0
- data/lib/samagotchi/bundles/knowledge/chi_adapters.rb +178 -0
- data/lib/samagotchi/bundles/knowledge/chunker.rb +55 -0
- data/lib/samagotchi/bundles/knowledge/github.rb +246 -0
- data/lib/samagotchi/bundles/knowledge/manifest.yml +27 -0
- data/lib/samagotchi/bundles/knowledge/plugin.rb +807 -0
- data/lib/samagotchi/bundles/knowledge/query.rb +30 -0
- data/lib/samagotchi/bundles/knowledge/query_log.rb +55 -0
- data/lib/samagotchi/bundles/knowledge/refresh.rb +133 -0
- data/lib/samagotchi/bundles/knowledge/store.rb +264 -0
- data/lib/samagotchi/bundles/reflect/manifest.yml +17 -0
- data/lib/samagotchi/bundles/reflect/scripts/reflect.rb +439 -0
- data/lib/samagotchi/bundles/reflect/skill_reflect.md +100 -0
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/context_change.rb +44 -0
- data/lib/samagotchi/context_note.rb +1 -1
- data/lib/samagotchi/context_providers.rb +14 -0
- data/lib/samagotchi/context_sources.rb +3 -25
- data/lib/samagotchi/engine/plugins.rb +21 -0
- data/lib/samagotchi/events.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +12 -4
- data/lib/samagotchi/guardrails/review_paths.rb +13 -3
- data/lib/samagotchi/guardrails/targets.rb +24 -2
- data/lib/samagotchi/guardrails_command.rb +3 -9
- data/lib/samagotchi/hook_label.rb +19 -0
- data/lib/samagotchi/hook_routes.rb +3 -2
- data/lib/samagotchi/installed_bundles/manifest.rb +7 -1
- data/lib/samagotchi/memory_bundle/builder.rb +2 -1
- data/lib/samagotchi/memory_bundle/installed_copy.rb +2 -1
- data/lib/samagotchi/page_command.rb +90 -6
- data/lib/samagotchi/pages/launch.rb +16 -8
- data/lib/samagotchi/pages/runner.rb +7 -2
- data/lib/samagotchi/pages/runtime.rb +62 -2
- data/lib/samagotchi/pages.rb +4 -0
- data/lib/samagotchi/panes/kitty.rb +20 -5
- data/lib/samagotchi/panes.rb +81 -12
- data/lib/samagotchi/participants.rb +17 -6
- data/lib/samagotchi/peer_exchanges.rb +1 -2
- data/lib/samagotchi/peer_note.rb +38 -5
- data/lib/samagotchi/peer_presence.rb +20 -7
- data/lib/samagotchi/plugin/api.rb +11 -1
- data/lib/samagotchi/plugin/attached_context.rb +46 -1
- data/lib/samagotchi/plugin/chips.rb +125 -0
- data/lib/samagotchi/plugin/context.rb +43 -8
- data/lib/samagotchi/plugin/panes.rb +52 -9
- data/lib/samagotchi/plugin/peer_pairing.rb +2 -2
- data/lib/samagotchi/plugin/peer_start.rb +61 -36
- data/lib/samagotchi/plugin/peers.rb +6 -3
- data/lib/samagotchi/plugin/project.rb +63 -0
- data/lib/samagotchi/plugin/sessions.rb +36 -1
- data/lib/samagotchi/plugin/tool_spec.rb +28 -9
- data/lib/samagotchi/schedules.rb +8 -2
- data/lib/samagotchi/session.rb +22 -9
- data/lib/samagotchi/session_access/local.rb +34 -33
- data/lib/samagotchi/session_chain/sharing.rb +79 -0
- data/lib/samagotchi/session_chain/successor.rb +4 -2
- data/lib/samagotchi/session_chips.rb +133 -0
- data/lib/samagotchi/session_inbox_delivery.rb +11 -11
- data/lib/samagotchi/session_manager/emptiness.rb +4 -1
- data/lib/samagotchi/session_observer.rb +1 -1
- data/lib/samagotchi/session_stats.rb +437 -0
- data/lib/samagotchi/session_stores.rb +3 -0
- data/lib/samagotchi/session_window.rb +30 -0
- data/lib/samagotchi/speaker.rb +228 -0
- data/lib/samagotchi/steer.rb +36 -132
- data/lib/samagotchi/system_one/approval_choice.rb +22 -0
- data/lib/samagotchi/system_one/approval_label.rb +4 -6
- data/lib/samagotchi/system_prompt.rb +3 -1
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +30 -0
- data/lib/samagotchi/testing/boundary.rb +17 -4
- data/lib/samagotchi/testing/bundle.rb +5 -0
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +10 -0
- data/lib/samagotchi/testing/sessions.rb +11 -3
- data/lib/samagotchi/toolkit.rb +11 -4
- data/lib/samagotchi/toolkit_report_command.rb +14 -18
- data/lib/samagotchi/toolkit_suggest.rb +9 -2
- data/lib/samagotchi/tools/registry.rb +48 -18
- data/lib/samagotchi/tools/tool_index.rb +6 -2
- data/lib/samagotchi/turn_excerpts.rb +302 -0
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +9 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +21 -10
- data/lib/samagotchi/web/participant_view.rb +1 -1
- data/lib/samagotchi/web/peer_routes.rb +5 -2
- data/lib/samagotchi/web/plugin_chip_rows.rb +39 -0
- data/lib/samagotchi/web/public/agent_rows.js +1 -0
- data/lib/samagotchi/web/public/app.js +17 -25
- data/lib/samagotchi/web/public/chains.js +0 -26
- data/lib/samagotchi/web/public/command_list.js +2 -3
- data/lib/samagotchi/web/public/composer.js +2 -3
- data/lib/samagotchi/web/public/composer_mount.js +3 -6
- data/lib/samagotchi/web/public/context_chips.js +240 -93
- data/lib/samagotchi/web/public/context_groups.js +84 -0
- data/lib/samagotchi/web/public/draft_follow.js +33 -0
- data/lib/samagotchi/web/public/drafts.js +26 -22
- data/lib/samagotchi/web/public/index.html +32 -0
- data/lib/samagotchi/web/public/peer_chip_kind.js +49 -0
- data/lib/samagotchi/web/public/peer_note.js +2 -2
- data/lib/samagotchi/web/public/peer_row.js +10 -5
- data/lib/samagotchi/web/public/peer_wait.js +4 -2
- data/lib/samagotchi/web/public/plugin_chip.js +55 -0
- data/lib/samagotchi/web/public/plugin_chip_kind.js +48 -0
- data/lib/samagotchi/web/public/send_turn.js +8 -21
- data/lib/samagotchi/web/public/session_actions.js +10 -23
- data/lib/samagotchi/web/public/session_view.js +7 -3
- data/lib/samagotchi/web/public/stream_handlers.js +2 -0
- metadata +33 -1
data/lib/samagotchi/web/app.rb
CHANGED
|
@@ -45,6 +45,7 @@ require_relative "../output_formatter"
|
|
|
45
45
|
require_relative "../image_store"
|
|
46
46
|
require_relative "../message_time"
|
|
47
47
|
require_relative "../context_candidates"
|
|
48
|
+
require_relative "../context_change"
|
|
48
49
|
require_relative "../context_note"
|
|
49
50
|
require_relative "../context_sources"
|
|
50
51
|
require_relative "../context_providers"
|
|
@@ -77,6 +78,7 @@ require_relative "participants_admin"
|
|
|
77
78
|
require_relative "participant_review"
|
|
78
79
|
require_relative "participant_show"
|
|
79
80
|
require_relative "message_display"
|
|
81
|
+
require_relative "plugin_chip_rows"
|
|
80
82
|
require_relative "session_show"
|
|
81
83
|
require_relative "session_create"
|
|
82
84
|
require_relative "ask_create"
|
|
@@ -120,6 +122,7 @@ module Samagotchi
|
|
|
120
122
|
include ParticipantReview
|
|
121
123
|
include ParticipantShow
|
|
122
124
|
include MessageDisplay
|
|
125
|
+
include PluginChipRows
|
|
123
126
|
include SessionShow
|
|
124
127
|
include SessionCreate
|
|
125
128
|
include AskCreate
|
|
@@ -1432,14 +1435,16 @@ module Samagotchi
|
|
|
1432
1435
|
# (chi context ls from another machine, SessionAccess::Remote): each
|
|
1433
1436
|
# source as it was added too, its command included (#context_row), and
|
|
1434
1437
|
# a project's source a session's own of its name shadows, marked
|
|
1435
|
-
# shadowed, and the session's candidates with their status.
|
|
1438
|
+
# shadowed, and the session's candidates with their status. +chips+:
|
|
1439
|
+
# the bundles' own chips (PluginChipRows).
|
|
1436
1440
|
def handle_context_list(req, id)
|
|
1437
1441
|
session = @session_class.load(id, state_dir: default_state_dir)
|
|
1438
1442
|
own = ContextSources.session_location(id, state_dir: default_state_dir)
|
|
1439
1443
|
subs = own.subscriptions
|
|
1440
1444
|
full = truthy_param?(req.GET["full"])
|
|
1441
|
-
|
|
1442
|
-
|
|
1445
|
+
labels = context_group_labels
|
|
1446
|
+
rows = attached_context(session, shadowed: full).map { |attached| context_row(attached, own, subs, full: full, labels: labels) }
|
|
1447
|
+
body = { session_id: id, sources: rows, can_add_url: ContextProviders.any?, chips: plugin_chip_rows(id) }
|
|
1443
1448
|
# The candidates too, for chi context ls (no UI shows them yet).
|
|
1444
1449
|
if full
|
|
1445
1450
|
body[:candidates] = ContextCandidates.with_status(id, project_root: session.project_root, project_id: session.project_id,
|
|
@@ -1456,7 +1461,7 @@ module Samagotchi
|
|
|
1456
1461
|
session = @session_class.load(id, state_dir: default_state_dir)
|
|
1457
1462
|
attached = find_context(session, name) or return error_response(404, "context_missing", "no source #{name[0, 40]}")
|
|
1458
1463
|
own = ContextSources.session_location(id, state_dir: default_state_dir)
|
|
1459
|
-
row = context_row(attached, own, own.subscriptions, full: truthy_param?(req.GET["full"]))
|
|
1464
|
+
row = context_row(attached, own, own.subscriptions, full: truthy_param?(req.GET["full"]), labels: context_group_labels)
|
|
1460
1465
|
json_response(200, row.merge(text: attached.snapshot.text))
|
|
1461
1466
|
end
|
|
1462
1467
|
|
|
@@ -1487,7 +1492,7 @@ module Samagotchi
|
|
|
1487
1492
|
return error_response(422, "no_provider", "no installed bundle resolves #{url[0, 200]}") unless resolved
|
|
1488
1493
|
|
|
1489
1494
|
own = ContextSources.session_location(session.id, state_dir: default_state_dir)
|
|
1490
|
-
source =
|
|
1495
|
+
source = ContextChange.under(session.id, state_dir: default_state_dir) do
|
|
1491
1496
|
own.add(web_source(resolved, body, own.scope))
|
|
1492
1497
|
end
|
|
1493
1498
|
json_response(201, { status: "attached", name: resolved.name, movable: source.movable? })
|
|
@@ -1546,7 +1551,7 @@ module Samagotchi
|
|
|
1546
1551
|
session = @session_class.load(id, state_dir: default_state_dir)
|
|
1547
1552
|
attached = find_context(session, name) or return error_response(404, "context_missing", "no source #{name[0, 40]}")
|
|
1548
1553
|
if attached.location.session?
|
|
1549
|
-
|
|
1554
|
+
ContextChange.under(id, state_dir: default_state_dir) { attached.location.remove(attached.name) }
|
|
1550
1555
|
json_response(200, { status: "detached", name: attached.name })
|
|
1551
1556
|
else
|
|
1552
1557
|
ContextSources.session_location(id, state_dir: default_state_dir).mute(attached.name)
|
|
@@ -1582,22 +1587,28 @@ module Samagotchi
|
|
|
1582
1587
|
nil
|
|
1583
1588
|
end
|
|
1584
1589
|
|
|
1585
|
-
# A source's row: what the page's chips show
|
|
1586
|
-
#
|
|
1590
|
+
# A source's row: what the page's chips show; provider: its bundle
|
|
1591
|
+
# (Source#provider), group: that bundle's context_group label (null:
|
|
1592
|
+
# none; +labels+ reads a bundle once per request). +full+ (chi context
|
|
1593
|
+
# ls and show from another machine, SessionAccess::Remote): also the
|
|
1587
1594
|
# source as it was added (source: Source#to_h, its command too) and
|
|
1588
1595
|
# the snapshot (Snapshot#to_h without its text), and shadowed.
|
|
1589
|
-
def context_row(attached, own, subs, full: false)
|
|
1596
|
+
def context_row(attached, own, subs, full: false, labels: context_group_labels)
|
|
1590
1597
|
source = attached.source
|
|
1591
1598
|
snapshot = attached.snapshot
|
|
1592
1599
|
row = { name: source.name, scope: source.scope, kind: source.push? ? "push" : "cmd", every_seconds: source.every_seconds,
|
|
1593
1600
|
why: source.why, hint: snapshot.hint || source.hint, summary: snapshot.summary, error: snapshot.error,
|
|
1594
1601
|
fetched_at: snapshot.fetched_at, has_text: snapshot.text?, muted: own.muted?(source.name),
|
|
1595
|
-
unread: snapshot.text? && subs[source.name]&.read != snapshot.revision
|
|
1602
|
+
unread: snapshot.text? && subs[source.name]&.read != snapshot.revision,
|
|
1603
|
+
provider: source.provider, group: source.provider && labels[source.provider] }
|
|
1596
1604
|
return row unless full
|
|
1597
1605
|
|
|
1598
1606
|
row.merge(source: source.to_h, snapshot: snapshot.to_h.except("text", :text), shadowed: attached.shadowed)
|
|
1599
1607
|
end
|
|
1600
1608
|
|
|
1609
|
+
# Each bundle's context_group label, read once for the hash's life (a request).
|
|
1610
|
+
def context_group_labels = Hash.new { |labels, bundle| labels[bundle] = ContextProviders.group_label(bundle) }
|
|
1611
|
+
|
|
1601
1612
|
def handle_stream(req, id)
|
|
1602
1613
|
# Validate session exists
|
|
1603
1614
|
begin
|
|
@@ -84,7 +84,7 @@ module Samagotchi
|
|
|
84
84
|
# named is dropped all the same.
|
|
85
85
|
DROPPED = %w[
|
|
86
86
|
after_generation after_tool_call after_turn answer_display before_generation before_tool_call before_turn block_fix
|
|
87
|
-
card command_output command_queued command_ran context_added empty_answer_retry
|
|
87
|
+
card chips_updated command_output command_queued command_ran context_added empty_answer_retry
|
|
88
88
|
generation_cancelled generation_progress generation_started guardrail_warning hook_notice
|
|
89
89
|
llm_context_edited merged_input objectives_updated part_settled participants_changed peer_wait_ended pending_input_merged plugin_init_finished
|
|
90
90
|
plugin_init_started plugin_init_wait question question_relay reasoning_history_refused
|
|
@@ -54,14 +54,17 @@ module Samagotchi
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# A peer this session waits for (/<peer> pair, PeerPresence): its row
|
|
57
|
-
# (made when there is none) with waiting: {until}
|
|
57
|
+
# (made when there is none) with waiting: {until}, and app (the peer's
|
|
58
|
+
# product name, PeerWaiting#app) when the mark names it. A stale wait is
|
|
58
59
|
# absent here, and stays on disk for the session's worker to say it
|
|
59
60
|
# ran out (PeerWaitExpiry).
|
|
60
61
|
def waiting_rows(id, rows)
|
|
61
62
|
PeerPresence.session_marks(id, state_dir: default_state_dir).each do |peer, mark|
|
|
62
63
|
next if mark.stale?
|
|
63
64
|
|
|
64
|
-
(rows[peer] ||= peer_row(peer).merge(exchanges: []))
|
|
65
|
+
row = (rows[peer] ||= peer_row(peer).merge(exchanges: []))
|
|
66
|
+
row[:waiting] = { until: mark.until_at.utc.iso8601 }
|
|
67
|
+
row[:app] = mark.app if mark.app
|
|
65
68
|
end
|
|
66
69
|
end
|
|
67
70
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../session_chips"
|
|
4
|
+
require_relative "../installed_bundles"
|
|
5
|
+
|
|
6
|
+
module Samagotchi
|
|
7
|
+
module Web
|
|
8
|
+
# The bundles' own chips (ctx.chips, SessionChips) as GET
|
|
9
|
+
# /api/sessions/:id/context's +chips+: the web draws them after the peer
|
|
10
|
+
# chips and the sources (plugin_chip.js). Read from the session's folder,
|
|
11
|
+
# so they show with no worker running. A bundle that isn't usable now
|
|
12
|
+
# (uninstalled, refused, too new for this chi) has its chips left out.
|
|
13
|
+
# Included in App: card_body_html (MessageDisplay) renders a chip's body
|
|
14
|
+
# as a card's.
|
|
15
|
+
module PluginChipRows
|
|
16
|
+
# @return [Array<Hash>] {key, bundle, name, label, state, dot, title,
|
|
17
|
+
# at, body_html, actions}, by bundle then as the bundle set them
|
|
18
|
+
def plugin_chip_rows(id)
|
|
19
|
+
SessionChips.read(id, state_dir: default_state_dir).flat_map do |bundle, chips|
|
|
20
|
+
next [] unless InstalledBundles.standing(bundle)&.usable?
|
|
21
|
+
|
|
22
|
+
chips.map { |name, chip| plugin_chip_row(bundle, name, chip) }
|
|
23
|
+
end
|
|
24
|
+
rescue SessionPaths::InvalidId
|
|
25
|
+
[]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def plugin_chip_row(bundle, name, chip)
|
|
31
|
+
actions = Array(chip["actions"]).select { |action| action.is_a?(Hash) }
|
|
32
|
+
.map { |action| action.slice("label", "command", "url", "primary") }
|
|
33
|
+
{ key: "chip:#{bundle}/#{name}", bundle: bundle, name: name, label: chip["label"].to_s,
|
|
34
|
+
state: chip["state"].to_s, dot: chip["dot"] == true, title: chip["title"], at: chip["at"],
|
|
35
|
+
body_html: card_body_html(chip["body"].to_s), actions: actions }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -70,6 +70,7 @@ function peerRowOf(bubble) {
|
|
|
70
70
|
name: who.replace(/\s+answered\s*$/, ""),
|
|
71
71
|
verdict: peerVerdict(bubble),
|
|
72
72
|
summary: note && !note.hasAttribute("data-fallback") ? note.textContent : "",
|
|
73
|
+
said: bubble.dataset.peerSaid, // the server's (PeerNote.said); none on an older note
|
|
73
74
|
first: (text !== null ? foldLabel(text, { display: true }) : "") || note?.textContent || "",
|
|
74
75
|
lines: text !== null ? lineCount(text) : null,
|
|
75
76
|
});
|
|
@@ -81,6 +81,7 @@ import { createQuestionCards } from "./question_cards.js";
|
|
|
81
81
|
import { PROMPT_LINE_PX, PROMPT_MIN_PX } from "./composer_size.js";
|
|
82
82
|
import { mountComposer } from "./composer_mount.js";
|
|
83
83
|
import { createDrafts } from "./drafts.js";
|
|
84
|
+
import { continuedDrafts } from "./draft_follow.js";
|
|
84
85
|
import { hasHistory, historyLoader } from "./participant_history.js";
|
|
85
86
|
import { createCommandList } from "./command_list.js";
|
|
86
87
|
import { sessionHash } from "./route.js";
|
|
@@ -174,7 +175,8 @@ const infoTextEl = $("#infoText");
|
|
|
174
175
|
// (updateInfoBar redraws #infoText every tick; the chips keep their popover).
|
|
175
176
|
const contextChips = viewer.can("context") ? createContextChips({
|
|
176
177
|
el: $("#contextChips"),
|
|
177
|
-
api: { list: listContext, show: getContext, detach: detachContext, message: getPeerMessage, unpair: unpairPeer
|
|
178
|
+
api: { list: listContext, show: getContext, detach: detachContext, message: getPeerMessage, unpair: unpairPeer,
|
|
179
|
+
command: (id, line) => sendCommand(id, line, { clientId, card: true }).then(() => store.selected === id && followWokenWorker()) },
|
|
178
180
|
toast: (text) => showToast(text),
|
|
179
181
|
// A paired peer's one chip (peer_chip.js): its exchanges are the peers model's (below).
|
|
180
182
|
peers: () => peers,
|
|
@@ -552,7 +554,7 @@ const sessionView = createSessionView({
|
|
|
552
554
|
later: {
|
|
553
555
|
handlers: () => streamHandlers, composer: () => composer, ownerVerify: () => ownerVerify,
|
|
554
556
|
commandList: () => commandList, initTasks: () => initTasks, resetTurnView: () => sessionSync.resetTurnView(),
|
|
555
|
-
drafts: () => drafts,
|
|
557
|
+
drafts: () => drafts, followContinuedDrafts: () => followContinuedDrafts(),
|
|
556
558
|
},
|
|
557
559
|
});
|
|
558
560
|
const { forgetSession, readTurnEnd, endTurnView } = sessionView;
|
|
@@ -632,11 +634,13 @@ function openSessionEvents() {
|
|
|
632
634
|
sweepFoldsOnce();
|
|
633
635
|
const sess = store.sessions.find((s) => s.id === store.selected);
|
|
634
636
|
if (sess) followSelectedSession(sess);
|
|
637
|
+
followContinuedDrafts();
|
|
635
638
|
}),
|
|
636
639
|
session: (data) => store.batch(() => {
|
|
637
640
|
notifications?.noticeSessions("session", data);
|
|
638
641
|
store.update({ sessions: applySessionEvent(store.sessions, "session", data) });
|
|
639
642
|
if (data.session && data.session.id === store.selected) followSelectedSession(data.session);
|
|
643
|
+
followContinuedDrafts();
|
|
640
644
|
}),
|
|
641
645
|
session_gone: (data) => {
|
|
642
646
|
notifications?.noticeSessions("session_gone", data);
|
|
@@ -743,13 +747,6 @@ const sessionActions = createSessionActions({
|
|
|
743
747
|
// Continue →: the session's draft to the new link (else its opener), then shown once it opens.
|
|
744
748
|
handOverDraft: (from, to, created) => drafts.handOver(from, to, created ? openerText(created) : null),
|
|
745
749
|
revealDraft,
|
|
746
|
-
// Kept for an older cached session_actions.js (it calls them after its select), until after the next release.
|
|
747
|
-
fillOpener: (created, continuedId) => {
|
|
748
|
-
drafts.handOver(continuedId, created.id, openerText(created));
|
|
749
|
-
revealDraft();
|
|
750
|
-
return null;
|
|
751
|
-
},
|
|
752
|
-
restoreDraft: () => {},
|
|
753
750
|
moveDraft: (from, to) => drafts.move(from, to),
|
|
754
751
|
dropDraft: (id) => drafts.drop(id),
|
|
755
752
|
closeLiveStream: () => sessionSync.closeLive(),
|
|
@@ -1230,21 +1227,17 @@ const sendTurnControl = createSendTurn({
|
|
|
1230
1227
|
dir: scope.dir,
|
|
1231
1228
|
startPage,
|
|
1232
1229
|
takeDelivery: () => deliveryControl.take(),
|
|
1233
|
-
// The drafts by key (drafts.js)
|
|
1230
|
+
// The drafts by key (drafts.js).
|
|
1234
1231
|
composer: {
|
|
1235
1232
|
text: (key) => drafts.text(key), setText: (key, text) => drafts.setText(key, text),
|
|
1236
1233
|
putChips: (key, list) => drafts.putChips(key, list), move: (from, to) => drafts.move(from, to),
|
|
1237
1234
|
sending: (key, line) => drafts.sending(key, line), settle: (key, line) => drafts.settle(key, line),
|
|
1238
|
-
el: promptEl,
|
|
1239
1235
|
button: actionBtn,
|
|
1240
|
-
chips: (key) => drafts.chips(key
|
|
1241
|
-
setChips: (list) => drafts.putChips(shownDraft(), list),
|
|
1236
|
+
chips: (key) => drafts.chips(key),
|
|
1242
1237
|
fit: fitPrompt,
|
|
1243
|
-
clear: (key) => drafts.clear(key
|
|
1238
|
+
clear: (key) => drafts.clear(key),
|
|
1244
1239
|
openForVisit: () => openForVisit(),
|
|
1245
1240
|
focus: () => focusPrompt(),
|
|
1246
|
-
// An older cached send_turn.js wrote the box itself, then called it.
|
|
1247
|
-
noteDraft: () => drafts.syncFromView(),
|
|
1248
1241
|
},
|
|
1249
1242
|
historyEl,
|
|
1250
1243
|
turnDom,
|
|
@@ -1252,11 +1245,7 @@ const sendTurnControl = createSendTurn({
|
|
|
1252
1245
|
bubbleById,
|
|
1253
1246
|
addCommandBubble,
|
|
1254
1247
|
addCreatedSession,
|
|
1255
|
-
|
|
1256
|
-
select: (id) => {
|
|
1257
|
-
if (!store.selected) drafts.move("", id);
|
|
1258
|
-
return select(id);
|
|
1259
|
-
},
|
|
1248
|
+
select,
|
|
1260
1249
|
showNotice,
|
|
1261
1250
|
followWokenWorker,
|
|
1262
1251
|
refreshHistory,
|
|
@@ -1317,9 +1306,8 @@ const composer = mountComposer({
|
|
|
1317
1306
|
},
|
|
1318
1307
|
minPx: promptMinPx,
|
|
1319
1308
|
toast: (text) => showToast(text),
|
|
1320
|
-
// A recalled ↑/↓ entry
|
|
1309
|
+
// A recalled ↑/↓ entry goes through the drafts' writer.
|
|
1321
1310
|
setText: (text) => drafts.setText(shownDraft(), text),
|
|
1322
|
-
onWrite: () => drafts.syncFromView(),
|
|
1323
1311
|
// ↑/↓: the owner's prompt history shared with the TUI; a participant's own messages here.
|
|
1324
1312
|
loadHistory: historyLoader(viewer, { fetchHistory, selected: () => store.selected }),
|
|
1325
1313
|
imagesOff: viewer.can("images") ? null : IMAGES_NOT_HERE,
|
|
@@ -1379,8 +1367,7 @@ const commandList = createCommandList({
|
|
|
1379
1367
|
list: $("#commandList"),
|
|
1380
1368
|
prompt: promptEl,
|
|
1381
1369
|
commands: () => (viewer.can("session_controls") && store.selected && store.current.owner !== "tui" ? store.current.commands : []),
|
|
1382
|
-
|
|
1383
|
-
afterPick: (text) => (text === undefined ? drafts.syncFromView() : drafts.setText(shownDraft(), text)),
|
|
1370
|
+
afterPick: (text) => drafts.setText(shownDraft(), text),
|
|
1384
1371
|
});
|
|
1385
1372
|
|
|
1386
1373
|
stopBtn?.addEventListener("click", () => sessionActions.stopSelected());
|
|
@@ -1417,6 +1404,11 @@ function fillComposer(text) {
|
|
|
1417
1404
|
drafts.setText(shownDraft(), text, { reveal: true, focus: true, caretEnd: true });
|
|
1418
1405
|
}
|
|
1419
1406
|
const composerText = () => drafts.text(shownDraft());
|
|
1407
|
+
// A continue made elsewhere: the draft to the chain's newest link, as Continue → does (draft_follow.js).
|
|
1408
|
+
function followContinuedDrafts() {
|
|
1409
|
+
const skip = (id) => id === shownDraft() || sessionActions.continuing.has(id);
|
|
1410
|
+
for (const [from, to] of continuedDrafts(store.sessions, { skip, has: (id) => drafts.has(id) })) drafts.follow(from, to);
|
|
1411
|
+
}
|
|
1420
1412
|
|
|
1421
1413
|
annotateBar = createAnnotateBar({
|
|
1422
1414
|
presets: withVerify(parsePresets(document.body.dataset.annotatePresets)),
|
|
@@ -25,32 +25,6 @@ export function openerText(created) {
|
|
|
25
25
|
return typeof own === "string" && own.trim() ? own : CONTINUE_OPENER;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// Kept for an older cached app.js until after the next release (this app.js hands the
|
|
29
|
-
// draft over instead: drafts.js handOver), with restoredComposer below.
|
|
30
|
-
// What continue → did with the composer as the new link opens (app.js
|
|
31
|
-
// fillOpener): +text+ / +hasChips+ the composer now; +draftFrom+ the session
|
|
32
|
-
// the text was last written in ("" the start page, undefined unknown);
|
|
33
|
-
// +continuedId+ the session continued, +linkId+ the new link. An empty
|
|
34
|
-
// composer gets the opener. A draft written in either session, or of unknown
|
|
35
|
-
// origin, stays (+value+ null). One carried over from another session or the
|
|
36
|
-
// start page gives way to the opener and comes back as +displaced+ (the
|
|
37
|
-
// toast's Restore draft). Its image chips stay either way: only text is
|
|
38
|
-
// replaced.
|
|
39
|
-
export function openerFill({ text, hasChips, draftFrom, continuedId, linkId, created }) {
|
|
40
|
-
const hasText = !!text?.trim();
|
|
41
|
-
if (!hasText && !hasChips) return { value: openerText(created), displaced: null };
|
|
42
|
-
if (draftFrom === undefined || draftFrom === continuedId || draftFrom === linkId) return { value: null, displaced: null };
|
|
43
|
-
return { value: openerText(created), displaced: hasText ? text : null };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// The composer after Restore draft: +draft+ (a displaced draft) replaces
|
|
47
|
-
// +current+ when that is empty or still exactly +opener+; else it goes after
|
|
48
|
-
// it, past a blank line. Never loses text typed since.
|
|
49
|
-
export function restoredComposer({ current, opener, draft }) {
|
|
50
|
-
if (!current.trim() || current === opener) return draft;
|
|
51
|
-
return `${current.replace(/\s+$/, "")}\n\n${draft}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
28
|
// Whether +text+ (a title or a first message) is the opener and nothing
|
|
55
29
|
// else, trimmed: "Continue where we left off. Then fix X" is a title of its own.
|
|
56
30
|
export function isOpener(text) {
|
|
@@ -21,11 +21,10 @@ function optionTemplate(command, i, active) {
|
|
|
21
21
|
// @param commands () => the open session's commands ([] when it takes none)
|
|
22
22
|
// @param afterPick (text) writes a pick's text into the composer (the page's
|
|
23
23
|
// drafts, drafts.js: the list never writes the box; the caret goes after
|
|
24
|
-
// it).
|
|
25
|
-
// reload.
|
|
24
|
+
// it).
|
|
26
25
|
// @return {update(), close(), handleKey(e)}; handleKey returns whether the
|
|
27
26
|
// open list took the key
|
|
28
|
-
export function createCommandList({ list, prompt, commands, afterPick
|
|
27
|
+
export function createCommandList({ list, prompt, commands, afterPick }) {
|
|
29
28
|
let shown = [];
|
|
30
29
|
let index = 0;
|
|
31
30
|
|
|
@@ -63,9 +63,8 @@ export function routeSessionLine(prompt, { commands = [], images = 0, delivery =
|
|
|
63
63
|
// failedElsewhere(line, text, id) a command to session id, no longer open, failed
|
|
64
64
|
// ownedByTui() a plain terminal holds the session
|
|
65
65
|
// composer: {busy(), text(id), clear(id), done()} the composer's send
|
|
66
|
-
// button and the drafts (drafts.js) by the session's
|
|
67
|
-
//
|
|
68
|
-
// cached app.js's take no id: the one box)
|
|
66
|
+
// button and the drafts (drafts.js) by the session's id
|
|
67
|
+
// (text(id): what that draft holds now)
|
|
69
68
|
export function createComposerCommands(deps) {
|
|
70
69
|
const { session, clientId, sendCommand, followWokenWorker, refreshHistory, failed, failedElsewhere, ownedByTui,
|
|
71
70
|
composer } = deps;
|
|
@@ -16,12 +16,9 @@ import { COMPOSER_FLOOR, read as readPref } from "./session_prefs.js";
|
|
|
16
16
|
// button (Send/Start), chips (the chips' row), attachBtn, attachInput (the
|
|
17
17
|
// hidden file picker; both null: no image button, viewer.js), grip}.
|
|
18
18
|
// Hooks: +minPx()+ the empty box's height; +toast(text)+ why images stayed
|
|
19
|
-
// out; +setText(text)+ writes a recalled entry
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// mount's (it wrote a recalled entry itself, then called it), never called
|
|
23
|
-
// here; +loadHistory()+ a promise of the ↑/↓ entries (oldest first; none: no
|
|
24
|
-
// history); +send({queue})+ Enter (+queue+: with Alt/Option) or the button;
|
|
19
|
+
// out; +setText(text)+ writes a recalled entry through the page's drafts,
|
|
20
|
+
// drafts.js; +loadHistory()+ a promise of the ↑/↓ entries (oldest first;
|
|
21
|
+
// none: no history); +send({queue})+ Enter (+queue+: with Alt/Option) or the button;
|
|
25
22
|
// +keyFirst(e)+ a key the page takes before the history's (true: taken);
|
|
26
23
|
// +escape()+ Esc, true when it let go of something. +imagesOff+: why this
|
|
27
24
|
// page takes no images (a participant's page, until its upload path): a
|