samagotchi 0.161.0 → 0.163.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 +41 -1
- data/docs/architecture.md +2 -2
- data/docs/cli.md +1 -1
- data/docs/configuration.md +1 -1
- data/docs/internals/block-renderers.md +3 -2
- data/docs/internals/bridge.md +85 -22
- data/docs/internals/inline-widgets.md +6 -3
- data/docs/internals/web-frontend.md +1 -1
- data/docs/memory.md +8 -2
- data/docs/sessions.md +1 -1
- data/docs/testing.md +13 -1
- data/lib/samagotchi/bridge/card_store.rb +23 -13
- data/lib/samagotchi/bridge/turn_accumulator.rb +7 -1
- data/lib/samagotchi/bridge/turn_drawings/synth.rb +559 -0
- data/lib/samagotchi/bridge/turn_drawings.rb +118 -7
- data/lib/samagotchi/bridge/turn_ranges.rb +175 -0
- data/lib/samagotchi/bridge.rb +35 -12
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/plugin/sessions.rb +8 -1
- data/lib/samagotchi/project_command.rb +74 -6
- data/lib/samagotchi/project_id_clash.rb +1 -1
- data/lib/samagotchi/project_subfolders.rb +188 -0
- data/lib/samagotchi/terminal_ui/join_replay.rb +36 -130
- data/lib/samagotchi/terminal_ui.rb +12 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/message_display.rb +58 -37
- data/lib/samagotchi/web/public/app.js +8 -7
- data/lib/samagotchi/web/public/block_frame.js +5 -1
- data/lib/samagotchi/web/public/data.js +4 -6
- data/lib/samagotchi/web/public/reload_check.js +7 -4
- data/lib/samagotchi/web/public/time_gaps.js +1 -2
- data/lib/samagotchi/web/public/timing.js +52 -216
- data/lib/samagotchi/web/public/turn_block.js +46 -124
- data/lib/samagotchi/web/public/turn_html.js +3 -2
- data/lib/samagotchi/web/public/widget_walk.js +4 -2
- data/lib/samagotchi/web/reload_check_route.rb +6 -3
- data/lib/samagotchi/web/session_show.rb +23 -28
- metadata +4 -1
|
@@ -141,8 +141,9 @@ function tailClip(text) {
|
|
|
141
141
|
// an execute/task_wait's last ones (inlineOutput), the rest on hover; a read
|
|
142
142
|
// of the file as-is also its numbered lines, closed: read_view.js), its images (+thumbs+(images) draws them) and an
|
|
143
143
|
// edit's collapsed diff, and a reloaded row's ✂ mark above its output. A
|
|
144
|
-
// part with nothing to say is left out.
|
|
145
|
-
// the live view
|
|
144
|
+
// part with nothing to say is left out. toolRowTemplate is the row in its
|
|
145
|
+
// element (the specs' harness); the live view, a drawn turn's too, renders
|
|
146
|
+
// toolRowInnerTemplate into its own row element
|
|
146
147
|
// (turn_block.js), again on each event: lit writes only what changed, so a
|
|
147
148
|
// part the user toggled (the raw command, the diff, the read lines) stays.
|
|
148
149
|
// +stop+: the live row's stop-task button (a node), after the title.
|
|
@@ -200,8 +200,10 @@ export function drawWalk(walk, doc = document) {
|
|
|
200
200
|
fork.append(el(doc, "span", "eyebrow", "Which case?"));
|
|
201
201
|
for (const c of cases) {
|
|
202
202
|
const b = button(doc, "ww-case");
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
// A case back to its own step (a retry, as models write it) has nowhere to go.
|
|
204
|
+
const here = c.to === k;
|
|
205
|
+
b.append(el(doc, "span", null, c.when), el(doc, "span", "ww-case-to", here ? "this step" : c.to != null ? `step ${c.to + 1} →` : "?"));
|
|
206
|
+
b.disabled = c.to == null || here;
|
|
205
207
|
b.addEventListener("click", () => { walker.go(c.to); render(); });
|
|
206
208
|
for (const [type, on] of [["mouseenter", true], ["mouseleave", false], ["focus", true], ["blur", false]]) {
|
|
207
209
|
b.addEventListener(type, () => peek(c.to, on));
|
|
@@ -51,8 +51,8 @@ module Samagotchi
|
|
|
51
51
|
|
|
52
52
|
private
|
|
53
53
|
|
|
54
|
-
# {turn_id, same, kinds, excused, explained, drawn} from the
|
|
55
|
-
# whatever it said
|
|
54
|
+
# {turn_id, same, kinds, excused, explained, drawn, undrawn} from the
|
|
55
|
+
# page: 204, whatever it said
|
|
56
56
|
# (fire-and-forget); 400 for a body that isn't a JSON object.
|
|
57
57
|
# worker_version is chi web's own view of the session's worker (its
|
|
58
58
|
# sidecar), never the body's.
|
|
@@ -66,7 +66,10 @@ module Samagotchi
|
|
|
66
66
|
|
|
67
67
|
same = body["same"] == true
|
|
68
68
|
drawn = body["drawn"] == true
|
|
69
|
-
|
|
69
|
+
# The reload's rows with no drawing (the page's plain fallback): a
|
|
70
|
+
# count chi web should keep at 0.
|
|
71
|
+
undrawn = body["undrawn"].is_a?(Integer) ? body["undrawn"].clamp(0, 10_000) : 0
|
|
72
|
+
fields = { sid: id, turn_id: turn_id, same: same, drawn: drawn, undrawn: undrawn, worker_version: checked_worker_version(id) }
|
|
70
73
|
Log.info(:web, "reload_checked", **fields)
|
|
71
74
|
unless same
|
|
72
75
|
Log.info(:web, "reload_mismatch", **fields.except(:same), kinds: checked_tokens(body["kinds"], KINDS),
|
|
@@ -69,16 +69,13 @@ module Samagotchi
|
|
|
69
69
|
session_json = shown_session_json(session, snapshot, owner, persisted)
|
|
70
70
|
raw_messages = live_or_saved(turn_snapshot, "messages") { session.messages }
|
|
71
71
|
timing = timing_payload(id, live_metrics: snapshot && snapshot["metrics"], persisted: persisted)
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
drawn = drawings ? drawn_lines(id, raw_messages) : []
|
|
80
|
-
messages = messages_for_display(raw_messages, parts: parts, cwd: session.working_directory,
|
|
81
|
-
drawings: drawn, strip_drawn: true)
|
|
72
|
+
# Every finished turn is drawn from a line (a real one, else one
|
|
73
|
+
# made from its messages): its items are stamped, and its drawing
|
|
74
|
+
# goes in turn_drawings. The running turn has none yet.
|
|
75
|
+
raw_cards = live_or_saved(turn_snapshot, "cards") { saved_cards(id, messages: raw_messages) }
|
|
76
|
+
drawn = drawn_lines(id, raw_messages, timing: timing, entries: raw_cards, cwd: session.working_directory,
|
|
77
|
+
skip_turn_id: current_turn.is_a?(Hash) ? current_turn["turn_id"] : nil)
|
|
78
|
+
messages = messages_for_display(raw_messages, cwd: session.working_directory, drawings: drawn)
|
|
82
79
|
json_response(200, {
|
|
83
80
|
session: session_json,
|
|
84
81
|
history: read_history(id),
|
|
@@ -100,7 +97,7 @@ module Samagotchi
|
|
|
100
97
|
plugin_warning: turn_snapshot && turn_snapshot["plugin_warning"],
|
|
101
98
|
# Plugins' slow setup still running (chi.init): the page's init row.
|
|
102
99
|
init_tasks: snapshot_list(turn_snapshot, "init_tasks"),
|
|
103
|
-
cards: cards_for_display(
|
|
100
|
+
cards: cards_for_display(raw_cards, cwd: session.working_directory),
|
|
104
101
|
# The composer's / autocomplete; the built-ins until a worker
|
|
105
102
|
# names its plugins' too.
|
|
106
103
|
commands: turn_snapshot&.fetch("commands", nil) || SessionCommands.builtin_registry.listing,
|
|
@@ -139,22 +136,20 @@ module Samagotchi
|
|
|
139
136
|
started_at: active.is_a?(Hash) ? active["started_at"] : nil)
|
|
140
137
|
end
|
|
141
138
|
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
#
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
dir = @session_class.session_dir(id, state_dir: default_state_dir)
|
|
157
|
-
Bridge::TurnDrawings.valid(Bridge::TurnDrawings.read(dir), messages).last(Bridge::TurnDrawings::SHOWN_MAX)
|
|
139
|
+
# The lines the show draws +messages+' turns from (the live snapshot's
|
|
140
|
+
# messages, else the file's), one per finished turn:
|
|
141
|
+
# Bridge::TurnDrawings.cover over the session's file (.read, cached by
|
|
142
|
+
# its size and mtime), the turns no line covers made from their
|
|
143
|
+
# messages with the show's +timing+ records and CardStore +entries+.
|
|
144
|
+
# A file that can't be read gives no lines: every turn is made. Should
|
|
145
|
+
# the cover itself fail, no turn has a line: the page draws each item
|
|
146
|
+
# as a plain row (turn_block.js, the fallback).
|
|
147
|
+
def drawn_lines(id, messages, timing:, entries:, cwd:, skip_turn_id:)
|
|
148
|
+
dir = @session_class.session_dir(id, state_dir: default_state_dir)
|
|
149
|
+
lines = Degrade.call(:web, "turn_drawings_unreadable", fallback: []) { Bridge::TurnDrawings.read(dir) }
|
|
150
|
+
Degrade.call(:web, "turn_drawings_uncovered", fallback: []) do
|
|
151
|
+
Bridge::TurnDrawings.cover(lines, messages, timing: timing, entries: entries, skip_turn_id: skip_turn_id,
|
|
152
|
+
session_id: id, cwd: cwd)
|
|
158
153
|
end
|
|
159
154
|
end
|
|
160
155
|
|
|
@@ -162,7 +157,7 @@ module Samagotchi
|
|
|
162
157
|
# (chi web's one unfold of a drawing, its cards too); nothing without
|
|
163
158
|
# one.
|
|
164
159
|
def turn_drawings_field(lines, messages)
|
|
165
|
-
stamped = messages.
|
|
160
|
+
stamped = messages.to_set { |item| item[:drawn] }
|
|
166
161
|
shown = lines.select { |line| stamped.include?(line.turn_id) }
|
|
167
162
|
return {} if shown.empty?
|
|
168
163
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: samagotchi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.163.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -206,7 +206,9 @@ files:
|
|
|
206
206
|
- lib/samagotchi/bridge/sse_writer.rb
|
|
207
207
|
- lib/samagotchi/bridge/turn_accumulator.rb
|
|
208
208
|
- lib/samagotchi/bridge/turn_drawings.rb
|
|
209
|
+
- lib/samagotchi/bridge/turn_drawings/synth.rb
|
|
209
210
|
- lib/samagotchi/bridge/turn_notice.rb
|
|
211
|
+
- lib/samagotchi/bridge/turn_ranges.rb
|
|
210
212
|
- lib/samagotchi/bridge_client.rb
|
|
211
213
|
- lib/samagotchi/bridge_client/event_stream.rb
|
|
212
214
|
- lib/samagotchi/bridge_client/sse_parser.rb
|
|
@@ -602,6 +604,7 @@ files:
|
|
|
602
604
|
- lib/samagotchi/project_id_clash.rb
|
|
603
605
|
- lib/samagotchi/project_init.rb
|
|
604
606
|
- lib/samagotchi/project_scope.rb
|
|
607
|
+
- lib/samagotchi/project_subfolders.rb
|
|
605
608
|
- lib/samagotchi/prompt.rb
|
|
606
609
|
- lib/samagotchi/prompt_files.rb
|
|
607
610
|
- lib/samagotchi/prompt_history.rb
|