samagotchi 0.173.0 → 0.175.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 +48 -1
- data/docs/architecture.md +2 -2
- data/docs/cli.md +9 -2
- data/docs/internals/background-tasks.md +0 -3
- data/docs/internals/bridge.md +8 -1
- data/docs/internals/participants.md +3 -1
- data/docs/internals/remote-sessions.md +8 -0
- data/docs/internals/web-frontend.md +45 -5
- data/docs/plugins.md +1 -3
- data/docs/scheduling.md +9 -3
- data/docs/sessions.md +3 -1
- data/docs/testing.md +31 -3
- data/lib/samagotchi/answer_text.rb +4 -2
- data/lib/samagotchi/bridge.rb +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_move.rb +11 -4
- data/lib/samagotchi/continued_from.rb +51 -0
- data/lib/samagotchi/engine.rb +1 -1
- data/lib/samagotchi/llm/stray_tool_call.rb +7 -4
- data/lib/samagotchi/llm_context_stale.rb +2 -1
- data/lib/samagotchi/message_parts.rb +5 -2
- data/lib/samagotchi/model_markup.rb +22 -0
- data/lib/samagotchi/model_profile.rb +8 -7
- data/lib/samagotchi/note_move.rb +11 -4
- data/lib/samagotchi/prompt_literal_guard.rb +7 -6
- data/lib/samagotchi/schedules.rb +13 -16
- data/lib/samagotchi/session_access/contract.rb +1 -0
- data/lib/samagotchi/session_access/local.rb +9 -1
- data/lib/samagotchi/session_access/remote.rb +26 -3
- data/lib/samagotchi/session_chain/delete.rb +405 -0
- data/lib/samagotchi/session_chain/delete_preview.rb +96 -0
- data/lib/samagotchi/session_chain/links.rb +38 -0
- data/lib/samagotchi/session_command_catalog.rb +2 -2
- data/lib/samagotchi/session_commands.rb +3 -13
- data/lib/samagotchi/session_continue.rb +51 -13
- data/lib/samagotchi/session_delete_command.rb +82 -17
- data/lib/samagotchi/session_manager/removal.rb +137 -31
- data/lib/samagotchi/session_stores.rb +2 -0
- data/lib/samagotchi/task_transcript.rb +10 -5
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/exit_lines.rb +16 -0
- data/lib/samagotchi/terminal_ui/local_link.rb +7 -1
- data/lib/samagotchi/terminal_ui.rb +3 -3
- data/lib/samagotchi/testing/boundary.rb +0 -5
- data/lib/samagotchi/testing/bundle.rb +1 -1
- data/lib/samagotchi/tool_call_parser.rb +6 -5
- data/lib/samagotchi/tools/task_runtime.rb +0 -5
- data/lib/samagotchi/turn_note.rb +2 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +7 -1
- data/lib/samagotchi/web/participant_show.rb +1 -0
- data/lib/samagotchi/web/participant_view.rb +4 -2
- data/lib/samagotchi/web/public/app.js +27 -5
- data/lib/samagotchi/web/public/chains.js +3 -3
- data/lib/samagotchi/web/public/data.js +12 -0
- data/lib/samagotchi/web/public/delete_sheet.js +344 -0
- data/lib/samagotchi/web/public/format.js +1 -1
- data/lib/samagotchi/web/public/index.html +27 -0
- data/lib/samagotchi/web/public/info_bar.js +3 -2
- data/lib/samagotchi/web/public/lists_view.js +2 -2
- data/lib/samagotchi/web/public/more_sheet.js +42 -5
- data/lib/samagotchi/web/public/reload_check.js +0 -3
- data/lib/samagotchi/web/public/session_actions.js +50 -6
- data/lib/samagotchi/web/public/session_view.js +9 -1
- data/lib/samagotchi/web/public/stage_asking.js +1 -7
- data/lib/samagotchi/web/public/stage_missing.js +150 -0
- data/lib/samagotchi/web/public/stage_view.js +8 -3
- data/lib/samagotchi/web/server.rb +13 -13
- data/lib/samagotchi/web/session_control.rb +58 -5
- data/lib/samagotchi/web/session_show.rb +42 -4
- metadata +7 -2
- data/lib/samagotchi/web/public/cards_offscreen.js +0 -69
|
@@ -1469,6 +1469,33 @@ body.has-session.composer-folded #infoBar{border-top-color:transparent}
|
|
|
1469
1469
|
.ss-cancel{background:transparent}
|
|
1470
1470
|
.stop-sheet.sheet .ss-acts button{flex:1 1 auto;font-size:14px;padding:10px 12px}
|
|
1471
1471
|
.ss-foot{font-size:11.5px;color:var(--text-muted);margin-top:6px}
|
|
1472
|
+
.delete-sheet{display:flex;flex-direction:column;gap:10px}
|
|
1473
|
+
.ds-head{display:flex;align-items:center;justify-content:space-between;min-height:24px}
|
|
1474
|
+
.ds-back{background:none;border:none;padding:0;color:var(--accent);font:inherit;cursor:pointer}
|
|
1475
|
+
.ds-title{font-size:14px;font-weight:600;color:var(--text-bright)}
|
|
1476
|
+
.ds-sub{color:var(--text-2)}
|
|
1477
|
+
.ds-banner{padding:8px 10px;border-radius:8px;background:var(--warn-bg);border:1px solid var(--warn-border);color:var(--warn-text)}
|
|
1478
|
+
.ds-choices{display:flex;flex-direction:column;gap:10px}
|
|
1479
|
+
.ds-choice{display:flex;flex-direction:column;gap:4px;text-align:left;padding:10px 12px;border-radius:10px;border:1px solid var(--border-strong);background:none;color:var(--text);font:inherit;cursor:pointer}
|
|
1480
|
+
.ds-choice:hover:not([disabled]){background:var(--bg-hover)}
|
|
1481
|
+
.ds-choice.primary{background:var(--bg-raised);border-color:var(--danger)}
|
|
1482
|
+
.ds-choice.primary .ds-label{color:var(--danger-text)}
|
|
1483
|
+
.ds-choice[disabled]{cursor:default;color:var(--text-muted);border-color:var(--border);background:none}
|
|
1484
|
+
.ds-choice[disabled] .ds-label{color:var(--text-muted)}
|
|
1485
|
+
.ds-label{font-weight:600}
|
|
1486
|
+
.ds-line{color:var(--text-2)}
|
|
1487
|
+
.ds-line.dim{color:var(--text-muted)}
|
|
1488
|
+
.ds-line.warn{color:var(--warn-bright)}
|
|
1489
|
+
.ds-foot{display:flex;align-items:center;gap:8px}
|
|
1490
|
+
.ds-note{flex-grow:1;color:var(--text-muted);font-size:12px}
|
|
1491
|
+
.ds-foot>span:first-child{flex-grow:1}
|
|
1492
|
+
.ds-cancel{padding:6px 14px;border-radius:8px;border:1px solid var(--border-strong);background:none;color:var(--text-2);font:inherit;cursor:pointer}
|
|
1493
|
+
.delete-sheet.busy .ds-choice{opacity:.6}
|
|
1494
|
+
.sheet .ds-choice{min-height:44px;padding:12px 14px;border-radius:12px}
|
|
1495
|
+
.sheet .ds-title{font-size:17px}
|
|
1496
|
+
.sheet .ds-back{min-height:44px}
|
|
1497
|
+
.sheet .ds-foot{flex-wrap:wrap}
|
|
1498
|
+
.sheet .ds-cancel{flex-basis:100%;min-height:48px;border:none;border-radius:12px;background:var(--bg-raised);font-weight:600}
|
|
1472
1499
|
.ctx-pop-head{display:flex;align-items:baseline;gap:8px}
|
|
1473
1500
|
.ctx-pop-head strong{font-family:ui-monospace,monospace;color:var(--text-bright)}
|
|
1474
1501
|
#updateSheet{width:calc(100vw - 32px);max-width:560px;max-height:calc(100dvh - 32px);overflow:auto;margin:auto;padding:14px 16px;border:1px solid var(--border-strong);border-radius:14px;background:var(--bg-panel);color:var(--text);box-shadow:var(--toast-shadow)}
|
|
@@ -111,10 +111,11 @@ export function infoBarHtml(bar) {
|
|
|
111
111
|
const setup = html`${settingsChip(bar.settings)}<span class=${`model model-name${bar.model.mismatch ? " served-mismatch" : ""}`} title=${bar.model.title}>${bar.model.text}</span>${toolkitChip(bar.toolkit)}${bar.notes ? html`<span class="model notes-chip" title=${bar.notes.title}>${bar.notes.text}</span>` : nothing}${bar.workingSet ? workingSetChipTemplate(bar.workingSet.chip) : memories.length ? html`<span class="model mem-chip" title=${memChipTitle(memories)}>${memChipText(memories)}</span>` : nothing}`;
|
|
112
112
|
const pruned = !!bar.chain?.pruned && !bar.chain?.prev;
|
|
113
113
|
const related = !!(bar.chain?.prev || bar.chain?.next || pruned || bar.parent || bar.kids || bar.participants);
|
|
114
|
-
// A chain
|
|
114
|
+
// A chain whose earlier link was deleted (by hand, or a schedule's prune:
|
|
115
|
+
// one word for both, the logs say who): the link before this one
|
|
115
116
|
// is gone, so there is nothing to link to — the bar says so instead.
|
|
116
117
|
const relations = related
|
|
117
|
-
? html`${sep("relations")}<span class="bar-group relations">${pruned ? html`<span class="model chain-pruned" title="The links before this one were
|
|
118
|
+
? html`${sep("relations")}<span class="bar-group relations">${pruned ? html`<span class="model chain-pruned" title="The links before this one were deleted">↩ earlier links deleted</span>` : nothing}${bar.chain?.prev ? chainLinkTemplate(bar.chain.prev, PREV, "The previous link of this chain") : nothing}${bar.chain?.next ? chainLinkTemplate(bar.chain.next, NEXT, "The next link of this chain") : nothing}${bar.parent ? html`<a class="model parent" href=${sessionHash(bar.parent.id)} title=${bar.parent.title}>↑ ${String(bar.parent.id).slice(0, 8)}</a>` : nothing}${kidsTemplate(bar.kids)}${participantsChip(bar.participants)}</span>`
|
|
118
119
|
: nothing;
|
|
119
120
|
const trail = html`<span class="dir" title=${bar.dir || ""}><bdi>${bar.dir || ""}</bdi></span>${workerBadgeTemplate(bar.worker)}`;
|
|
120
121
|
return html`<div class="meta"><span class="bar-group identity">${identity}</span>${sep("setup")}<span class="bar-group setup">${setup}</span>${relations}${sep("trail")}<span class="bar-group trail">${trail}</span></div>`;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// eventsLive() whether the hub's events stream is open
|
|
19
19
|
// refresh() fetch the list (no events stream)
|
|
20
20
|
// select(id) open a session
|
|
21
|
-
// confirmDelete(id), setArchived(id, archive), archiveOne(id, archive)
|
|
21
|
+
// confirmDelete(id, {anchor}), setArchived(id, archive), archiveOne(id, archive)
|
|
22
22
|
// updateSessionTitle(), showToast(text, action)
|
|
23
23
|
// allViewOpen(), openAllView(), closeAllView(), leaveAllView(hash)
|
|
24
24
|
// renameShown(owner) whether a card's title has its ✎ (session_title.js)
|
|
@@ -482,7 +482,7 @@ export function createListsView(deps) {
|
|
|
482
482
|
const del = e.target.closest(".card-del");
|
|
483
483
|
if (del) {
|
|
484
484
|
e.stopPropagation();
|
|
485
|
-
confirmDelete(del.dataset.del);
|
|
485
|
+
confirmDelete(del.dataset.del, { anchor: del });
|
|
486
486
|
return;
|
|
487
487
|
}
|
|
488
488
|
// Archive from the list: the view stays open, the toast has Undo.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//
|
|
9
9
|
// +folded+ (a Set of BAR_ITEMS keys: the items folded off the row) narrows
|
|
10
10
|
// the menu to them: a row only for a folded chip (the id, ⚙ when folded, not
|
|
11
|
-
// when compact, and "earlier links
|
|
11
|
+
// when compact, and "earlier links deleted" included), Continue and Stop only
|
|
12
12
|
// when folded (Archive and Delete always: they are never on the row), ⋯'s
|
|
13
13
|
// dot from folded rows alone and its count (moreCount: shown on a desktop
|
|
14
14
|
// only). Without it (null) the menu has its fixed set: every chip's row but
|
|
@@ -113,7 +113,7 @@ export function moreRows(bar, folded = null) {
|
|
|
113
113
|
!bar.workingSet && memories.length > 0
|
|
114
114
|
&& { key: "memories", label: "Memories", value: memChipText(memories), info: memoriesTooltip(memories, bar.preloaded, bar.muted) },
|
|
115
115
|
bar.participants && participantsRow(bar.participants),
|
|
116
|
-
folded?.has("pruned") && bar.chain?.pruned && !bar.chain?.prev && { key: "pruned", label: "Earlier links
|
|
116
|
+
folded?.has("pruned") && bar.chain?.pruned && !bar.chain?.prev && { key: "pruned", label: "Earlier links deleted", value: "" },
|
|
117
117
|
bar.chain?.prev && { key: "prev", label: "Previous link", value: `${PREV} ${bar.chain.prev.date || short(bar.chain.prev.id)}`, href: bar.chain.prev.id },
|
|
118
118
|
bar.chain?.next && { key: "next", label: "Next link", value: `${bar.chain.next.date || short(bar.chain.next.id)} ${NEXT}`, href: bar.chain.next.id },
|
|
119
119
|
bar.parent && { key: "parent", label: "Delegated by", value: `↑ ${short(bar.parent.id)}`, href: bar.parent.id },
|
|
@@ -217,28 +217,65 @@ export function moreSheetTemplate({ bar, buttons, folded = null, shownInfo = nul
|
|
|
217
217
|
|
|
218
218
|
// ⋯'s sheet. el: where ⋯ is drawn (#infoBar); button: ⋯ itself; session(): the
|
|
219
219
|
// open session's id; hash: a session's id to its link (route.js sessionHash).
|
|
220
|
+
// onDelete(id, host): Delete on a chained session turns this panel into the
|
|
221
|
+
// delete sheet (delete_sheet.js) instead of clicking #infoDeleteBtn: it
|
|
222
|
+
// answers true when it took the host ({back: true, show(template), close(),
|
|
223
|
+
// wire(handler)}), whose ‹ More (del:back) draws the panel's list again.
|
|
220
224
|
// @return {update({bar, buttons, folded}), close, isOpen, pop}
|
|
221
|
-
export function createMoreSheet({ el, button, session = () => null, hash, doc = document, win = window }) {
|
|
225
|
+
export function createMoreSheet({ el, button, session = () => null, hash, onDelete = null, doc = document, win = window }) {
|
|
222
226
|
let bar = null;
|
|
223
227
|
let buttons = null;
|
|
224
228
|
let folded = null;
|
|
225
229
|
let shownInfo = null;
|
|
230
|
+
// The delete sheet drawn in the panel's place, its act handler, and the
|
|
231
|
+
// live host (one per Delete: a flow from an earlier one draws nothing).
|
|
232
|
+
let subview = null;
|
|
233
|
+
let subHandler = null;
|
|
234
|
+
let subHost = null;
|
|
226
235
|
|
|
227
236
|
function draw() {
|
|
228
|
-
render(moreSheetTemplate({ bar, buttons, folded, shownInfo, hash }), shell.pop);
|
|
237
|
+
render(subview ?? moreSheetTemplate({ bar, buttons, folded, shownInfo, hash }), shell.pop);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function makeHost() {
|
|
241
|
+
const me = {
|
|
242
|
+
back: true,
|
|
243
|
+
live: () => subHost === me,
|
|
244
|
+
show(tpl) {
|
|
245
|
+
if (subHost !== me) return;
|
|
246
|
+
subview = tpl;
|
|
247
|
+
draw();
|
|
248
|
+
shell.pop.querySelector(".ds-choice:not([disabled]), .ds-cancel, .ds-back")?.focus();
|
|
249
|
+
},
|
|
250
|
+
close() { if (subHost === me) shell.close(); },
|
|
251
|
+
wire(handler) { if (subHost === me) subHandler = handler; },
|
|
252
|
+
};
|
|
253
|
+
subHost = me;
|
|
254
|
+
return me;
|
|
229
255
|
}
|
|
230
256
|
|
|
231
257
|
const shell = createChipPopover({
|
|
232
258
|
id: "moreSheet", className: "ctx-popover more-sheet", width: 400, el, anchor: `#${button.id}`,
|
|
233
259
|
summary: () => bar, session, show: () => draw(), sheet: true, sheetShare: SHEET_TALL, label: "More about this session",
|
|
234
260
|
onOpen: () => shell.pop.querySelector(".more-row, .more-act")?.focus(),
|
|
235
|
-
onClose: () => { shownInfo = null; },
|
|
261
|
+
onClose: () => { shownInfo = null; subview = null; subHandler = null; subHost = null; },
|
|
236
262
|
onAct: (act) => {
|
|
237
263
|
const [what, name] = act.split(":");
|
|
238
264
|
if (what === "info") {
|
|
239
265
|
shownInfo = shownInfo === name ? null : name;
|
|
240
266
|
return draw();
|
|
241
267
|
}
|
|
268
|
+
if (what === "del") {
|
|
269
|
+
if (name === "back") {
|
|
270
|
+
subview = null;
|
|
271
|
+
subHandler = null;
|
|
272
|
+
subHost = null;
|
|
273
|
+
draw();
|
|
274
|
+
return shell.pop.querySelector(".more-act.delete")?.focus();
|
|
275
|
+
}
|
|
276
|
+
return subHandler?.act(name);
|
|
277
|
+
}
|
|
278
|
+
if (what === "go" && name === "delete" && onDelete?.(session(), makeHost())) return undefined;
|
|
242
279
|
// After this click is done: it goes on to the document, where what the
|
|
243
280
|
// target opens would take it as a click outside, and a link still has
|
|
244
281
|
// to follow its href.
|
|
@@ -91,9 +91,6 @@ const NOT_CARDS = (item) => item.kind !== "card" && item.kind !== "question";
|
|
|
91
91
|
// @param render (data) => that read drawn as a reload draws it (a fragment)
|
|
92
92
|
// @param cards () => the page's card registry (card_registry.js); without
|
|
93
93
|
// it, the cards and questions are left out
|
|
94
|
-
// @param place unused: an older app.js passes cards_offscreen.js's placer
|
|
95
|
-
// @param capabilities () => the page's capabilities (unused now; an older
|
|
96
|
-
// app.js passes it)
|
|
97
94
|
// @param post (id, body) => the counts to chi web
|
|
98
95
|
export function createReloadCheck({ enabled, sessionId, running, read, render, cards = null, post }) {
|
|
99
96
|
// The hand-off's pieces (stage_view.js onHandedOff), in their order;
|
|
@@ -2,6 +2,7 @@ import { continueRefusal, continuedText, openChildrenTemplate, openerText } from
|
|
|
2
2
|
import { cantText, deleteConfirmText, goneSessionNotice } from "./format.js";
|
|
3
3
|
import { sessionHash } from "./route.js";
|
|
4
4
|
import { inTree } from "./sessions_list.js";
|
|
5
|
+
import { isChained, listAfterDelete, deleteToast, runDeleteFlow } from "./delete_sheet.js";
|
|
5
6
|
|
|
6
7
|
// What the page does to a whole session (used by app.js): Continue, Archive
|
|
7
8
|
// and Unarchive, Delete and Stop, from the info bar's buttons, a card's or a
|
|
@@ -13,7 +14,8 @@ import { inTree } from "./sessions_list.js";
|
|
|
13
14
|
// +setSessions(list)+ the page's list (the store's: a new list redraws the
|
|
14
15
|
// lists and the bar);
|
|
15
16
|
// +api+: {continueSession, archiveSession, unarchiveSession,
|
|
16
|
-
// deleteSession, stopSession, sessionHolds,
|
|
17
|
+
// deleteSession, deleteChain, deletePlan, stopSession, sessionHolds,
|
|
18
|
+
// stopSessionHolds} (data.js);
|
|
17
19
|
// +eventsLive()+ the hub's stream is open (else
|
|
18
20
|
// +refresh()+ fetches the list);
|
|
19
21
|
// +select(id)+, +clearSelection()+, +showNotice(text)+,
|
|
@@ -31,20 +33,62 @@ export function createSessionActions({
|
|
|
31
33
|
// true; nothing to stop (or no sheet wired) is false, and Stop is the
|
|
32
34
|
// confirm.
|
|
33
35
|
stopSheet = { open: () => false },
|
|
36
|
+
// A card's delete sheet (delete_sheet.js createDeleteSheet): +host(anchor)+
|
|
37
|
+
// draws a chained session's choices at it.
|
|
38
|
+
deleteSheet = null,
|
|
34
39
|
}) {
|
|
35
40
|
// The session this tab is stopping: its stream may close before the stop
|
|
36
41
|
// request returns (workerGone reads it).
|
|
37
42
|
let stoppingId = null;
|
|
38
43
|
|
|
39
|
-
// Delete a session (the
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
44
|
+
// Delete a session (the ⋯ More panel's Delete, an all-sessions card's ✕).
|
|
45
|
+
// A chained session gets the delete sheet (delete_sheet.js): in the More
|
|
46
|
+
// panel's place (deleteIn), at the card's ✕ (+anchor+), else at ⋯. Any
|
|
47
|
+
// other keeps today's confirm. The list drops what went without a reload.
|
|
48
|
+
// The server stops a live worker first and refuses a session a terminal
|
|
49
|
+
// chi has open.
|
|
50
|
+
async function confirmDelete(id, { anchor = null } = {}) {
|
|
43
51
|
const sess = sessions().find((s) => s.id === id) || { id };
|
|
44
52
|
if (sess.owner === "tui") {
|
|
45
53
|
alert(`Session ${id.slice(0, 8)} is open in a terminal chi; close it there first.`);
|
|
46
54
|
return;
|
|
47
55
|
}
|
|
56
|
+
if (deleteSheet && api.deletePlan && isChained(sess, sessions())) {
|
|
57
|
+
const at = anchor || globalThis.document?.querySelector("#infoMoreBtn");
|
|
58
|
+
if (at) { startDeleteFlow(id, sess, deleteSheet.host(at, id)); return; }
|
|
59
|
+
}
|
|
60
|
+
await plainDelete(id, sess);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The More panel's Delete: true when it took +host+ (a chained session).
|
|
64
|
+
function deleteIn(id, host) {
|
|
65
|
+
const sess = sessions().find((s) => s.id === id);
|
|
66
|
+
if (!sess || sess.owner === "tui" || !api.deletePlan || !isChained(sess, sessions())) return false;
|
|
67
|
+
startDeleteFlow(id, sess, host);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function startDeleteFlow(id, sess, host) {
|
|
72
|
+
const flow = runDeleteFlow({
|
|
73
|
+
id, session: sess, host, api,
|
|
74
|
+
done: (which, result, plan) => afterDelete(id, which, result, plan),
|
|
75
|
+
plain: () => plainDelete(id, sess),
|
|
76
|
+
failed: (error) => alert(`Could not delete session ${id.slice(0, 8)}: ${error.message}`),
|
|
77
|
+
});
|
|
78
|
+
host.wire(flow);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function afterDelete(id, which, result, plan) {
|
|
82
|
+
setSessions(listAfterDelete(sessions(), result));
|
|
83
|
+
const gone = new Set(result.deleted || [id]);
|
|
84
|
+
if (gone.has(selected())) clearSelection();
|
|
85
|
+
if (!eventsLive()) refresh();
|
|
86
|
+
const { text, back } = deleteToast(which, result, plan, id);
|
|
87
|
+
toast(text, back ? { label: `Open ${back.slice(0, 8)}`, run: () => select(back) } : null);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Today's confirm: a session in no chain.
|
|
91
|
+
async function plainDelete(id, sess) {
|
|
48
92
|
if (!confirm(deleteConfirmText(sess))) return;
|
|
49
93
|
try {
|
|
50
94
|
await api.deleteSession(id);
|
|
@@ -245,7 +289,7 @@ export function createSessionActions({
|
|
|
245
289
|
}
|
|
246
290
|
|
|
247
291
|
return {
|
|
248
|
-
confirmDelete, leaveGoneSession, stopSelected, continueSelected, archiveOne, setArchived, toggleArchiveSelected,
|
|
292
|
+
confirmDelete, deleteIn, leaveGoneSession, stopSelected, continueSelected, archiveOne, setArchived, toggleArchiveSelected,
|
|
249
293
|
// The sessions whose Continue is under way (the info bar's button).
|
|
250
294
|
continuing: continuingIds,
|
|
251
295
|
// The session this tab is stopping, or null.
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
// bubbles, cards bubbles.js, cards_place.js
|
|
22
22
|
// cardRegistry the open session's cards as data (card_registry.js): seeded
|
|
23
23
|
// from a read before its replay, reset with the session; null: none
|
|
24
|
+
// stageMissing the stage's running-with-no-turn check (stage_missing.js);
|
|
25
|
+
// null: no check (the render then says nothing)
|
|
24
26
|
// markdown markdown_place.js (linkTextRefs, applyFinalMarkdown)
|
|
25
27
|
// capabilities() the page's capabilities (card.js shownElsewhere, the history's cards)
|
|
26
28
|
// page: {setReviseAnchor(anchor), renderInitRow(), setMarkdownWarning(warning),
|
|
@@ -51,7 +53,7 @@ export function createSessionView(deps) {
|
|
|
51
53
|
const {
|
|
52
54
|
store, historyEl, getSession,
|
|
53
55
|
liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet = null, wsPreview = null, gapClock,
|
|
54
|
-
bubbles, cards, markdown, capabilities, page, later, cardRegistry = null,
|
|
56
|
+
bubbles, cards, markdown, capabilities, page, later, cardRegistry = null, stageMissing = null,
|
|
55
57
|
} = deps;
|
|
56
58
|
const { makeUserBubble, addEndBubble, showGuardrailWarning, showRecap } = bubbles;
|
|
57
59
|
const { placeSnapshotCards, upsertCard } = cards;
|
|
@@ -178,6 +180,12 @@ export function createSessionView(deps) {
|
|
|
178
180
|
}
|
|
179
181
|
// A turn ran out of iterations and waits for a yes or no.
|
|
180
182
|
if (data.continue_offer) questionCards.renderContinue(data.continue_offer);
|
|
183
|
+
// The read is drawn: a running session whose stage holds no turn keeps its
|
|
184
|
+
// bare status row and marks itself (stage_missing.js).
|
|
185
|
+
if (stageMissing) {
|
|
186
|
+
stageMissing.note(data);
|
|
187
|
+
stageMissing.check();
|
|
188
|
+
}
|
|
181
189
|
// A whole view drawn: the composer and the bar once more (the working
|
|
182
190
|
// set's seed may change the bar's chip).
|
|
183
191
|
store.batch(() => {
|
|
@@ -124,12 +124,6 @@ export function createStageAsking({
|
|
|
124
124
|
opener.open(handOffOrder({ prompt: promptEl(), block: blockEl, extras: rows }), { follow });
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// A no-op kept one release for a mixed cache (remove in the next one): a
|
|
128
|
-
// stale stage_view.js (0.172.1's) calls it at the end of each refresh. The
|
|
129
|
-
// drift check it ran is the tests' now (stage_cuts_parity.test.js
|
|
130
|
-
// crossCheck, the e2e's stage check).
|
|
131
|
-
function reconcileWaiting() {}
|
|
132
|
-
|
|
133
127
|
// An opened turn's cards that stopped waiting go into the history: one
|
|
134
128
|
// with a lead-in under it (also after the turn's end, so a card
|
|
135
129
|
// cancelled by Stop turn sits there), another one at the history's end
|
|
@@ -273,7 +267,7 @@ export function createStageAsking({
|
|
|
273
267
|
}
|
|
274
268
|
|
|
275
269
|
return {
|
|
276
|
-
askingGen, asksOf, askedFor, askedText, docks, leadInText, openTurn,
|
|
270
|
+
askingGen, asksOf, askedFor, askedText, docks, leadInText, openTurn, settleCards, askingCard, cardOf, foldedText, markOwnToggles,
|
|
277
271
|
isCollapsed, trackFold, drawCollapsed, applyCollapsed, setCollapsed,
|
|
278
272
|
// A ref's "show in turn" opens a collapsed stage for this turn only.
|
|
279
273
|
reveal() {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// A running session whose stage shows nothing of its turn (docs/internals/web-frontend.md,
|
|
2
|
+
// "A running session without a turn"). At the points a turn could have been
|
|
3
|
+
// drawn — the end of a render (session_view.js), the hand-off and the end of a
|
|
4
|
+
// fold (stage_view.js's clearStage) — and again on a resize, a composer that
|
|
5
|
+
// changed size or a status change, it does two things:
|
|
6
|
+
// the safety net: the session's status runs and the stage holds no turn, so
|
|
7
|
+
// the stage keeps its bare status row ("running", Stop turn) instead of
|
|
8
|
+
// vanishing (runningWithoutTurn, stage_view.js), and a status that leaves
|
|
9
|
+
// running takes that row with it;
|
|
10
|
+
// the diagnostic: the stage is marked `data-stage-missing` ("1" for no turn,
|
|
11
|
+
// "covered" for a turn the composer card is over) and, once per session
|
|
12
|
+
// visit, a console.warn with counts only — never a prompt, a message or an
|
|
13
|
+
// answer — saying what the read had (live_read, current_turn, the replay's
|
|
14
|
+
// event types and their counts, the last replayed end event's turn id beside
|
|
15
|
+
// the running turn's) and where the stage sat (its status row's top and
|
|
16
|
+
// bottom, the composer's top, the window's height, the composer's saved floor
|
|
17
|
+
// and fold). The covered case is reported only: a stage the user made tall is
|
|
18
|
+
// their own doing, and the net is for a stage that shows nothing at all.
|
|
19
|
+
//
|
|
20
|
+
// The numbers come from getBoundingClientRect at the call; the pure functions
|
|
21
|
+
// take them as arguments, so a spec can pass its own. Its own module: new
|
|
22
|
+
// exports go in new modules (web-frontend.md).
|
|
23
|
+
import { readStored } from "./storage.js";
|
|
24
|
+
import { COMPOSER_FOLD_KEY } from "./composer_fold.js";
|
|
25
|
+
import { GRIP_KEY } from "./composer_grip.js";
|
|
26
|
+
|
|
27
|
+
// The replay events that end a turn.
|
|
28
|
+
const ENDS = ["turn_completed", "turn_canceled", "turn_failed"];
|
|
29
|
+
|
|
30
|
+
// What a show read said, in counts.
|
|
31
|
+
export function readCounts(data = {}) {
|
|
32
|
+
const replay = Array.isArray(data.replay) ? data.replay : [];
|
|
33
|
+
const events = {};
|
|
34
|
+
let lastEndTurn = null;
|
|
35
|
+
for (const event of replay) {
|
|
36
|
+
events[event.type] = (events[event.type] || 0) + 1;
|
|
37
|
+
if (ENDS.includes(event.type)) lastEndTurn = event.turn_id ?? null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
liveRead: data.live_read ?? null,
|
|
41
|
+
currentTurn: data.current_turn?.turn_id ?? null,
|
|
42
|
+
replay: replay.length,
|
|
43
|
+
events,
|
|
44
|
+
lastEndTurn,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The stage's status row out of sight: wholly above or below the window, or
|
|
49
|
+
// below the composer card's top edge (the dock puts the stage above it:
|
|
50
|
+
// index.html, .turn-stage). A hidden stage is hidden, not covered; a row with
|
|
51
|
+
// no measured height (a stub, a stage not yet laid out) says nothing.
|
|
52
|
+
export function stageCovered({ hidden, stageTop, stageBottom, composerTop, viewport }) {
|
|
53
|
+
if (hidden) return false;
|
|
54
|
+
if (stageBottom > stageTop && (stageBottom <= 0 || stageTop >= viewport)) return true;
|
|
55
|
+
return composerTop !== null && stageTop > composerTop;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Why the stage shows nothing of a turn, or null when it shows it: "none" (no
|
|
59
|
+
// turn in the stage), "covered" (it holds one, out of sight).
|
|
60
|
+
export function missingReason({ status, holds, hidden, stageTop, stageBottom, composerTop, viewport }) {
|
|
61
|
+
if (status !== "running") return null;
|
|
62
|
+
if (!holds) return "none";
|
|
63
|
+
return stageCovered({ hidden, stageTop, stageBottom, composerTop, viewport }) ? "covered" : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The console line: counts, no text from the session.
|
|
67
|
+
export function missingLine({ session, reason, counts, stage, composer }) {
|
|
68
|
+
const events = Object.entries(counts.events || {}).map(([type, n]) => `${type}=${n}`).join(" ") || "none";
|
|
69
|
+
return `stage-missing ${session || "none"} (${reason}) live_read=${counts.liveRead ?? "unknown"} ` +
|
|
70
|
+
`current_turn=${counts.currentTurn ?? "none"} replay=${counts.replay} events=${events} ` +
|
|
71
|
+
`last_end=${counts.lastEndTurn ?? "none"} vs turn=${counts.currentTurn ?? "none"} ` +
|
|
72
|
+
`stage_row=${stage.stageTop}..${stage.stageBottom} composer_top=${stage.composerTop} window=${stage.viewport} ` +
|
|
73
|
+
`composer_floor=${composer.floor ?? "unset"} composer_fold=${composer.fold ?? "unset"}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// +store+, +turnDom+ the page's views; +composerEl+ the composer card's box;
|
|
77
|
+
// +win+ the page's window; +warn+ where the line goes.
|
|
78
|
+
// @return {note(data), check()}
|
|
79
|
+
export function createStageMissing({ store, turnDom, composerEl, win = globalThis, warn = (line) => console.warn(line) }) {
|
|
80
|
+
const warned = new Set();
|
|
81
|
+
let counts = null;
|
|
82
|
+
|
|
83
|
+
function geometry() {
|
|
84
|
+
const stage = turnDom.root;
|
|
85
|
+
const row = stage.querySelector(".ts-status") || stage;
|
|
86
|
+
const stageRect = row.getBoundingClientRect?.() || { top: 0, bottom: 0 };
|
|
87
|
+
const composerRect = composerEl?.getBoundingClientRect?.() || { top: null, bottom: null };
|
|
88
|
+
return {
|
|
89
|
+
hidden: !!stage.hidden,
|
|
90
|
+
stageTop: stageRect.top ?? 0,
|
|
91
|
+
stageBottom: stageRect.bottom ?? 0,
|
|
92
|
+
// A folded composer shows nothing (composer.css), so it has no top to
|
|
93
|
+
// cover with; neither has one not laid out yet.
|
|
94
|
+
composerTop: composerRect.bottom > composerRect.top ? composerRect.top : null,
|
|
95
|
+
viewport: win?.innerHeight ?? 0,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The stage's state at one of the points a turn could have been drawn.
|
|
100
|
+
function check() {
|
|
101
|
+
const stage = turnDom.root;
|
|
102
|
+
const status = store.current.status;
|
|
103
|
+
if (status !== "running") {
|
|
104
|
+
delete stage.dataset.stageMissing;
|
|
105
|
+
// A status that left running takes the bare row with it: setTurnRunning
|
|
106
|
+
// is not the only writer (turnEndStatus and the hub change the status too).
|
|
107
|
+
turnDom.runningWithoutTurn?.(false);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
// The safety net: a session that runs keeps its status row (running and
|
|
111
|
+
// Stop turn) rather than showing nothing. It is a no-op when the stage
|
|
112
|
+
// holds or is folding a turn (stage_view.js's runningWithoutTurn).
|
|
113
|
+
if (!turnDom.holds()) turnDom.runningWithoutTurn?.(true);
|
|
114
|
+
const where = geometry();
|
|
115
|
+
const reason = missingReason({ status, holds: turnDom.holds(), ...where });
|
|
116
|
+
if (!reason) {
|
|
117
|
+
delete stage.dataset.stageMissing;
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
stage.dataset.stageMissing = reason === "covered" ? "covered" : "1";
|
|
121
|
+
const session = store.selected;
|
|
122
|
+
if (!warned.has(session)) {
|
|
123
|
+
warned.add(session);
|
|
124
|
+
warn(missingLine({
|
|
125
|
+
session, reason, counts: counts || readCounts({}),
|
|
126
|
+
stage: where,
|
|
127
|
+
composer: {
|
|
128
|
+
top: stage.composerTop,
|
|
129
|
+
floor: readStored(GRIP_KEY),
|
|
130
|
+
fold: readStored(COMPOSER_FOLD_KEY),
|
|
131
|
+
},
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
return reason;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// A status write redraws the bar: only a change needs the stage looked at,
|
|
138
|
+
// and only one away from running. A turn that runs is drawn by the render,
|
|
139
|
+
// the hand-off or the fold; a status that comes to running before the replay
|
|
140
|
+
// is drawn would warn about a stage not yet filled.
|
|
141
|
+
let lastStatus = null;
|
|
142
|
+
function checkOnStatus() {
|
|
143
|
+
if (store.current.status === lastStatus) return null;
|
|
144
|
+
lastStatus = store.current.status;
|
|
145
|
+
if (store.current.status === "running") return null;
|
|
146
|
+
return check();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { note: (data) => { counts = readCounts(data); }, check, checkOnStatus };
|
|
150
|
+
}
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
// the cloud stage_cloud.js's, the docked card and the fold stage_asking.js's,
|
|
26
26
|
// its pager stage_pager.js's, the waiting cards as data stage_waiting.js's,
|
|
27
27
|
// the answer's reading stage_answer.js's, the quiet signal stage_stall.js's
|
|
28
|
-
// and its clocks stage_quiet_clock.js's, the perf probe stage_probe.js's
|
|
28
|
+
// and its clocks stage_quiet_clock.js's, the perf probe stage_probe.js's and the
|
|
29
|
+
// running-with-no-turn check stage_missing.js's. A new
|
|
29
30
|
// stage feature goes into its own stage_<feature>.js, wired here in a few
|
|
30
31
|
// lines; each module resets itself from emptySlots.
|
|
31
32
|
import { createTurnBlock } from "./turn_block.js";
|
|
@@ -69,6 +70,8 @@ const FLASH_MS = 4000;
|
|
|
69
70
|
// status row's Stop turn (a promise of the cancel request; the button is
|
|
70
71
|
// disabled until it settles); null: no Stop turn. +onHandedOff+({pieces,
|
|
71
72
|
// immediate}): a turn's pieces reached the history (reload_check.js).
|
|
73
|
+
// +onStageCleared+(): the stage just went empty (the fold's end, a release):
|
|
74
|
+
// app.js's stage_missing.js looks at it then.
|
|
72
75
|
// The quiet signal's inputs (stage_quiet_clock.js): +clock+() the page's time,
|
|
73
76
|
// +streamLive+() the session's stream is open, +timingNote+() what the turn
|
|
74
77
|
// waits on (live_timing.js note), +serverGen+() a joiner's generation.
|
|
@@ -78,7 +81,7 @@ const FLASH_MS = 4000;
|
|
|
78
81
|
// factory (stage_waiting.js; a test passes an older one's shape).
|
|
79
82
|
export function createStageView({
|
|
80
83
|
historyEl, isNearBottom: historyNearBottom, sawText, sessionId, dockEl, centerEl, taskStop = null,
|
|
81
|
-
renderMarkdown, linkRefs, workingSet = null, onCancel = null, onHandedOff = null,
|
|
84
|
+
renderMarkdown, linkRefs, workingSet = null, onCancel = null, onHandedOff = null, onStageCleared = null,
|
|
82
85
|
clock = () => Date.now(), streamLive = () => true, timingNote = () => "", serverGen = () => null,
|
|
83
86
|
canCancel = () => true, ownerWait = () => null, createWaiting = createStageWaiting,
|
|
84
87
|
}) {
|
|
@@ -521,7 +524,8 @@ export function createStageView({
|
|
|
521
524
|
view.reset();
|
|
522
525
|
}
|
|
523
526
|
|
|
524
|
-
// The stage empty and hidden, its frame free.
|
|
527
|
+
// The stage empty and hidden, its frame free. The page then looks at it
|
|
528
|
+
// (stage_missing.js): a session that still runs gets its bare status row back.
|
|
525
529
|
function clearStage() {
|
|
526
530
|
dropBare();
|
|
527
531
|
handoff.cancelFold();
|
|
@@ -529,6 +533,7 @@ export function createStageView({
|
|
|
529
533
|
stage.hidden = true;
|
|
530
534
|
frame.frameFree();
|
|
531
535
|
ask.unreveal();
|
|
536
|
+
onStageCleared?.();
|
|
532
537
|
}
|
|
533
538
|
|
|
534
539
|
function release() {
|
|
@@ -91,24 +91,24 @@ module Samagotchi
|
|
|
91
91
|
LINGER_BYTES = 4 * 1024 * 1024
|
|
92
92
|
LINGER_SECONDS = 2.0
|
|
93
93
|
|
|
94
|
-
# A refusal (status 400 or more) to a request
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
# per route: the gate's 401, a participant's 403/404, the image
|
|
102
|
-
# path's own 413 and 429 close as App's 413 does. A 2xx/3xx stays
|
|
103
|
-
# alive (WEBrick drains a body the app left, as before); a hijacked
|
|
104
|
-
# stream is left to its own.
|
|
94
|
+
# A refusal (status 400 or more) to a request with a body, a successful
|
|
95
|
+
# answer to a large body the app may have left unread (over the small
|
|
96
|
+
# body limit or any Transfer-Encoding), and any answer with
|
|
97
|
+
# Connection: close end the connection: otherwise WEBrick drains the
|
|
98
|
+
# unread body before answering, holding a thread for an unbounded
|
|
99
|
+
# upload. One rule here, not per route. A small body on a 2xx/3xx stays
|
|
100
|
+
# alive; a hijacked stream is left to its own.
|
|
105
101
|
module CloseOnConnectionClose
|
|
106
102
|
def service(req, res)
|
|
107
103
|
super
|
|
108
104
|
return if res.body.respond_to?(:call)
|
|
109
105
|
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
content_length = req["content-length"].to_i
|
|
107
|
+
transfer_encoding = !req["transfer-encoding"].nil?
|
|
108
|
+
body = content_length.positive? || transfer_encoding
|
|
109
|
+
large_body = content_length > RequestBody::SMALL_BODY_LIMIT || transfer_encoding
|
|
110
|
+
close_for_body = body && (res.status >= 400 || large_body)
|
|
111
|
+
return unless res["connection"].to_s.casecmp?("close") || close_for_body
|
|
112
112
|
|
|
113
113
|
res.keep_alive = false
|
|
114
114
|
res.linger = body
|
|
@@ -524,14 +524,67 @@ module Samagotchi
|
|
|
524
524
|
# session is always refused.
|
|
525
525
|
def handle_delete(req, id)
|
|
526
526
|
result = @manager.delete_session(id, state_dir: @state_dir, stop: truthy_param?(req.GET["force"]),
|
|
527
|
-
wait: STOP_WAIT_SECONDS)
|
|
528
|
-
|
|
529
|
-
json_response(200, { status: "deleted", session_id: result[:id], stopped: result[:stopped]
|
|
527
|
+
wait: STOP_WAIT_SECONDS, revive_previous: true, refuse_continuing: true)
|
|
528
|
+
touch_deleted(result[:id], result)
|
|
529
|
+
json_response(200, { status: "deleted", session_id: result[:id], stopped: result[:stopped],
|
|
530
|
+
unarchived: Array(result[:unarchived]), moved_back: Array(result[:moved_back]),
|
|
531
|
+
deleted: Array(result[:deleted] || [result[:id]]), left_running: Array(result[:left_running]) })
|
|
530
532
|
rescue SessionManager::OwnedByTUI => e
|
|
531
533
|
owned_by_one_shot(id, e)
|
|
532
534
|
rescue SessionManager::DeleteRefused => e
|
|
533
|
-
|
|
534
|
-
|
|
535
|
+
delete_refused(e)
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# DELETE /api/sessions/:id/chain?force=: every link of the chain with
|
|
539
|
+
# their delegates (SessionManager.delete_chain). Query-only.
|
|
540
|
+
def handle_delete_chain(req, id)
|
|
541
|
+
result = @manager.delete_chain(id, state_dir: @state_dir, stop: truthy_param?(req.GET["force"]),
|
|
542
|
+
wait: STOP_WAIT_SECONDS)
|
|
543
|
+
touch_deleted(id, result)
|
|
544
|
+
json_response(200, { status: "deleted", session_id: id, deleted: result[:deleted], left: result[:left],
|
|
545
|
+
left_running: result[:left_running], unarchived: result[:unarchived],
|
|
546
|
+
stopped: result[:stopped], cut_off: result[:cut_off], refusal: result[:refusal] })
|
|
547
|
+
rescue SessionManager::OwnedByTUI => e
|
|
548
|
+
owned_by_one_shot(e.session_id, e)
|
|
549
|
+
rescue SessionManager::DeleteRefused => e
|
|
550
|
+
delete_refused(e)
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
# GET /api/sessions/:id/delete_plan: what the delete sheet shows for a
|
|
554
|
+
# chained session (SessionChain::Delete::Preview: the plan and the
|
|
555
|
+
# refusals the delete itself runs), {chained: false} for one in no
|
|
556
|
+
# chain. One session listing walk per call; the page asks only for a
|
|
557
|
+
# chained session, as the sheet opens. No query or body read; no-store
|
|
558
|
+
# (json_response's).
|
|
559
|
+
def handle_delete_plan(_req, id)
|
|
560
|
+
return unknown_session(id) unless Session.exist?(id, state_dir: @state_dir || Session.default_state_dir)
|
|
561
|
+
|
|
562
|
+
require_relative "../session_chain/delete_preview"
|
|
563
|
+
json_response(200, SessionChain::Delete::Preview.call(id, state_dir: @state_dir))
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
# The hub hears every session a delete changed: deleted, back in the
|
|
567
|
+
# lists, moved back to the previous link, left running without a parent.
|
|
568
|
+
def touch_deleted(id, result)
|
|
569
|
+
return unless @hub
|
|
570
|
+
|
|
571
|
+
ids = [id, *result[:deleted], *result[:unarchived], *result[:moved_back], *result[:left_running]]
|
|
572
|
+
ids.compact.uniq.each { |sid| @hub.touch(sid) }
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
# 409 with the refusal's reason as its code, and what a remote client
|
|
576
|
+
# raises it again from (ids, the schedule).
|
|
577
|
+
def delete_refused(error)
|
|
578
|
+
detail = error.reason == :still_stopping ? "#{error.message}; try again in a moment" : error.message
|
|
579
|
+
# A moved delegate that can't go back: whether the page can stop it
|
|
580
|
+
# (its "Stop its worker, then delete"), as the refusal saw it.
|
|
581
|
+
if error.reason == :delegate_unmovable
|
|
582
|
+
require_relative "../session_chain/delete"
|
|
583
|
+
stoppable = SessionChain::Delete.stoppable?(error.ids, @state_dir || Session.default_state_dir)
|
|
584
|
+
end
|
|
585
|
+
refusal_response(409, error.reason.to_s, error, detail: detail, session_id: error.session_id,
|
|
586
|
+
reason: error.reason.to_s, ids: error.ids.empty? ? nil : error.ids,
|
|
587
|
+
schedule_id: error.schedule_id, stoppable: stoppable)
|
|
535
588
|
end
|
|
536
589
|
|
|
537
590
|
# 409 owned_by_tui in the words a refused archive, delete or continue
|