samagotchi 0.169.0 → 0.171.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 +44 -1
- data/docs/architecture.md +2 -2
- data/docs/cli.md +37 -23
- data/docs/configuration.md +1 -1
- data/docs/internals/block-renderers.md +2 -2
- data/docs/internals/bridge.md +9 -5
- data/docs/internals/context-telemetry.md +13 -1
- data/docs/internals/engine.md +4 -4
- data/docs/internals/inline-widgets.md +1 -1
- data/docs/internals/objectives.md +1 -1
- data/docs/internals/participants.md +235 -119
- data/docs/internals/web-frontend.md +173 -39
- data/docs/internals/working-set.md +71 -6
- data/docs/releasing.md +5 -2
- data/docs/sessions.md +6 -3
- data/docs/testing.md +10 -5
- data/lib/samagotchi/bridge/turn_accumulator.rb +8 -4
- data/lib/samagotchi/bridge.rb +53 -13
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/delivery.rb +13 -0
- data/lib/samagotchi/engine/events.rb +9 -0
- data/lib/samagotchi/engine.rb +6 -2
- data/lib/samagotchi/event_fanout.rb +25 -7
- data/lib/samagotchi/grants.rb +5 -0
- data/lib/samagotchi/guardrails/review_paths.rb +2 -2
- data/lib/samagotchi/image_store.rb +51 -12
- data/lib/samagotchi/kernel_loop.rb +7 -1
- data/lib/samagotchi/llm/stray_tool_call.rb +7 -4
- data/lib/samagotchi/llm_context_stale.rb +4 -1
- data/lib/samagotchi/participant_messages.rb +39 -0
- data/lib/samagotchi/participant_revise.rb +61 -0
- data/lib/samagotchi/participant_uploads.rb +98 -0
- data/lib/samagotchi/reply_wait/poll.rb +5 -1
- data/lib/samagotchi/revise_anchor.rb +9 -0
- data/lib/samagotchi/send_command.rb +5 -0
- data/lib/samagotchi/session_inbox.rb +20 -12
- data/lib/samagotchi/session_manager/delivery.rb +7 -0
- data/lib/samagotchi/session_stores.rb +2 -0
- data/lib/samagotchi/tool_runner.rb +39 -5
- data/lib/samagotchi/tools/memory.rb +26 -7
- data/lib/samagotchi/turn_anchors.rb +0 -3
- data/lib/samagotchi/turn_stages/verify_anchors.rb +13 -1
- data/lib/samagotchi/verify_anchor.rb +6 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +42 -62
- data/lib/samagotchi/web/participant_access.rb +129 -26
- data/lib/samagotchi/web/participant_images.rb +185 -0
- data/lib/samagotchi/web/participant_review.rb +19 -138
- data/lib/samagotchi/web/participant_show.rb +240 -0
- data/lib/samagotchi/web/participant_stream_filter.rb +25 -2
- data/lib/samagotchi/web/participant_view.rb +331 -24
- data/lib/samagotchi/web/public/annotate_bar.css +1 -2
- data/lib/samagotchi/web/public/annotate_bar.js +1 -2
- data/lib/samagotchi/web/public/app.js +125 -88
- data/lib/samagotchi/web/public/block_host.js +7 -4
- data/lib/samagotchi/web/public/bubbles.js +9 -1
- data/lib/samagotchi/web/public/cards_offscreen.js +69 -0
- data/lib/samagotchi/web/public/chip_popover.js +5 -4
- data/lib/samagotchi/web/public/claim_link.js +4 -4
- data/lib/samagotchi/web/public/composer.css +4 -6
- data/lib/samagotchi/web/public/composer_mode.js +11 -6
- data/lib/samagotchi/web/public/composer_mount.js +4 -4
- data/lib/samagotchi/web/public/ctx.js +12 -3
- data/lib/samagotchi/web/public/delivery_line.js +34 -5
- data/lib/samagotchi/web/public/history_shape.js +5 -1
- data/lib/samagotchi/web/public/images.js +7 -1
- data/lib/samagotchi/web/public/index.html +49 -4
- data/lib/samagotchi/web/public/info_bar_model.js +2 -1
- data/lib/samagotchi/web/public/live_timing.js +5 -3
- data/lib/samagotchi/web/public/markdown_place.js +5 -4
- data/lib/samagotchi/web/public/owner_claim.js +3 -3
- data/lib/samagotchi/web/public/owner_verify.js +0 -2
- data/lib/samagotchi/web/public/participant_bar.js +108 -0
- data/lib/samagotchi/web/public/participant_main.js +289 -0
- data/lib/samagotchi/web/public/participant_model.js +5 -292
- data/lib/samagotchi/web/public/participant_names.js +6 -1
- data/lib/samagotchi/web/public/participant_revise.js +66 -0
- data/lib/samagotchi/web/public/participants_panel.js +3 -12
- data/lib/samagotchi/web/public/question_cards.js +24 -4
- data/lib/samagotchi/web/public/refs.js +53 -36
- data/lib/samagotchi/web/public/reload_check.js +68 -11
- data/lib/samagotchi/web/public/revise_stack.js +21 -10
- data/lib/samagotchi/web/public/send_turn.js +24 -6
- data/lib/samagotchi/web/public/session_fields.js +1 -1
- data/lib/samagotchi/web/public/session_state.js +12 -4
- data/lib/samagotchi/web/public/session_sync.js +9 -2
- data/lib/samagotchi/web/public/session_view.js +17 -7
- data/lib/samagotchi/web/public/stage_asking.js +6 -4
- data/lib/samagotchi/web/public/stage_frame.js +3 -3
- data/lib/samagotchi/web/public/stage_model.js +12 -5
- data/lib/samagotchi/web/public/stage_opened.js +8 -5
- data/lib/samagotchi/web/public/stage_owner_wait.js +35 -0
- data/lib/samagotchi/web/public/stage_view.js +54 -17
- data/lib/samagotchi/web/public/stage_waiting.js +74 -6
- data/lib/samagotchi/web/public/storage.js +22 -0
- data/lib/samagotchi/web/public/stream_handlers.js +2 -1
- data/lib/samagotchi/web/public/tokens.css +1 -1
- data/lib/samagotchi/web/public/turn_block.js +3 -2
- data/lib/samagotchi/web/public/turn_events.js +15 -6
- data/lib/samagotchi/web/public/turn_html.js +9 -2
- data/lib/samagotchi/web/public/turn_range.js +1 -2
- data/lib/samagotchi/web/public/verify_target.js +2 -4
- data/lib/samagotchi/web/public/viewer.js +59 -0
- data/lib/samagotchi/web/public/viewer_self.js +53 -0
- data/lib/samagotchi/web/public/working_set.js +11 -5
- data/lib/samagotchi/web/public/working_set_view.js +53 -8
- data/lib/samagotchi/web/public/ws_cards.js +89 -0
- data/lib/samagotchi/web/public/ws_peek.js +106 -0
- data/lib/samagotchi/web/public/ws_preview.css +126 -0
- data/lib/samagotchi/web/public/ws_reader.js +319 -0
- data/lib/samagotchi/web/public/ws_timeline.js +200 -0
- data/lib/samagotchi/web/public/ws_way_in.js +25 -0
- data/lib/samagotchi/web/session_control.rb +42 -15
- data/lib/samagotchi/web/session_create.rb +1 -1
- data/lib/samagotchi/web/session_hub.rb +16 -0
- data/lib/samagotchi/web/session_show.rb +75 -28
- data/lib/samagotchi/web/viewer.rb +70 -0
- data/lib/samagotchi/web/working_set_routes.rb +132 -0
- data/lib/samagotchi/worker.rb +19 -14
- data/lib/samagotchi/working_set.rb +260 -8
- metadata +20 -6
- data/lib/samagotchi/web/public/participant.html +0 -218
- data/lib/samagotchi/web/public/participant.js +0 -719
- data/lib/samagotchi/web/public/participant_annotate.js +0 -76
- data/lib/samagotchi/web/public/review_history.js +0 -72
- data/lib/samagotchi/web/public/tools_overview.js +0 -42
|
@@ -47,13 +47,14 @@ import { createSessionStore } from "./session_store.js";
|
|
|
47
47
|
import { createFeatureGates } from "./feature_gates.js";
|
|
48
48
|
import { stillOn } from "./latest.js";
|
|
49
49
|
import { normalize, cantText } from "./format.js";
|
|
50
|
-
import { turnHistoryNodes } from "./turn_block.js";
|
|
51
50
|
import { elementOf } from "./turn_html.js";
|
|
52
51
|
import { createBubbles } from "./bubbles.js";
|
|
53
52
|
import { createCardsPlace } from "./cards_place.js";
|
|
54
53
|
import { createStageView } from "./stage_view.js";
|
|
55
54
|
import { createReloadCheck } from "./reload_check.js";
|
|
55
|
+
import { placeCardsOffscreen } from "./cards_offscreen.js";
|
|
56
56
|
import { createWorkingSet } from "./working_set_view.js";
|
|
57
|
+
import { createWorkingSetPreview } from "./ws_reader.js";
|
|
57
58
|
import { createObjectives } from "./objectives_wiring.js";
|
|
58
59
|
import { trackWorkerUnavailable } from "./objectives_track.js";
|
|
59
60
|
import { createGapClock } from "./time_gaps.js";
|
|
@@ -124,7 +125,11 @@ import { createSendTurn } from "./send_turn.js";
|
|
|
124
125
|
import { createSessionSync } from "./session_sync.js";
|
|
125
126
|
import { createSessionView } from "./session_view.js";
|
|
126
127
|
import { createMarkdownTip } from "./markdown_tip.js";
|
|
128
|
+
import { IMAGES_NOT_HERE } from "./images.js";
|
|
127
129
|
import { withoutStaleParams } from "./stale_params.js";
|
|
130
|
+
import { createViewer } from "./viewer.js";
|
|
131
|
+
import { createParticipantMain } from "./participant_main.js";
|
|
132
|
+
import { PARTICIPANT_REVISE_UNAVAILABLE, participantMayRevise, participantReviseUnavailable } from "./participant_revise.js";
|
|
128
133
|
|
|
129
134
|
// A link's #code= (behind an auth proxy): traded for the cookie before
|
|
130
135
|
// anything else runs; the page reloads without it.
|
|
@@ -141,6 +146,8 @@ const authLost = createAuthLost();
|
|
|
141
146
|
onAuthLost(authLost);
|
|
142
147
|
|
|
143
148
|
const $ = (s) => document.querySelector(s);
|
|
149
|
+
// Who looks and what they may do (viewer.js): every owner-only control and call asks it.
|
|
150
|
+
const viewer = createViewer(document.body);
|
|
144
151
|
const topStripEl = $("#topStrip");
|
|
145
152
|
const allListEl = $("#allList");
|
|
146
153
|
const historyEl = $("#history");
|
|
@@ -150,36 +157,38 @@ const composerEl = $("#composer");
|
|
|
150
157
|
// shows it; the tab's base ("Chi · <project>"), set by renderScope.
|
|
151
158
|
const sessionTitleEl = $("#sessionTitle");
|
|
152
159
|
const sessionTitleRowEl = $("#sessionTitleRow");
|
|
153
|
-
const titleRenameBtn = $("#titleRenameBtn");
|
|
160
|
+
const titleRenameBtn = viewer.control($("#titleRenameBtn"), "rename");
|
|
154
161
|
let tabBase = null;
|
|
155
162
|
let tabShown = null;
|
|
156
163
|
const infoTextEl = $("#infoText");
|
|
157
164
|
// The open session's attached context, in its own row of the session bar
|
|
158
165
|
// (updateInfoBar redraws #infoText every tick; the chips keep their popover).
|
|
159
|
-
const contextChips = createContextChips({
|
|
166
|
+
const contextChips = viewer.can("context") ? createContextChips({
|
|
160
167
|
el: $("#contextChips"),
|
|
161
168
|
api: { list: listContext, show: getContext, detach: detachContext },
|
|
162
169
|
toast: (text) => showToast(text),
|
|
163
|
-
});
|
|
170
|
+
}) : null;
|
|
164
171
|
// The open session's ⚙ chip in the info bar, and its panel (thinking,
|
|
165
172
|
// reasoning history, LLM context): a pick runs its command in the session's
|
|
166
173
|
// worker.
|
|
167
|
-
const settingsControl = createSettingsControl({
|
|
174
|
+
const settingsControl = viewer.can("session_controls") ? createSettingsControl({
|
|
168
175
|
el: infoTextEl,
|
|
169
176
|
summaries: () => (store.selected ? { thinking: store.current.thinking, reasoningHistory: store.current.reasoningHistory,
|
|
170
177
|
llmContext: store.current.llmContext } : null),
|
|
171
178
|
session: () => store.selected,
|
|
172
179
|
running: () => liveTurn.running,
|
|
173
180
|
run: (line) => runSessionCommand(line),
|
|
174
|
-
});
|
|
175
|
-
// ⋯ on the info bar, and its menu: the chips and buttons the row has no room for.
|
|
176
|
-
const
|
|
181
|
+
}) : null;
|
|
182
|
+
// ⋯ on the info bar, and its menu: the chips and buttons the row has no room for; and the bar's other buttons.
|
|
183
|
+
const [continueBtn, archiveBtn, stopBtn, deleteBtn, moreBtn] = viewer.controls(
|
|
184
|
+
["#infoContinueBtn", "#infoArchiveBtn", "#infoStopBtn", "#infoDeleteBtn", "#infoMoreBtn"].map($), "session_controls");
|
|
185
|
+
const moreSheet = moreBtn ? createMoreSheet({ el: $("#infoBar"), button: moreBtn, session: () => store.selected, hash: sessionHash }) : null;
|
|
177
186
|
// The bar's fold (bar_fold.js): one row, what doesn't fit folded into ⋯. A
|
|
178
187
|
// resize, the fonts or a zoom refolds it by itself: ⋯ follows on the redraw.
|
|
179
188
|
const barFold = createBarFold({ barEl: $("#infoBar"), keysFor: barItemKeys, onChange: () => store.touch("infoBar") });
|
|
180
189
|
// The open session's participants chip in the info bar, and its panel
|
|
181
190
|
// (Invite, revoke, caps, the participant view).
|
|
182
|
-
const participantsControl = createParticipantsControl({
|
|
191
|
+
const participantsControl = viewer.can("participants_admin") ? createParticipantsControl({
|
|
183
192
|
el: infoTextEl,
|
|
184
193
|
session: () => store.selected,
|
|
185
194
|
api: { list: listParticipants, invite: inviteParticipant, revoke: revokeParticipant, cap: setParticipantCap },
|
|
@@ -195,7 +204,7 @@ const participantsControl = createParticipantsControl({
|
|
|
195
204
|
},
|
|
196
205
|
onChange: () => store.touch("infoBar"),
|
|
197
206
|
toast: (text, action, options) => showToast(text, action, options),
|
|
198
|
-
});
|
|
207
|
+
}) : null;
|
|
199
208
|
// The start page's model picker, its ⚙ panel and 🧰 list with the override chips
|
|
200
209
|
// (start_page.js); a fresh chain link's picker too.
|
|
201
210
|
const startPage = createStartPage({
|
|
@@ -226,15 +235,14 @@ const markdownTip = createMarkdownTip($("#markdownTip"));
|
|
|
226
235
|
// What the page renders that a notice may stand in for (the server's
|
|
227
236
|
// Web::Capabilities, next to markdown_warning); a notice it names isn't
|
|
228
237
|
// drawn (shownElsewhere). An older server sends none: every notice shows.
|
|
229
|
-
// And
|
|
230
|
-
// editor
|
|
231
|
-
// to it: refs.js's actions read both (
|
|
238
|
+
// And whether this request's viewer can open a path in this machine's
|
|
239
|
+
// editor (per request), with the editor's URL template (editor_url) next
|
|
240
|
+
// to it: refs.js's actions read both (refEditor).
|
|
232
241
|
let pageCapabilities = {};
|
|
233
242
|
let pageEditorUrl = null;
|
|
234
243
|
const promptEl = $("#prompt");
|
|
235
244
|
const actionBtn = $("#actionBtn");
|
|
236
|
-
const attachBtn = $("#attachBtn");
|
|
237
|
-
const attachInput = $("#attachInput");
|
|
245
|
+
const [attachBtn, attachInput] = viewer.controls([$("#attachBtn"), $("#attachInput")], "images");
|
|
238
246
|
const composeHintEl = $("#composeHint");
|
|
239
247
|
|
|
240
248
|
// The open session (store.selected), its fields (store.current: session_state.js;
|
|
@@ -244,6 +252,12 @@ const composeHintEl = $("#composeHint");
|
|
|
244
252
|
// the page's first draw); an input the store doesn't hold calls
|
|
245
253
|
// store.touch(name).
|
|
246
254
|
const store = createSessionStore({ initial: emptySessionState() });
|
|
255
|
+
// An invited person's link: their session, name, bottom row and limits (participant_main.js).
|
|
256
|
+
const participant = viewer.kind() === "participant" ? createParticipantMain({ body: document.body, topBar: $("#topBar"), infoBar: $("#infoBar"),
|
|
257
|
+
composer: $("#composer"), store, running: () => liveTurn.running, stage: { redraw: () => turnDom.redraw?.() }, read: (id) => getSession(id),
|
|
258
|
+
onClosed: () => reviseStacks?.decorate() }) : null;
|
|
259
|
+
// Revise's worker gate and its words: a participant's own (participant_revise.js).
|
|
260
|
+
const [reviseGate, reviseOffText] = participant ? [participantReviseUnavailable, PARTICIPANT_REVISE_UNAVAILABLE] : [reviseWorkerUnavailable, undefined];
|
|
247
261
|
// The page actions the open session's worker must support (feature_gates.js),
|
|
248
262
|
// the store's featureGates redraw: a gate's redraw runs when its answer
|
|
249
263
|
// flips (a restart brings the feature, the worker goes). forgetSession and
|
|
@@ -258,7 +272,7 @@ const featureGates = createFeatureGates([
|
|
|
258
272
|
// Revise on an answer and the composer's Revising chip (revise_stack.js).
|
|
259
273
|
{
|
|
260
274
|
name: "revise",
|
|
261
|
-
unavailable: (cur) =>
|
|
275
|
+
unavailable: (cur) => reviseGate(cur.workerFeatures, cur.bridgeUp),
|
|
262
276
|
redraw: () => redrawRevise(),
|
|
263
277
|
},
|
|
264
278
|
// The objectives' Where are we? (objectives_track.js).
|
|
@@ -274,11 +288,11 @@ const openId = () => store.selected;
|
|
|
274
288
|
let pendingReviseAnchor = null;
|
|
275
289
|
let reviseStacks = null;
|
|
276
290
|
const reviseChipEl = $("#reviseChip");
|
|
277
|
-
const reviseUnavailable = () =>
|
|
291
|
+
const reviseUnavailable = () => reviseGate(store.current.workerFeatures, store.current.bridgeUp);
|
|
278
292
|
function redrawRevise() {
|
|
279
293
|
if (reviseChipEl) {
|
|
280
294
|
render(reviseChipTemplate(pendingReviseAnchor, {
|
|
281
|
-
unavailable: reviseUnavailable(),
|
|
295
|
+
unavailable: reviseUnavailable(), text: reviseOffText,
|
|
282
296
|
onClear: () => { setReviseAnchor(null); focusPrompt(); },
|
|
283
297
|
}), reviseChipEl);
|
|
284
298
|
reviseChipEl.hidden = !pendingReviseAnchor;
|
|
@@ -314,7 +328,7 @@ let eventsControl = null;
|
|
|
314
328
|
const shownTexts = createShownTexts();
|
|
315
329
|
const markdownPlace = createMarkdownPlace({
|
|
316
330
|
capabilities: () => pageCapabilities,
|
|
317
|
-
renderText,
|
|
331
|
+
renderText: viewer.can("render") ? renderText : null,
|
|
318
332
|
roots: () => turnRoots(),
|
|
319
333
|
touchedFiles,
|
|
320
334
|
currentDir: () => store.current.dir,
|
|
@@ -331,14 +345,17 @@ const { renderMarkdown, pairRefsIn, linkRefsIn, applyFinalMarkdown } = markdownP
|
|
|
331
345
|
// what each turn brought into context, in a rail in the stage, a footprint
|
|
332
346
|
// under each finished turn and a "set N" chip in the mem chip's place
|
|
333
347
|
// (working_set_view.js).
|
|
334
|
-
const
|
|
348
|
+
const wsLine = viewer.can("session_controls") ? (line) => (store.selected ? sendCommand(store.selected, line, { clientId }) : null) : null;
|
|
349
|
+
// What chi has of an item (the owner's): the rows' peek and the reader over the stage (ws_reader.js).
|
|
350
|
+
const wsPreview = document.body.dataset.workingSet === "1" && viewer.can("working_set_items")
|
|
351
|
+
? createWorkingSetPreview({ centerEl: $("#center"), session: () => store.selected, state: () => store.current, sendLine: wsLine }) : null;
|
|
352
|
+
const workingSet = document.body.dataset.workingSet === "1" && viewer.can("working_set")
|
|
335
353
|
? createWorkingSet({
|
|
336
354
|
historyEl, stageRoot: () => turnDom.root, state: () => store.current, session: () => store.selected, infoEl: infoTextEl,
|
|
337
|
-
onChange: () => store.touch("infoBar"), getWorkingSet,
|
|
338
|
-
// A drop or undrop from the list: the session's command, as typed.
|
|
339
|
-
sendLine: (line) => (store.selected ? sendCommand(store.selected, line, { clientId }) : null),
|
|
355
|
+
onChange: () => store.touch("infoBar"), getWorkingSet, sendLine: wsLine, peek: wsPreview?.peek ?? null, onTimeline: wsPreview?.open ?? null,
|
|
340
356
|
})
|
|
341
357
|
: null;
|
|
358
|
+
wsPreview?.attach(workingSet);
|
|
342
359
|
document.body.classList.toggle("working-set", !!workingSet);
|
|
343
360
|
// The running turn's DOM: the stage pinned above the composer
|
|
344
361
|
// (stage_view.js), the turn block (turn_block.js) in its cloud.
|
|
@@ -349,14 +366,15 @@ const turnDom = createStageView({
|
|
|
349
366
|
sessionId: () => store.selected,
|
|
350
367
|
// The stop-task button on a running task_wait, for a worker that has
|
|
351
368
|
// the route (its sidecar features).
|
|
352
|
-
taskStop: createTaskStopper({ sessionId: () => store.selected, features: () => store.current.workerFeatures }),
|
|
369
|
+
taskStop: viewer.can("session_controls") ? createTaskStopper({ sessionId: () => store.selected, features: () => store.current.workerFeatures }) : null,
|
|
353
370
|
dockEl: $("#dock"),
|
|
354
371
|
centerEl: $("#center"),
|
|
355
372
|
renderMarkdown,
|
|
356
373
|
linkRefs: linkRefsIn,
|
|
357
374
|
workingSet,
|
|
358
375
|
// Stop turn in its status row (disabled until the request settles).
|
|
359
|
-
onCancel: () => handleCancel(),
|
|
376
|
+
onCancel: viewer.can("stop_any_turn") || viewer.can("stop_own_turn") ? () => handleCancel() : null,
|
|
377
|
+
canCancel: () => !participant || participant.canCancel(), ownerWait: () => participant?.ownerWait() ?? null,
|
|
360
378
|
onHandedOff: (handed) => reloadCheck.handedOff(handed),
|
|
361
379
|
// The quiet signal (stage_stall.js): the stream, what the turn waits on, a joiner's step clock.
|
|
362
380
|
streamLive: () => sessionSync.streamLive(), timingNote: () => liveTurn.timing.note, serverGen: () => liveTurn.serverGen,
|
|
@@ -364,11 +382,13 @@ const turnDom = createStageView({
|
|
|
364
382
|
// The opt-in reload check (web.reload_check): a handed-off turn against a
|
|
365
383
|
// reload of it, the counts to chi web (reload_check.js).
|
|
366
384
|
const reloadCheck = createReloadCheck({
|
|
367
|
-
enabled: () => document.body.dataset.reloadCheck === "1",
|
|
385
|
+
enabled: () => document.body.dataset.reloadCheck === "1" && viewer.can("session_controls"),
|
|
368
386
|
sessionId: () => store.selected,
|
|
369
387
|
running: () => liveTurn.running,
|
|
370
388
|
read: (id) => getSession(id),
|
|
371
|
-
render: (data) =>
|
|
389
|
+
render: (data) => sessionView.reloadRender(data),
|
|
390
|
+
place: (holder, entries) => placeCardsOffscreen(holder, entries, { capabilities: pageCapabilities, answers: viewer.can("answer_cards") }),
|
|
391
|
+
capabilities: () => pageCapabilities,
|
|
372
392
|
post: (id, body) => api(`/api/sessions/${id}/reload_check`, { method: "POST", body: JSON.stringify(body) }),
|
|
373
393
|
});
|
|
374
394
|
// The history's bottom reserve and the toast's place follow the composer
|
|
@@ -388,7 +408,7 @@ function turnRoots() {
|
|
|
388
408
|
return [historyEl, turnDom.root];
|
|
389
409
|
}
|
|
390
410
|
const systemOneWrongAction = createSystemOneWrongAction({ sessionId: () => store.selected });
|
|
391
|
-
turnRoots().forEach((root) => root.addEventListener("click", systemOneWrongAction));
|
|
411
|
+
if (viewer.can("answer_cards")) turnRoots().forEach((root) => root.addEventListener("click", systemOneWrongAction));
|
|
392
412
|
function findInTurnRoots(selector) {
|
|
393
413
|
return turnRoots().flatMap((root) => [...root.querySelectorAll(selector)]);
|
|
394
414
|
}
|
|
@@ -404,6 +424,7 @@ const liveTurn = createLiveTurn({
|
|
|
404
424
|
(stageHost || historyEl).appendChild(el);
|
|
405
425
|
return !!stageHost;
|
|
406
426
|
},
|
|
427
|
+
stageToolRunning: () => turnDom.callClockActive?.() ?? false,
|
|
407
428
|
// The stage's quiet signal and tool clock tick with it (?.: a stage_view.js an open tab loaded before).
|
|
408
429
|
onTick: () => { store.touch("infoBar"); turnDom.tick?.(); },
|
|
409
430
|
});
|
|
@@ -424,10 +445,11 @@ const deliveryControl = createDeliveryControl({
|
|
|
424
445
|
serverGen: liveTurn.serverGen,
|
|
425
446
|
canQueue: store.current.workerFeatures.includes("delivery"),
|
|
426
447
|
model: store.current.model,
|
|
427
|
-
participantTurn: !!liveTurn.participantTurn,
|
|
448
|
+
participantTurn: !!liveTurn.participantTurn, viewerTurn: participant?.deliveryTurn() ?? null,
|
|
428
449
|
};
|
|
429
450
|
},
|
|
430
451
|
composerEmpty: () => !composer.hasDraft(),
|
|
452
|
+
history: viewer.can("prompt_history"),
|
|
431
453
|
send: (delivery) => handleSendTurn({ delivery }),
|
|
432
454
|
session: () => store.selected,
|
|
433
455
|
});
|
|
@@ -444,6 +466,7 @@ const objectives = createObjectives({
|
|
|
444
466
|
const questionCards = createQuestionCards({
|
|
445
467
|
sessionId: () => store.selected,
|
|
446
468
|
clientId,
|
|
469
|
+
answers: viewer.can("answer_cards"),
|
|
447
470
|
place: (card) => appendToHistory(card),
|
|
448
471
|
isNearBottom: () => isNearBottom(),
|
|
449
472
|
scrollToEnd: () => { historyEl.scrollTop = historyEl.scrollHeight; },
|
|
@@ -497,9 +520,10 @@ turnRoots().forEach((root) => root.addEventListener("click", cards.onCardAction)
|
|
|
497
520
|
// the ones made later come in as getters, and each reaches the other lazily.
|
|
498
521
|
const sessionView = createSessionView({
|
|
499
522
|
store, historyEl, getSession,
|
|
500
|
-
liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet, gapClock,
|
|
523
|
+
liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet, wsPreview, gapClock,
|
|
501
524
|
bubbles, cards, markdown: markdownPlace,
|
|
502
525
|
capabilities: () => pageCapabilities,
|
|
526
|
+
can: viewer.can,
|
|
503
527
|
page: {
|
|
504
528
|
setReviseAnchor, renderInitRow, setMarkdownWarning, setCapabilities, findInTurnRoots, appendToHistory,
|
|
505
529
|
setTurnRunning, mergeTurnTiming, applySessionPayload, turnEndStatus, replaceSelectedCard,
|
|
@@ -509,7 +533,7 @@ const sessionView = createSessionView({
|
|
|
509
533
|
commandList: () => commandList, initTasks: () => initTasks, resetTurnView: () => sessionSync.resetTurnView(),
|
|
510
534
|
},
|
|
511
535
|
});
|
|
512
|
-
const { forgetSession,
|
|
536
|
+
const { forgetSession, readTurnEnd, endTurnView } = sessionView;
|
|
513
537
|
const sessionSync = createSessionSync({
|
|
514
538
|
store, historyEl, emptyEl, getSession, openStream,
|
|
515
539
|
liveTurn, turnDom, questionCards, contextChips, participantsControl,
|
|
@@ -554,9 +578,10 @@ function sweepFoldsOnce() {
|
|
|
554
578
|
// The list by fetching: the fallback when there is no events stream (a
|
|
555
579
|
// chi web without a hub, or ?dir the server refused: the 400 is read here).
|
|
556
580
|
async function refresh() {
|
|
581
|
+
if (!viewer.can("sessions")) return;
|
|
557
582
|
try {
|
|
558
583
|
store.update({ sessions: await listSessions("updated_at", "desc", { dir: scope.dir }) });
|
|
559
|
-
notifications
|
|
584
|
+
notifications?.noticeList(store.sessions);
|
|
560
585
|
sweepFoldsOnce();
|
|
561
586
|
} catch (e) {
|
|
562
587
|
if (e.status !== 400 || !scope.dir) throw e;
|
|
@@ -570,6 +595,7 @@ async function refresh() {
|
|
|
570
595
|
// (re)connect, then upserts and removals. The selected session's owner and
|
|
571
596
|
// worker follow its events (a new worker's bridge_up reconnects the stream).
|
|
572
597
|
function openSessionEvents() {
|
|
598
|
+
if (!viewer.can("sessions")) return;
|
|
573
599
|
eventsControl = openEvents({
|
|
574
600
|
// The list redraws the lists and the bar (its children chip, its chain's
|
|
575
601
|
// ← → links): store.update({sessions}).
|
|
@@ -577,19 +603,19 @@ function openSessionEvents() {
|
|
|
577
603
|
versionNotices.notice(data);
|
|
578
604
|
versionNotices.reconnected(data.version);
|
|
579
605
|
if (data.chi_update) versionNotices.frame(data.chi_update, { snapshot: true });
|
|
580
|
-
notifications
|
|
606
|
+
notifications?.noticeSessions("snapshot", data);
|
|
581
607
|
store.update({ sessions: applySessionEvent(store.sessions, "snapshot", data) });
|
|
582
608
|
sweepFoldsOnce();
|
|
583
609
|
const sess = store.sessions.find((s) => s.id === store.selected);
|
|
584
610
|
if (sess) followSelectedSession(sess);
|
|
585
611
|
}),
|
|
586
612
|
session: (data) => store.batch(() => {
|
|
587
|
-
notifications
|
|
613
|
+
notifications?.noticeSessions("session", data);
|
|
588
614
|
store.update({ sessions: applySessionEvent(store.sessions, "session", data) });
|
|
589
615
|
if (data.session && data.session.id === store.selected) followSelectedSession(data.session);
|
|
590
616
|
}),
|
|
591
617
|
session_gone: (data) => {
|
|
592
|
-
notifications
|
|
618
|
+
notifications?.noticeSessions("session_gone", data);
|
|
593
619
|
lists.forget(data.id);
|
|
594
620
|
store.update({ sessions: applySessionEvent(store.sessions, "session_gone", data) });
|
|
595
621
|
leaveGoneSession(data.id, "deleted");
|
|
@@ -620,17 +646,19 @@ const EVENTS_REOPEN_MS = 3000;
|
|
|
620
646
|
// to the same place without ?dir); "all projects" otherwise, with where a
|
|
621
647
|
// new session starts on the start page.
|
|
622
648
|
function renderScope() {
|
|
623
|
-
const el = $("#scope");
|
|
624
|
-
|
|
625
|
-
|
|
649
|
+
const el = viewer.control($("#scope"), "sessions");
|
|
650
|
+
if (el) {
|
|
651
|
+
render(scopeTemplate(scope, { error: scopeError, where: () => ({ hash: location.hash }) }), el);
|
|
652
|
+
el.hidden = false;
|
|
653
|
+
}
|
|
626
654
|
// The tab: "<session title> · Chi · <project>" (updateSessionTitle).
|
|
627
655
|
tabBase = scope.projectName ? `Chi · ${scope.projectName}` : "Chi";
|
|
628
656
|
updateSessionTitle();
|
|
629
657
|
}
|
|
630
658
|
|
|
631
|
-
createProjectPicker({
|
|
632
|
-
|
|
633
|
-
|
|
659
|
+
if (viewer.can("sessions")) createProjectPicker({ el: $("#scope"), scope, scopeError: () => scopeError, api });
|
|
660
|
+
// The strip, its pill and grip: the session list's (lists_view.js draws into the hidden strip all the same).
|
|
661
|
+
viewer.controls([topStripEl, $("#stripStatus"), $("#stripGrip")], "sessions");
|
|
634
662
|
|
|
635
663
|
// The session lists (lists_view.js): the strip, all sessions, their cards,
|
|
636
664
|
// select mode, the family and chain popovers.
|
|
@@ -712,7 +740,7 @@ const rename = createRename({
|
|
|
712
740
|
onClose: () => queueMicrotask(() => lists.catchUp()),
|
|
713
741
|
run: (line) => runSessionCommand(line),
|
|
714
742
|
});
|
|
715
|
-
titleRenameBtn
|
|
743
|
+
titleRenameBtn?.addEventListener("click", () => rename.open());
|
|
716
744
|
document.addEventListener("scroll", () => rename.reposition(), true);
|
|
717
745
|
window.addEventListener("resize", () => rename.reposition());
|
|
718
746
|
|
|
@@ -722,7 +750,7 @@ const { confirmDelete, leaveGoneSession, continueSelected, archiveOne, setArchiv
|
|
|
722
750
|
// leaves it. Opened from the page, it closes with history.back().
|
|
723
751
|
let allViewPushed = false;
|
|
724
752
|
function allViewOpen() {
|
|
725
|
-
return location.hash === ALL_SESSIONS_HASH;
|
|
753
|
+
return !participant && location.hash === ALL_SESSIONS_HASH;
|
|
726
754
|
}
|
|
727
755
|
function openAllView() {
|
|
728
756
|
if (allViewOpen()) return;
|
|
@@ -762,7 +790,8 @@ function setSessionHash(id) {
|
|
|
762
790
|
function selectFromHash() {
|
|
763
791
|
const claim = claimFromHash(location.hash);
|
|
764
792
|
if (claim) ownerClaim.pending(claim);
|
|
765
|
-
|
|
793
|
+
// A participant's page has one session, whatever the hash names.
|
|
794
|
+
const intent = participant ? { kind: "session", id: participant.sessionId } : hashIntent(location.hash, { selected: store.selected, claim });
|
|
766
795
|
if (intent.kind === "session" && intent.id !== store.selected) select(intent.id);
|
|
767
796
|
else if (claim) ownerClaim.showPending();
|
|
768
797
|
else if (intent.kind === "start") clearSelection();
|
|
@@ -770,7 +799,7 @@ function selectFromHash() {
|
|
|
770
799
|
// The page's claim links (owner_claim.js): one opened here, once drawn, and
|
|
771
800
|
// annotate's Copy link.
|
|
772
801
|
const ownerClaim = createOwnerClaim({
|
|
773
|
-
historyEl, store, claimTarget: () => participantsControl
|
|
802
|
+
historyEl, store, claimTarget: () => participantsControl?.claimTarget() ?? null,
|
|
774
803
|
toast: (...args) => showToast(...args), copyText, allViewOpen, home: document.body.dataset.home || "",
|
|
775
804
|
});
|
|
776
805
|
function applyView() {
|
|
@@ -806,7 +835,7 @@ window.addEventListener("hashchange", () => {
|
|
|
806
835
|
const composerMode = createComposerMode({
|
|
807
836
|
els: { body: document.body, prompt: promptEl, hint: composeHintEl, button: actionBtn, attach: attachBtn, empty: emptyEl,
|
|
808
837
|
history: historyEl },
|
|
809
|
-
store, liveTurn, startPage, deliveryControl, fitPrompt, placeToast,
|
|
838
|
+
store, liveTurn, startPage, deliveryControl, fitPrompt, placeToast, steers: () => !participant || participant.deliveryTurn().steer,
|
|
810
839
|
});
|
|
811
840
|
|
|
812
841
|
function setTurnRunning(running) {
|
|
@@ -862,8 +891,8 @@ function clearSelection() {
|
|
|
862
891
|
store.update({ selected: null });
|
|
863
892
|
setSessionHash(null);
|
|
864
893
|
forgetSession();
|
|
865
|
-
contextChips
|
|
866
|
-
participantsControl
|
|
894
|
+
contextChips?.clear();
|
|
895
|
+
participantsControl?.load(null);
|
|
867
896
|
});
|
|
868
897
|
focusPrompt();
|
|
869
898
|
}
|
|
@@ -900,22 +929,26 @@ function setMarkdownWarning(warning) {
|
|
|
900
929
|
markdownWarningEl.hidden = false;
|
|
901
930
|
}
|
|
902
931
|
|
|
903
|
-
// Both from one payload, together; the body's has-editor class follows.
|
|
904
|
-
|
|
932
|
+
// Both from one payload, together; the body's has-editor class follows. A
|
|
933
|
+
// show's viewer narrows the page's (viewer.js); none read (forgetSession) is the stamp's again.
|
|
934
|
+
function setCapabilities(capabilities, editorUrl, shownViewer = null) {
|
|
905
935
|
pageCapabilities = capabilities && typeof capabilities === "object" ? capabilities : {};
|
|
906
936
|
pageEditorUrl = pageCapabilities.editor === true && typeof editorUrl === "string" && editorUrl ? editorUrl : null;
|
|
907
937
|
document.body.classList.toggle("has-editor", pageEditorUrl !== null);
|
|
938
|
+
if (shownViewer) viewer.update(shownViewer);
|
|
939
|
+
else if (!capabilities) viewer.reset();
|
|
940
|
+
participant?.shown(shownViewer);
|
|
908
941
|
}
|
|
909
942
|
|
|
910
|
-
//
|
|
911
|
-
function
|
|
943
|
+
// Where this page can open a ref (refs.js REF_ACTIONS): not the viewer's capabilities (viewer.js).
|
|
944
|
+
function refEditor() {
|
|
912
945
|
return { editor: pageCapabilities.editor === true, editorUrl: pageEditorUrl };
|
|
913
946
|
}
|
|
914
947
|
|
|
915
948
|
// Refs anywhere on the page (a tool row's file, its diff lines, an
|
|
916
949
|
// answer's path:line): one listener set; "Copy path" says so in a toast.
|
|
917
|
-
installRefClicks(document.body,
|
|
918
|
-
copy: async (text) => showToast((await copyText(text)) ? "Path copied" : "Couldn't copy the path"),
|
|
950
|
+
installRefClicks(document.body, refEditor, {
|
|
951
|
+
copy: async (text) => showToast((await copyText(text)) ? "Path copied" : "Couldn't copy the path"), whatChiHas: wsPreview?.whatChiHas ?? null,
|
|
919
952
|
});
|
|
920
953
|
|
|
921
954
|
// Sticky-follow scroll: only auto-scroll to the bottom while the user is
|
|
@@ -962,7 +995,7 @@ const ownerVerify = createOwnerVerify({
|
|
|
962
995
|
|
|
963
996
|
// Apply: the owner's Apply turn into the composer, after what is typed
|
|
964
997
|
// there; never sent from here.
|
|
965
|
-
historyEl.addEventListener("click", async (e) => {
|
|
998
|
+
if (viewer.can("apply")) historyEl.addEventListener("click", async (e) => {
|
|
966
999
|
const button = e.target.closest(".review-apply-btn");
|
|
967
1000
|
if (!button || !store.selected) return;
|
|
968
1001
|
const id = store.selected;
|
|
@@ -991,15 +1024,12 @@ function sessionWaits() {
|
|
|
991
1024
|
}
|
|
992
1025
|
function updateInfoBar() {
|
|
993
1026
|
annotateBar?.refresh();
|
|
1027
|
+
if (participant) return [participant.drawBar(), updateSessionTitle()];
|
|
994
1028
|
const { buttons, bar } = sessionBar({
|
|
995
1029
|
id: store.selected, state: store.current, sessions: store.sessions, versions: versionNotices.versions(), cardTitle: (s) => lists.cardTitle(s),
|
|
996
1030
|
continuing: sessionActions.continuing, restarting: versionNotices.restarting, streaming: sessionSync.hasStream(), running: liveTurn.running, waiting: sessionWaits(),
|
|
997
|
-
workingSet: workingSet ? workingSet.chip() : undefined, participants: participantsControl
|
|
1031
|
+
workingSet: workingSet ? workingSet.chip() : undefined, participants: participantsControl?.chip() ?? null,
|
|
998
1032
|
});
|
|
999
|
-
const stopBtn = document.getElementById("infoStopBtn");
|
|
1000
|
-
const deleteBtn = document.getElementById("infoDeleteBtn");
|
|
1001
|
-
const archiveBtn = document.getElementById("infoArchiveBtn");
|
|
1002
|
-
const continueBtn = document.getElementById("infoContinueBtn");
|
|
1003
1033
|
if (continueBtn) {
|
|
1004
1034
|
continueBtn.style.display = buttons.continue.shown ? "" : "none";
|
|
1005
1035
|
continueBtn.disabled = buttons.continue.disabled;
|
|
@@ -1015,6 +1045,8 @@ function updateInfoBar() {
|
|
|
1015
1045
|
archiveBtn.title = buttons.archive.title;
|
|
1016
1046
|
}
|
|
1017
1047
|
if (stopBtn) stopBtn.style.display = buttons.stop.shown ? "" : "none";
|
|
1048
|
+
// The ⚙ chip only with its panel (session_controls, viewer.js).
|
|
1049
|
+
if (bar && !settingsControl) bar.settings = null;
|
|
1018
1050
|
drawFoldControls();
|
|
1019
1051
|
// No session: the start page hides the info bar (the storage path is on
|
|
1020
1052
|
// #/sessions). The session clock ticks every second while a turn runs:
|
|
@@ -1022,7 +1054,7 @@ function updateInfoBar() {
|
|
|
1022
1054
|
// mid-press) stay.
|
|
1023
1055
|
renderInfoBar(infoTextEl, bar);
|
|
1024
1056
|
const { folded } = barFold.update({ bar, buttons });
|
|
1025
|
-
moreSheet
|
|
1057
|
+
moreSheet?.update({ bar, buttons, folded });
|
|
1026
1058
|
updateSessionTitle();
|
|
1027
1059
|
// A fresh link's picker follows what the bar follows: its model, its
|
|
1028
1060
|
// owner, a next link continued from elsewhere.
|
|
@@ -1034,6 +1066,7 @@ function updateInfoBar() {
|
|
|
1034
1066
|
// browser tab names it too. It follows the card's (openTitle): a chain link
|
|
1035
1067
|
// reads its card's title (cardTitle), whatever opener it was sent.
|
|
1036
1068
|
function shownTitle() {
|
|
1069
|
+
if (participant) return participant.title();
|
|
1037
1070
|
const shown = store.selected ? lists.sessionsById().get(store.selected) : null;
|
|
1038
1071
|
const first = store.current.firstPreview || "";
|
|
1039
1072
|
const raw = !store.selected ? "" : openTitle({ shown, first, cardTitle: (s) => lists.cardTitle(s) });
|
|
@@ -1052,13 +1085,14 @@ function updateSessionTitle() {
|
|
|
1052
1085
|
if (sessionTitleEl.textContent !== text) sessionTitleEl.textContent = text;
|
|
1053
1086
|
if (sessionTitleRowEl.hidden !== !text) sessionTitleRowEl.hidden = !text;
|
|
1054
1087
|
const renamable = !!text && renameShown(store.current.owner);
|
|
1055
|
-
if (titleRenameBtn.hidden !== !renamable) titleRenameBtn.hidden = !renamable;
|
|
1088
|
+
if (titleRenameBtn && titleRenameBtn.hidden !== !renamable) titleRenameBtn.hidden = !renamable;
|
|
1056
1089
|
const tip = text ? title : "";
|
|
1057
1090
|
if (sessionTitleEl.title !== tip) sessionTitleEl.title = tip;
|
|
1058
1091
|
const tab = tabBase === null ? null : tabTitle({ title, base: tabBase });
|
|
1059
1092
|
if (tab !== null && tab !== tabShown) {
|
|
1060
1093
|
tabShown = tab;
|
|
1061
|
-
notifications.setBaseTitle(tab);
|
|
1094
|
+
if (notifications) notifications.setBaseTitle(tab);
|
|
1095
|
+
else document.title = tab;
|
|
1062
1096
|
}
|
|
1063
1097
|
rename.follow(store.selected);
|
|
1064
1098
|
rename.reposition();
|
|
@@ -1138,7 +1172,7 @@ function turnEndStatus(data) {
|
|
|
1138
1172
|
|
|
1139
1173
|
// The stream's event handlers (stream_handlers.js); renderSessionView
|
|
1140
1174
|
// replays a snapshot through them too.
|
|
1141
|
-
const streamHandlers = createStreamHandlers({
|
|
1175
|
+
const streamHandlers = (participant ? participant.wrapHandlers : (handlers) => handlers)(createStreamHandlers({
|
|
1142
1176
|
selected: () => store.selected,
|
|
1143
1177
|
store,
|
|
1144
1178
|
clientId,
|
|
@@ -1151,7 +1185,7 @@ const streamHandlers = createStreamHandlers({
|
|
|
1151
1185
|
contextChips,
|
|
1152
1186
|
workingSet,
|
|
1153
1187
|
participantsControl,
|
|
1154
|
-
placeApply,
|
|
1188
|
+
placeApply: viewer.can("apply") ? placeApply : null,
|
|
1155
1189
|
placeVerdict: ownerVerify.placeVerdict,
|
|
1156
1190
|
restoreVerify: (anchor) => ownerVerify.set(anchor),
|
|
1157
1191
|
restoreRevise,
|
|
@@ -1190,7 +1224,7 @@ const streamHandlers = createStreamHandlers({
|
|
|
1190
1224
|
syncModelPick: startPage.commandRan,
|
|
1191
1225
|
objectivesUpdated: (data) => objectives.update(data),
|
|
1192
1226
|
cardActionFailed: cards.actionFailed,
|
|
1193
|
-
});
|
|
1227
|
+
}));
|
|
1194
1228
|
|
|
1195
1229
|
async function refreshTimingFromSession() {
|
|
1196
1230
|
if (!store.selected) return;
|
|
@@ -1215,7 +1249,7 @@ function addCreatedSession(created) {
|
|
|
1215
1249
|
|
|
1216
1250
|
// /model, !ls … from the composer, and a control's command (the llm ctx
|
|
1217
1251
|
// and thinking chips): composer.js.
|
|
1218
|
-
const composerCommands = createComposerCommands({
|
|
1252
|
+
const composerCommands = viewer.can("session_controls") ? createComposerCommands({
|
|
1219
1253
|
session: () => store.selected,
|
|
1220
1254
|
clientId,
|
|
1221
1255
|
sendCommand,
|
|
@@ -1238,7 +1272,7 @@ const composerCommands = createComposerCommands({
|
|
|
1238
1272
|
focusPrompt({ open: false });
|
|
1239
1273
|
},
|
|
1240
1274
|
},
|
|
1241
|
-
});
|
|
1275
|
+
}) : null;
|
|
1242
1276
|
|
|
1243
1277
|
// The composer's send (send_turn.js): a line into the open session, or a
|
|
1244
1278
|
// new session first on the start page.
|
|
@@ -1282,7 +1316,8 @@ const sendTurnControl = createSendTurn({
|
|
|
1282
1316
|
followWokenWorker,
|
|
1283
1317
|
refreshHistory,
|
|
1284
1318
|
leaveGoneSession,
|
|
1285
|
-
|
|
1319
|
+
closesOn: participant?.refused ?? null,
|
|
1320
|
+
runCommand: composerCommands ? (command) => composerCommands.send(command) : null,
|
|
1286
1321
|
toast: showToast,
|
|
1287
1322
|
});
|
|
1288
1323
|
// +delivery+: the composer's choice for a running turn (Alt+Enter: queue;
|
|
@@ -1292,7 +1327,7 @@ function handleSendTurn({ delivery = null } = {}) {
|
|
|
1292
1327
|
}
|
|
1293
1328
|
|
|
1294
1329
|
function runSessionCommand(line) {
|
|
1295
|
-
return composerCommands
|
|
1330
|
+
return composerCommands?.run(line);
|
|
1296
1331
|
}
|
|
1297
1332
|
|
|
1298
1333
|
function clearComposer() {
|
|
@@ -1320,7 +1355,7 @@ async function handleCancel() {
|
|
|
1320
1355
|
// session (from all sessions too).
|
|
1321
1356
|
// The typed draft stays in the composer: paste in a session, then + new session
|
|
1322
1357
|
// starts from it (with the model picker). clearSelection leaves #prompt alone.
|
|
1323
|
-
$("#newBtn")
|
|
1358
|
+
viewer.control($("#newBtn"), "sessions")?.addEventListener("click", () => {
|
|
1324
1359
|
if (allViewOpen()) leaveAllView("");
|
|
1325
1360
|
clearSelection();
|
|
1326
1361
|
startPage.loadModels({ asked: true });
|
|
@@ -1346,7 +1381,8 @@ const composer = mountComposer({
|
|
|
1346
1381
|
toast: (text) => showToast(text),
|
|
1347
1382
|
onWrite: () => noteDraft(),
|
|
1348
1383
|
// ↑/↓: the prompt history shared with the TUI.
|
|
1349
|
-
loadHistory: fetchHistory,
|
|
1384
|
+
loadHistory: viewer.can("prompt_history") ? fetchHistory : null,
|
|
1385
|
+
imagesOff: viewer.can("images") ? null : IMAGES_NOT_HERE,
|
|
1350
1386
|
// Alt/Option+Enter: queued for after the running turn (D6), only to a
|
|
1351
1387
|
// worker that queues (else it would steer): the text stays, a note says why.
|
|
1352
1388
|
send: ({ queue }) => {
|
|
@@ -1411,19 +1447,19 @@ document.addEventListener("keydown", (e) => {
|
|
|
1411
1447
|
const commandList = createCommandList({
|
|
1412
1448
|
list: $("#commandList"),
|
|
1413
1449
|
prompt: promptEl,
|
|
1414
|
-
commands: () => (store.selected && store.current.owner !== "tui" ? store.current.commands : []),
|
|
1450
|
+
commands: () => (viewer.can("session_controls") && store.selected && store.current.owner !== "tui" ? store.current.commands : []),
|
|
1415
1451
|
afterPick: () => {
|
|
1416
1452
|
noteDraft();
|
|
1417
1453
|
fitPrompt();
|
|
1418
1454
|
},
|
|
1419
1455
|
});
|
|
1420
1456
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1457
|
+
stopBtn?.addEventListener("click", () => sessionActions.stopSelected());
|
|
1458
|
+
deleteBtn?.addEventListener("click", () => {
|
|
1423
1459
|
if (store.selected) confirmDelete(store.selected);
|
|
1424
1460
|
});
|
|
1425
|
-
|
|
1426
|
-
|
|
1461
|
+
continueBtn?.addEventListener("click", () => continueSelected());
|
|
1462
|
+
archiveBtn?.addEventListener("click", () => sessionActions.toggleArchiveSelected());
|
|
1427
1463
|
|
|
1428
1464
|
// The new link's composer: the opener (openerText: the previous link's own,
|
|
1429
1465
|
// else the constant). A draft written in this session (or the new link, or
|
|
@@ -1456,6 +1492,7 @@ function restoreDraft(draft, opener) {
|
|
|
1456
1492
|
const toasts = createToasts({ el: $("#toast"), onChange: placeToast });
|
|
1457
1493
|
// chi's versions, the update sheet and the worker Restart (version_notices.js).
|
|
1458
1494
|
// After toasts: openSessionEvents, its first caller, runs at boot.
|
|
1495
|
+
if (participant) onAuthLost(participant.linkEnded);
|
|
1459
1496
|
const versionNotices = createVersionNotices({
|
|
1460
1497
|
store, toasts, dialog: $("#updateSheet"), loadedVersion: document.body.dataset.version,
|
|
1461
1498
|
api: { updateChi, restartWorkers, restartWeb, restartSession },
|
|
@@ -1514,7 +1551,7 @@ turnRoots().forEach((root) => installCopy(root));
|
|
|
1514
1551
|
// chi-ui blocks (inline_widgets.js) are a core drawer, ahead of the bundles'
|
|
1515
1552
|
// renderers; a picks' Fill reply only fills the composer.
|
|
1516
1553
|
const widgets = createWidgetDrawer({ roots: turnRoots(), composerText: () => promptEl.value, fillComposer });
|
|
1517
|
-
createBlockHost({ roots: turnRoots(), sessionId: () => store.selected, drawers: [widgets] });
|
|
1554
|
+
createBlockHost({ roots: turnRoots(), sessionId: () => store.selected, drawers: [widgets], renderers: viewer.can("block_renderers") });
|
|
1518
1555
|
// A steps block, a thinking block and the recap open and close by hand
|
|
1519
1556
|
// with their height animated (details_motion.js), in the history and on
|
|
1520
1557
|
// the stage.
|
|
@@ -1527,34 +1564,34 @@ installAnswerFold({
|
|
|
1527
1564
|
});
|
|
1528
1565
|
// Revise stacks (revise_stack.js): the superseded versions fold to stubs,
|
|
1529
1566
|
// the top answer gets its version chip, a final answer its Revise button.
|
|
1530
|
-
reviseStacks = installReviseStacks({
|
|
1567
|
+
reviseStacks = viewer.can("revise") || viewer.can("revise_own_turn") ? installReviseStacks({
|
|
1531
1568
|
historyEl,
|
|
1532
1569
|
sessionId: () => store.selected,
|
|
1533
1570
|
projectRoot: () => store.sessions.find((s) => s.id === store.selected)?.project_root ?? null,
|
|
1534
1571
|
running: () => (liveTurn.running ? { turnId: liveTurn.timing.turnId || null } : null),
|
|
1535
1572
|
verifyTurn: (turnId) => (store.current.verdicts || []).some((v) => v.check_turn_id === turnId),
|
|
1536
|
-
unavailable: reviseUnavailable,
|
|
1537
|
-
armed: () => pendingReviseAnchor?.turn_id ?? null,
|
|
1573
|
+
unavailable: reviseUnavailable, unavailableText: reviseOffText,
|
|
1574
|
+
armed: () => pendingReviseAnchor?.turn_id ?? null, mayRevise: participant ? participantMayRevise(participant.closed) : undefined,
|
|
1538
1575
|
onRevise: (anchor) => {
|
|
1539
1576
|
setReviseAnchor(anchor);
|
|
1540
1577
|
openForVisit();
|
|
1541
1578
|
focusPrompt();
|
|
1542
1579
|
},
|
|
1543
|
-
});
|
|
1580
|
+
}) : null;
|
|
1544
1581
|
|
|
1545
1582
|
// Notifications (notifications.js): an OS notification and a title count
|
|
1546
1583
|
// when a session needs the user while this tab is not in front. On a
|
|
1547
1584
|
// project's page the Home Screen app's device tidy-up still covers every
|
|
1548
1585
|
// project: it gets a stream of every session of its own (allEvents).
|
|
1549
|
-
const notifications = createNotifications({
|
|
1586
|
+
const notifications = viewer.can("push") ? createNotifications({
|
|
1550
1587
|
button: $("#notifyBtn"),
|
|
1551
1588
|
scoped: !!scope.dir,
|
|
1552
1589
|
allEvents: (handlers, opts) => openEvents(handlers, opts),
|
|
1553
|
-
});
|
|
1590
|
+
}) : null;
|
|
1554
1591
|
|
|
1555
1592
|
// The strip hidden or shown (strip_hidden.js): its grip, the saved choice and
|
|
1556
1593
|
// the short window's rule; applied now.
|
|
1557
|
-
createStripHidden({
|
|
1594
|
+
if (viewer.can("sessions")) createStripHidden({
|
|
1558
1595
|
gripEl: $("#stripGrip"), body: document.body, onApply: () => updateSessionTitle(),
|
|
1559
1596
|
closeFamilyPop: () => lists.familyPop.close(),
|
|
1560
1597
|
});
|
|
@@ -1574,7 +1611,7 @@ document.addEventListener("keydown", (e) => {
|
|
|
1574
1611
|
// before it (none at load) would redraw nothing.
|
|
1575
1612
|
store.on("lists", () => lists.render());
|
|
1576
1613
|
store.on("paintActive", () => lists.paintActive());
|
|
1577
|
-
store.on("settingsPanel", () => settingsControl
|
|
1614
|
+
store.on("settingsPanel", () => settingsControl?.refresh());
|
|
1578
1615
|
// The working set's list offers pin only under forget.
|
|
1579
1616
|
store.on("workingSetStrategy", () => workingSet?.strategyChanged());
|
|
1580
1617
|
store.on("featureGates", () => featureGates.check(store.current));
|
|
@@ -1582,7 +1619,7 @@ store.on("composer", composerMode.update);
|
|
|
1582
1619
|
store.on("composer", () => objectives.redraw());
|
|
1583
1620
|
// The answers' Revise buttons follow liveTurn.running too (none on the
|
|
1584
1621
|
// running turn's answer), which touches the composer.
|
|
1585
|
-
store.on("composer", () => reviseStacks
|
|
1622
|
+
store.on("composer", () => reviseStacks?.decorate());
|
|
1586
1623
|
store.on("infoBar", updateInfoBar);
|
|
1587
1624
|
|
|
1588
1625
|
applyView();
|
|
@@ -1598,7 +1635,7 @@ store.batch(() => {
|
|
|
1598
1635
|
store.touch("composer");
|
|
1599
1636
|
store.touch("infoBar");
|
|
1600
1637
|
});
|
|
1601
|
-
startPage.loadModels();
|
|
1638
|
+
if (viewer.can("models")) startPage.loadModels();
|
|
1602
1639
|
// The list: the hub's stream when the browser has EventSource, else fetched.
|
|
1603
1640
|
if (typeof globalThis.EventSource === "function") openSessionEvents();
|
|
1604
1641
|
else refresh();
|