samagotchi 0.171.0 → 0.172.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 +33 -1
- data/bin/chi +6 -4
- data/docs/architecture.md +24 -7
- data/docs/bundles.md +4 -21
- data/docs/cli.md +50 -80
- data/docs/configuration.md +11 -13
- data/docs/context.md +5 -6
- data/docs/guardrails.md +57 -96
- data/docs/hooks.md +3 -4
- data/docs/internals/attached-context.md +6 -7
- data/docs/internals/background-tasks.md +4 -3
- data/docs/internals/bridge.md +29 -3
- data/docs/internals/engine.md +21 -9
- data/docs/internals/objectives.md +3 -5
- data/docs/internals/participants.md +118 -143
- data/docs/internals/prompt-caching.md +4 -5
- data/docs/internals/web-frontend.md +33 -14
- data/docs/internals/working-set.md +7 -5
- data/docs/memory.md +1 -1
- data/docs/plugins.md +2 -16
- data/docs/scheduling.md +1 -1
- data/docs/sessions.md +15 -49
- data/docs/sub-agent.md +2 -2
- data/docs/system-one.md +2 -2
- data/docs/testing.md +56 -7
- data/lib/samagotchi/bridge/card_store.rb +1 -0
- data/lib/samagotchi/bridge/sse_writer.rb +1 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +0 -1
- data/lib/samagotchi/bridge.rb +26 -9
- data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
- data/lib/samagotchi/bundle_command/test_run.rb +1 -0
- data/lib/samagotchi/bundle_command/try/run.rb +1 -0
- data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
- data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
- data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
- data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
- data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +126 -67
- data/lib/samagotchi/command_intake.rb +15 -3
- data/lib/samagotchi/compat.rb +6 -1
- data/lib/samagotchi/context_candidate_choice.rb +1 -3
- data/lib/samagotchi/context_candidates.rb +3 -4
- data/lib/samagotchi/continue_offer.rb +9 -2
- data/lib/samagotchi/delivery.rb +23 -12
- data/lib/samagotchi/empty_answer_error.rb +5 -0
- data/lib/samagotchi/engine/cards.rb +3 -0
- data/lib/samagotchi/engine/context_judge.rb +5 -3
- data/lib/samagotchi/engine/events.rb +4 -0
- data/lib/samagotchi/engine/hooks.rb +3 -0
- data/lib/samagotchi/engine/messages.rb +5 -0
- data/lib/samagotchi/engine/model_settings.rb +2 -0
- data/lib/samagotchi/engine/models.rb +10 -0
- data/lib/samagotchi/engine/objectives.rb +6 -0
- data/lib/samagotchi/engine/participants.rb +18 -14
- data/lib/samagotchi/engine/plugins.rb +8 -0
- data/lib/samagotchi/engine/questions.rb +3 -0
- data/lib/samagotchi/engine/recap.rb +1 -0
- data/lib/samagotchi/engine/session.rb +4 -0
- data/lib/samagotchi/engine/side_requests.rb +9 -0
- data/lib/samagotchi/engine/steering.rb +2 -0
- data/lib/samagotchi/engine/toolkit.rb +5 -0
- data/lib/samagotchi/engine/turn_end.rb +7 -0
- data/lib/samagotchi/engine/turn_helpers.rb +8 -0
- data/lib/samagotchi/engine/verify.rb +2 -0
- data/lib/samagotchi/engine.rb +3 -2
- data/lib/samagotchi/grants.rb +28 -22
- data/lib/samagotchi/guardrail_wiring.rb +23 -18
- data/lib/samagotchi/guardrails/approval_use.rb +59 -0
- data/lib/samagotchi/guardrails/approvals.rb +9 -11
- data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
- data/lib/samagotchi/guardrails/gate.rb +10 -5
- data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
- data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
- data/lib/samagotchi/guardrails/review_paths.rb +2 -3
- data/lib/samagotchi/guardrails.rb +1 -1
- data/lib/samagotchi/llm_context_strategy.rb +2 -0
- data/lib/samagotchi/objectives.rb +1 -4
- data/lib/samagotchi/objectives_audit.rb +1 -1
- data/lib/samagotchi/objectives_track.rb +1 -1
- data/lib/samagotchi/owner_prompt.rb +3 -6
- data/lib/samagotchi/parent_report.rb +1 -0
- data/lib/samagotchi/participant_messages.rb +9 -4
- data/lib/samagotchi/participant_turn_mode.rb +50 -0
- data/lib/samagotchi/participants.rb +21 -12
- data/lib/samagotchi/participants_watch.rb +2 -2
- data/lib/samagotchi/plugin/api.rb +2 -2
- data/lib/samagotchi/plugin/attached_context.rb +1 -1
- data/lib/samagotchi/plugin/context.rb +0 -4
- data/lib/samagotchi/plugin/sessions.rb +1 -25
- data/lib/samagotchi/run_options.rb +2 -3
- data/lib/samagotchi/send_command.rb +10 -10
- data/lib/samagotchi/session.rb +0 -3
- data/lib/samagotchi/session_access/contract.rb +1 -10
- data/lib/samagotchi/session_access/local.rb +10 -23
- data/lib/samagotchi/session_access/remote.rb +9 -20
- data/lib/samagotchi/session_access.rb +12 -16
- data/lib/samagotchi/session_chain.rb +4 -6
- data/lib/samagotchi/session_commands.rb +6 -3
- data/lib/samagotchi/session_continue.rb +1 -2
- data/lib/samagotchi/session_manager/delivery.rb +25 -5
- data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
- data/lib/samagotchi/session_manager/listing.rb +5 -0
- data/lib/samagotchi/session_manager/spawn.rb +2 -2
- data/lib/samagotchi/session_manager/worker_command.rb +9 -0
- data/lib/samagotchi/session_participants.rb +12 -8
- data/lib/samagotchi/session_review.rb +5 -7
- data/lib/samagotchi/session_stores.rb +3 -3
- data/lib/samagotchi/share_command.rb +10 -12
- data/lib/samagotchi/share_terms.rb +41 -0
- data/lib/samagotchi/steer.rb +8 -14
- data/lib/samagotchi/system_prompt.rb +16 -25
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
- data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
- data/lib/samagotchi/terminal_ui.rb +1 -2
- data/lib/samagotchi/testing/sessions.rb +2 -10
- data/lib/samagotchi/tool_runner.rb +8 -9
- data/lib/samagotchi/toolkit.rb +4 -22
- data/lib/samagotchi/toolkit_suggest.rb +3 -3
- data/lib/samagotchi/tools/deferred_tools.rb +1 -0
- data/lib/samagotchi/tools/execute.rb +11 -45
- data/lib/samagotchi/tools/leftovers.rb +122 -0
- data/lib/samagotchi/tools/memory.rb +70 -26
- data/lib/samagotchi/tools/task_get.rb +1 -0
- data/lib/samagotchi/tools/task_list.rb +3 -2
- data/lib/samagotchi/tools/task_record.rb +6 -4
- data/lib/samagotchi/tools/task_runtime.rb +199 -20
- data/lib/samagotchi/tools/task_wait.rb +4 -3
- data/lib/samagotchi/turn_context.rb +1 -1
- data/lib/samagotchi/turn_origin.rb +1 -1
- data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
- data/lib/samagotchi/turn_stages/objectives.rb +2 -2
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
- data/lib/samagotchi/update_hint.rb +3 -1
- data/lib/samagotchi/verify_fresh.rb +1 -1
- data/lib/samagotchi/verify_fresh_origin.rb +13 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -5
- data/lib/samagotchi/web/participant_access.rb +14 -18
- data/lib/samagotchi/web/participant_review.rb +3 -4
- data/lib/samagotchi/web/participant_show.rb +4 -3
- data/lib/samagotchi/web/participant_view.rb +3 -3
- data/lib/samagotchi/web/participants_admin.rb +21 -40
- data/lib/samagotchi/web/public/app.js +5 -47
- data/lib/samagotchi/web/public/data.js +2 -10
- data/lib/samagotchi/web/public/delivery_line.js +17 -60
- data/lib/samagotchi/web/public/index.html +10 -30
- data/lib/samagotchi/web/public/live_turn.js +1 -1
- data/lib/samagotchi/web/public/owner_claim.js +2 -2
- data/lib/samagotchi/web/public/participant_bar.js +4 -5
- data/lib/samagotchi/web/public/participant_names.js +14 -10
- data/lib/samagotchi/web/public/participants_panel.js +29 -62
- data/lib/samagotchi/web/public/reload_check.js +2 -3
- data/lib/samagotchi/web/public/send_turn.js +4 -23
- data/lib/samagotchi/web/public/session_actions.js +4 -45
- data/lib/samagotchi/web/public/session_fields.js +0 -1
- data/lib/samagotchi/web/public/session_state.js +0 -3
- data/lib/samagotchi/web/public/session_view.js +2 -3
- data/lib/samagotchi/web/public/settings_panel.js +4 -18
- data/lib/samagotchi/web/public/stage_answer.js +56 -0
- data/lib/samagotchi/web/public/stage_asking.js +1 -1
- data/lib/samagotchi/web/public/stage_cloud.js +93 -0
- data/lib/samagotchi/web/public/stage_dom.js +100 -0
- data/lib/samagotchi/web/public/stage_handoff.js +154 -0
- data/lib/samagotchi/web/public/stage_pager.js +59 -0
- data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
- data/lib/samagotchi/web/public/stage_view.js +90 -411
- data/lib/samagotchi/web/public/start_page.js +12 -33
- data/lib/samagotchi/web/public/start_settings.js +24 -78
- data/lib/samagotchi/web/public/start_toolkit.js +6 -10
- data/lib/samagotchi/web/public/stream_handlers.js +1 -9
- data/lib/samagotchi/web/public/turn_block.js +3 -7
- data/lib/samagotchi/web/public/turn_events.js +15 -6
- data/lib/samagotchi/web/public/turn_pieces.js +3 -4
- data/lib/samagotchi/web/public/viewer_self.js +8 -2
- data/lib/samagotchi/web/qr.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +3 -1
- data/lib/samagotchi/web/session_create.rb +5 -71
- data/lib/samagotchi/web/session_summary.rb +1 -4
- data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
- data/lib/samagotchi/web/viewer.rb +3 -3
- data/lib/samagotchi/worker.rb +16 -14
- data/lib/samagotchi/worker_inbound.rb +4 -3
- data/lib/samagotchi/worker_link.rb +17 -0
- data/lib/samagotchi/working_set.rb +87 -28
- metadata +13 -8
- data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
- data/lib/samagotchi/participant_mode.rb +0 -86
- data/lib/samagotchi/review_apply.rb +0 -131
- data/lib/samagotchi/review_command.rb +0 -123
- data/lib/samagotchi/review_start.rb +0 -196
- data/lib/samagotchi/web/public/review_apply.js +0 -34
- data/lib/samagotchi/web/public/review_start.js +0 -55
|
@@ -17,8 +17,8 @@ import { createStartToolkit, toolkitLabel, toolkitOverride } from "./start_toolk
|
|
|
17
17
|
// default in charge. The search list itself is model_picker.js'; a pick
|
|
18
18
|
// sends the focus to the message box.
|
|
19
19
|
//
|
|
20
|
-
// Beside it, the start page's ⚙ panel (start_settings.js): thinking
|
|
21
|
-
// context
|
|
20
|
+
// Beside it, the start page's ⚙ panel (start_settings.js): thinking and LLM
|
|
21
|
+
// context, each a choice for the next new session only
|
|
22
22
|
// (sent with its create, then dropped; never remembered: a reload or opening
|
|
23
23
|
// a session drops it too, a failed create keeps it). What is set shows as
|
|
24
24
|
// override chips on the row, each opening the panel (a dot on ⚙ on a phone).
|
|
@@ -29,8 +29,8 @@ export const START_PICK_TITLE = "The model the new session starts on";
|
|
|
29
29
|
|
|
30
30
|
// Used by app.js. Elements: +pickEl+ (the picker's button), +panelEl+,
|
|
31
31
|
// +searchEl+, +listEl+, +composerEl+, +centerEl+ (model_picker.js'),
|
|
32
|
-
// +settingsEl+ (⚙), +thinkingEl+ / +llmContextEl+
|
|
33
|
-
//
|
|
32
|
+
// +settingsEl+ (⚙), +thinkingEl+ / +llmContextEl+ (the override chips),
|
|
33
|
+
// +toolkitBtnEl+ (🧰) and
|
|
34
34
|
// +toolkitEl+ (its override chip; both optional).
|
|
35
35
|
// Hooks: +selected()+ the open session's id or null; +state()+ the open
|
|
36
36
|
// session's fields (session_state.js: model, continues…); +running()+ a turn
|
|
@@ -38,7 +38,7 @@ export const START_PICK_TITLE = "The model the new session starts on";
|
|
|
38
38
|
// (resolves true once the worker took it); +focusPrompt()+; +toast(text)+;
|
|
39
39
|
// +listModels()+ GET /api/models (data.js). +win+: the page's unload events.
|
|
40
40
|
export function createStartPage({
|
|
41
|
-
pickEl, panelEl, searchEl, listEl, composerEl, centerEl, settingsEl, llmContextEl, thinkingEl,
|
|
41
|
+
pickEl, panelEl, searchEl, listEl, composerEl, centerEl, settingsEl, llmContextEl, thinkingEl,
|
|
42
42
|
toolkitBtnEl = null, toolkitEl = null,
|
|
43
43
|
selected, state, running, sessions, run, focusPrompt, toast, listModels,
|
|
44
44
|
doc = globalThis.document, win = globalThis.window,
|
|
@@ -46,8 +46,6 @@ export function createStartPage({
|
|
|
46
46
|
// The new session's own choices (null: follow the picked model's).
|
|
47
47
|
let newChatLlmContext = null;
|
|
48
48
|
let newChatThinking = null;
|
|
49
|
-
// The files that make the new session a review session ([]: an ordinary one).
|
|
50
|
-
let newChatReview = [];
|
|
51
49
|
// The kit the new session starts on (null: Auto, nothing sent), and the
|
|
52
50
|
// models payload's toolkits (null: no 🧰).
|
|
53
51
|
let newChatToolkit = null;
|
|
@@ -72,7 +70,7 @@ export function createStartPage({
|
|
|
72
70
|
const settings = createStartSettings({
|
|
73
71
|
el: settingsEl,
|
|
74
72
|
button: settingsEl,
|
|
75
|
-
openers: [settingsEl, thinkingEl, llmContextEl
|
|
73
|
+
openers: [settingsEl, thinkingEl, llmContextEl].map((e) => `#${e.id}`).join(", "),
|
|
76
74
|
thinking: {
|
|
77
75
|
summary: newChatThinkingSummary,
|
|
78
76
|
choice: () => newChatThinking,
|
|
@@ -83,16 +81,11 @@ export function createStartPage({
|
|
|
83
81
|
choice: () => newChatLlmContext,
|
|
84
82
|
choose: (next) => { newChatLlmContext = next; renderOverrides(); },
|
|
85
83
|
},
|
|
86
|
-
review: reviewEl ? {
|
|
87
|
-
choice: () => newChatReview,
|
|
88
|
-
choose: (next) => { newChatReview = next; renderOverrides(); },
|
|
89
|
-
} : null,
|
|
90
84
|
doc,
|
|
91
85
|
win,
|
|
92
86
|
});
|
|
93
|
-
thinkingEl.addEventListener("click", () => settings.toggle(
|
|
94
|
-
llmContextEl.addEventListener("click", () => settings.toggle(
|
|
95
|
-
reviewEl?.addEventListener("click", () => settings.toggle("review", reviewEl));
|
|
87
|
+
thinkingEl.addEventListener("click", () => settings.toggle(thinkingEl));
|
|
88
|
+
llmContextEl.addEventListener("click", () => settings.toggle(llmContextEl));
|
|
96
89
|
const toolkitList = toolkitBtnEl ? createStartToolkit({
|
|
97
90
|
el: toolkitBtnEl,
|
|
98
91
|
button: toolkitBtnEl,
|
|
@@ -100,18 +93,16 @@ export function createStartPage({
|
|
|
100
93
|
toolkits: () => toolkits,
|
|
101
94
|
choice: () => newChatToolkit,
|
|
102
95
|
choose: (next) => { newChatToolkit = next; renderOverrides(); },
|
|
103
|
-
review: () => newChatReview.length > 0,
|
|
104
96
|
doc,
|
|
105
97
|
win,
|
|
106
98
|
}) : null;
|
|
107
99
|
toolkitEl?.addEventListener("click", () => toolkitList?.toggle(toolkitEl));
|
|
108
100
|
// The override chips (only what is set) and ⚙: its dot and label say
|
|
109
|
-
// what is set; hidden with nothing to show (no model values
|
|
101
|
+
// what is set; hidden with nothing to show (no model values).
|
|
110
102
|
function renderOverrides() {
|
|
111
103
|
const thinkingSummary = newChatThinkingSummary();
|
|
112
104
|
const llmContextSummary = newChatLlmSummary();
|
|
113
|
-
const over = overrides({ thinking: newChatThinking, llmContext: newChatLlmContext,
|
|
114
|
-
thinkingSummary, llmContextSummary });
|
|
105
|
+
const over = overrides({ thinking: newChatThinking, llmContext: newChatLlmContext, thinkingSummary, llmContextSummary });
|
|
115
106
|
const paint = (chipEl, chip) => {
|
|
116
107
|
if (!chipEl) return;
|
|
117
108
|
chipEl.hidden = !chip;
|
|
@@ -120,9 +111,8 @@ export function createStartPage({
|
|
|
120
111
|
};
|
|
121
112
|
paint(thinkingEl, over.thinking);
|
|
122
113
|
paint(llmContextEl, over.llmContext);
|
|
123
|
-
paint(reviewEl, over.review);
|
|
124
114
|
const label = settingsLabel(over);
|
|
125
|
-
settingsEl.hidden = !(thinkingSummary || llmContextSummary ||
|
|
115
|
+
settingsEl.hidden = !(thinkingSummary || llmContextSummary || label.set);
|
|
126
116
|
settingsEl.classList.toggle("set", label.set);
|
|
127
117
|
settingsEl.title = label.label;
|
|
128
118
|
settingsEl.setAttribute("aria-label", label.label);
|
|
@@ -239,7 +229,7 @@ export function createStartPage({
|
|
|
239
229
|
} catch (e) {
|
|
240
230
|
const text = modelsFailedText(e, { startPage: !selected(), asked, leaving: pageLeaving });
|
|
241
231
|
if (text) toast(text);
|
|
242
|
-
// ⚙ without the model's rows
|
|
232
|
+
// ⚙ without the model's rows, no 🧰.
|
|
243
233
|
toolkits = null;
|
|
244
234
|
renderOverrides();
|
|
245
235
|
return;
|
|
@@ -261,14 +251,12 @@ export function createStartPage({
|
|
|
261
251
|
// The create request's own choices (the ⚙ panel's).
|
|
262
252
|
function newChoices() {
|
|
263
253
|
return { llm_context: choiceWords(newChatLlmContext), thinking: newChatThinking || undefined,
|
|
264
|
-
review: newChatReview.length ? { subjects: newChatReview } : undefined,
|
|
265
254
|
toolkit: newChatToolkit || undefined };
|
|
266
255
|
}
|
|
267
256
|
// The choices were for that new session only: a create took them.
|
|
268
257
|
function clearChoices() {
|
|
269
258
|
newChatLlmContext = null;
|
|
270
259
|
newChatThinking = null;
|
|
271
|
-
newChatReview = [];
|
|
272
260
|
newChatToolkit = null;
|
|
273
261
|
renderOverrides();
|
|
274
262
|
}
|
|
@@ -283,15 +271,6 @@ export function createStartPage({
|
|
|
283
271
|
syncModelPick, commandRan, restoreStartPick, loadModels, chosenModel, newChoices, clearChoices, dropChoices,
|
|
284
272
|
// A fresh link's /model still in flight (a send waits for it), or null.
|
|
285
273
|
pendingPick: () => pendingPick,
|
|
286
|
-
// The start page's review files ([]: the new session isn't a review).
|
|
287
|
-
reviewSubjects: () => newChatReview,
|
|
288
|
-
// Start refused them (400 invalid_review): said in the ⚙ panel's review
|
|
289
|
-
// view, opened again. @return whether it was said there
|
|
290
|
-
reviewRefused: (message) => {
|
|
291
|
-
if (!reviewEl || !newChatReview.length) return false;
|
|
292
|
-
settings.refuse(message);
|
|
293
|
-
return true;
|
|
294
|
-
},
|
|
295
274
|
// Start refused the picked kit (400 toolkit_refused): said in the 🧰
|
|
296
275
|
// list, opened again. Without a pick it is config.yml's default that
|
|
297
276
|
// is broken: @return false (the caller's alert).
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// The start page's ⚙ panel: the new session's rarely used settings in one
|
|
2
|
-
// place (thinking, LLM context
|
|
2
|
+
// place (thinking, LLM context), each a choice for the next
|
|
3
3
|
// create only (start_page.js keeps them; never remembered). A pick applies
|
|
4
4
|
// at once and the panel stays open; a typed budget has its own Set. Rows
|
|
5
5
|
// the picked model has no values for are hidden, but a choice already made
|
|
6
|
-
// is still sent: the panel says so and offers to clear it.
|
|
7
|
-
// are a view of their own (‹ back to the settings).
|
|
6
|
+
// is still sent: the panel says so and offers to clear it.
|
|
8
7
|
//
|
|
9
8
|
// Beside ⚙ on the row, override chips name what is set (overrides(): "think
|
|
10
|
-
// high", "ctx stale"
|
|
9
|
+
// high", "ctx stale"); on a phone ⚙ carries a dot
|
|
11
10
|
// instead (settingsLabel()).
|
|
12
11
|
|
|
13
12
|
import { createChipPopover, SHEET_TALL } from "./chip_popover.js";
|
|
14
13
|
import { mergeChoice, ownValues } from "./llm_context_chip.js";
|
|
15
|
-
import { readSubjects, reviewChipModel, reviewFormTemplate } from "./review_start.js";
|
|
16
14
|
import {
|
|
17
15
|
contextSegments, contextWords, DEFAULT, settingsPanelTemplate, thinkingSegments,
|
|
18
16
|
} from "./settings_panel.js";
|
|
@@ -29,7 +27,7 @@ const NO_LLM_CONTEXT = "the picked model has no LLM context values; it is sent a
|
|
|
29
27
|
// The row's override chips: what is set for the new session, each
|
|
30
28
|
// {text, title} or null. A choice the picked model shows no row for (its
|
|
31
29
|
// summary is null) stays, its title saying it is sent anyway.
|
|
32
|
-
export function overrides({ thinking = null, llmContext = null,
|
|
30
|
+
export function overrides({ thinking = null, llmContext = null, thinkingSummary = null,
|
|
33
31
|
llmContextSummary = null } = {}) {
|
|
34
32
|
const ctx = contextWords(llmContext);
|
|
35
33
|
return {
|
|
@@ -45,22 +43,20 @@ export function overrides({ thinking = null, llmContext = null, review = [], thi
|
|
|
45
43
|
? `LLM context: ${ctx} for the new session (the model's: ${llmContextSummary.strategy}). Click to change it.`
|
|
46
44
|
: `LLM context: ${ctx} for the new session: ${NO_LLM_CONTEXT}. Click to change it.`,
|
|
47
45
|
} : null,
|
|
48
|
-
review: review?.length ? reviewChipModel(review) : null,
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// ⚙'s state: whether anything is set (its dot on a phone) and its tooltip
|
|
53
50
|
// and accessible name, which list what is.
|
|
54
51
|
export function settingsLabel(over) {
|
|
55
|
-
const set = [over.thinking, over.llmContext
|
|
52
|
+
const set = [over.thinking, over.llmContext].filter(Boolean);
|
|
56
53
|
return { set: set.length > 0, label: set.length ? `${PANEL_LABEL}: ${set.map((o) => o.text).join(", ")}` : PANEL_LABEL };
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
// The main view (settings_panel.js settingsPanelTemplate over the new
|
|
60
57
|
// session's choices). +state+: {thinking: {summary, choice}, llmContext:
|
|
61
|
-
// {summary, choice},
|
|
62
|
-
|
|
63
|
-
export function panelTemplate({ thinking, llmContext, review = null, more = false, error = null }) {
|
|
58
|
+
// {summary, choice}, more: the disclosure open, error: the context Set's}.
|
|
59
|
+
export function panelTemplate({ thinking, llmContext, more = false, error = null }) {
|
|
64
60
|
const think = thinkingSegments(thinking.summary, thinking.choice);
|
|
65
61
|
const ctx = contextSegments(llmContext.summary, llmContext.choice);
|
|
66
62
|
const ctxAnyway = !ctx && contextWords(llmContext.choice);
|
|
@@ -73,7 +69,6 @@ export function panelTemplate({ thinking, llmContext, review = null, more = fals
|
|
|
73
69
|
more: { open: more, summary: llmContext.summary, choice: llmContext.choice, error } } : null,
|
|
74
70
|
ctxAnyway ? { anyway: `Context ${ctxAnyway}: ${NO_LLM_CONTEXT}.`, act: "ctx-clear" } : null,
|
|
75
71
|
],
|
|
76
|
-
review,
|
|
77
72
|
note: NOTE,
|
|
78
73
|
});
|
|
79
74
|
}
|
|
@@ -83,49 +78,32 @@ export function panelTemplate({ thinking, llmContext, review = null, more = fals
|
|
|
83
78
|
// and focus goes back to it whichever opener was clicked); +openers+: the
|
|
84
79
|
// selector of every element that opens it (⚙ and the override chips: a click
|
|
85
80
|
// there is not a click outside). +thinking+ / +llmContext+: {summary(),
|
|
86
|
-
// choice(), choose(next)}
|
|
87
|
-
// (
|
|
88
|
-
|
|
89
|
-
export function createStartSettings({ el, button, openers = `#${button.id}`, thinking, llmContext, review = null,
|
|
81
|
+
// choice(), choose(next)}.
|
|
82
|
+
// @return {open(), toggle(), close, refresh, isOpen}
|
|
83
|
+
export function createStartSettings({ el, button, openers = `#${button.id}`, thinking, llmContext,
|
|
90
84
|
doc = document, win = window }) {
|
|
91
|
-
//
|
|
92
|
-
// form's error and text as typed.
|
|
93
|
-
let view = "main";
|
|
85
|
+
// The disclosure; the context Set's error.
|
|
94
86
|
let more = false;
|
|
95
87
|
let error = null;
|
|
96
|
-
let reviewError = null;
|
|
97
|
-
let reviewText = null;
|
|
98
88
|
|
|
99
89
|
function draw() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
llmContext: { summary: llmContext.summary(), choice: llmContext.choice() },
|
|
106
|
-
review: review ? review.choice() : null, more, error,
|
|
107
|
-
}), shell.pop);
|
|
108
|
-
}
|
|
90
|
+
render(panelTemplate({
|
|
91
|
+
thinking: { summary: thinking.summary(), choice: thinking.choice() },
|
|
92
|
+
llmContext: { summary: llmContext.summary(), choice: llmContext.choice() },
|
|
93
|
+
more, error,
|
|
94
|
+
}), shell.pop);
|
|
109
95
|
shell.replace();
|
|
110
96
|
}
|
|
111
97
|
|
|
112
98
|
// Focus inside on open (the popover sits at the end of <body>, so Tab
|
|
113
99
|
// from ⚙ wouldn't reach it): the pressed segment of the first row, else
|
|
114
|
-
// the first button
|
|
100
|
+
// the first button.
|
|
115
101
|
function focusInside() {
|
|
116
102
|
const pop = shell.pop;
|
|
117
|
-
const at =
|
|
118
|
-
: pop.querySelector(".sset-seg [aria-pressed=true]") || pop.querySelector(".sset-link, .sset-seg button");
|
|
103
|
+
const at = pop.querySelector(".sset-seg [aria-pressed=true]") || pop.querySelector(".sset-link, .sset-seg button");
|
|
119
104
|
at?.focus();
|
|
120
105
|
}
|
|
121
106
|
|
|
122
|
-
function switchTo(next) {
|
|
123
|
-
view = next;
|
|
124
|
-
draw();
|
|
125
|
-
if (next === "review") focusInside();
|
|
126
|
-
else shell.pop.querySelector("[data-act=review]")?.focus();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
107
|
function pickContext(changes) {
|
|
130
108
|
const initial = ownValues({ own: llmContext.choice() });
|
|
131
109
|
let next;
|
|
@@ -155,17 +133,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
155
133
|
else if (what === "ctx") return pickContext({ strategy: value });
|
|
156
134
|
else if (what === "ctx-clear") llmContext.choose(null);
|
|
157
135
|
else if (what === "ctx-more") more = !more;
|
|
158
|
-
else
|
|
159
|
-
else if (what === "back") {
|
|
160
|
-
reviewError = null;
|
|
161
|
-
reviewText = null;
|
|
162
|
-
return switchTo("main");
|
|
163
|
-
} else if (what === "review-clear" || what === "clear") {
|
|
164
|
-
review.choose([]);
|
|
165
|
-
reviewError = null;
|
|
166
|
-
reviewText = null;
|
|
167
|
-
if (view === "review") return switchTo("main");
|
|
168
|
-
} else return;
|
|
136
|
+
else return;
|
|
169
137
|
draw();
|
|
170
138
|
}
|
|
171
139
|
|
|
@@ -173,23 +141,12 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
173
141
|
if (form.classList.contains("sset-ctx-form")) {
|
|
174
142
|
return pickContext({ apply: form.elements.apply.value, budget: form.elements.budget.value });
|
|
175
143
|
}
|
|
176
|
-
const typed = form.elements.subjects?.value || "";
|
|
177
|
-
const read = readSubjects(typed);
|
|
178
|
-
if (read.error) {
|
|
179
|
-
reviewError = read.error;
|
|
180
|
-
reviewText = typed;
|
|
181
|
-
return draw();
|
|
182
|
-
}
|
|
183
|
-
review.choose(read.subjects);
|
|
184
|
-
reviewError = null;
|
|
185
|
-
reviewText = null;
|
|
186
|
-
switchTo("main");
|
|
187
144
|
}
|
|
188
145
|
|
|
189
146
|
const shell = createChipPopover({
|
|
190
147
|
id: "startSettingsPopover", className: "ctx-popover start-settings", width: 440, el, anchor: `#${button.id}`, openers,
|
|
191
|
-
// Taller than a plain sheet: the Apply and budget fields
|
|
192
|
-
//
|
|
148
|
+
// Taller than a plain sheet: the Apply and budget fields would push the
|
|
149
|
+
// note under the edge of a 60 % one.
|
|
193
150
|
summary: () => ({}), sheet: true, sheetShare: SHEET_TALL, label: PANEL_LABEL, doc, win,
|
|
194
151
|
show: (_data, opening) => {
|
|
195
152
|
if (opening) {
|
|
@@ -200,10 +157,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
200
157
|
},
|
|
201
158
|
onOpen: focusInside,
|
|
202
159
|
onClose: () => {
|
|
203
|
-
view = "main";
|
|
204
160
|
error = null;
|
|
205
|
-
reviewError = null;
|
|
206
|
-
reviewText = null;
|
|
207
161
|
},
|
|
208
162
|
onSubmit: submit,
|
|
209
163
|
onAct: act,
|
|
@@ -217,8 +171,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
217
171
|
});
|
|
218
172
|
|
|
219
173
|
// +from+: the opener clicked (focus goes back to it), ⚙ by default.
|
|
220
|
-
function open(
|
|
221
|
-
view = review ? at : "main";
|
|
174
|
+
function open(from = button) {
|
|
222
175
|
if (shell.isOpen()) {
|
|
223
176
|
draw();
|
|
224
177
|
focusInside();
|
|
@@ -229,18 +182,11 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
229
182
|
|
|
230
183
|
return {
|
|
231
184
|
open,
|
|
232
|
-
// An override chip's click: opens the panel
|
|
233
|
-
toggle: (
|
|
185
|
+
// An override chip's click: opens the panel, or closes it.
|
|
186
|
+
toggle: (from = button) => (shell.isOpen() ? shell.close() : open(from)),
|
|
234
187
|
close: () => shell.close(),
|
|
235
188
|
isOpen: () => shell.isOpen(),
|
|
236
189
|
// The picked model changed (its default labels, which rows show).
|
|
237
190
|
refresh: () => { if (shell.isOpen()) draw(); },
|
|
238
|
-
// Start refused the review files (400 invalid_review): said in the
|
|
239
|
-
// review view, opened at the files chosen.
|
|
240
|
-
refuse: (message) => {
|
|
241
|
-
reviewError = message;
|
|
242
|
-
reviewText = null;
|
|
243
|
-
open("review");
|
|
244
|
-
},
|
|
245
191
|
};
|
|
246
192
|
}
|
|
@@ -68,9 +68,8 @@ export function toolkitLabel(choice) {
|
|
|
68
68
|
return { set: !!choice, label: choice ? `${LIST_LABEL}: ${choice}` : LIST_LABEL };
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// +state+: {toolkits, choice,
|
|
72
|
-
|
|
73
|
-
export function listTemplate({ toolkits, choice, review = false, error = null }) {
|
|
71
|
+
// +state+: {toolkits, choice, error: Start's refusal}.
|
|
72
|
+
export function listTemplate({ toolkits, choice, error = null }) {
|
|
74
73
|
const rows = toolkitRows(toolkits, choice);
|
|
75
74
|
return html`<div class="ctx-pop-head"><strong>Toolkit · new session</strong
|
|
76
75
|
><button type="button" class="ctx-pop-close" data-act="close" aria-label="Close">×</button></div
|
|
@@ -78,9 +77,7 @@ export function listTemplate({ toolkits, choice, review = false, error = null })
|
|
|
78
77
|
data-act=${`kit:${r.value}`} aria-pressed=${r.pressed ? "true" : "false"} title=${r.title || nothing}
|
|
79
78
|
><span class="st-check" aria-hidden="true">${r.pressed ? "✓" : ""}</span><span class="st-name">${r.label}</span
|
|
80
79
|
><span class="st-detail">${r.detail}</span></button>`)}</div
|
|
81
|
-
|
|
82
|
-
toolkits.default} unless you pick a kit.</div>` : nothing
|
|
83
|
-
}<div class="ctx-pop-error" role="alert" ?hidden=${!error}>${error || ""}</div
|
|
80
|
+
><div class="ctx-pop-error" role="alert" ?hidden=${!error}>${error || ""}</div
|
|
84
81
|
><div class="ctx-pop-meta">${NOTE}</div>`;
|
|
85
82
|
}
|
|
86
83
|
|
|
@@ -88,16 +85,15 @@ export function listTemplate({ toolkits, choice, review = false, error = null })
|
|
|
88
85
|
// where 🧰 is; +button+: 🧰 (the list opens at it; focus goes back to it);
|
|
89
86
|
// +openers+: the selector of every element that opens it (🧰 and the
|
|
90
87
|
// override chip). Hooks: +toolkits()+ the payload's toolkits (null: nothing
|
|
91
|
-
// opens), +choice()+, +choose(next)
|
|
92
|
-
// set.
|
|
88
|
+
// opens), +choice()+, +choose(next)+.
|
|
93
89
|
// @return {open, toggle, close, refresh, refuse(message), isOpen}
|
|
94
90
|
export function createStartToolkit({ el, button, openers = `#${button.id}`, toolkits, choice, choose,
|
|
95
|
-
|
|
91
|
+
doc = document, win = window }) {
|
|
96
92
|
// Start's refusal of the picked kit (400 toolkit_refused), until a pick.
|
|
97
93
|
let error = null;
|
|
98
94
|
|
|
99
95
|
function draw() {
|
|
100
|
-
render(listTemplate({ toolkits: toolkits(), choice: choice(),
|
|
96
|
+
render(listTemplate({ toolkits: toolkits(), choice: choice(), error }), shell.pop);
|
|
101
97
|
shell.replace();
|
|
102
98
|
}
|
|
103
99
|
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
} from "./turn_events.js";
|
|
59
59
|
import { commandView, drawCommandBubble, historyHasCommandBubble } from "./commands.js";
|
|
60
60
|
import { keepEarlyRestore, restoreAction } from "./restore.js";
|
|
61
|
-
import {
|
|
61
|
+
import { setBadgeMode } from "./participant_names.js";
|
|
62
62
|
import { isParticipantAuthor } from "./participant_model.js";
|
|
63
63
|
import { stillOn } from "./latest.js";
|
|
64
64
|
|
|
@@ -165,12 +165,8 @@ export function createStreamHandlers(deps) {
|
|
|
165
165
|
if (when && promptBubble?.setAttribute && !promptBubble.title) promptBubble.title = when;
|
|
166
166
|
liveTurn.cutAfter = data.cut_after ?? null;
|
|
167
167
|
liveTurn.serverGen = null;
|
|
168
|
-
// A participant's review turn: its id and author, for Apply at its end
|
|
169
|
-
// (turn_completed names neither). A pair turn acted itself: no Apply.
|
|
170
168
|
const author = data.author || data.origin?.author;
|
|
171
169
|
const participant = isParticipantAuthor(author);
|
|
172
|
-
const pair = data.participant_mode === PAIR;
|
|
173
|
-
liveTurn.review = participant && data.turn_id && !pair ? { turn_id: data.turn_id, author, author_name: data.author_name } : null;
|
|
174
170
|
// Its prompt drawn while queued takes the turn's mode now.
|
|
175
171
|
if (data.participant_mode) setBadgeMode(promptBubble, data.participant_mode);
|
|
176
172
|
// The owner's input queues behind it (the composer's delivery line).
|
|
@@ -220,10 +216,6 @@ export function createStreamHandlers(deps) {
|
|
|
220
216
|
// the hand-off never moves it before its links swap in.
|
|
221
217
|
if (display) await display.promise;
|
|
222
218
|
turnDom.answerReady();
|
|
223
|
-
// A participant's review turn: Apply under its reply, as a reload shows it.
|
|
224
|
-
const review = liveTurn.review;
|
|
225
|
-
liveTurn.review = null;
|
|
226
|
-
if (review && !data.turn_summary?.empty_answer) deps.placeApply?.(review);
|
|
227
219
|
},
|
|
228
220
|
// An after_turn hook presented the answer (AnswerDisplay) or attached
|
|
229
221
|
// refs to it (AnswerRefs: refs, a count; display null when only refs):
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
// removed at the end: the answer bubble takes its place. A lone step that
|
|
23
23
|
// closed with text keeps its chrome: a line steered in after it left it alone
|
|
24
24
|
// in the block when the answer went, and its summary is the way to its text.
|
|
25
|
-
import { authorBadge,
|
|
25
|
+
import { authorBadge, READ_ONLY } from "./participant_names.js";
|
|
26
26
|
import { isParticipantAuthor } from "./participant_model.js";
|
|
27
|
-
import { applyRowTemplate } from "./review_apply.js";
|
|
28
27
|
import { html, nothing, render } from "./vendor/lit-html.js";
|
|
29
28
|
import { answerRefsOf, setAnswerRefs } from "./answer_refs.js";
|
|
30
29
|
import { bindRowRefs } from "./refs.js";
|
|
@@ -978,9 +977,8 @@ function pairStepTexts(els, group, items) {
|
|
|
978
977
|
// turn's footprint on its summary line.
|
|
979
978
|
// +cards+ the snapshot's cards (a drawn card's body), +capabilities+ the
|
|
980
979
|
// page's (a notice shown elsewhere).
|
|
981
|
-
// +apply+: false for a viewer without the owner's Apply (viewer.js): no Apply row.
|
|
982
980
|
export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, now = Date.now(), drawings = null, cards = null, capabilities = {},
|
|
983
|
-
runningTurnId = null
|
|
981
|
+
runningTurnId = null }) {
|
|
984
982
|
const timingTemplate = (group) => {
|
|
985
983
|
const record = group.record;
|
|
986
984
|
// Numbered by its place in the turn records, as live (a failed turn
|
|
@@ -1001,7 +999,7 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1001
999
|
const userTemplate = (m, opts = {}) => {
|
|
1002
1000
|
const shell = shellCommandMessage(m?.content);
|
|
1003
1001
|
if (shell) return commandBubbleTemplate({ ...shell, at: m?.at });
|
|
1004
|
-
return userBubbleTemplate(m, { label: sourceLabel(m?.source), thumbs: thumbs(m.images), author: authorBadge(m?.author, m?.author_name, m?.participant_mode), ...opts });
|
|
1002
|
+
return userBubbleTemplate(m, { label: sourceLabel(m?.source), thumbs: thumbs(m.images), author: authorBadge(m?.author, m?.author_name, m?.participant_mode || READ_ONLY), ...opts });
|
|
1005
1003
|
};
|
|
1006
1004
|
// The first text after a delegate report merged mid-turn, unless it is
|
|
1007
1005
|
// the turn's answer (shown anyway). Its key (answer_fold.js): the turn's
|
|
@@ -1027,7 +1025,6 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1027
1025
|
blockTurns.push(ordinal);
|
|
1028
1026
|
}
|
|
1029
1027
|
const lineKey = (i) => (items[i]?.source === "delegate_report" ? `${group.turnId}:input:${i - (group.user ?? i)}` : null);
|
|
1030
|
-
const reviewer = apply && group.answer !== null && prompt?.turn_id && prompt.participant_mode !== PAIR ? authorBadge(prompt.author, prompt.author_name) : null;
|
|
1031
1028
|
const pieces = turnPieces({
|
|
1032
1029
|
prompt: prompt ? (prompt.role === "note" ? noteBubbleTemplate(prompt) : userTemplate(prompt)) : null,
|
|
1033
1030
|
block: drawn.block,
|
|
@@ -1036,7 +1033,6 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1036
1033
|
: null)),
|
|
1037
1034
|
answer: drawn.answer,
|
|
1038
1035
|
timing: timingTemplate(group),
|
|
1039
|
-
apply: reviewer ? applyRowTemplate(prompt.turn_id, reviewer) : null,
|
|
1040
1036
|
end: drawn.end,
|
|
1041
1037
|
kept: drawn.kept,
|
|
1042
1038
|
});
|
|
@@ -114,14 +114,21 @@ export function isOwn(clientId, myId) {
|
|
|
114
114
|
return clientId != null && (clientId === myId || isViewerClient(clientId));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// As the TUI labels them (Formatting::CLIENT_LABELS);
|
|
118
|
-
// helpers and the TUI's agree per
|
|
119
|
-
// By the whole id or its prefix (up to and
|
|
120
|
-
// chi doesn't know is "automatic", not the user
|
|
117
|
+
// As the TUI labels them (ClientId::ROWS' labels, Formatting::CLIENT_LABELS);
|
|
118
|
+
// this file's label helpers and the TUI's agree per
|
|
119
|
+
// spec/shared/labels_matrix.json. By the whole id or its prefix (up to and
|
|
120
|
+
// with its first ":"); an id chi doesn't know is "automatic", not the user
|
|
121
|
+
// (ClientId.human?). null: labelled as no sender is (no label): a worker's
|
|
122
|
+
// own first prompt (ClientId::FIRST_PROMPT) and a person's card answer
|
|
123
|
+
// (ClientId::CARD_ANSWER).
|
|
121
124
|
const CLIENT_LABELS = Object.freeze({
|
|
122
125
|
"tui:": "tui", "web:": "web", "system:": "reminder", "delegate:": "delegate", "child:": "delegate report",
|
|
123
|
-
"cli:send": "chi send", "cli:answer": "chi answer", plugin: "plugin", "
|
|
126
|
+
"cli:send": "chi send", "cli:answer": "chi answer", plugin: "plugin", "participant:": "invited",
|
|
127
|
+
"spawn:first": null, "card:answer": null,
|
|
128
|
+
// compat shim review_client_id: a participant's id from before participant:.
|
|
129
|
+
"review:": "invited",
|
|
124
130
|
});
|
|
131
|
+
const labelFor = (key) => (Object.hasOwn(CLIENT_LABELS, key) ? CLIENT_LABELS[key] : undefined);
|
|
125
132
|
const AUTOMATIC_LABEL = "automatic";
|
|
126
133
|
|
|
127
134
|
// A delegate child's report comes in as client child:<id8> (ChildReports).
|
|
@@ -156,7 +163,9 @@ export function clientLabel(clientId) {
|
|
|
156
163
|
if (id.startsWith(TASK_CLIENT) && id.length > TASK_CLIENT.length) return `task ${shortTaskId(id.slice(TASK_CLIENT.length))} finished`;
|
|
157
164
|
if (id.startsWith(SCHEDULE_CLIENT)) return "schedule";
|
|
158
165
|
const colon = id.indexOf(":");
|
|
159
|
-
|
|
166
|
+
let label = labelFor(id);
|
|
167
|
+
if (label === undefined && colon >= 0) label = labelFor(id.slice(0, colon + 1));
|
|
168
|
+
return label === undefined ? AUTOMATIC_LABEL : label;
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
// The note for reminders a turn got (a reminder turn has no prompt).
|
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
// The turn's pieces in order: its prompt (none for a reminder turn), its
|
|
9
9
|
// block of steps, the steers no step holds, the lines merged into it in
|
|
10
10
|
// arrival order (live: every extra, cards too), the answer's pieces or the
|
|
11
|
-
// notice of a turn with none, the timing line,
|
|
12
|
-
// the end line (cancel, failure), the kept cards, then the lines queued for
|
|
11
|
+
// notice of a turn with none, the timing line, the end line (cancel, failure), the kept cards, then the lines queued for
|
|
13
12
|
// after the turn (they run next).
|
|
14
13
|
export function turnPieces({ prompt = null, block = null, steers = [], merged = [], answer = [], emptyNote = null, timing = null,
|
|
15
|
-
|
|
16
|
-
return [prompt, block, ...steers, ...merged, ...answer, emptyNote, timing,
|
|
14
|
+
end = null, kept = [], queued = [] } = {}) {
|
|
15
|
+
return [prompt, block, ...steers, ...merged, ...answer, emptyNote, timing, end, ...kept, ...queued].filter(Boolean);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
// The generation whose text is +turn+'s answer when it ended as +kind+
|
|
@@ -33,9 +33,15 @@ export function viewerSelf() {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Whether +clientId+ is the viewer's own (chi web gives a participant's
|
|
36
|
-
// turns
|
|
36
|
+
// turns participant:<grant id>, whichever tab or device sent them).
|
|
37
|
+
const PARTICIPANT_CLIENT = "participant:";
|
|
38
|
+
// compat shim review_client_id: the same id as an older chi gave it.
|
|
39
|
+
const LEGACY_PARTICIPANT_CLIENT = "review:";
|
|
37
40
|
export function isViewerClient(clientId) {
|
|
38
|
-
|
|
41
|
+
if (!self?.clientId) return false;
|
|
42
|
+
if (clientId === self.clientId) return true;
|
|
43
|
+
const own = String(self.clientId);
|
|
44
|
+
return own.startsWith(PARTICIPANT_CLIENT) && clientId === LEGACY_PARTICIPANT_CLIENT + own.slice(PARTICIPANT_CLIENT.length);
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
// Whether +author+ ("p:<id>") is the viewer's.
|
data/lib/samagotchi/web/qr.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Samagotchi
|
|
|
42
42
|
row.each_index.select { |x| row[x] }.map { |x| "M#{x} #{y}h1v1h-1z" }
|
|
43
43
|
end
|
|
44
44
|
%(<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 #{size} #{size}" shape-rendering="crispEdges" role="img" ) +
|
|
45
|
-
%(aria-label="QR code of the
|
|
45
|
+
%(aria-label="QR code of the invite link"><rect width="#{size}" height="#{size}" fill="#fff"/>) +
|
|
46
46
|
%(<path d="#{dark.join}" fill="#000"/></svg>)
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -393,7 +393,9 @@ module Samagotchi
|
|
|
393
393
|
unless (who = principal(req)).owner?
|
|
394
394
|
return not_permitted_for(req, who) unless own_turn?(who.grant, id, enqueued_id)
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
# Only echoed in the worker's turn_dequeued (no shim: an older
|
|
397
|
+
# worker's echo of it is a cosmetic mismatch).
|
|
398
|
+
client_id = ClientId.participant(who.grant.id)
|
|
397
399
|
end
|
|
398
400
|
|
|
399
401
|
request = ->(client) { client.dequeue(enqueued_id: enqueued_id, client_id: client_id) }
|