samagotchi 0.162.0 → 0.164.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 +42 -1
- data/docs/architecture.md +2 -2
- data/docs/bundles.md +4 -2
- data/docs/cli.md +7 -2
- data/docs/configuration.md +1 -1
- data/docs/internals/block-renderers.md +3 -1
- data/docs/internals/bridge.md +37 -24
- data/docs/internals/inline-widgets.md +5 -2
- data/docs/internals/remote-sessions.md +7 -2
- data/docs/internals/web-frontend.md +1 -1
- data/docs/memory.md +8 -2
- data/docs/sessions.md +3 -2
- data/docs/sub-agent.md +11 -0
- data/docs/testing.md +8 -2
- data/lib/samagotchi/block_renderers.rb +14 -4
- data/lib/samagotchi/bridge/turn_drawings/synth.rb +7 -3
- data/lib/samagotchi/bridge/turn_drawings.rb +45 -30
- data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
- data/lib/samagotchi/bundles/inline-widgets/plugin.rb +8 -4
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/cli/parent_wait.rb +5 -1
- data/lib/samagotchi/continue_intent.rb +48 -0
- data/lib/samagotchi/message_parts.rb +13 -0
- data/lib/samagotchi/note_command.rb +3 -6
- data/lib/samagotchi/parent_report.rb +3 -2
- data/lib/samagotchi/project_command.rb +74 -6
- data/lib/samagotchi/project_subfolders.rb +188 -0
- data/lib/samagotchi/send_command/parent_gate.rb +8 -5
- data/lib/samagotchi/send_command.rb +139 -34
- data/lib/samagotchi/session_access/local.rb +6 -0
- data/lib/samagotchi/session_access/remote.rb +25 -0
- data/lib/samagotchi/session_continue.rb +5 -3
- data/lib/samagotchi/session_inbox_delivery.rb +54 -7
- data/lib/samagotchi/session_manager/delivery.rb +3 -1
- data/lib/samagotchi/terminal_ui/join_replay.rb +2 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/message_display.rb +45 -36
- data/lib/samagotchi/web/public/app.js +8 -7
- data/lib/samagotchi/web/public/apple-touch-icon.png +0 -0
- data/lib/samagotchi/web/public/data.js +4 -6
- data/lib/samagotchi/web/public/favicon.svg +1 -1
- data/lib/samagotchi/web/public/icons/chi-180.png +0 -0
- data/lib/samagotchi/web/public/icons/chi-192.png +0 -0
- data/lib/samagotchi/web/public/icons/chi-512.png +0 -0
- data/lib/samagotchi/web/public/inline_widgets.js +4 -1
- 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 +49 -224
- data/lib/samagotchi/web/public/turn_block.js +40 -122
- data/lib/samagotchi/web/public/turn_html.js +3 -2
- data/lib/samagotchi/web/public/widget_walk.js +14 -4
- data/lib/samagotchi/web/reload_check_route.rb +6 -3
- data/lib/samagotchi/web/session_access_routes.rb +8 -1
- data/lib/samagotchi/web/session_show.rb +8 -24
- metadata +3 -1
|
@@ -4,6 +4,7 @@ require_relative "session"
|
|
|
4
4
|
require_relative "session_inbox"
|
|
5
5
|
require_relative "archive_store"
|
|
6
6
|
require_relative "worker_presence"
|
|
7
|
+
require_relative "continue_intent"
|
|
7
8
|
|
|
8
9
|
module Samagotchi
|
|
9
10
|
# Loaded on first use: this autoload keeps SessionManager and its ~80
|
|
@@ -18,9 +19,28 @@ module Samagotchi
|
|
|
18
19
|
# (spec/samagotchi/testing/sandbox_spec.rb) stays as it was.
|
|
19
20
|
module SessionInbox
|
|
20
21
|
# Where a delivery for +asked+ goes: +id+, reached +via+ :pinned (the
|
|
21
|
-
# kind never follows a chain), :same (followed, nothing to follow)
|
|
22
|
-
# :head (a later link of +asked+'s chain)
|
|
23
|
-
|
|
22
|
+
# kind never follows a chain), :same (followed, nothing to follow),
|
|
23
|
+
# :head (a later link of +asked+'s chain) or :continuing (a send whose
|
|
24
|
+
# link is being continued: +id+ is the successor, not saved yet; the
|
|
25
|
+
# sender asks again in a moment, Head.resolve).
|
|
26
|
+
Resolved = Data.define(:id, :asked, :via) do
|
|
27
|
+
# How a line names where it went: +asked+'s short id, or
|
|
28
|
+
# "OLD → NEW (continued)" when a later link took it (chi send's and
|
|
29
|
+
# chi note's one wording).
|
|
30
|
+
def self.label(asked, id)
|
|
31
|
+
return asked[0, 8] if asked == id
|
|
32
|
+
|
|
33
|
+
"#{asked[0, 8]} → #{id[0, 8]} (continued)"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def label = Resolved.label(asked, id)
|
|
37
|
+
|
|
38
|
+
def continuing? = via == :continuing
|
|
39
|
+
|
|
40
|
+
# The refusal of a send whose link is still being continued once the
|
|
41
|
+
# sender's wait is over.
|
|
42
|
+
def continuing_refusal = "being continued as #{id[0, 8]}; send again in a moment"
|
|
43
|
+
end
|
|
24
44
|
|
|
25
45
|
# A delivery's outcome.
|
|
26
46
|
# @!attribute kind [Symbol] the WakePolicy row
|
|
@@ -105,8 +125,15 @@ module Samagotchi
|
|
|
105
125
|
private def scratch?(load) = load ? load.call.scratch == true : false
|
|
106
126
|
end
|
|
107
127
|
|
|
128
|
+
# A send follows a chain as a note does: input for a continued link
|
|
129
|
+
# goes to its chain's newest link (chi send resolves it once up front,
|
|
130
|
+
# SessionAccess#head; SessionManager.deliver_turn resolves nothing).
|
|
131
|
+
# What stays on the id it names doesn't ask Head: the web composer (a
|
|
132
|
+
# person on that page means that session), a participant's grant (one
|
|
133
|
+
# session), delegate follow-ups, Plugin::Sessions and Schedules (their
|
|
134
|
+
# own rule).
|
|
108
135
|
WakePolicy::ROWS = {
|
|
109
|
-
send: WakePolicy.new(kind: :send, resolves: :
|
|
136
|
+
send: WakePolicy.new(kind: :send, resolves: :head, starts: true, unstops: true, starts_archived: true,
|
|
110
137
|
refuse_tui: true, refuse_scratch: true),
|
|
111
138
|
note: WakePolicy.new(kind: :note, resolves: :head, starts: false, unstops: false, starts_archived: false,
|
|
112
139
|
refuse_tui: true, refuse_scratch: true),
|
|
@@ -133,12 +160,22 @@ module Samagotchi
|
|
|
133
160
|
# Else the walk forward over archived links that have a successor:
|
|
134
161
|
# to the first link not archived, or the last (a loop a hand-edited
|
|
135
162
|
# file could make ends where it started); a :reader kind goes one hop
|
|
136
|
-
# at most.
|
|
163
|
+
# at most. Then, for a kind that would un-archive the link it reaches
|
|
164
|
+
# (a send: WakePolicy#starts_archived), a continue of that link in
|
|
165
|
+
# flight (ContinueIntent.in_flight: its successor not saved yet) gives
|
|
166
|
+
# :continuing, the successor's id. A note needs no such check: written
|
|
167
|
+
# to the link before NoteMove.move it moves, after it the new link's
|
|
168
|
+
# worker adopts it (NoteMove.adoption).
|
|
137
169
|
# @return [Resolved]
|
|
138
170
|
def resolve(kind, id, state_dir:)
|
|
139
|
-
|
|
140
|
-
return Resolved.new(id: id, asked: id, via: :pinned) if
|
|
171
|
+
policy = WakePolicy.for(kind)
|
|
172
|
+
return Resolved.new(id: id, asked: id, via: :pinned) if policy.resolves == :pinned
|
|
173
|
+
|
|
174
|
+
resolved = walk(policy.resolves, id, state_dir)
|
|
175
|
+
(continuing(resolved, state_dir) if policy.starts_archived) || resolved
|
|
176
|
+
end
|
|
141
177
|
|
|
178
|
+
def walk(how, id, state_dir)
|
|
142
179
|
same = Resolved.new(id: id, asked: id, via: :same)
|
|
143
180
|
return same unless archived?(id, state_dir)
|
|
144
181
|
|
|
@@ -151,6 +188,16 @@ module Samagotchi
|
|
|
151
188
|
seen.size == 1 ? same : Resolved.new(id: seen.last, asked: id, via: :head)
|
|
152
189
|
end
|
|
153
190
|
|
|
191
|
+
# +resolved+'s link being continued, its successor not saved yet: the
|
|
192
|
+
# successor, via :continuing; else nil (none in flight, or saved: the
|
|
193
|
+
# walk reached it).
|
|
194
|
+
def continuing(resolved, state_dir)
|
|
195
|
+
successor = ContinueIntent.in_flight(resolved.id, state_dir: state_dir)
|
|
196
|
+
return nil if successor.nil? || Session.exist?(successor, state_dir: state_dir)
|
|
197
|
+
|
|
198
|
+
Resolved.new(id: successor, asked: resolved.asked, via: :continuing)
|
|
199
|
+
end
|
|
200
|
+
|
|
154
201
|
def archived?(id, state_dir)
|
|
155
202
|
Session.valid_id?(id) && ArchiveStore.archived?(Session.session_dir(id, state_dir: state_dir))
|
|
156
203
|
end
|
|
@@ -225,7 +225,9 @@ module Samagotchi
|
|
|
225
225
|
|
|
226
226
|
# deliver_turn's two liveness checks, on the session inbox's send row
|
|
227
227
|
# (SessionInbox::WakePolicy: send un-stops and starts an archived
|
|
228
|
-
# link
|
|
228
|
+
# link). The row follows a chain, deliver_turn doesn't: it acts on
|
|
229
|
+
# the id it is given, and a caller that follows (chi send) resolves
|
|
230
|
+
# the head first (SessionAccess#head): resume_session unless a
|
|
229
231
|
# worker holds the session or one is being started. Its refusals (no
|
|
230
232
|
# session, a one-turn run's, a scratch one) are resume_session's to
|
|
231
233
|
# raise, in their one wording: +before+ the write, a session it would
|
|
@@ -146,8 +146,8 @@ module Samagotchi
|
|
|
146
146
|
|
|
147
147
|
# The snapshot's drawing as [turn, end event] when it is +prompt+'s
|
|
148
148
|
# turn (a Continue's or a reminder's drawing isn't the prompt's: the
|
|
149
|
-
#
|
|
150
|
-
# list of rows.
|
|
149
|
+
# prompt's turn is made from its messages, #made_turn), else nil; nil
|
|
150
|
+
# too for one whose parts aren't a list of rows.
|
|
151
151
|
def drawn_turn(drawing, prompt)
|
|
152
152
|
return nil unless drawing.is_a?(Hash) && drawing[:drawing].is_a?(Hash) && drawing[:end].is_a?(Hash)
|
|
153
153
|
|
data/lib/samagotchi/version.rb
CHANGED
|
@@ -90,27 +90,31 @@ module Samagotchi
|
|
|
90
90
|
|
|
91
91
|
# @param msgs [Array<Hash>] a session's messages; symbol keys from disk,
|
|
92
92
|
# string keys from a Bridge snapshot
|
|
93
|
-
# @param parts [Boolean] the
|
|
94
|
-
#
|
|
95
|
-
#
|
|
96
|
-
#
|
|
93
|
+
# @param parts [Boolean] the participant review's: each assistant
|
|
94
|
+
# message also carries what it did (MessageParts: thinking, tool
|
|
95
|
+
# calls with params and output), and a message with nothing to show
|
|
96
|
+
# but that (a text-less step) is kept with empty content
|
|
97
97
|
# @param cwd [String, nil] the session's working directory (the parts'
|
|
98
98
|
# tool titles are relative to it)
|
|
99
99
|
# @param markdown [Boolean] false: no html for a delegate report or an
|
|
100
100
|
# answer (the participant review drops both and renders its replies
|
|
101
101
|
# from their redacted text, ParticipantReview#with_reply_html)
|
|
102
|
-
# @param drawings [Array<Bridge::TurnDrawings::Line
|
|
103
|
-
# (TurnDrawings.
|
|
104
|
-
# draws (#drawn_kind?) from a line's range gets
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
|
|
102
|
+
# @param drawings [Array<Bridge::TurnDrawings::Line>, nil] the owner
|
|
103
|
+
# show's lines (TurnDrawings.cover against +msgs+): each item of a
|
|
104
|
+
# kind a drawing draws (#drawn_kind?) from a line's range gets
|
|
105
|
+
# `drawn: <turn_id>`, a step its outputs' ✂ marks as `marks:
|
|
106
|
+
# {tool_id => edit}` (an overlay on the drawing's rows), and a
|
|
107
|
+
# text-less step stays (empty content: its marks, the turn's last
|
|
108
|
+
# step); nil: no stamps (the participant review, a lone answer)
|
|
109
|
+
def messages_for_display(msgs, parts: false, cwd: nil, markdown: true, drawings: nil)
|
|
108
110
|
filtered = []
|
|
109
111
|
list = Array(msgs)
|
|
112
|
+
steps = !drawings.nil?
|
|
110
113
|
# Each item's message index, for the drawings' stamps.
|
|
111
114
|
origins = []
|
|
112
|
-
# The outputs' ✂ marks (LLM context edits), by id, for the parts
|
|
113
|
-
|
|
115
|
+
# The outputs' ✂ marks (LLM context edits), by id, for the parts
|
|
116
|
+
# and the drawn steps.
|
|
117
|
+
marks = parts || steps ? MessageParts.edit_marks(list) : {}
|
|
114
118
|
# The list before each objectives note, for what its entry says changed.
|
|
115
119
|
objectives = nil
|
|
116
120
|
list.each_with_index do |m, index|
|
|
@@ -145,7 +149,7 @@ module Samagotchi
|
|
|
145
149
|
# empty steps (with ?parts=1) and the item the page draws its
|
|
146
150
|
# notice from; the note itself stays hidden.
|
|
147
151
|
if (marker = Samagotchi::TurnNote.empty_answer(m))
|
|
148
|
-
filtered.concat(empty_answer_items(marker, parts: parts, cwd: cwd))
|
|
152
|
+
filtered.concat(empty_answer_items(marker, parts: parts, steps: steps, cwd: cwd))
|
|
149
153
|
next
|
|
150
154
|
end
|
|
151
155
|
next if role == "system"
|
|
@@ -155,8 +159,9 @@ module Samagotchi
|
|
|
155
159
|
next if Samagotchi::Steer.recovery?(m)
|
|
156
160
|
|
|
157
161
|
stripped = Samagotchi::OutputFormatter.strip_markup(content)
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
step = %w[model assistant].include?(role)
|
|
163
|
+
did = parts && step ? message_parts(list, index, cwd, marks) : nil
|
|
164
|
+
next if stripped.empty? && did.nil? && !(steps && step && MessageParts.something?(m))
|
|
160
165
|
|
|
161
166
|
norm_role = role == "model" ? "assistant" : role
|
|
162
167
|
# normalize assistant vs model, keep user as is
|
|
@@ -219,31 +224,44 @@ module Samagotchi
|
|
|
219
224
|
message[:display_refs] = refs unless refs.empty?
|
|
220
225
|
end
|
|
221
226
|
message[:parts] = did if did
|
|
227
|
+
step_marks = steps && step ? output_marks(list, index, cwd, marks) : {}
|
|
228
|
+
message[:marks] = step_marks unless step_marks.empty?
|
|
222
229
|
filtered << message
|
|
223
230
|
end
|
|
224
231
|
origins.fill(list.size - 1, origins.size...filtered.size)
|
|
225
|
-
stamp_drawn(filtered, origins, Array(drawings)
|
|
232
|
+
stamp_drawn(filtered, origins, Array(drawings))
|
|
226
233
|
rescue StandardError
|
|
227
234
|
[]
|
|
228
235
|
end
|
|
229
236
|
|
|
237
|
+
# The ✂ marks of the outputs right after the model message at +index+,
|
|
238
|
+
# by output id, as its parts have them (a stub's size from its own
|
|
239
|
+
# output): its parts are read only when +marks+ (the session's, by
|
|
240
|
+
# output id) names one of them.
|
|
241
|
+
def output_marks(list, index, cwd, marks)
|
|
242
|
+
return {} if marks.empty?
|
|
243
|
+
|
|
244
|
+
responses = list.drop(index + 1).take_while { |r| (r[:role] || r["role"]).to_s == "tool_response" }
|
|
245
|
+
return {} unless responses.any? { |r| Array(r[:tool_ids] || r["tool_ids"]).any? { |id| marks.key?(id.to_s) } }
|
|
246
|
+
|
|
247
|
+
tools = Array(message_parts(list, index, cwd, marks)&.dig(:tools))
|
|
248
|
+
tools.filter_map { |tool| [tool[:tool_id], tool[:edit]] if tool[:tool_id] && tool[:edit] }.to_h
|
|
249
|
+
end
|
|
250
|
+
|
|
230
251
|
# +items+ with a drawn turn's stamp on each item of a kind its drawing
|
|
231
252
|
# draws (the opening, steps, steers, merged lines, the empty answer):
|
|
232
253
|
# a context note, a `!cmd`'s record and anything else keep today's
|
|
233
254
|
# place. +origins+: each item's message index.
|
|
234
255
|
# One walk: +drawings+ are sorted apart by range, +origins+ never go
|
|
235
256
|
# back.
|
|
236
|
-
def stamp_drawn(items, origins, drawings
|
|
257
|
+
def stamp_drawn(items, origins, drawings)
|
|
237
258
|
return items if drawings.empty?
|
|
238
259
|
|
|
239
260
|
at = 0
|
|
240
261
|
items.each_with_index.map do |item, i|
|
|
241
262
|
at += 1 while at < drawings.size && drawings[at].to <= origins[i]
|
|
242
263
|
line = drawings[at] if at < drawings.size && drawings[at].range.cover?(origins[i])
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
stamped = item.merge(drawn: line.turn_id)
|
|
246
|
-
strip ? without_parts(stamped) : stamped
|
|
264
|
+
line && drawn_kind?(item) ? item.merge(drawn: line.turn_id) : item
|
|
247
265
|
end
|
|
248
266
|
end
|
|
249
267
|
|
|
@@ -255,15 +273,6 @@ module Samagotchi
|
|
|
255
273
|
end
|
|
256
274
|
end
|
|
257
275
|
|
|
258
|
-
# A drawn item without its parts: its ✂ marks by output id stay (an
|
|
259
|
-
# overlay on the drawing's rows: later state, as a card's latest body).
|
|
260
|
-
def without_parts(item)
|
|
261
|
-
tools = Array(item.dig(:parts, :tools))
|
|
262
|
-
marks = tools.filter_map { |tool| [tool[:tool_id], tool[:edit]] if tool[:tool_id] && tool[:edit] }.to_h
|
|
263
|
-
out = item.except(:parts)
|
|
264
|
-
marks.empty? ? out : out.merge(marks: marks)
|
|
265
|
-
end
|
|
266
|
-
|
|
267
276
|
# A turn opening's Revise stamp as {revises: {turn_id:}}, checked again
|
|
268
277
|
# (a stored file is never trusted), or nothing.
|
|
269
278
|
def revises_of(message)
|
|
@@ -280,13 +289,13 @@ module Samagotchi
|
|
|
280
289
|
|
|
281
290
|
# A no-answer turn's marker as display items: each empty step that
|
|
282
291
|
# has something to show (its thinking) as a text-less assistant step
|
|
283
|
-
# (only with +parts+, as other text-less steps
|
|
284
|
-
# { role: "empty_answer", retries: }.
|
|
285
|
-
def empty_answer_items(marker, parts:, cwd:)
|
|
286
|
-
|
|
287
|
-
items =
|
|
292
|
+
# (only with +parts+ or +steps+, as other text-less steps; its parts
|
|
293
|
+
# with +parts+), then { role: "empty_answer", retries: }.
|
|
294
|
+
def empty_answer_items(marker, parts:, steps:, cwd:)
|
|
295
|
+
saved = parts || steps ? Array(marker[:steps] || marker["steps"]) : []
|
|
296
|
+
items = saved.filter_map do |step|
|
|
288
297
|
did = step.is_a?(Hash) ? MessageParts.for_message(step, [], cwd: cwd) : nil
|
|
289
|
-
{ role: "assistant", content: "", parts: did } if did
|
|
298
|
+
{ role: "assistant", content: "", **(parts ? { parts: did } : {}) } if did
|
|
290
299
|
end
|
|
291
300
|
refusal = marker[:refusal] || marker["refusal"]
|
|
292
301
|
items << { role: "empty_answer", content: "", retries: (marker[:retries] || marker["retries"]).to_i, refusal: refusal }.compact
|
|
@@ -365,7 +365,7 @@ const reloadCheck = createReloadCheck({
|
|
|
365
365
|
enabled: () => document.body.dataset.reloadCheck === "1",
|
|
366
366
|
sessionId: () => store.selected,
|
|
367
367
|
running: () => liveTurn.running,
|
|
368
|
-
read: (id) => getSession(id
|
|
368
|
+
read: (id) => getSession(id),
|
|
369
369
|
render: (data) => turnHistoryNodes(data.messages || [], normalizeTiming(data.timing), historyOpts(data)),
|
|
370
370
|
post: (id, body) => api(`/api/sessions/${id}/reload_check`, { method: "POST", body: JSON.stringify(body) }),
|
|
371
371
|
});
|
|
@@ -961,7 +961,7 @@ async function resync({ endText = null } = {}) {
|
|
|
961
961
|
let data;
|
|
962
962
|
try {
|
|
963
963
|
try {
|
|
964
|
-
data = await getSession(id
|
|
964
|
+
data = await getSession(id);
|
|
965
965
|
} catch (e) {
|
|
966
966
|
if (e.status === 404) return leaveGoneSession(id, "not_found");
|
|
967
967
|
if (id === store.selected) {
|
|
@@ -1090,13 +1090,12 @@ function renderSessionView(data, { kept = [] } = {}) {
|
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
1092
|
// The working set's turns from a session's messages, as turnHistoryNodes
|
|
1093
|
-
// numbers them
|
|
1094
|
-
//
|
|
1093
|
+
// numbers them: the drawn ones (the running turn, which the replay draws
|
|
1094
|
+
// in the stage, has no drawing yet).
|
|
1095
1095
|
function seedWorkingSet(data) {
|
|
1096
1096
|
if (!workingSet) return;
|
|
1097
1097
|
const items = data.messages || [];
|
|
1098
1098
|
const groups = typeof items[0] === "object" && items[0]?.role ? turnGroups(items, store.current.timing, { drawings: data.turn_drawings }).filter((g) => g.kind === "turn") : [];
|
|
1099
|
-
if (data.current_turn && groups.length) groups.pop();
|
|
1100
1099
|
workingSet.seed(groups.map((g, i) => {
|
|
1101
1100
|
const text = String(items[g.user]?.content ?? "").replace(/\s+/g, " ").trim();
|
|
1102
1101
|
return { items: groupItems(g, i), prompt: text.length > 60 ? `${text.slice(0, 59)}\u2026` : text };
|
|
@@ -1104,9 +1103,11 @@ function seedWorkingSet(data) {
|
|
|
1104
1103
|
}
|
|
1105
1104
|
|
|
1106
1105
|
// turnHistoryNodes' options for a read's +data+: its turns' drawings
|
|
1107
|
-
// (turn_drawing.js)
|
|
1106
|
+
// (turn_drawing.js), cards (a drawn card's body) and the running turn's id
|
|
1107
|
+
// (its prompt has no drawing yet: a plain row, no miss).
|
|
1108
1108
|
const historyOpts = (data = {}) => ({ thumbs: (images) => thumbsTemplate(store.selected, images), workingSet: !!workingSet,
|
|
1109
|
-
drawings: data.turn_drawings || null, cards: data.cards || null, capabilities: pageCapabilities
|
|
1109
|
+
drawings: data.turn_drawings || null, cards: data.cards || null, capabilities: pageCapabilities,
|
|
1110
|
+
runningTurnId: data.current_turn?.turn_id || null });
|
|
1110
1111
|
|
|
1111
1112
|
function renderHistory(items, data = {}) {
|
|
1112
1113
|
gapClock.seed(null);
|
|
Binary file
|
|
@@ -129,12 +129,10 @@ export function uploadImage(id, file, name, opts = {}) {
|
|
|
129
129
|
// opts.recent its timing holds the newest turn's records and turn_count
|
|
130
130
|
// (mergeTiming), and opts.turnId asks for that turn's answer.
|
|
131
131
|
// opts.timing: the whole timing alone (when the merge came up short).
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
export function getSession(id, { tail, recent, turnId, timing, parts, cards, ...opts } = {}) {
|
|
137
|
-
let query = cards ? "?cards=1" : tail ? "?tail=1" : timing ? "?timing=1" : parts ? "?parts=1&drawings=1" : "";
|
|
132
|
+
// The full read (none of those): every finished turn as its
|
|
133
|
+
// turn_drawings, its items stamped (drawn: turn_drawing.js).
|
|
134
|
+
export function getSession(id, { tail, recent, turnId, timing, cards, ...opts } = {}) {
|
|
135
|
+
let query = cards ? "?cards=1" : tail ? "?tail=1" : timing ? "?timing=1" : "";
|
|
138
136
|
if (tail && recent) query += "&recent=1";
|
|
139
137
|
if (tail && turnId) query += `&turn_id=${encodeURIComponent(turnId)}`;
|
|
140
138
|
return api(`/api/sessions/${id}${query}`, opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="1" y="1" width="30" height="30" rx="7.5" fill="#22262f"/><
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="1" y="1" width="30" height="30" rx="7.5" fill="#22262f"/><path fill="#fff" d="M23.3 8.12L22.94 8.25L22.58 8.38L22.23 8.52L21.89 8.66L21.56 8.82L21.25 8.99L20.95 9.16L20.66 9.35L20.39 9.55L20.13 9.77L19.88 9.99L19.65 10.23L19.43 10.48L19.23 10.74L19.03 11.01L18.83 11.27L18.63 11.54L18.44 11.81L18.24 12.07L18.04 12.34L17.83 12.6L17.63 12.87L17.43 13.13L17.23 13.4L17.02 13.66L16.82 13.92L16.61 14.18L16.41 14.45L16.2 14.71L15.99 14.97L15.78 15.23L15.57 15.49L15.37 15.75L15.15 16.01L14.94 16.26L14.73 16.52L14.52 16.78L14.31 17.04L14.09 17.29L13.88 17.55L13.66 17.8L13.45 18.06L13.23 18.31L13.01 18.57L12.8 18.82L12.58 19.07L12.36 19.33L12.14 19.58L11.92 19.83L11.7 20.08L11.48 20.33L11.25 20.58L11.03 20.83L10.81 21.08L10.58 21.32L10.36 21.57L10.13 21.82L9.9 22.06L9.67 22.3L9.44 22.55L9.21 22.79L8.98 23.03L8.75 23.27L8.51 23.51L8.69 23.69L8.94 23.47L9.19 23.26L9.45 23.04L9.71 22.83L9.96 22.61L10.22 22.4L10.48 22.18L10.73 21.97L10.99 21.75L11.25 21.54L11.51 21.32L11.77 21.11L12.02 20.9L12.28 20.68L12.54 20.47L12.8 20.25L13.05 20.04L13.31 19.82L13.57 19.6L13.83 19.39L14.08 19.17L14.34 18.95L14.6 18.74L14.85 18.52L15.11 18.3L15.36 18.08L15.62 17.86L15.88 17.64L16.13 17.42L16.39 17.2L16.64 16.98L16.9 16.76L17.15 16.54L17.4 16.32L17.66 16.1L17.91 15.88L18.17 15.65L18.42 15.43L18.67 15.21L18.92 14.98L19.18 14.76L19.43 14.53L19.68 14.31L19.93 14.08L20.18 13.85L20.43 13.63L20.68 13.4L20.93 13.17L21.18 12.94L21.43 12.71L21.67 12.48L21.9 12.23L22.11 11.96L22.31 11.69L22.49 11.4L22.66 11.1L22.81 10.78L22.94 10.46L23.07 10.12L23.17 9.77L23.27 9.41L23.35 9.04L23.43 8.66L23.5 8.28Z"/><path fill="#fff" stroke="#22262f" stroke-width="1.7" stroke-linejoin="round" paint-order="stroke" d="M6.28 10.12L6.76 10.1L7.2 10.05L7.61 10.02L8 10L8.37 10.01L8.72 10.05L9.03 10.12L9.31 10.22L9.55 10.34L9.77 10.48L9.96 10.64L10.13 10.82L10.3 11.01L10.46 11.22L10.62 11.45L10.77 11.7L10.92 11.97L11.06 12.25L11.2 12.55L11.4 12.94L11.59 13.32L11.8 13.69L12 14.06L12.21 14.43L12.42 14.8L12.64 15.17L12.86 15.53L13.09 15.89L13.32 16.25L13.55 16.6L13.79 16.95L14.03 17.31L14.28 17.65L14.52 18L14.77 18.35L15.03 18.69L15.29 19.03L15.55 19.37L15.81 19.71L16.07 20.04L16.34 20.38L16.61 20.71L16.88 21.04L17.16 21.37L17.43 21.7L17.74 22.07L18.09 22.45L18.48 22.81L18.91 23.15L19.37 23.45L19.86 23.69L20.39 23.88L20.93 23.99L21.47 24.03L21.99 24L22.48 23.91L22.95 23.76L23.39 23.58L23.8 23.37L24.19 23.12L24.54 22.84L24.93 22.65L25.31 22.44L25.68 22.23L25.52 21.97L25.16 22.18L24.79 22.38L24.41 22.56L23.98 22.61L23.57 22.65L23.16 22.67L22.77 22.67L22.4 22.62L22.04 22.55L21.72 22.43L21.43 22.28L21.17 22.11L20.94 21.9L20.74 21.67L20.55 21.41L20.39 21.14L20.24 20.84L20.11 20.52L19.97 20.17L19.81 19.77L19.64 19.38L19.47 18.98L19.3 18.59L19.13 18.19L18.96 17.8L18.78 17.41L18.6 17.03L18.42 16.64L18.23 16.25L18.05 15.87L17.85 15.49L17.66 15.11L17.46 14.74L17.26 14.36L17.05 13.99L16.84 13.62L16.63 13.25L16.41 12.89L16.19 12.53L15.97 12.17L15.74 11.81L15.5 11.45L15.26 11.1L15.02 10.75L14.77 10.41L14.47 9.99L14.12 9.58L13.74 9.18L13.32 8.8L12.86 8.45L12.35 8.14L11.8 7.87L11.22 7.67L10.61 7.55L9.99 7.5L9.39 7.55L8.82 7.67L8.29 7.86L7.81 8.1L7.38 8.38L6.99 8.7L6.65 9.05L6.35 9.43L6.12 9.88Z"/></svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -36,12 +36,15 @@ export const STYLESHEET = "/assets/widgets.css";
|
|
|
36
36
|
export const TOGGLE_PICTURE = "Show the widget";
|
|
37
37
|
|
|
38
38
|
// widgets.css as a constructable sheet, fetched once per page; a failed fetch
|
|
39
|
-
// draws unstyled and is tried again by the next draw.
|
|
39
|
+
// draws unstyled and is tried again by the next draw. An answer that isn't CSS
|
|
40
|
+
// (an auth proxy's 200 login page) counts as failed.
|
|
40
41
|
let shared = null;
|
|
41
42
|
export function loadWidgetSheet(win = window) {
|
|
42
43
|
shared ??= win.fetch(STYLESHEET, { headers: { Accept: "text/css" } })
|
|
43
44
|
.then((res) => {
|
|
44
45
|
if (!res.ok) throw new Error(`widgets.css answered ${res.status}`);
|
|
46
|
+
const type = res.headers.get("content-type") || "";
|
|
47
|
+
if (!type.startsWith("text/css")) throw new Error(`widgets.css answered ${type || "no Content-Type"}`);
|
|
45
48
|
return res.text();
|
|
46
49
|
})
|
|
47
50
|
.catch((e) => {
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
// entries that would explain the differences (`explained`: all of them
|
|
8
8
|
// have one), so chi web's log counts each class apart (the bugs turn
|
|
9
9
|
// drawings close, the deliberate ones). It posts the counts, never
|
|
10
|
-
// content: {turn_id, same, kinds, excused, explained, drawn}; chi
|
|
11
|
-
// them (reload_checked, reload_mismatch).
|
|
10
|
+
// content: {turn_id, same, kinds, excused, explained, drawn, undrawn}; chi
|
|
11
|
+
// web logs them (reload_checked, reload_mismatch). `undrawn`: how many rows
|
|
12
|
+
// of the reload came without their turn's drawing (turn_block.js's plain
|
|
13
|
+
// fallback, data-undrawn): 0 unless chi web missed one. Fire-and-forget: no toast, no
|
|
12
14
|
// store write, a failure is dropped.
|
|
13
15
|
//
|
|
14
16
|
// Cards are left out on both sides: a reload places them after the render
|
|
@@ -34,7 +36,7 @@ function withoutCards(shape) {
|
|
|
34
36
|
// @param sessionId () => the open session's id
|
|
35
37
|
// @param running () => whether a turn runs now (liveTurn.running: a queued
|
|
36
38
|
// turn started streaming)
|
|
37
|
-
// @param read (id) => the session as a reload reads it (GET
|
|
39
|
+
// @param read (id) => the session as a reload reads it (the full GET)
|
|
38
40
|
// @param render (data) => that read drawn as a reload draws it (a fragment)
|
|
39
41
|
// @param post (id, body) => the counts to chi web
|
|
40
42
|
export function createReloadCheck({ enabled, sessionId, running, read, render, post }) {
|
|
@@ -62,7 +64,8 @@ export function createReloadCheck({ enabled, sessionId, running, read, render, p
|
|
|
62
64
|
: { same: false, kinds: ["prompt"], excused: [], explained: false };
|
|
63
65
|
// Whether the read had a drawing for the turn (turn drawings, P2).
|
|
64
66
|
const drawn = !!data?.turn_drawings?.[turnId];
|
|
65
|
-
|
|
67
|
+
const undrawn = holder.querySelectorAll("[data-undrawn]").length;
|
|
68
|
+
await post(id, { turn_id: turnId, same, kinds, excused, explained, drawn, undrawn });
|
|
66
69
|
} catch (_) {
|
|
67
70
|
// Fire-and-forget: a failed read or post is no finding.
|
|
68
71
|
}
|
|
@@ -28,8 +28,7 @@ export function timeGapEl(text) {
|
|
|
28
28
|
|
|
29
29
|
// The history items a group (timing.js turnGroups) holds, by index.
|
|
30
30
|
function groupIndexes(group) {
|
|
31
|
-
if (group.kind === "note" || group.kind === "
|
|
32
|
-
if (group.kind === "answer") return [group.answer];
|
|
31
|
+
if (group.kind === "note" || group.kind === "plain" || group.kind === "command") return [group.i];
|
|
33
32
|
const steps = group.steps || [];
|
|
34
33
|
return [
|
|
35
34
|
group.user, ...steps.map((step) => step.i), ...steps.flatMap((step) => step.steers || []),
|