samagotchi 0.165.0 → 0.166.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 +37 -1
- data/docs/cli.md +6 -2
- data/docs/configuration.md +3 -1
- data/docs/guardrails.md +6 -2
- data/docs/internals/bridge.md +6 -0
- data/docs/internals/remote-sessions.md +1 -1
- data/docs/internals/web-frontend.md +36 -3
- data/docs/releasing.md +12 -3
- data/docs/sessions.md +4 -4
- data/docs/testing.md +12 -3
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/compat.rb +8 -10
- data/lib/samagotchi/guardrails/approvals.rb +36 -9
- data/lib/samagotchi/plugin/sessions.rb +4 -1
- data/lib/samagotchi/reply_wait/poll.rb +4 -15
- data/lib/samagotchi/reply_wait.rb +0 -23
- data/lib/samagotchi/run_options.rb +1 -1
- data/lib/samagotchi/session_access/remote.rb +4 -19
- data/lib/samagotchi/session_inbox.rb +1 -1
- data/lib/samagotchi/tools/delegate.rb +2 -4
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/app.js +15 -8
- data/lib/samagotchi/web/public/auth_lost.js +3 -1
- data/lib/samagotchi/web/public/bar_fold.js +1 -1
- data/lib/samagotchi/web/public/chip_popover.js +5 -1
- data/lib/samagotchi/web/public/delivery_line.js +19 -4
- data/lib/samagotchi/web/public/index.html +122 -41
- data/lib/samagotchi/web/public/info_bar.js +1 -1
- data/lib/samagotchi/web/public/info_bar_model.js +6 -1
- data/lib/samagotchi/web/public/live_timing.js +3 -0
- data/lib/samagotchi/web/public/resync_reach.js +59 -0
- data/lib/samagotchi/web/public/session_fields.js +1 -0
- data/lib/samagotchi/web/public/session_state.js +5 -0
- data/lib/samagotchi/web/public/stage_frame.js +4 -2
- data/lib/samagotchi/web/public/stage_stall.js +134 -0
- data/lib/samagotchi/web/public/stage_view.js +75 -6
- data/lib/samagotchi/web/token.rb +2 -2
- metadata +3 -1
|
@@ -6,6 +6,7 @@ require "fileutils"
|
|
|
6
6
|
require "time"
|
|
7
7
|
require_relative "../atomic_file"
|
|
8
8
|
require_relative "../log"
|
|
9
|
+
require_relative "../state_format"
|
|
9
10
|
require_relative "approval"
|
|
10
11
|
|
|
11
12
|
module Samagotchi
|
|
@@ -26,8 +27,17 @@ module Samagotchi
|
|
|
26
27
|
# "once" is never stored. A file that doesn't parse is moved aside to
|
|
27
28
|
# approvals.json.corrupt-<UTC time>[-N], with a warning, and the store
|
|
28
29
|
# starts empty: it only means more asks, and nothing is overwritten.
|
|
30
|
+
#
|
|
31
|
+
# The file is either a list of entries (0.165 and before) or a
|
|
32
|
+
# versioned store, {"version", "approvals": [...]} (FORMAT). Both are
|
|
33
|
+
# read; a write keeps the shape it read, and a store with no file is
|
|
34
|
+
# written as a list: a 0.165 reader sets an object aside, so the list
|
|
35
|
+
# stays the written shape until 0.167 (compat shims approvals_array_read
|
|
36
|
+
# and approvals_array_write).
|
|
29
37
|
class Approvals
|
|
30
38
|
FILE = "approvals.json"
|
|
39
|
+
COLLECTION = "approvals"
|
|
40
|
+
FORMAT = StateFormat.new(version: 1, members: [StateFormat.required(:scope), StateFormat.extra(:extra, in_version: 1)])
|
|
31
41
|
STORED_SCOPES = %w[session repo rule].freeze
|
|
32
42
|
# Rules a stored answer allows only for its session: their asks offer
|
|
33
43
|
# once/session, and a repo entry for the same call (from another
|
|
@@ -50,13 +60,13 @@ module Samagotchi
|
|
|
50
60
|
|
|
51
61
|
# @return [Array<Hash>] the entries (string keys), oldest first
|
|
52
62
|
def entries
|
|
53
|
-
read
|
|
63
|
+
read.first
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
# @param verdict [Verdict] an ask with its targets and context
|
|
57
67
|
# @return [Hash, nil] the first entry that allows it
|
|
58
68
|
def match(verdict)
|
|
59
|
-
self.class.find_in(read, verdict)
|
|
69
|
+
self.class.find_in(read.first, verdict)
|
|
60
70
|
end
|
|
61
71
|
|
|
62
72
|
# Store the verdict's allowed scope (not "once").
|
|
@@ -158,8 +168,10 @@ module Samagotchi
|
|
|
158
168
|
private
|
|
159
169
|
|
|
160
170
|
# @param locked [Boolean] the caller holds the store's lock
|
|
171
|
+
# @return [Array(Array<Hash>, StateFormat::Document)] the entries and,
|
|
172
|
+
# for a versioned store, its document (nil for a list or no file)
|
|
161
173
|
def read(locked: false)
|
|
162
|
-
return [] unless File.exist?(@path)
|
|
174
|
+
return [[], nil] unless File.exist?(@path)
|
|
163
175
|
|
|
164
176
|
parse(File.read(@path))
|
|
165
177
|
rescue JSON::ParserError, SystemCallError => e
|
|
@@ -175,14 +187,24 @@ module Samagotchi
|
|
|
175
187
|
where = aside ? "moved it to #{aside}" : "left it in place"
|
|
176
188
|
@warn.call("[samagotchi:guardrails] #{@path} is unreadable (#{e.message}); #{where}, no stored approvals apply")
|
|
177
189
|
end
|
|
178
|
-
[]
|
|
190
|
+
[[], nil]
|
|
179
191
|
end
|
|
180
192
|
|
|
193
|
+
# @return [Array(Array<Hash>, StateFormat::Document)] as #read's
|
|
181
194
|
def parse(text)
|
|
182
195
|
data = JSON.parse(text)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
case data
|
|
197
|
+
when Hash
|
|
198
|
+
raise JSON::ParserError, "#{COLLECTION} is not a list" unless data.fetch(COLLECTION, []).is_a?(Array)
|
|
199
|
+
|
|
200
|
+
document = FORMAT.read(data, collection: COLLECTION)
|
|
201
|
+
# An entry it can't read (no scope) is kept as it is: it matches
|
|
202
|
+
# nothing, and a write keeps it for the chi that wrote it.
|
|
203
|
+
[document.entries.map(&:raw).select { |e| e.is_a?(Hash) }, document]
|
|
204
|
+
# compat shim approvals_array_read: the list 0.165 and before write.
|
|
205
|
+
when Array then [data.select { |e| e.is_a?(Hash) }, nil]
|
|
206
|
+
else raise JSON::ParserError, "not a list or a versioned store"
|
|
207
|
+
end
|
|
186
208
|
end
|
|
187
209
|
|
|
188
210
|
# Under the lock: rename the file aside if it is still unreadable.
|
|
@@ -215,11 +237,16 @@ module Samagotchi
|
|
|
215
237
|
end
|
|
216
238
|
end
|
|
217
239
|
|
|
240
|
+
# Writes the shape it read: a versioned store keeps its version and
|
|
241
|
+
# the keys this chi doesn't know.
|
|
218
242
|
def update
|
|
219
243
|
with_lock do
|
|
220
|
-
list = read(locked: true)
|
|
244
|
+
list, document = read(locked: true)
|
|
221
245
|
yield list
|
|
222
|
-
|
|
246
|
+
# compat shim approvals_array_write: a list (or no file) is written
|
|
247
|
+
# as a list, since a 0.165 reader sets an object aside.
|
|
248
|
+
body = document ? FORMAT.write(document.with(entries: list), collection: COLLECTION, updated_at: nil) : list
|
|
249
|
+
AtomicFile.write(@path, JSON.pretty_generate(body))
|
|
223
250
|
end
|
|
224
251
|
end
|
|
225
252
|
|
|
@@ -238,8 +238,11 @@ module Samagotchi
|
|
|
238
238
|
"#{Tools::Delegate::MAX_CHILDREN_KEY}): #{running.map(&:short_id).join(", ")}"
|
|
239
239
|
end
|
|
240
240
|
|
|
241
|
+
# The worker's turn snapshot (GET snapshot's "snapshot": messages,
|
|
242
|
+
# current_turn), nil with no worker or no reply.
|
|
241
243
|
def live_snapshot(sid, state_dir)
|
|
242
|
-
WorkerLink.client(sid, session_dir: Session.session_dir(sid, state_dir: state_dir))&.get_json("snapshot")
|
|
244
|
+
live = WorkerLink.client(sid, session_dir: Session.session_dir(sid, state_dir: state_dir))&.get_json("snapshot")
|
|
245
|
+
live.is_a?(Hash) && live["snapshot"].is_a?(Hash) ? live["snapshot"] : nil
|
|
243
246
|
rescue StandardError
|
|
244
247
|
nil
|
|
245
248
|
end
|
|
@@ -126,22 +126,11 @@ module Samagotchi
|
|
|
126
126
|
|
|
127
127
|
# Taken but never run as a turn of its own: a running turn's drain
|
|
128
128
|
# merged it as a steer, so that turn's reply (or question) is its
|
|
129
|
-
# answer.
|
|
130
|
-
# the wait is that turn's from here on, as if it had been
|
|
131
|
-
# (#follow_into).
|
|
132
|
-
# merge from before the update) the merge is inferred
|
|
133
|
-
# (ReplyWait.merged_elsewhere?) and waited for as the next reply past
|
|
134
|
-
# the cursor, as without turn:, never as a turn that will not come
|
|
135
|
-
# (compat shim merge_inference: Compat::SHIMS).
|
|
129
|
+
# answer. The drain's merge record (SessionInbox.mark_merged) says
|
|
130
|
+
# which turn: the wait is that turn's from here on, as if it had been
|
|
131
|
+
# bound to it (#follow_into).
|
|
136
132
|
def follow_merge(session, merge)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if merge
|
|
140
|
-
follow_into(session, merge)
|
|
141
|
-
elsif ReplyWait.merged_elsewhere?(session, @turn, @baseline, @session_dir)
|
|
142
|
-
@turn = nil
|
|
143
|
-
@seen_running = running?(session)
|
|
144
|
-
end
|
|
133
|
+
follow_into(session, merge) if merge && may_follow?
|
|
145
134
|
end
|
|
146
135
|
|
|
147
136
|
def may_follow? = @turn && @claimed && !@seen_own && !@own_turn_input
|
|
@@ -259,29 +259,6 @@ module Samagotchi
|
|
|
259
259
|
!baseline.ended_at?(session.last_turn&.ended_at)
|
|
260
260
|
end
|
|
261
261
|
|
|
262
|
-
# A turn: wait's taken input ran in another turn (a steer its drain
|
|
263
|
-
# merged): that turn runs (its mark has another id, or none from a
|
|
264
|
-
# worker that writes ids), or, idle, a turn not its ended since the
|
|
265
|
-
# baseline. last_turn or a reply file being its own is never that, nor
|
|
266
|
-
# an input with a tombstone (a removal's, written before its claim),
|
|
267
|
-
# nor one whose claimed file is still there: a drain deletes the file
|
|
268
|
-
# it merges as it reads it, while a turn of its own keeps it until the
|
|
269
|
-
# turn ends (WorkerInbound#take_input), so a look between that claim
|
|
270
|
-
# and the turn's running save (idle, an earlier turn's end since the
|
|
271
|
-
# baseline) doesn't take the earlier turn's reply for it.
|
|
272
|
-
def merged_elsewhere?(session, turn, baseline, session_dir)
|
|
273
|
-
return false if session.last_turn&.enqueued_id == turn || SessionInbox.reply_for(session_dir, turn)
|
|
274
|
-
return false if SessionInbox.removed?(session_dir, turn) || SessionInbox.claimed_input?(session_dir, turn)
|
|
275
|
-
|
|
276
|
-
if session.status == Session::STATUS_RUNNING
|
|
277
|
-
running_id = session.interrupted_turn&.enqueued_id
|
|
278
|
-
return running_id != turn if running_id
|
|
279
|
-
|
|
280
|
-
return turn_ids?(session_dir)
|
|
281
|
-
end
|
|
282
|
-
turn_ended_since?(session, baseline)
|
|
283
|
-
end
|
|
284
|
-
|
|
285
262
|
# A turn seen running (+own_base+: last_turn's ended_at then) is past:
|
|
286
263
|
# last_turn isn't its, and another turn runs (a mark with another id)
|
|
287
264
|
# or a turn ended since.
|
|
@@ -267,7 +267,7 @@ module Samagotchi
|
|
|
267
267
|
opts.on("--no-default-input", "Skip the default input typed into a new session's first read (SAMAGOTCHI_DEFAULT_INPUT)") { options[:no_default_input] = true; cli_overrides["no_default_input"] = true }
|
|
268
268
|
opts.on("--port PORT", "Port for `chi web` (default: 4567, env SAMAGOTCHI_WEB_PORT)") { |p| options[:web_port] = p.to_i; cli_overrides["web.port"] = p.to_s }
|
|
269
269
|
opts.on("--open", "Open browser for `chi web`") { options[:web_open] = true }
|
|
270
|
-
opts.on("--new-token", "`chi web`: replace
|
|
270
|
+
opts.on("--new-token", "`chi web`: replace its access token (LAN link, --tunnel tailscale, proxy); old links, QR codes and cookies stop working, participant grants stay") { options[:new_token] = true }
|
|
271
271
|
opts.on("--tunnel PROVIDER", %w[tailscale],
|
|
272
272
|
"`chi web`: reach it over https from your tailnet through Tailscale Serve (never Funnel), for this run; " \
|
|
273
273
|
"turned off on exit") { |v| options[:tunnel] = v }
|
|
@@ -730,28 +730,13 @@ module Samagotchi
|
|
|
730
730
|
reply.status == 404 && reply.error == "not_found" && reply.json["detail"].to_s.start_with?("not found: /")
|
|
731
731
|
end
|
|
732
732
|
|
|
733
|
-
def context_missing?(reply)
|
|
734
|
-
return false unless reply.status == 404
|
|
735
|
-
return true if reply.error == "context_missing"
|
|
733
|
+
def context_missing?(reply) = reply.status == 404 && reply.error == "context_missing"
|
|
736
734
|
|
|
737
|
-
|
|
738
|
-
# (compat shim remote_refusal_details: Compat::SHIMS).
|
|
739
|
-
reply.error == "not_found" && reply.json["detail"].to_s.start_with?("no source")
|
|
740
|
-
end
|
|
741
|
-
|
|
742
|
-
def no_provider?(reply)
|
|
743
|
-
return true if reply.error == "no_provider"
|
|
744
|
-
|
|
745
|
-
# Older chi web didn't give this refusal its own error code
|
|
746
|
-
# (compat shim remote_refusal_details).
|
|
747
|
-
reply.json["detail"].to_s.start_with?("no installed bundle resolves")
|
|
748
|
-
end
|
|
735
|
+
def no_provider?(reply) = reply.error == "no_provider"
|
|
749
736
|
|
|
750
737
|
# chi web's 404 not_found detail for a session it doesn't have:
|
|
751
|
-
# "no session X" (Session::NotFound)
|
|
752
|
-
|
|
753
|
-
# compat shim session_not_found_words: Compat::SHIMS).
|
|
754
|
-
SESSION_NOT_FOUND = /\A(?:no session |Session not found: )(.+)\z/m
|
|
738
|
+
# "no session X" (Session::NotFound).
|
|
739
|
+
SESSION_NOT_FOUND = /\Ano session (.+)\z/m
|
|
755
740
|
|
|
756
741
|
# Session::NotFound for a missing session's 404, else an
|
|
757
742
|
# ArgumentError with chi web's words (another route's 404). chi web
|
|
@@ -521,7 +521,7 @@ module Samagotchi
|
|
|
521
521
|
# (Worker#pending_input_drain): a wait for it (ReplyWait's turn:) then
|
|
522
522
|
# waits for that turn (Poll#follow_merge). Nothing for an id that
|
|
523
523
|
# can't name a file, nor for a turn with none; a failed write only
|
|
524
|
-
# logs (
|
|
524
|
+
# logs (a wait for that input then never follows it to that turn).
|
|
525
525
|
def self.mark_merged(session_dir, id, into:, now: Time.now)
|
|
526
526
|
return unless ENQUEUED_ID_NAME.match?(id.to_s) && ENQUEUED_ID_NAME.match?(into.to_s)
|
|
527
527
|
|
|
@@ -397,10 +397,8 @@ module Samagotchi
|
|
|
397
397
|
# whether it runs as a turn of its own (the child idle, or its
|
|
398
398
|
# running turn ended before taking it) or a running turn's drain
|
|
399
399
|
# merges it (that turn's end is its answer: the drain's merge record,
|
|
400
|
-
#
|
|
401
|
-
#
|
|
402
|
-
# otherwise: the wait takes the next reply (compat shim merge_inference:
|
|
403
|
-
# Compat::SHIMS).
|
|
400
|
+
# ReplyWait::Poll#follow_merge). Only from a worker that names
|
|
401
|
+
# turn_ids; nil otherwise: the wait takes the next reply.
|
|
404
402
|
# @return [String, nil]
|
|
405
403
|
def self.follow_up_turn(id, enqueued_id, state_dir:)
|
|
406
404
|
ReplyWait.turn_ids?(Session.session_dir(id, state_dir: state_dir)) ? enqueued_id : nil
|
data/lib/samagotchi/version.rb
CHANGED
|
@@ -106,6 +106,7 @@ import { installRefClicks } from "./refs.js";
|
|
|
106
106
|
import { linkRefs, touchedFiles } from "./ref_scan.js";
|
|
107
107
|
import { DONE_MS, applyInitEvent, dropDone, fadeDone, initRowTemplate, newInitTasks, seedInitTasks } from "./init_row.js";
|
|
108
108
|
import { newClientId, resyncRetry, streamDropEnd } from "./turn_events.js";
|
|
109
|
+
import { createResyncReach } from "./resync_reach.js";
|
|
109
110
|
import { applyConfirm, keptCommandBubbles, restoreCommandBubbles } from "./commands.js";
|
|
110
111
|
import { createComposerCommands } from "./composer.js";
|
|
111
112
|
import { createStreamHandlers } from "./stream_handlers.js";
|
|
@@ -314,6 +315,8 @@ let eventsControl = null;
|
|
|
314
315
|
// session while one ran (its bridge_up event): the tail runs once more.
|
|
315
316
|
let resyncsInFlight = 0;
|
|
316
317
|
let resyncAgain = false;
|
|
318
|
+
// A failed re-read keeps the drawn history and says so in the bar (resync_reach.js).
|
|
319
|
+
const resyncReach = createResyncReach({ store, historyEl, errorHint: (message) => hintEl(`Error: ${message}`) });
|
|
317
320
|
// The running turn's texts on the page (the turn output dedupe).
|
|
318
321
|
const shownTexts = createShownTexts();
|
|
319
322
|
const markdownPlace = createMarkdownPlace({
|
|
@@ -362,6 +365,8 @@ const turnDom = createStageView({
|
|
|
362
365
|
// Stop turn in its status row (disabled until the request settles).
|
|
363
366
|
onCancel: () => handleCancel(),
|
|
364
367
|
onHandedOff: (handed) => reloadCheck.handedOff(handed),
|
|
368
|
+
// The quiet signal (stage_stall.js): the stream, what the turn waits on, a joiner's step clock.
|
|
369
|
+
streamLive: () => !!streamControl?.live, timingNote: () => liveTurn.timing.note, serverGen: () => liveTurn.serverGen,
|
|
365
370
|
});
|
|
366
371
|
// The opt-in reload check (web.reload_check): a handed-off turn against a
|
|
367
372
|
// reload of it, the counts to chi web (reload_check.js).
|
|
@@ -406,7 +411,8 @@ const liveTurn = createLiveTurn({
|
|
|
406
411
|
(stageHost || historyEl).appendChild(el);
|
|
407
412
|
return !!stageHost;
|
|
408
413
|
},
|
|
409
|
-
|
|
414
|
+
// The stage's quiet signal and tool clock tick with it (?.: a stage_view.js an open tab loaded before).
|
|
415
|
+
onTick: () => { store.touch("infoBar"); turnDom.tick?.(); },
|
|
410
416
|
});
|
|
411
417
|
|
|
412
418
|
// The composer's delivery line while the open session's turn runs
|
|
@@ -595,7 +601,7 @@ function followSelectedSession(sess) {
|
|
|
595
601
|
store.update({ current: fieldsFromCard(sess) });
|
|
596
602
|
store.setStatus(sess.status, "hub", { streaming });
|
|
597
603
|
});
|
|
598
|
-
if (!sess.bridge_up ||
|
|
604
|
+
if (streaming || !(sess.bridge_up || resyncReach.needsReread())) return;
|
|
599
605
|
if (resyncsInFlight > 0) resyncAgain = true;
|
|
600
606
|
else resync();
|
|
601
607
|
}
|
|
@@ -909,6 +915,7 @@ async function select(id) {
|
|
|
909
915
|
store.update({ selected: id });
|
|
910
916
|
setSessionHash(id);
|
|
911
917
|
historyEl.replaceChildren(hintEl("Loading…"));
|
|
918
|
+
resyncReach.loading();
|
|
912
919
|
emptyEl.classList.add("hidden");
|
|
913
920
|
resyncAttempts = 0; // this session has its own re-read budget
|
|
914
921
|
forgetSession({ keepVerify: same });
|
|
@@ -938,15 +945,17 @@ function resetTurnView() {
|
|
|
938
945
|
const RESYNC_RETRIES = 3;
|
|
939
946
|
let resyncAttempts = 0;
|
|
940
947
|
|
|
948
|
+
// @return whether another try is scheduled
|
|
941
949
|
function retryResync(id, { endText = null } = {}) {
|
|
942
|
-
if (id !== store.selected) return;
|
|
950
|
+
if (id !== store.selected) return false;
|
|
943
951
|
const { attempt, delayMs } = resyncRetry({ attempts: resyncAttempts, max: RESYNC_RETRIES, baseMs: STREAM_RETRY_MS });
|
|
944
|
-
if (delayMs === null) return;
|
|
952
|
+
if (delayMs === null) return false;
|
|
945
953
|
resyncAttempts = attempt;
|
|
946
954
|
setTimeout(() => {
|
|
947
955
|
if (id !== store.selected || (streamControl && streamControl.live)) return;
|
|
948
956
|
resync({ endText });
|
|
949
957
|
}, delayMs);
|
|
958
|
+
return true;
|
|
950
959
|
}
|
|
951
960
|
|
|
952
961
|
// (Re)render the selected session from the server and stream on from the
|
|
@@ -968,10 +977,7 @@ async function resync({ endText = null } = {}) {
|
|
|
968
977
|
data = await getSession(id);
|
|
969
978
|
} catch (e) {
|
|
970
979
|
if (e.status === 404) return leaveGoneSession(id, "not_found");
|
|
971
|
-
if (id === store.selected) {
|
|
972
|
-
historyEl.replaceChildren(hintEl(`Error: ${e.message}`));
|
|
973
|
-
retryResync(id, { endText });
|
|
974
|
-
}
|
|
980
|
+
if (id === store.selected) resyncReach.failed(id, e.message, { retrying: retryResync(id, { endText }) });
|
|
975
981
|
return;
|
|
976
982
|
}
|
|
977
983
|
resyncAttempts = 0;
|
|
@@ -982,6 +988,7 @@ async function resync({ endText = null } = {}) {
|
|
|
982
988
|
const kept = keptCommandBubbles(historyEl, id);
|
|
983
989
|
resetTurnView();
|
|
984
990
|
renderSessionView(data, { kept });
|
|
991
|
+
resyncReach.drawn(id);
|
|
985
992
|
ownerClaim.showPending();
|
|
986
993
|
// Preview is read-only: a worker is woken only by POST /turn, so attach
|
|
987
994
|
// only when a live bridge exists.
|
|
@@ -61,7 +61,9 @@ export function createAuthLost({
|
|
|
61
61
|
const bar = doc.createElement("div");
|
|
62
62
|
bar.id = "authLost";
|
|
63
63
|
bar.setAttribute("role", "alert");
|
|
64
|
-
|
|
64
|
+
// Its top padding clears a phone's status bar (both pages run under it: viewport-fit=cover).
|
|
65
|
+
bar.style.cssText = "position:fixed;top:0;left:0;right:0;z-index:10000;padding:8px 16px;"
|
|
66
|
+
+ "padding-top:calc(8px + env(safe-area-inset-top, 0px));font-size:14px;"
|
|
65
67
|
+ "color:var(--warn-text);background:var(--warn-bg);border-bottom:1px solid var(--warn-border);"
|
|
66
68
|
+ "display:flex;gap:12px;align-items:center;justify-content:center";
|
|
67
69
|
const text = doc.createElement("span");
|
|
@@ -98,7 +98,7 @@ export function foldSignature(bar, buttons) {
|
|
|
98
98
|
if (!bar) return "";
|
|
99
99
|
const gear = bar.settings ? settingsChipModel(bar.settings) : null;
|
|
100
100
|
return JSON.stringify([
|
|
101
|
-
bar.id, bar.status, bar.model?.text, bar.model?.mismatch, gear?.text, gear?.own,
|
|
101
|
+
bar.id, bar.status, bar.statusText, bar.model?.text, bar.model?.mismatch, gear?.text, gear?.own,
|
|
102
102
|
bar.toolkit?.summary?.name, bar.toolkit?.summary?.label, bar.toolkit?.defaultKit, bar.notes?.text,
|
|
103
103
|
bar.workingSet ? [bar.workingSet.chip?.n] : (bar.memories || []).join(","),
|
|
104
104
|
bar.participants?.text, bar.participants?.count,
|
|
@@ -110,7 +110,11 @@ export function createChipPopover({ id, className, width: widest, el, anchor: an
|
|
|
110
110
|
pop.style.width = `${at.width}px`;
|
|
111
111
|
pop.style.left = `${at.left}px`;
|
|
112
112
|
pop.style.top = "";
|
|
113
|
-
|
|
113
|
+
// On the window's bottom: clear of a phone's home indicator too
|
|
114
|
+
// (index.html --safe-b; 0 where unset). On a keyboard: its offset,
|
|
115
|
+
// already above the indicator, alone. (Not max(): the specs' DOM
|
|
116
|
+
// drops it.)
|
|
117
|
+
pop.style.bottom = at.bottom > SHEET_EDGE ? `${at.bottom}px` : `calc(${SHEET_EDGE}px + var(--safe-b, 0px))`;
|
|
114
118
|
pop.style.maxHeight = `${at.maxHeight}px`;
|
|
115
119
|
return;
|
|
116
120
|
}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// text field in a session, always there so the composer never changes
|
|
3
3
|
// height (the stage above it would jump). Idle it holds the key hint; while
|
|
4
4
|
// the open session's turn runs it says where a message typed now goes in,
|
|
5
|
-
// and offers the other two deliveries as links:
|
|
5
|
+
// and offers the other two deliveries as links (a phone has no row: idle
|
|
6
|
+
// the line is gone; running it lies over the session bar's left, where
|
|
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):
|
|
6
10
|
//
|
|
7
11
|
// ↳ goes in after this thinking step · 2:31 · 31k chars cut in now · queue for after the turn
|
|
8
12
|
// ↳ goes in after this tool call (execute · 0:12) queue for after the turn
|
|
@@ -215,6 +219,7 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
|
|
|
215
219
|
if (mode !== "running" || !line?.[which]?.enabled) return;
|
|
216
220
|
if (!composerEmpty()) {
|
|
217
221
|
armed = null;
|
|
222
|
+
mark();
|
|
218
223
|
send(which);
|
|
219
224
|
return;
|
|
220
225
|
}
|
|
@@ -222,15 +227,25 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
|
|
|
222
227
|
refresh();
|
|
223
228
|
};
|
|
224
229
|
|
|
230
|
+
// For a phone's CSS (index.html): whether a choice is armed or an Apply
|
|
231
|
+
// turn held while the turn runs ("1" or ""): the line shows then. Not the
|
|
232
|
+
// queue chip's pressed look: a participant's turn draws it with nothing
|
|
233
|
+
// armed.
|
|
234
|
+
const mark = () => {
|
|
235
|
+
el.dataset.armed = mode === "running" && armed ? "1" : "";
|
|
236
|
+
el.dataset.held = mode === "running" && held() ? "1" : "";
|
|
237
|
+
};
|
|
238
|
+
|
|
225
239
|
function refresh() {
|
|
226
|
-
if (mode
|
|
227
|
-
|
|
228
|
-
render(idleTemplate(), el);
|
|
240
|
+
if (mode !== "running") {
|
|
241
|
+
mark();
|
|
242
|
+
if (mode === "idle") render(idleTemplate(), el);
|
|
229
243
|
return;
|
|
230
244
|
}
|
|
231
245
|
line = deliveryLine({ ...read(), now: now(), armed, held: held() });
|
|
232
246
|
// A choice no longer possible (a tool started) disarms.
|
|
233
247
|
armed = line.armed;
|
|
248
|
+
mark();
|
|
234
249
|
render(deliveryLineTemplate(line, { onCut: () => click("cut"), onQueue: () => click("queue") }), el);
|
|
235
250
|
}
|
|
236
251
|
|