samagotchi 0.144.0 → 0.146.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 +57 -1
- data/docs/cli.md +1 -1
- data/docs/guardrails.md +7 -2
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/engine.md +1 -1
- data/docs/internals/web-frontend.md +24 -3
- data/docs/memory.md +45 -0
- data/docs/sessions.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_reports.rb +13 -6
- data/lib/samagotchi/guardrails/approval.rb +17 -4
- data/lib/samagotchi/guardrails/parent_approvals.rb +5 -1
- data/lib/samagotchi/guardrails/verdict.rb +5 -3
- data/lib/samagotchi/memory_command.rb +135 -7
- data/lib/samagotchi/memory_paths.rb +9 -0
- data/lib/samagotchi/memory_usage.rb +368 -0
- data/lib/samagotchi/relay.rb +2 -2
- data/lib/samagotchi/tool_activity.rb +3 -3
- data/lib/samagotchi/tool_output_cut.rb +12 -1
- data/lib/samagotchi/toolkit_suggest.rb +7 -4
- data/lib/samagotchi/tools/delegate.rb +88 -13
- data/lib/samagotchi/tools/memory.rb +12 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +1 -1
- data/lib/samagotchi/web/public/app.js +10 -2
- data/lib/samagotchi/web/public/composer_fold.js +5 -2
- data/lib/samagotchi/web/public/composer_grip.js +45 -2
- data/lib/samagotchi/web/public/index.html +8 -6
- data/lib/samagotchi/web/public/info_bar_model.js +6 -4
- data/lib/samagotchi/web/public/participant_annotate.js +2 -1
- data/lib/samagotchi/web/public/question_cards.js +59 -12
- data/lib/samagotchi/web/public/revise_stack.js +6 -5
- data/lib/samagotchi/web/public/stage_frame.js +19 -7
- data/lib/samagotchi/web/public/stage_model.js +2 -1
- data/lib/samagotchi/web/public/stage_view.js +39 -24
- data/lib/samagotchi/web/public/verify_preset.js +5 -1
- data/lib/samagotchi/web/public/worker_features.js +14 -0
- data/lib/samagotchi/working_set.rb +3 -2
- metadata +3 -1
|
@@ -41,13 +41,18 @@ import { plainText } from "./plain_line.js";
|
|
|
41
41
|
// own text; markdown_place.js pairRefsIn)
|
|
42
42
|
// @param api {sendAnswer, dismissQuestion, sendCommand} (data.js)
|
|
43
43
|
// @param doc the page's document
|
|
44
|
+
// @param onPending (pending|null) called whenever the open question changes:
|
|
45
|
+
// the page touches the redraws that read pendingQuestion() (the session
|
|
46
|
+
// bar's waiting chip, docs/internals/web-frontend.md write -> redraw)
|
|
44
47
|
// @return {renderQuestion(pq, {said}), resolveQuestion(id, opts), removeQuestion(),
|
|
45
48
|
// questionCard() (the live card or null), pendingQuestion() (or null),
|
|
49
|
+
// isResolved(id) (this page already saw that question answered),
|
|
46
50
|
// renderContinue(offer), resolveContinue(data), forgetContinue()}
|
|
47
51
|
export function createQuestionCards({
|
|
48
52
|
sessionId, clientId, place, isNearBottom, scrollToEnd, removeHintIfEmpty, askingText = () => "",
|
|
49
53
|
renderMarkdown = () => Promise.resolve(null), linkRefs = () => {}, pairRefs = () => {},
|
|
50
54
|
api = { sendAnswer, dismissQuestion, sendCommand }, doc = globalThis.document,
|
|
55
|
+
onPending = () => {},
|
|
51
56
|
}) {
|
|
52
57
|
// Live ask_user_question card, keyed by pending question id. Re-rendered from
|
|
53
58
|
// pending_question on session select so a reload mid-question restores it.
|
|
@@ -57,6 +62,16 @@ export function createQuestionCards({
|
|
|
57
62
|
let continueEl = null;
|
|
58
63
|
// card → the reply that asked it, drawn under the summary once resolved.
|
|
59
64
|
const saidOf = new WeakMap();
|
|
65
|
+
// The question last answered here: a session summary fetched earlier still
|
|
66
|
+
// names it as pending until the next refresh (isResolved).
|
|
67
|
+
let resolvedId = null;
|
|
68
|
+
|
|
69
|
+
// The one way the open question changes: +onPending+ is the page's hook for
|
|
70
|
+
// the redraws that read it (the session bar's waiting chip).
|
|
71
|
+
function setPending(next) {
|
|
72
|
+
pending = next;
|
|
73
|
+
onPending(pending);
|
|
74
|
+
}
|
|
60
75
|
|
|
61
76
|
// +said+: the asking reply when the caller knows it (a reloaded card: its
|
|
62
77
|
// step's text, "" for none); else the running turn's (askingText).
|
|
@@ -65,8 +80,8 @@ export function createQuestionCards({
|
|
|
65
80
|
if (action === "same") return;
|
|
66
81
|
// A resolved card stays where it was; only a pending one is replaced.
|
|
67
82
|
if (action === "keep") questionEl = null;
|
|
68
|
-
else
|
|
69
|
-
|
|
83
|
+
else replaceQuestionCard();
|
|
84
|
+
setPending(pq);
|
|
70
85
|
removeHintIfEmpty();
|
|
71
86
|
|
|
72
87
|
const approval = approvalView(pq);
|
|
@@ -111,13 +126,18 @@ export function createQuestionCards({
|
|
|
111
126
|
}
|
|
112
127
|
|
|
113
128
|
const options = Array.isArray(pq.options) ? pq.options : [];
|
|
129
|
+
// An approval's last option denies: here that is the Deny button beside
|
|
130
|
+
// Submit, one tap, so no radio says it again. The option stays in the
|
|
131
|
+
// data (a terminal, chi answer and a relay answer it by its label).
|
|
132
|
+
const denies = approval && options[options.length - 1] === "Deny";
|
|
133
|
+
const shown = denies ? options.slice(0, -1) : options;
|
|
114
134
|
if (stepLimit) {
|
|
115
135
|
renderStepLimitActions(card, pq, options);
|
|
116
|
-
} else if (
|
|
136
|
+
} else if (shown.length) {
|
|
117
137
|
const list = doc.createElement("div");
|
|
118
138
|
list.className = "question-options";
|
|
119
139
|
const inputType = pq.multi_select ? "checkbox" : "radio";
|
|
120
|
-
|
|
140
|
+
shown.forEach((label, i) => {
|
|
121
141
|
const row = doc.createElement("label");
|
|
122
142
|
row.className = "question-option";
|
|
123
143
|
const input = doc.createElement("input");
|
|
@@ -155,6 +175,7 @@ export function createQuestionCards({
|
|
|
155
175
|
if (pq.allow_freeform) {
|
|
156
176
|
freeformInput = doc.createElement("input");
|
|
157
177
|
freeformInput.type = "text";
|
|
178
|
+
noContactFill(freeformInput);
|
|
158
179
|
freeformInput.className = "question-freeform";
|
|
159
180
|
freeformInput.placeholder = approval ? "Reason for the model (with Deny, or alone to deny)…" : "Other…";
|
|
160
181
|
card.appendChild(freeformInput);
|
|
@@ -201,7 +222,13 @@ export function createQuestionCards({
|
|
|
201
222
|
err.classList.add("hidden");
|
|
202
223
|
submit.disabled = true;
|
|
203
224
|
dismiss.disabled = true;
|
|
204
|
-
|
|
225
|
+
// A reason typed in the box goes with the Deny: the answer carries it,
|
|
226
|
+
// a dismissal has no text.
|
|
227
|
+
const reason = denies && freeformInput ? freeformInput.value.trim() : "";
|
|
228
|
+
const sent = reason
|
|
229
|
+
? api.sendAnswer(sessionId(), { id: pq.id, selected: ["Deny"], freeform: reason })
|
|
230
|
+
: api.dismissQuestion(sessionId(), pq.id);
|
|
231
|
+
sent.catch((e) => {
|
|
205
232
|
submit.disabled = false;
|
|
206
233
|
dismiss.disabled = false;
|
|
207
234
|
err.textContent = answerErrorText(e);
|
|
@@ -228,6 +255,15 @@ export function createQuestionCards({
|
|
|
228
255
|
focusWhenIdle(card, pq.id, { staged });
|
|
229
256
|
}
|
|
230
257
|
|
|
258
|
+
// A card's text field isn't a contact form: what iOS Safari respects
|
|
259
|
+
// against its "AutoFill Contact" bar (no autocomplete, a name with no
|
|
260
|
+
// contact word in it). Autocorrect stays: the reader writes prose here.
|
|
261
|
+
function noContactFill(input) {
|
|
262
|
+
input.setAttribute("autocomplete", "off");
|
|
263
|
+
input.setAttribute("autocorrect", "on");
|
|
264
|
+
input.name = "chi-card-note";
|
|
265
|
+
}
|
|
266
|
+
|
|
231
267
|
function isPlainEnter(e) {
|
|
232
268
|
return e.key === "Enter" && !e.isComposing && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey;
|
|
233
269
|
}
|
|
@@ -258,6 +294,7 @@ export function createQuestionCards({
|
|
|
258
294
|
function renderStepLimitActions(card, pq, options) {
|
|
259
295
|
const reason = doc.createElement("input");
|
|
260
296
|
reason.type = "text";
|
|
297
|
+
noContactFill(reason);
|
|
261
298
|
reason.className = "question-freeform continue-reason";
|
|
262
299
|
reason.placeholder = CONTINUE_REASON_PLACEHOLDER;
|
|
263
300
|
const err = doc.createElement("div");
|
|
@@ -402,7 +439,7 @@ export function createQuestionCards({
|
|
|
402
439
|
// The parent relayed the open question, or no longer does (question_relay).
|
|
403
440
|
function markRelayed(id, relayedTo) {
|
|
404
441
|
if (!questionEl || !pending || String(pending.id) !== String(id)) return;
|
|
405
|
-
|
|
442
|
+
setPending({ ...pending, relayed_to: relayedTo || null });
|
|
406
443
|
questionEl.querySelector(".question-relayed")?.replaceWith(renderRelayedTo(pending));
|
|
407
444
|
}
|
|
408
445
|
|
|
@@ -469,7 +506,8 @@ export function createQuestionCards({
|
|
|
469
506
|
if (!questionEl.dataset.toggled) questionEl.open = false;
|
|
470
507
|
// After the collapse: a card left open by hand renders at once.
|
|
471
508
|
if (full) renderSaidOnOpen(questionEl, full, asked, refs);
|
|
472
|
-
|
|
509
|
+
resolvedId = pending.id;
|
|
510
|
+
setPending(null);
|
|
473
511
|
}
|
|
474
512
|
|
|
475
513
|
// The body's copy as markdown, from the card's first open on (a reload
|
|
@@ -524,11 +562,18 @@ export function createQuestionCards({
|
|
|
524
562
|
}
|
|
525
563
|
|
|
526
564
|
function removeQuestionCard() {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
565
|
+
replaceQuestionCard();
|
|
566
|
+
setPending(null);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// The live card taken off the history because a new one takes its place:
|
|
570
|
+
// the question itself changes in the same step, so the hook is not touched
|
|
571
|
+
// for the in-between null.
|
|
572
|
+
function replaceQuestionCard() {
|
|
573
|
+
if (!questionEl) return;
|
|
574
|
+
|
|
575
|
+
questionEl.remove();
|
|
576
|
+
questionEl = null;
|
|
532
577
|
}
|
|
533
578
|
|
|
534
579
|
// ── continue card ──────────────────────────────────────────────────────────
|
|
@@ -590,6 +635,7 @@ export function createQuestionCards({
|
|
|
590
635
|
no.addEventListener("click", () => answer(continueLine("no")));
|
|
591
636
|
const reason = doc.createElement("input");
|
|
592
637
|
reason.type = "text";
|
|
638
|
+
noContactFill(reason);
|
|
593
639
|
reason.className = "continue-reason";
|
|
594
640
|
reason.placeholder = "Why not? (the model reads it)";
|
|
595
641
|
const noBecause = doc.createElement("button");
|
|
@@ -630,6 +676,7 @@ export function createQuestionCards({
|
|
|
630
676
|
removeQuestion: removeQuestionCard,
|
|
631
677
|
questionCard: () => questionEl,
|
|
632
678
|
pendingQuestion: () => pending,
|
|
679
|
+
isResolved: (id) => resolvedId !== null && String(resolvedId) === String(id),
|
|
633
680
|
renderContinue: renderContinueCard,
|
|
634
681
|
resolveContinue: resolveContinueCard,
|
|
635
682
|
// The running turn's DOM was reset: a later offer draws a new card.
|
|
@@ -30,6 +30,7 @@ import { bubbleCopyText } from "./copy.js";
|
|
|
30
30
|
import { foldLabel, keepRowInView, lineCount, readFolded, writeFold } from "./answer_fold.js";
|
|
31
31
|
import { clip } from "./format.js";
|
|
32
32
|
import { NOTE_BOUNDARY } from "./turn_range.js";
|
|
33
|
+
import { workerPredates } from "./worker_features.js";
|
|
33
34
|
import { SWAPPED_CLASS, VIEW_CLASS, stepVersion, switcherTemplate, viewOf } from "./revise_switch.js";
|
|
34
35
|
|
|
35
36
|
// The classes and attributes this module puts on the history.
|
|
@@ -113,12 +114,12 @@ export function versionChipText(count, at = count - 1) {
|
|
|
113
114
|
// the worker predates Revise turns).
|
|
114
115
|
export const REVISE_UNAVAILABLE = "restart this session to use Revise";
|
|
115
116
|
|
|
116
|
-
// The feature gate (app.js featureGates): a live worker without the
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
117
|
+
// The feature gate (app.js featureGates): a live worker without the "revise"
|
|
118
|
+
// feature predates Revise turns (chi web would answer 409 revise_unavailable).
|
|
119
|
+
// A worker that isn't up isn't asked: the send wakes a new one, which has it
|
|
120
|
+
// (worker_features.js's rule, the same as Verify's gate).
|
|
120
121
|
export function reviseWorkerUnavailable(workerFeatures, bridgeUp) {
|
|
121
|
-
return
|
|
122
|
+
return workerPredates(workerFeatures, bridgeUp, "revise");
|
|
122
123
|
}
|
|
123
124
|
export function reviseChipText(label, { unavailable = false } = {}) {
|
|
124
125
|
if (unavailable) return `Revise: ${REVISE_UNAVAILABLE}`;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// The stage view's cap and frame (stage_view.js): the one place that
|
|
2
2
|
// writes the stage's height, and the stage's own scrolls. The cap: at most
|
|
3
|
-
// ~60% of the page (~80% with the cloud open, 85%
|
|
4
|
-
//
|
|
5
|
-
// panel. The frame: held and grow-only while the
|
|
6
|
-
// (stage_model.js frameTarget), its growth eased
|
|
3
|
+
// ~60% of the page (~80% with the cloud open, 85% from a card that needs the
|
|
4
|
+
// room until the next step: a long reply's question, a tall approval), and
|
|
5
|
+
// never above the session panel. The frame: held and grow-only while the
|
|
6
|
+
// stage holds a turn (stage_model.js frameTarget), its growth eased; the next
|
|
7
|
+
// step after an answered card lets it go once (forgetContent). The stage's state comes
|
|
7
8
|
// in as getters (+isHolding+, +isCollapsed+, +isCloudOpen+, +isRoomCap+);
|
|
8
9
|
// what the stage changes of the frame's goes through resetHeld and
|
|
9
10
|
// forgetContent. +waitingCard+: the card blocking the turn, or null.
|
|
@@ -58,7 +59,7 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
// ── the cap: at most ~60% of the page (~80% with the cloud open, 85%
|
|
61
|
-
//
|
|
62
|
+
// while a card has the room), and never above the session
|
|
62
63
|
// panel (the dock is absolute: a tall composer or a phone's keyboard
|
|
63
64
|
// would push the stage's top out) ──────────────────────────────────────
|
|
64
65
|
|
|
@@ -113,6 +114,14 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
|
|
|
113
114
|
if (!card || !cardInSight()) reveal(card?.parentElement ?? extras, { now: true });
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
// +card+ fits the stage's view at the cap now: it, the scroller's padding
|
|
118
|
+
// and the stage's rows around the scroller.
|
|
119
|
+
function fitsCap(card) {
|
|
120
|
+
const css = getComputedStyle(scroller);
|
|
121
|
+
const around = stage.offsetHeight - scroller.offsetHeight + (parseFloat(css.paddingTop) || 0) + (parseFloat(css.paddingBottom) || 0);
|
|
122
|
+
return card.offsetHeight + around <= capPx();
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
function fitCap() {
|
|
117
126
|
if (stage.hidden) return;
|
|
118
127
|
// The composer card and the gap above it (the stage floats over them,
|
|
@@ -144,7 +153,8 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
|
|
|
144
153
|
// Nothing in the stage view jumps. The rules: the stage is out of the
|
|
145
154
|
// dock's flow (index.html), so its height never moves the composer; while
|
|
146
155
|
// it holds a turn its height is held and grow-only (frameTarget), so a
|
|
147
|
-
// content change happens inside it
|
|
156
|
+
// content change happens inside it (the next step after an answered card
|
|
157
|
+
// lets it go once: forgetContent); growth eases (frameTo); the chip is a
|
|
148
158
|
// footer no content can push; the hand-off releases the turn at once
|
|
149
159
|
// (releaseTurn) and empties the stage only after it slid away under the
|
|
150
160
|
// composer (a transform, then finishFold/clearStage).
|
|
@@ -215,6 +225,7 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
|
|
|
215
225
|
|
|
216
226
|
return {
|
|
217
227
|
fitCap,
|
|
228
|
+
fitsCap,
|
|
218
229
|
frameFree,
|
|
219
230
|
afterGrowth,
|
|
220
231
|
easeStage,
|
|
@@ -222,7 +233,8 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
|
|
|
222
233
|
// A new turn, or none: no height held yet.
|
|
223
234
|
resetHeld: () => { held = null; },
|
|
224
235
|
// The tallest content seen and the height held for it are forgotten (a
|
|
225
|
-
// new turn, the cloud closed by hand
|
|
236
|
+
// new turn, the cloud closed by hand, the next step after an answered
|
|
237
|
+
// card): the frame refits to what shows now.
|
|
226
238
|
forgetContent: () => {
|
|
227
239
|
maxContent = 0;
|
|
228
240
|
held = null;
|
|
@@ -198,7 +198,8 @@ export function liveSlots(turn, { narration = "", thinking = "", pending = false
|
|
|
198
198
|
|
|
199
199
|
// The stage's frame height (px) while it holds a turn: grow-only, so a
|
|
200
200
|
// content change inside it (the plain flip, an answered card, a short
|
|
201
|
-
// answer) never moves its top edge. +
|
|
201
|
+
// answer) never moves its top edge. (Its one shrink forgets +held+: the next
|
|
202
|
+
// step after an answered card, stage_view.js releaseHeldWait.) +natural+: its content's own height;
|
|
202
203
|
// +held+: the height it holds (null: none yet); +cap+: --stage-max. A lower
|
|
203
204
|
// cap (a phone's keyboard) clamps it at once and the clamp is the new held
|
|
204
205
|
// height: a cap that rises again doesn't bring the old one back, only new
|
|
@@ -38,6 +38,8 @@ const ANSWER_SEEN = 72;
|
|
|
38
38
|
const ANSWER_CUT = 12;
|
|
39
39
|
// An answered card's one line.
|
|
40
40
|
const ANSWERED_LINE = 40;
|
|
41
|
+
// That line brought back sits this far under the scroller's edge.
|
|
42
|
+
const ANSWERED_GAP = 8;
|
|
41
43
|
const PENDING = ".bubble.question:not(.answered):not(.cancelled), .bubble.continue:not(.resolved)";
|
|
42
44
|
// A running turn's card with actions (check-in's Nudge / Keep going / Stop)
|
|
43
45
|
// asks the user too, but the turn goes on: it waits only while the turn runs
|
|
@@ -47,6 +49,9 @@ const ASKS = ".plugin-card[data-in-turn] .card-action";
|
|
|
47
49
|
// the step limit, a hook's question or a delegate's relayed one): the one
|
|
48
50
|
// card whose long asking text gets the question room.
|
|
49
51
|
const ASK_CARD = '.bubble.question[data-kind="question"]:not([data-relay])';
|
|
52
|
+
// A blocking approval, a delegate's relayed one too: too tall for the stage's
|
|
53
|
+
// view, it gets the question room's raised cap (raiseForApproval).
|
|
54
|
+
const APPROVAL_CARD = '.bubble.question[data-kind="approval"]';
|
|
50
55
|
|
|
51
56
|
function readCollapsed() {
|
|
52
57
|
return readStored(COLLAPSE_KEY) === "1";
|
|
@@ -190,8 +195,9 @@ export function createStageView({
|
|
|
190
195
|
let bare = false;
|
|
191
196
|
let foldTimer = null;
|
|
192
197
|
// The question room (drawRoom): the pending ask card whose asking text
|
|
193
|
-
// overflowed its cap
|
|
194
|
-
//
|
|
198
|
+
// overflowed its cap; and the raised cap (stage_frame.js), which an
|
|
199
|
+
// approval too tall for the stage gets too (raiseForApproval), kept until
|
|
200
|
+
// the next step (releaseHeldWait).
|
|
195
201
|
let roomCard = null;
|
|
196
202
|
let roomCap = false;
|
|
197
203
|
// What the overflow was measured for ({ card, text }): measured once the
|
|
@@ -258,8 +264,8 @@ export function createStageView({
|
|
|
258
264
|
// The question room: while a model's own question waits and its asking
|
|
259
265
|
// text didn't fit its cap, the slot loses its cap and the stage's one
|
|
260
266
|
// scroll reads the whole reply (index.html .question-room); the cap rises
|
|
261
|
-
//
|
|
262
|
-
//
|
|
267
|
+
// until the next step. The card keeps the room until it stops pending
|
|
268
|
+
// (+text+: the asking text drawn).
|
|
263
269
|
function drawRoom(blocked, text) {
|
|
264
270
|
const ask = blocked ? askCard() : null;
|
|
265
271
|
if (roomCard && ask === roomCard) return;
|
|
@@ -292,6 +298,18 @@ export function createStageView({
|
|
|
292
298
|
}
|
|
293
299
|
}
|
|
294
300
|
|
|
301
|
+
// A blocking approval too tall for the stage's view: the same raised cap,
|
|
302
|
+
// the stage takes what the page has. The card still opens at its question
|
|
303
|
+
// and command (stage_frame.js revealTop), so no room class and no pill. The
|
|
304
|
+
// cap is a ceiling: a card that fits never gets here.
|
|
305
|
+
function raiseForApproval(blocked) {
|
|
306
|
+
if (!blocked || roomCap) return;
|
|
307
|
+
const card = extras.querySelector(PENDING) || tail.querySelector(PENDING);
|
|
308
|
+
if (!card?.matches(APPROVAL_CARD) || frame.fitsCap(card)) return;
|
|
309
|
+
roomCap = true;
|
|
310
|
+
frame.fitCap();
|
|
311
|
+
}
|
|
312
|
+
|
|
295
313
|
// The pill: the room's card out of the stage's view, once its arrival
|
|
296
314
|
// reveal has run, the stage open.
|
|
297
315
|
function drawPill() {
|
|
@@ -340,7 +358,6 @@ export function createStageView({
|
|
|
340
358
|
const wasWaiting = stage.classList.contains("waiting");
|
|
341
359
|
if (blocked && !wasWaiting) {
|
|
342
360
|
stage.classList.add("held-wait");
|
|
343
|
-
live.style.minHeight = "";
|
|
344
361
|
}
|
|
345
362
|
if (!blocked && wasWaiting) stage.style.setProperty("--live-held", `${live.offsetHeight}px`);
|
|
346
363
|
stage.classList.toggle("plain", plain);
|
|
@@ -356,6 +373,7 @@ export function createStageView({
|
|
|
356
373
|
slotsView.drawHeadline(slots.headline);
|
|
357
374
|
slotsView.drawAsking(slots.asking, slots.askingRefs);
|
|
358
375
|
drawRoom(blocked, slots.asking);
|
|
376
|
+
raiseForApproval(blocked);
|
|
359
377
|
drawPill();
|
|
360
378
|
slotsView.drawNow(slots.tool, slots.quiet);
|
|
361
379
|
slotsView.drawTrail(slots.trail, flash);
|
|
@@ -389,15 +407,18 @@ export function createStageView({
|
|
|
389
407
|
tail.hidden = !tail.firstChild;
|
|
390
408
|
}
|
|
391
409
|
|
|
392
|
-
// A card stopped waiting and its slot has its cap and own scroll again:
|
|
393
|
-
//
|
|
394
|
-
//
|
|
410
|
+
// A card stopped waiting and its slot has its cap and own scroll again: the
|
|
411
|
+
// slot's end shows (the answered card's line). The stage's scroll stays, so
|
|
412
|
+
// nothing moves at the tap (the frame holds, and the blank goes at the next
|
|
413
|
+
// step), unless the reader had scrolled down the tall card past its line:
|
|
414
|
+
// then the line comes back, to the view's top and no further.
|
|
395
415
|
function settleAnsweredCard() {
|
|
396
416
|
const slot = tail.firstChild ? tail : extras;
|
|
397
417
|
if (!slot.firstChild) return;
|
|
398
418
|
slot.scrollTop = slot.scrollHeight;
|
|
399
419
|
const end = slot.offsetTop + slot.offsetHeight;
|
|
400
|
-
if (scroller.scrollTop
|
|
420
|
+
if (scroller.scrollTop <= end - ANSWERED_LINE) return;
|
|
421
|
+
scroller.scrollTop = Math.max(0, Math.min(slot.lastElementChild.offsetTop, end - ANSWERED_LINE) - ANSWERED_GAP);
|
|
401
422
|
}
|
|
402
423
|
|
|
403
424
|
// The prompt's first words (the working set's session tags say whose
|
|
@@ -407,23 +428,18 @@ export function createStageView({
|
|
|
407
428
|
return text.length > 60 ? `${text.slice(0, 59)}\u2026` : text;
|
|
408
429
|
}
|
|
409
430
|
|
|
410
|
-
// The next step
|
|
411
|
-
//
|
|
412
|
-
//
|
|
413
|
-
//
|
|
414
|
-
//
|
|
431
|
+
// The next step after a blocking card's answer: the one time a turn's
|
|
432
|
+
// frame shrinks (stage_frame.js forgetContent; grow-only otherwise). What
|
|
433
|
+
// the wait held goes together: the live slots' waiting height, a raised
|
|
434
|
+
// cap, the tallest content seen. +held-wait+ says it is due, so a later
|
|
435
|
+
// step, or a generation with the card still waiting, changes nothing.
|
|
415
436
|
function releaseHeldWait() {
|
|
416
|
-
|
|
417
|
-
const before = held ? live.offsetHeight : 0;
|
|
418
|
-
const top = scroller.scrollTop;
|
|
437
|
+
if (!stage.classList.contains("held-wait") || stage.classList.contains("waiting")) return;
|
|
419
438
|
stage.classList.remove("held-wait");
|
|
420
439
|
stage.style.removeProperty("--live-held");
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const absorbed = Math.min(Math.max(0, before - after), top);
|
|
425
|
-
if (before - absorbed > after) live.style.minHeight = `${before - absorbed}px`;
|
|
426
|
-
if (absorbed) scroller.scrollTop = top - absorbed;
|
|
440
|
+
roomCap = false;
|
|
441
|
+
frame.fitCap();
|
|
442
|
+
frame.forgetContent();
|
|
427
443
|
}
|
|
428
444
|
|
|
429
445
|
// One line in the trail for FLASH_MS, ahead of the calls (a newer flash
|
|
@@ -625,7 +641,6 @@ export function createStageView({
|
|
|
625
641
|
setCloud(false);
|
|
626
642
|
stage.classList.remove("plain", "ended", "waiting", "held-wait", "asking", "in-use", "question-room");
|
|
627
643
|
stage.style.removeProperty("--live-held");
|
|
628
|
-
live.style.minHeight = "";
|
|
629
644
|
}
|
|
630
645
|
|
|
631
646
|
// The turn leaves the stage's care (the hand-off's start, a reset, a new
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// module of its own: static JS is cached at unversioned URLs, and a new
|
|
7
7
|
// export on an old module would blank the page.
|
|
8
8
|
|
|
9
|
+
import { workerPredates } from "./worker_features.js";
|
|
10
|
+
|
|
9
11
|
export const VERIFY_PRESET = Object.freeze({
|
|
10
12
|
label: "Verify",
|
|
11
13
|
text: "Verify this claim against the code. If this session's context doesn't settle it, say so. "
|
|
@@ -14,8 +16,10 @@ export const VERIFY_PRESET = Object.freeze({
|
|
|
14
16
|
|
|
15
17
|
export const VERIFY_UNAVAILABLE = "restart this session to use Verify";
|
|
16
18
|
|
|
19
|
+
// The Verify gate (app.js featureGates): a live worker without "verify"
|
|
20
|
+
// predates Verify turns (worker_features.js's rule).
|
|
17
21
|
export function verifyWorkerUnavailable(workerFeatures, bridgeUp) {
|
|
18
|
-
return
|
|
22
|
+
return workerPredates(workerFeatures, bridgeUp, "verify");
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
// +presets+ (annotate_presets.js parsePresets) with Verify after them.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// One rule for the worker-side feature gates: a worker that is up and whose
|
|
2
|
+
// features lack +feature+ predates it (chi web would answer 409
|
|
3
|
+
// <feature>_unavailable), so the page says so instead of offering the action.
|
|
4
|
+
// A worker that isn't up isn't asked: the send wakes a new one that has it.
|
|
5
|
+
// Used by Verify's gate (verify_preset.js) and Revise's (revise_stack.js).
|
|
6
|
+
//
|
|
7
|
+
// A new module: the page's modules are cached at unversioned URLs, and a new
|
|
8
|
+
// export of an old one (docs/internals/web-frontend.md) leaves a cached copy
|
|
9
|
+
// without it.
|
|
10
|
+
|
|
11
|
+
// @return [bool] true only for a live worker without the feature.
|
|
12
|
+
export function workerPredates(workerFeatures, bridgeUp, feature) {
|
|
13
|
+
return bridgeUp === true && Array.isArray(workerFeatures) && !workerFeatures.includes(feature);
|
|
14
|
+
}
|
|
@@ -235,7 +235,8 @@ module Samagotchi
|
|
|
235
235
|
def shared_with(touch, key) = touch.share > 1 ? found_names(touch.run) - [key] : []
|
|
236
236
|
|
|
237
237
|
# A memory_read's names (Tools::MemoryRead.parse_names: none for the
|
|
238
|
-
# index listing), less the ones its output says weren't found.
|
|
238
|
+
# index listing), less the ones its output says weren't found. Public:
|
|
239
|
+
# `chi memory usage` counts reads the same way (MemoryUsage).
|
|
239
240
|
def found_names(run)
|
|
240
241
|
names = Tools::MemoryRead.parse_names(run.call[:content].to_s)
|
|
241
242
|
last = run.text.split(ToolResponse::SEPARATOR).last.to_s
|
|
@@ -308,6 +309,6 @@ module Samagotchi
|
|
|
308
309
|
|
|
309
310
|
def field(hash, key) = hash.key?(key) ? hash[key] : hash[key.to_s]
|
|
310
311
|
|
|
311
|
-
private_class_method :all_touches, :touches, :failed?, :
|
|
312
|
+
private_class_method :all_touches, :touches, :failed?, :shared_with, :item, :still_sent?, :dropped?, :with_id, :changed?, :stamp_of, :field
|
|
312
313
|
end
|
|
313
314
|
end
|
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.146.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -487,6 +487,7 @@ files:
|
|
|
487
487
|
- lib/samagotchi/memory_command.rb
|
|
488
488
|
- lib/samagotchi/memory_orphans.rb
|
|
489
489
|
- lib/samagotchi/memory_paths.rb
|
|
490
|
+
- lib/samagotchi/memory_usage.rb
|
|
490
491
|
- lib/samagotchi/message_parts.rb
|
|
491
492
|
- lib/samagotchi/message_time.rb
|
|
492
493
|
- lib/samagotchi/model_binding.rb
|
|
@@ -958,6 +959,7 @@ files:
|
|
|
958
959
|
- lib/samagotchi/web/public/verify_card.css
|
|
959
960
|
- lib/samagotchi/web/public/verify_preset.js
|
|
960
961
|
- lib/samagotchi/web/public/verify_target.js
|
|
962
|
+
- lib/samagotchi/web/public/worker_features.js
|
|
961
963
|
- lib/samagotchi/web/public/working_set.js
|
|
962
964
|
- lib/samagotchi/web/public/working_set_rail.js
|
|
963
965
|
- lib/samagotchi/web/public/working_set_view.js
|