samagotchi 0.170.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 +61 -1
- data/bin/chi +6 -4
- data/docs/architecture.md +26 -9
- data/docs/bundles.md +4 -21
- data/docs/cli.md +81 -97
- data/docs/configuration.md +12 -14
- 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/block-renderers.md +2 -2
- data/docs/internals/bridge.md +34 -7
- data/docs/internals/context-telemetry.md +13 -1
- data/docs/internals/engine.md +25 -13
- data/docs/internals/inline-widgets.md +1 -1
- data/docs/internals/objectives.md +4 -6
- data/docs/internals/participants.md +340 -249
- data/docs/internals/prompt-caching.md +4 -5
- data/docs/internals/web-frontend.md +185 -35
- data/docs/internals/working-set.md +71 -5
- data/docs/memory.md +1 -1
- data/docs/plugins.md +2 -16
- data/docs/releasing.md +2 -1
- data/docs/scheduling.md +1 -1
- data/docs/sessions.md +17 -48
- 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 +8 -5
- data/lib/samagotchi/bridge.rb +64 -20
- 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 +36 -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 +8 -3
- data/lib/samagotchi/event_fanout.rb +22 -1
- data/lib/samagotchi/grants.rb +33 -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/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/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 +48 -4
- data/lib/samagotchi/participant_revise.rb +61 -0
- data/lib/samagotchi/participant_turn_mode.rb +50 -0
- data/lib/samagotchi/participant_uploads.rb +98 -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/reply_wait/poll.rb +5 -1
- data/lib/samagotchi/revise_anchor.rb +9 -0
- data/lib/samagotchi/run_options.rb +2 -3
- data/lib/samagotchi/send_command.rb +15 -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_inbox.rb +20 -12
- data/lib/samagotchi/session_manager/delivery.rb +32 -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 -1
- 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 +42 -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 +88 -25
- 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_anchors.rb +0 -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/turn_stages/verify_anchors.rb +13 -1
- data/lib/samagotchi/update_hint.rb +3 -1
- data/lib/samagotchi/verify_anchor.rb +6 -0
- 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 +45 -82
- data/lib/samagotchi/web/participant_access.rb +139 -40
- data/lib/samagotchi/web/participant_images.rb +185 -0
- data/lib/samagotchi/web/participant_review.rb +22 -142
- data/lib/samagotchi/web/participant_show.rb +241 -0
- data/lib/samagotchi/web/participant_stream_filter.rb +25 -2
- data/lib/samagotchi/web/participant_view.rb +334 -27
- data/lib/samagotchi/web/participants_admin.rb +21 -40
- 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 +126 -132
- 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/data.js +2 -10
- data/lib/samagotchi/web/public/delivery_line.js +49 -63
- 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 +50 -34
- data/lib/samagotchi/web/public/info_bar_model.js +2 -1
- data/lib/samagotchi/web/public/live_turn.js +1 -1
- data/lib/samagotchi/web/public/markdown_place.js +5 -4
- data/lib/samagotchi/web/public/owner_claim.js +5 -5
- data/lib/samagotchi/web/public/owner_verify.js +0 -2
- data/lib/samagotchi/web/public/participant_bar.js +107 -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 +17 -8
- data/lib/samagotchi/web/public/participant_revise.js +66 -0
- data/lib/samagotchi/web/public/participants_panel.js +32 -74
- data/lib/samagotchi/web/public/question_cards.js +14 -3
- data/lib/samagotchi/web/public/refs.js +53 -36
- data/lib/samagotchi/web/public/reload_check.js +70 -14
- data/lib/samagotchi/web/public/revise_stack.js +21 -10
- data/lib/samagotchi/web/public/send_turn.js +28 -29
- data/lib/samagotchi/web/public/session_actions.js +4 -45
- data/lib/samagotchi/web/public/session_fields.js +1 -2
- data/lib/samagotchi/web/public/session_state.js +12 -7
- data/lib/samagotchi/web/public/session_sync.js +9 -2
- data/lib/samagotchi/web/public/session_view.js +14 -5
- 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 +7 -5
- 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_owner_wait.js +35 -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 +103 -410
- data/lib/samagotchi/web/public/stage_waiting.js +74 -6
- 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/storage.js +22 -0
- data/lib/samagotchi/web/public/stream_handlers.js +3 -10
- data/lib/samagotchi/web/public/tokens.css +1 -1
- data/lib/samagotchi/web/public/turn_block.js +2 -5
- data/lib/samagotchi/web/public/turn_events.js +30 -12
- data/lib/samagotchi/web/public/turn_html.js +9 -2
- data/lib/samagotchi/web/public/turn_pieces.js +3 -4
- 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 +59 -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/qr.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +42 -15
- data/lib/samagotchi/web/session_create.rb +6 -72
- data/lib/samagotchi/web/session_show.rb +75 -28
- 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 +70 -0
- data/lib/samagotchi/web/working_set_routes.rb +132 -0
- data/lib/samagotchi/worker.rb +35 -28
- data/lib/samagotchi/worker_inbound.rb +4 -3
- data/lib/samagotchi/worker_link.rb +17 -0
- data/lib/samagotchi/working_set.rb +322 -11
- metadata +32 -13
- 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/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_apply.js +0 -34
- data/lib/samagotchi/web/public/review_history.js +0 -72
- data/lib/samagotchi/web/public/review_start.js +0 -55
- data/lib/samagotchi/web/public/tools_overview.js +0 -42
|
@@ -393,12 +393,15 @@ export function createFrameDrawer({
|
|
|
393
393
|
// limit what they hold (docs/internals/block-renderers.md, residual risk)
|
|
394
394
|
// @param drawers core drawers, asked before the bundle renderers
|
|
395
395
|
// The rest are seams for the specs.
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
// +renderers+: false for a viewer without the bundles' renderers (viewer.js):
|
|
397
|
+
// the core +drawers+ only, and GET /api/block_renderers is never asked.
|
|
398
|
+
export function createBlockHost({ roots, sessionId, drawers = [], copy = copyText, watch = null, win = window, renderers = true,
|
|
399
|
+
...frameOpts }) {
|
|
400
|
+
const frames = renderers ? createFrameDrawer({ roots, win, ...frameOpts }) : null;
|
|
401
|
+
const watcher = createBlockWatch({ roots, sessionId, drawers: frames ? [...drawers, frames] : drawers, watch, copy, win });
|
|
399
402
|
// A system theme change redraws through the figure (needsDraw's theme check).
|
|
400
403
|
win.matchMedia?.("(prefers-color-scheme: dark)").addEventListener?.("change", () => {
|
|
401
404
|
for (const root of roots) watcher.scan(root);
|
|
402
405
|
});
|
|
403
|
-
return { scan: watcher.scan, dropFrames: frames.dropFrames };
|
|
406
|
+
return { scan: watcher.scan, dropFrames: frames ? frames.dropFrames : () => {} };
|
|
404
407
|
}
|
|
@@ -195,6 +195,14 @@ export function createBubbles({
|
|
|
195
195
|
return echoes.find((el) => el.dataset.userContent === text) || echoes[0] || null;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
// A participant's own queued bubble for their turn's start (+mine+: no
|
|
199
|
+
// origin names its enqueued id), the oldest, preferring one with the same text.
|
|
200
|
+
function queuedOwnBubble(prompt) {
|
|
201
|
+
const queued = findInTurnRoots(".bubble.user.queued[data-own][data-enqueued-id]");
|
|
202
|
+
const text = normalize(prompt || "");
|
|
203
|
+
return queued.find((el) => el.dataset.userContent === text) || queued[0] || null;
|
|
204
|
+
}
|
|
205
|
+
|
|
198
206
|
// The running wake turn's id (a turn chi ran for reports), for its report's bubble.
|
|
199
207
|
let wakeTurnId = null;
|
|
200
208
|
|
|
@@ -229,7 +237,7 @@ export function createBubbles({
|
|
|
229
237
|
// Re-rendered from a snapshot: the echo is gone, the prompt still queued.
|
|
230
238
|
else makeUserBubble(op.prompt, { state: "queued", own: true, enqueuedId: op.enqueuedId, images: op.images, delivery: op.delivery });
|
|
231
239
|
} else if (op.op === "start") {
|
|
232
|
-
const bubble = bubbleById(op.enqueuedId) || untaggedOwnBubble(op.prompt);
|
|
240
|
+
const bubble = bubbleById(op.enqueuedId) || untaggedOwnBubble(op.prompt) || (op.mine ? queuedOwnBubble(op.prompt) : null);
|
|
233
241
|
// A resync (a new worker woken by this page's send) re-rendered the
|
|
234
242
|
// history and took the echo with it: draw the prompt again.
|
|
235
243
|
if (!bubble) started = makeUserBubble(op.prompt, { own: true, enqueuedId: op.enqueuedId, images: op.images });
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// A snapshot's cards placed into a holder that is not the page (cards_offscreen.js):
|
|
2
|
+
// the opt-in reload check (reload_check.js) draws a handed-off turn offscreen and
|
|
3
|
+
// compares it with what the page has. A reload's render (turnHistoryNodes) doesn't
|
|
4
|
+
// run the placement (cards_place.js placeSnapshotCards), so the check needs its own.
|
|
5
|
+
//
|
|
6
|
+
// It is the real placer, not a copy: createCardsPlace, createBubbles and
|
|
7
|
+
// createQuestionCards over a detached holder, with every page hook made inert:
|
|
8
|
+
// no stage (turnDom answers "nothing holds it", and has no settleFold/settleWaiting
|
|
9
|
+
// — cards_place.js calls those with `?.`), no scroll, no hint, no info bar, no
|
|
10
|
+
// session id, no api. Nothing outside +holder+ is read or written; the page's
|
|
11
|
+
// questionCards, its turnDom and its appendToHistory are never touched.
|
|
12
|
+
import { createBubbles } from "./bubbles.js";
|
|
13
|
+
import { createCardsPlace } from "./cards_place.js";
|
|
14
|
+
import { createQuestionCards } from "./question_cards.js";
|
|
15
|
+
import { splitSnapshotCards } from "./card.js";
|
|
16
|
+
|
|
17
|
+
// +cards+ the read's snapshot (data.cards); +capabilities+ the page's, for the
|
|
18
|
+
// notices it shows elsewhere (splitSnapshotCards); +answers+ whether this viewer
|
|
19
|
+
// may answer cards at all (viewer.js answer_cards).
|
|
20
|
+
export function placeCardsOffscreen(holder, cards, { capabilities = null, answers = true, doc = globalThis.document } = {}) {
|
|
21
|
+
const shared = {
|
|
22
|
+
historyEl: holder,
|
|
23
|
+
findInTurnRoots: (selector) => [...holder.querySelectorAll(selector)],
|
|
24
|
+
isNearBottom: () => false,
|
|
25
|
+
selected: () => null,
|
|
26
|
+
clientId: null,
|
|
27
|
+
};
|
|
28
|
+
// No running turn here: nothing holds a piece, nothing takes a card or a steer.
|
|
29
|
+
const turnDom = { card: () => false, steer: () => false, holds: () => false };
|
|
30
|
+
const bubbles = createBubbles({
|
|
31
|
+
...shared,
|
|
32
|
+
appendToHistory: (el) => holder.appendChild(el),
|
|
33
|
+
turnDom,
|
|
34
|
+
shownTexts: { shows: () => false },
|
|
35
|
+
liveTurn: { timing: { el: null } },
|
|
36
|
+
});
|
|
37
|
+
const questionCards = createQuestionCards({
|
|
38
|
+
...shared,
|
|
39
|
+
sessionId: () => null,
|
|
40
|
+
place: (card) => { holder.appendChild(card); return false; },
|
|
41
|
+
scrollToEnd: () => {},
|
|
42
|
+
removeHintIfEmpty: () => {},
|
|
43
|
+
askingText: () => "",
|
|
44
|
+
renderMarkdown: () => Promise.resolve(null),
|
|
45
|
+
onPending: () => {},
|
|
46
|
+
onSettled: () => {},
|
|
47
|
+
answers,
|
|
48
|
+
doc,
|
|
49
|
+
// A card's button is inert here: a placed card is a comparison, not a live ask.
|
|
50
|
+
api: {
|
|
51
|
+
sendAnswer: () => Promise.reject(new Error("offscreen card")),
|
|
52
|
+
dismissQuestion: () => Promise.reject(new Error("offscreen card")),
|
|
53
|
+
sendCommand: () => Promise.reject(new Error("offscreen card")),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const place = createCardsPlace({
|
|
57
|
+
...shared,
|
|
58
|
+
turnDom,
|
|
59
|
+
questionCards,
|
|
60
|
+
bubbles,
|
|
61
|
+
followWokenWorker: () => {},
|
|
62
|
+
api: {
|
|
63
|
+
getSession: () => Promise.reject(new Error("offscreen card")),
|
|
64
|
+
sendCommand: () => Promise.reject(new Error("offscreen card")),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
place.placeSnapshotCards(splitSnapshotCards(cards, capabilities).placed, { before: null });
|
|
68
|
+
return holder;
|
|
69
|
+
}
|
|
@@ -60,7 +60,8 @@ function shownAnchor(anchor, doc) {
|
|
|
60
60
|
return standIn?.getClientRects().length ? standIn : anchor;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// id, className: the popover's; width: its widest (px
|
|
63
|
+
// id, className: the popover's; width: its widest (px, or a function of
|
|
64
|
+
// none read at each placing: the working set's grows while a row peeks); el: where the chip
|
|
64
65
|
// is drawn; anchor: the chip's selector; openers: the selector of every
|
|
65
66
|
// element that opens it (a click there is not a click outside; default the
|
|
66
67
|
// anchor's); summary(anchor): what the form is drawn from (null: nothing
|
|
@@ -72,7 +73,7 @@ function shownAnchor(anchor, doc) {
|
|
|
72
73
|
// dialog's accessible name (aria-label), none by default. onOpen(): after
|
|
73
74
|
// an open has shown and placed it (where focus can go into it: show runs
|
|
74
75
|
// while it is still hidden). sheetShare: the share of a phone's window the
|
|
75
|
-
// sheet takes at most (SHEET_SHARE). Always a modal dialog (modalDialog);
|
|
76
|
+
// sheet takes at most (SHEET_SHARE; a function of none is read at each placing). Always a modal dialog (modalDialog);
|
|
76
77
|
// the opener clicked (and the anchor it is placed at) carries aria-expanded
|
|
77
78
|
// "true" while it is open, "false" once closed: a lit-drawn chip writes
|
|
78
79
|
// aria-expanded="false" as a static attribute (lit leaves it to the shell).
|
|
@@ -106,7 +107,7 @@ export function createChipPopover({ id, className, width: widest, el, anchor: an
|
|
|
106
107
|
if (narrow) {
|
|
107
108
|
const vv = win.visualViewport;
|
|
108
109
|
const at = sheetPlace({ innerWidth: win.innerWidth, innerHeight: win.innerHeight },
|
|
109
|
-
{ share: sheetShare, viewport: vv ? { height: vv.height, offsetTop: vv.offsetTop } : null });
|
|
110
|
+
{ share: typeof sheetShare === "function" ? sheetShare() : sheetShare, viewport: vv ? { height: vv.height, offsetTop: vv.offsetTop } : null });
|
|
110
111
|
pop.style.width = `${at.width}px`;
|
|
111
112
|
pop.style.left = `${at.left}px`;
|
|
112
113
|
pop.style.top = "";
|
|
@@ -118,7 +119,7 @@ export function createChipPopover({ id, className, width: widest, el, anchor: an
|
|
|
118
119
|
pop.style.maxHeight = `${at.maxHeight}px`;
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
|
-
const width = Math.min(widest, win.innerWidth - 32);
|
|
122
|
+
const width = Math.min(typeof widest === "function" ? widest() : widest, win.innerWidth - 32);
|
|
122
123
|
pop.style.width = `${width}px`;
|
|
123
124
|
pop.style.maxHeight = "";
|
|
124
125
|
const at = popoverPlace(shownAnchor(anchor, doc).getBoundingClientRect(), { width, height: pop.offsetHeight,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A link to a claim (docs/internals/participants.md, Deep links): one turn
|
|
2
2
|
// of a session and a quote in it, on either page.
|
|
3
3
|
//
|
|
4
|
-
// participant page
|
|
4
|
+
// participant's page:<chi web>/#s=<id>&t=<turn8>&q=<quote>&p=<prefix>
|
|
5
5
|
// owner's page: #/s/<id>?t=<turn8>&q=<quote>&p=<prefix>
|
|
6
6
|
//
|
|
7
7
|
// t is the turn's id, its first 8 characters (a turn-opening message's
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// when there are none). URLSearchParams encodes both, so a link is
|
|
12
12
|
// URL-safe and a space is one "+".
|
|
13
13
|
//
|
|
14
|
-
// Normalized: whitespace collapsed, and what
|
|
14
|
+
// Normalized: whitespace collapsed, and what a participant's page shows
|
|
15
15
|
// instead (Samagotchi::Redact): secret shapes "[redacted]" (so a link
|
|
16
16
|
// never carries one, and matches the participant's redacted text), and on
|
|
17
17
|
// the owner's page the session's folder relative ("<cwd>/x" → "x",
|
|
@@ -85,7 +85,7 @@ function secretSpans(raw) {
|
|
|
85
85
|
return spans;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
// The spans of +raw+ that read differently on
|
|
88
|
+
// The spans of +raw+ that read differently on a participant's page:
|
|
89
89
|
// [{start, end, text}], in order, not overlapping. Secrets first, then
|
|
90
90
|
// the session's folder (it is usually under home), as Redact.text.
|
|
91
91
|
function replacements(raw, { home = "", cwd = "" } = {}) {
|
|
@@ -191,7 +191,7 @@ export function claimParams({ turnId = "", q = "", p = "" } = {}) {
|
|
|
191
191
|
return params.toString();
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
//
|
|
194
|
+
// A participant's page's link: +base+ the participant link's origin
|
|
195
195
|
// ("https://chi.example/", "http://192.168.1.5:4567/"), no token.
|
|
196
196
|
export function participantClaimLink(base, sessionId, claim) {
|
|
197
197
|
const params = claimParams(claim);
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/* The composer (composer_mount.js): the message box, its image chips, grip and fold, its key hint and its toolbar row
|
|
2
|
-
(the image button, Send).
|
|
3
|
-
linked after tokens.css and before a page's own <style>, so a page's rules of the same weight win. The owner's
|
|
2
|
+
(the image button, Send). Linked by index.html after tokens.css and before a page's own <style>, so a page's rules of the same weight win. The owner's
|
|
4
3
|
own parts stay in index.html: the card's placing (#dock), the delivery line's links, the start page's picker and chips,
|
|
5
4
|
the / list, and the 16px text fields for iOS. */
|
|
6
5
|
/* The image button's icon mask (the stroke only shapes the mask; the icon takes currentColor); index.html's phone info
|
|
7
6
|
bar and all view's cards use it too. */
|
|
8
7
|
:root{--icon-toolkit:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1.75' y='5.25' width='12.5' height='8' rx='1.5'/%3E%3Cpath d='M5.75 5.25v-1.5a1 1 0 0 1 1-1h2.5a1 1 0 0 1 1 1v1.5M1.75 8.75h12.5M7 8.75v1.5h2v-1.5'/%3E%3C/svg%3E");--icon-settings:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M12.75 6.14L14.45 6.59L14.45 9.41L12.75 9.86L12.67 10.04L13.56 11.56L11.56 13.56L10.04 12.67L9.86 12.75L9.41 14.45L6.59 14.45L6.14 12.75L5.96 12.67L4.44 13.56L2.44 11.56L3.33 10.04L3.25 9.86L1.55 9.41L1.55 6.59L3.25 6.14L3.33 5.96L2.44 4.44L4.44 2.44L5.96 3.33L6.14 3.25L6.59 1.55L9.41 1.55L9.86 3.25L10.04 3.33L11.56 2.44L13.56 4.44L12.67 5.96Z'/%3E%3Ccircle cx='8' cy='8' r='2.1'/%3E%3C/svg%3E");--icon-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='10.5' rx='1.5'/%3E%3Ccircle cx='5.75' cy='6.25' r='1.1'/%3E%3Cpath d='m2.5 12.5 3.75-3.75 2.5 2.5 1.75-1.75 3 3'/%3E%3C/svg%3E")}
|
|
9
|
-
/* The composer card: the glass card
|
|
10
|
-
participant
|
|
11
|
-
|
|
12
|
-
participant's key hint). A page's own rules only place the card. */
|
|
8
|
+
/* The composer card: the glass card the composer sits in (#dock, the stage view's .dock-card), with its focus ring;
|
|
9
|
+
its footer (the info bar, a participant's bottom row) under a hairline; and the composer's line, the quiet row above
|
|
10
|
+
the text field (the delivery line). A page's own rules only place the card. */
|
|
13
11
|
.composer-card{display:flex;flex-direction:column;border-radius:16px;position:relative;background:var(--glass-bg);-webkit-backdrop-filter:blur(18px) saturate(1.35);backdrop-filter:blur(18px) saturate(1.35);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-highlight),var(--glass-shadow);transition:border-color .12s ease,box-shadow .12s ease}
|
|
14
12
|
.composer-card:focus-within{border-color:color-mix(in srgb,var(--accent) 70%,transparent);box-shadow:0 0 0 3px var(--accent-ring),var(--glass-shadow)}
|
|
15
13
|
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.composer-card{background:var(--bg-panel)}}
|
|
@@ -15,12 +15,15 @@ export const SEND_HINT = "Enter to send · Shift+Enter for a newline · ↑ hist
|
|
|
15
15
|
// start page), +owner+ its owner, +running+ whether its turn runs, +narrow+ a
|
|
16
16
|
// phone's width. While a turn runs, Send still sends: the prompt merges into
|
|
17
17
|
// the turn at its next step (steering); Cancel is its own button then.
|
|
18
|
+
// +steers+ false: a message sent now doesn't go into the running turn (a
|
|
19
|
+
// participant's into someone else's): the plain placeholder, the delivery
|
|
20
|
+
// line says where it goes.
|
|
18
21
|
// @return {placeholder, hint, button, disabled, empty, clearHistory,
|
|
19
22
|
// attachHidden, delivery}: +disabled+ undefined while a turn runs (the
|
|
20
23
|
// button keeps whatever a send in flight set); +empty+ the start page's
|
|
21
24
|
// empty state shown, +clearHistory+ #history emptied (the start page only);
|
|
22
25
|
// +delivery+ the delivery line's mode (delivery_line.js show).
|
|
23
|
-
export function composerMode({ selected, owner, running, narrow }) {
|
|
26
|
+
export function composerMode({ selected, owner, running, narrow, steers = true }) {
|
|
24
27
|
const session = !!selected;
|
|
25
28
|
const tui = session && owner === "tui";
|
|
26
29
|
const live = !!running && session;
|
|
@@ -34,7 +37,7 @@ export function composerMode({ selected, owner, running, narrow }) {
|
|
|
34
37
|
// composer is off, so is its row.
|
|
35
38
|
const delivery = !session || tui ? "off" : running ? "running" : "idle";
|
|
36
39
|
const base = { attachHidden, delivery, empty: false, clearHistory: false };
|
|
37
|
-
if (live) {
|
|
40
|
+
if (live && steers) {
|
|
38
41
|
return {
|
|
39
42
|
...base,
|
|
40
43
|
placeholder: pick("Running… a message goes in at the next step · Enter to send · Alt+Enter queues", "Steer the turn…"),
|
|
@@ -56,7 +59,7 @@ export function composerMode({ selected, owner, running, narrow }) {
|
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
// The keys are in the delivery line's row above.
|
|
59
|
-
return { ...base, placeholder: "Message chi…", hint: SEND_HINT, button: "Send", disabled: false };
|
|
62
|
+
return { ...base, placeholder: "Message chi…", hint: SEND_HINT, button: "Send", disabled: live ? undefined : false };
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
// The composer's mode drawn: update() is the store's `composer` redraw, and a
|
|
@@ -68,9 +71,10 @@ export function composerMode({ selected, owner, running, narrow }) {
|
|
|
68
71
|
// live_turn.js's (running). +startPage+: start_page.js's (restoreStartPick,
|
|
69
72
|
// syncModelPick, dropChoices). +deliveryControl+: delivery_line.js's.
|
|
70
73
|
// +fitPrompt()+,
|
|
71
|
-
// +placeToast()+: the page's. +win+: the window (matchMedia).
|
|
74
|
+
// +placeToast()+: the page's. +win+: the window (matchMedia). +steers()+:
|
|
75
|
+
// whether a message now goes into the running turn (composerMode's).
|
|
72
76
|
export function createComposerMode({
|
|
73
|
-
els, store, liveTurn, startPage, deliveryControl, fitPrompt, placeToast, win = globalThis,
|
|
77
|
+
els, store, liveTurn, startPage, deliveryControl, fitPrompt, placeToast, win = globalThis, steers = () => true,
|
|
74
78
|
}) {
|
|
75
79
|
const narrowScreen = win.matchMedia(NARROW_QUERY);
|
|
76
80
|
let hadSession = false;
|
|
@@ -89,8 +93,9 @@ export function createComposerMode({
|
|
|
89
93
|
if (store.selected) startPage.dropChoices();
|
|
90
94
|
const mode = composerMode({
|
|
91
95
|
selected: store.selected, owner: store.current.owner, running: liveTurn.running, narrow: narrowScreen.matches,
|
|
96
|
+
steers: steers(),
|
|
92
97
|
});
|
|
93
|
-
els.attach.hidden = mode.attachHidden;
|
|
98
|
+
if (els.attach) els.attach.hidden = mode.attachHidden;
|
|
94
99
|
deliveryControl.show(mode.delivery);
|
|
95
100
|
els.prompt.placeholder = mode.placeholder;
|
|
96
101
|
els.hint.textContent = mode.hint;
|
|
@@ -14,14 +14,14 @@ import { readStored } from "./storage.js";
|
|
|
14
14
|
//
|
|
15
15
|
// +els+: {composer (the card's box, where files drop), prompt (the text box),
|
|
16
16
|
// button (Send/Start), chips (the chips' row), attachBtn, attachInput (the
|
|
17
|
-
// hidden file picker), grip}.
|
|
17
|
+
// hidden file picker; both null: no image button, viewer.js), grip}.
|
|
18
18
|
// Hooks: +minPx()+ the empty box's height; +toast(text)+ why images stayed
|
|
19
19
|
// out; +onWrite()+ the composer wrote the text itself (a recalled entry);
|
|
20
20
|
// +loadHistory()+ a promise of the ↑/↓ entries (oldest first; none: no
|
|
21
21
|
// history); +send({queue})+ Enter (+queue+: with Alt/Option) or the button;
|
|
22
22
|
// +keyFirst(e)+ a key the page takes before the history's (true: taken);
|
|
23
23
|
// +escape()+ Esc, true when it let go of something. +imagesOff+: why this
|
|
24
|
-
// page takes no images (
|
|
24
|
+
// page takes no images (a participant's page, until its upload path): a
|
|
25
25
|
// paste, drop or pick of one toasts it and adds no chip; null takes them.
|
|
26
26
|
// +fold+: createComposerGrip's page hooks (session, waiting, allViewOpen,
|
|
27
27
|
// lightboxOpen, infoBarEl, typeAnywhere).
|
|
@@ -79,8 +79,8 @@ export function mountComposer({
|
|
|
79
79
|
});
|
|
80
80
|
// The image button: the file picker's images join the chips. Its value is
|
|
81
81
|
// cleared after each pick, so the same file can be picked again.
|
|
82
|
-
attachBtn
|
|
83
|
-
attachInput
|
|
82
|
+
attachBtn?.addEventListener("click", () => attachInput.click());
|
|
83
|
+
attachInput?.addEventListener("change", () => {
|
|
84
84
|
addImageFiles([...attachInput.files]);
|
|
85
85
|
attachInput.value = "";
|
|
86
86
|
});
|
|
@@ -124,10 +124,14 @@ export function ctxBarText(pct, windowSource = null) {
|
|
|
124
124
|
// page isn't told context.status is off, so "?" never means 0); after one,
|
|
125
125
|
// "Context window unknown" over the session's tokens and per-model rows with
|
|
126
126
|
// no window line (a window lookup that failed; a model list without a context
|
|
127
|
-
// length still falls back to context.window_tokens or chi's default)
|
|
127
|
+
// length still falls back to context.window_tokens or chi's default), or,
|
|
128
|
+
// when the window is known but no count has come yet, "No context count yet:
|
|
129
|
+
// the next request counts it". +window.afterSwitch+ (the info
|
|
128
130
|
// bar's; a /model whose new window didn't resolve, no request since:
|
|
129
131
|
// Engine#announce_switched_context! sent usage null) adds "until the next
|
|
130
132
|
// request", which asks for it again.
|
|
133
|
+
// +window.running+ (the info bar's own running flag) makes the title of a
|
|
134
|
+
// turn in flight: "Context in use (this turn so far)".
|
|
131
135
|
// +side+ (the timing's side block) adds the side requests' line, in the
|
|
132
136
|
// "No request in this session yet" answer too (a /btw before any turn).
|
|
133
137
|
export function ctxBarTip(tokens, memoryIndex, window, segments = null, side = null) {
|
|
@@ -136,11 +140,16 @@ export function ctxBarTip(tokens, memoryIndex, window, segments = null, side = n
|
|
|
136
140
|
const sideText = sideRequestsText(side);
|
|
137
141
|
return `No request in this session yet${sideText ? `\nside requests: ${sideText}` : ""}`;
|
|
138
142
|
}
|
|
139
|
-
const why = window?.afterSwitch
|
|
143
|
+
const why = window?.afterSwitch
|
|
144
|
+
? "Context window unknown until the next request"
|
|
145
|
+
: num(window?.tokens) > 0
|
|
146
|
+
? "No context count yet: the next request counts it"
|
|
147
|
+
: "Context window unknown";
|
|
140
148
|
return tokensTipText(tokens, why, memoryIndex, null, segments, side);
|
|
141
149
|
}
|
|
142
150
|
|
|
143
|
-
return tokensTipText(tokens,
|
|
151
|
+
return tokensTipText(tokens, window?.running ? "Context in use (this turn so far)" : undefined,
|
|
152
|
+
memoryIndex, window, segments, side);
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
// The ctx tooltip's window line ({tokens:, source:, pct:, budget:} the
|
|
@@ -60,11 +60,9 @@ export function listSessions(sort, order, { dir, ...opts } = {}) {
|
|
|
60
60
|
// start page's ⚙ panel set some; thinking: its own level ("low"), when the
|
|
61
61
|
// start page's ⚙ panel set one; toolkit: the kit it starts on, when the
|
|
62
62
|
// start page's 🧰 list picked one (none: config's default, maybe suggested).
|
|
63
|
-
// review: {subjects} makes it a review session (it starts idle; no preview).
|
|
64
63
|
// The other fields are api()'s fetch options.
|
|
65
|
-
export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit,
|
|
66
|
-
|
|
67
|
-
const start = review ? { review } : { idle: true, ...(preview ? { preview } : {}) };
|
|
64
|
+
export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit, ...opts } = {}) {
|
|
65
|
+
const start = { idle: true, ...(preview ? { preview } : {}) };
|
|
68
66
|
const body = { ...start, ...(dir ? { dir } : {}), ...(model ? { model } : {}),
|
|
69
67
|
...(llmContext ? { llm_context: llmContext } : {}), ...(thinking ? { thinking } : {}),
|
|
70
68
|
...(toolkit ? { toolkit } : {}) };
|
|
@@ -80,12 +78,6 @@ export function continueSession(id, opts = {}) {
|
|
|
80
78
|
return api("/api/sessions", { method: "POST", body: JSON.stringify({ continues: id, idle: true }), ...opts });
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
// A review fork of +id+ (docs/sessions.md, Review sessions): a new session in
|
|
84
|
-
// its folder, seeded with its recap, not its transcript; +id+ keeps running.
|
|
85
|
-
export function startReview(id, opts = {}) {
|
|
86
|
-
return api("/api/sessions", { method: "POST", body: JSON.stringify({ review: { from: id } }), ...opts });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
81
|
// The models a new session can start on: {default, models: [{name, host, id}],
|
|
90
82
|
// warning?} (a host that failed is in the warning, the list has the rest).
|
|
91
83
|
export function listModels(opts = {}) {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// and offers the other two deliveries as links (a phone has no row: idle
|
|
6
6
|
// the line is gone; running it lies over the session bar's left, where
|
|
7
7
|
// status, ctx and speed are, only while it matters: the text field focused
|
|
8
|
-
// or holding text or images, a choice armed
|
|
9
|
-
//
|
|
8
|
+
// or holding text or images, or a choice armed, the last written here as
|
|
9
|
+
// data-armed; index.html):
|
|
10
10
|
//
|
|
11
11
|
// ↳ goes in after this thinking step · 2:31 · 31k chars cut in now · queue for after the turn
|
|
12
12
|
// ↳ goes in after this tool call (execute · 0:12) queue for after the turn
|
|
@@ -19,16 +19,15 @@
|
|
|
19
19
|
// composer arms its choice for the next Enter; Esc or a second click
|
|
20
20
|
// disarms it.
|
|
21
21
|
//
|
|
22
|
-
//
|
|
23
|
-
// never a steer into the running one (that may be a participant's
|
|
24
|
-
// read-only review turn): while the composer holds it (hold(), till it is
|
|
25
|
-
// sent, emptied or Esc'd) Enter queues it, and the line says so.
|
|
26
|
-
//
|
|
27
|
-
// While a participant's turn runs (a review turn, or a working session's
|
|
28
|
-
// pair turn), the worker queues the owner's input behind it whatever it
|
|
22
|
+
// While a participant's turn runs, the worker queues the owner's input behind it whatever it
|
|
29
23
|
// asks (never a steer or a cut into their turn): Enter queues, no cut is
|
|
30
24
|
// offered, and the line says so.
|
|
31
25
|
//
|
|
26
|
+
// A participant looking (the participant main page: +viewerTurn+) gets no
|
|
27
|
+
// cut and no links: in their own turn the message goes in at its next step
|
|
28
|
+
// (Alt+Enter queues it), on a worker that takes it; in anyone else's it
|
|
29
|
+
// runs as their own turn afterwards (the worker queues it).
|
|
30
|
+
//
|
|
32
31
|
// deliveryLine is pure (node tests); deliveryLineTemplate is its lit view.
|
|
33
32
|
import { html, nothing, render } from "./vendor/lit-html.js";
|
|
34
33
|
|
|
@@ -41,17 +40,20 @@ const CUT_SHORT = "cut in";
|
|
|
41
40
|
// would steer it), the text kept, this said.
|
|
42
41
|
export const QUEUE_NEEDS_WORKER = "Not sent: queueing needs a newer worker (it would steer the running turn). "
|
|
43
42
|
+ "Restart it (chi sessions restart ID, or the update badge), then send again.";
|
|
44
|
-
// The line while
|
|
45
|
-
export const APPLY_QUEUES = "your Apply turn queues for after this turn · Esc to steer it in instead";
|
|
46
|
-
export const APPLY_QUEUES_SHORT = "Apply: queued after the turn";
|
|
47
|
-
// The same to a worker without the delivery feature: Enter refuses it.
|
|
48
|
-
export const APPLY_CANT_QUEUE = "your Apply turn can't queue on this worker (restart it) · Esc to steer it in instead";
|
|
49
|
-
// The line while a participant's turn runs (the worker queues), whichever
|
|
50
|
-
// mode: review or pair.
|
|
43
|
+
// The line while a participant's turn runs (the worker queues).
|
|
51
44
|
export const PARTICIPANT_TURN_QUEUES = "goes in as your own turn after this participant's turn";
|
|
52
45
|
export const PARTICIPANT_TURN_QUEUES_SHORT = "after their turn";
|
|
46
|
+
// A participant's line: their own turn, the owner's, another participant's.
|
|
47
|
+
export const OWN_TURN_STEERS = "goes in at the next step · Alt+Enter keeps it for after the turn";
|
|
48
|
+
export const OWN_TURN_STEERS_SHORT = "goes in at the next step";
|
|
49
|
+
export const OWN_TURN_QUEUES = "goes in as your own turn after this one";
|
|
50
|
+
export const AFTER_OWNER = "Your message goes in as your own turn after the owner's";
|
|
51
|
+
export const afterTheirs = (name) => `Your message goes in as your own turn after ${name}'s`;
|
|
52
|
+
export const AFTER_SHORT = "after this turn";
|
|
53
53
|
// The idle row: the keys (the placeholder's hint before the row existed).
|
|
54
54
|
export const IDLE_HINT = "Enter to send · Shift+Enter newline · ↑ history";
|
|
55
|
+
// The same for a viewer without the prompt history (a participant).
|
|
56
|
+
export const IDLE_HINT_NO_HISTORY = "Enter to send · Shift+Enter newline";
|
|
55
57
|
|
|
56
58
|
// m:ss (h:mm:ss past an hour) of +seconds+; "" when unknown.
|
|
57
59
|
export function clockText(seconds) {
|
|
@@ -102,10 +104,11 @@ function thinkingOnly(gen, serverGen) {
|
|
|
102
104
|
// armed "cut" | "queue" | null: the choice the next Enter sends
|
|
103
105
|
// canQueue the worker takes delivery: queue (its "delivery" feature)
|
|
104
106
|
// model the session's model, for the cut-off reason
|
|
105
|
-
// held the composer holds an Apply turn: Enter queues it (an armed
|
|
106
|
-
// cut still wins)
|
|
107
107
|
// participantTurn the running turn is a participant's: Enter queues,
|
|
108
108
|
// no cut (the worker queues the owner's input behind it)
|
|
109
|
+
// viewerTurn a participant looks: {own, steer, by} (their own turn, it
|
|
110
|
+
// takes their message at its next step, its author's name or
|
|
111
|
+
// null for the owner's); null on the owner's page
|
|
109
112
|
// → {text, short, cut: {enabled, shown, reason, label, short}, queue:
|
|
110
113
|
// {enabled, shown, label, short}, armed, enter}: short is the phone's text;
|
|
111
114
|
// armed is what is still armed (a cut no longer possible disarms); enter
|
|
@@ -113,7 +116,8 @@ function thinkingOnly(gen, serverGen) {
|
|
|
113
116
|
// cutting off the cut link goes (the text says why); without the
|
|
114
117
|
// feature the queue link goes.
|
|
115
118
|
export function deliveryLine({ phase = "thinking", gen = null, tool = null, cutAfter = null, serverGen = null, now = Date.now(),
|
|
116
|
-
armed = null, canQueue = true, model = "",
|
|
119
|
+
armed = null, canQueue = true, model = "", participantTurn = false, viewerTurn = null } = {}) {
|
|
120
|
+
if (viewerTurn) return viewerLine(viewerTurn);
|
|
117
121
|
const cutOff = cutAfter === 0 || (cutAfter != null && cutAfter < 0);
|
|
118
122
|
const thinking = phase === "thinking" && thinkingOnly(gen, serverGen);
|
|
119
123
|
const age = genAge(gen, serverGen, now);
|
|
@@ -146,16 +150,10 @@ export function deliveryLine({ phase = "thinking", gen = null, tool = null, cutA
|
|
|
146
150
|
let wait = "";
|
|
147
151
|
if (cutEnabled && cutAfter > 0 && age != null && age < cutAfter) wait = `cuts at about ${clockText(cutAfter)} if you choose ${CUT_LABEL}`;
|
|
148
152
|
const effective = (armed === "cut" && cutEnabled) || (armed === "queue" && canQueue) ? armed : null;
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const enter = effective || (applies && canQueue ? "queue" : null);
|
|
152
|
-
let parts = [cutOff ? reason : "", where, wait].filter(Boolean);
|
|
153
|
+
const enter = effective;
|
|
154
|
+
const parts = [cutOff ? reason : "", where, wait].filter(Boolean);
|
|
153
155
|
// A phone's short row leaves it out: its ticked chip says it.
|
|
154
156
|
if (effective) parts.push("Enter sends");
|
|
155
|
-
if (applies) {
|
|
156
|
-
parts = [canQueue ? APPLY_QUEUES : APPLY_CANT_QUEUE];
|
|
157
|
-
if (canQueue) short = APPLY_QUEUES_SHORT;
|
|
158
|
-
}
|
|
159
157
|
if (participantTurn) {
|
|
160
158
|
return {
|
|
161
159
|
text: `\u21B3 ${PARTICIPANT_TURN_QUEUES}`,
|
|
@@ -177,6 +175,16 @@ export function deliveryLine({ phase = "thinking", gen = null, tool = null, cutA
|
|
|
177
175
|
};
|
|
178
176
|
}
|
|
179
177
|
|
|
178
|
+
// A participant's line (deliveryLine's +viewerTurn+): no links; Enter
|
|
179
|
+
// steers only into their own turn on a worker that takes it.
|
|
180
|
+
function viewerLine({ own = false, steer = false, by = null } = {}) {
|
|
181
|
+
const none = { enabled: false, shown: false, reason: "", label: QUEUE_LABEL, short: QUEUE_SHORT };
|
|
182
|
+
const line = (text, short, enter) => ({ text, short, cut: { ...none, label: CUT_LABEL, short: CUT_SHORT }, queue: none, armed: null, enter });
|
|
183
|
+
if (own && steer) return line(`\u21B3 ${OWN_TURN_STEERS}`, `\u21B3 ${OWN_TURN_STEERS_SHORT}`, null);
|
|
184
|
+
if (own) return line(`\u21B3 ${OWN_TURN_QUEUES}`, `\u21B3 ${AFTER_SHORT}`, "queue");
|
|
185
|
+
return line(by ? afterTheirs(by) : AFTER_OWNER, `\u21B3 after ${by ? `${by}'s` : "the owner's"} turn`, "queue");
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
// The line's view: +line+ is deliveryLine's; +onCut+ / +onQueue+ the
|
|
181
189
|
// links' clicks. A disabled cut stays in place, its reason on hover.
|
|
182
190
|
export function deliveryLineTemplate(line, { onCut, onQueue } = {}) {
|
|
@@ -191,8 +199,8 @@ export function deliveryLineTemplate(line, { onCut, onQueue } = {}) {
|
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
// The idle row: the key hint (none on a phone: no keyboard keys there).
|
|
194
|
-
function idleTemplate() {
|
|
195
|
-
return html`<span class="delivery-where idle"><span class="long">${
|
|
202
|
+
function idleTemplate(hint = IDLE_HINT) {
|
|
203
|
+
return html`<span class="delivery-where idle"><span class="long">${hint}</span><span class="short"></span></span>`;
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
// The row on the page: the key hint while idle, the line while the turn
|
|
@@ -202,16 +210,14 @@ function idleTemplate() {
|
|
|
202
210
|
// phase, gen, tool, cutAfter, serverGen, canQueue, model)
|
|
203
211
|
// composerEmpty() nothing typed and no image chips: a link arms
|
|
204
212
|
// send(delivery) send the composer's line with +delivery+ ("cut", "queue")
|
|
205
|
-
// session() the open session's id: an Apply hold is that session's
|
|
206
213
|
const TICK_MS = 500;
|
|
207
214
|
|
|
208
|
-
|
|
215
|
+
// +history+: the viewer walks a prompt history with ↑ (the idle hint says so).
|
|
216
|
+
export function createDeliveryControl({ el, read, composerEmpty, send, now = () => Date.now(), history = true,
|
|
209
217
|
setTimer = (fn, ms) => setInterval(fn, ms), clearTimer = (t) => clearInterval(t) }) {
|
|
210
218
|
// "off" (no session: the row is gone), "idle" or "running".
|
|
211
219
|
let mode = "off";
|
|
212
220
|
let armed = null;
|
|
213
|
-
// The session whose Apply turn the composer holds, or null.
|
|
214
|
-
let heldFor = null;
|
|
215
221
|
let timer = null;
|
|
216
222
|
let line = null;
|
|
217
223
|
|
|
@@ -227,30 +233,26 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
|
|
|
227
233
|
refresh();
|
|
228
234
|
};
|
|
229
235
|
|
|
230
|
-
// For a phone's CSS (index.html): whether a choice is armed
|
|
231
|
-
// turn
|
|
232
|
-
//
|
|
233
|
-
// armed.
|
|
236
|
+
// For a phone's CSS (index.html): whether a choice is armed while the
|
|
237
|
+
// turn runs ("1" or ""): the line shows then. Not the queue chip's
|
|
238
|
+
// pressed look: a participant's turn draws it with nothing armed.
|
|
234
239
|
const mark = () => {
|
|
235
240
|
el.dataset.armed = mode === "running" && armed ? "1" : "";
|
|
236
|
-
el.dataset.held = mode === "running" && held() ? "1" : "";
|
|
237
241
|
};
|
|
238
242
|
|
|
239
243
|
function refresh() {
|
|
240
244
|
if (mode !== "running") {
|
|
241
245
|
mark();
|
|
242
|
-
if (mode === "idle") render(idleTemplate(), el);
|
|
246
|
+
if (mode === "idle") render(idleTemplate(history ? IDLE_HINT : IDLE_HINT_NO_HISTORY), el);
|
|
243
247
|
return;
|
|
244
248
|
}
|
|
245
|
-
line = deliveryLine({ ...read(), now: now(), armed
|
|
249
|
+
line = deliveryLine({ ...read(), now: now(), armed });
|
|
246
250
|
// A choice no longer possible (a tool started) disarms.
|
|
247
251
|
armed = line.armed;
|
|
248
252
|
mark();
|
|
249
253
|
render(deliveryLineTemplate(line, { onCut: () => click("cut"), onQueue: () => click("queue") }), el);
|
|
250
254
|
}
|
|
251
255
|
|
|
252
|
-
const held = () => heldFor != null && heldFor === session();
|
|
253
|
-
|
|
254
256
|
return {
|
|
255
257
|
// +next+: "off", "idle" or "running".
|
|
256
258
|
show(next) {
|
|
@@ -271,36 +273,20 @@ export function createDeliveryControl({ el, read, composerEmpty, send, session =
|
|
|
271
273
|
refresh,
|
|
272
274
|
click,
|
|
273
275
|
armed: () => armed,
|
|
274
|
-
// The composer holds an Apply turn (of the open session): Enter queues it.
|
|
275
|
-
hold() {
|
|
276
|
-
heldFor = session();
|
|
277
|
-
refresh();
|
|
278
|
-
},
|
|
279
|
-
held,
|
|
280
|
-
// The composer let it go (emptied).
|
|
281
|
-
release() {
|
|
282
|
-
if (heldFor == null) return;
|
|
283
|
-
heldFor = null;
|
|
284
|
-
refresh();
|
|
285
|
-
},
|
|
286
276
|
// What this send goes in as while the turn runs ("cut", "queue" or
|
|
287
|
-
// null), the armed choice
|
|
288
|
-
// line's word on it (it knows the worker can queue); idle, none.
|
|
277
|
+
// null), the armed choice let go; idle, none.
|
|
289
278
|
take() {
|
|
290
279
|
const was = mode === "running" && line ? line.enter : armed;
|
|
291
|
-
if (armed
|
|
280
|
+
if (armed) {
|
|
292
281
|
armed = null;
|
|
293
|
-
heldFor = null;
|
|
294
282
|
refresh();
|
|
295
283
|
}
|
|
296
284
|
return was || null;
|
|
297
285
|
},
|
|
298
|
-
// Esc: the armed choice goes
|
|
299
|
-
// (Enter then steers it in).
|
|
286
|
+
// Esc: the armed choice goes.
|
|
300
287
|
disarm() {
|
|
301
|
-
if (armed)
|
|
302
|
-
|
|
303
|
-
else return false;
|
|
288
|
+
if (!armed) return false;
|
|
289
|
+
armed = null;
|
|
304
290
|
refresh();
|
|
305
291
|
return true;
|
|
306
292
|
},
|
|
@@ -88,7 +88,11 @@ function rowItem(el) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function cardItem(el) {
|
|
91
|
-
|
|
91
|
+
const card = item("card", `${el.dataset.cardId || ""} ${textOf(el.querySelector(".card-title"))}`.trim());
|
|
92
|
+
// Its id on its own (already in the text): the reload check keeps a turn's
|
|
93
|
+
// own cards by it and drops the rest (reload_check.js).
|
|
94
|
+
card.id = el.dataset.cardId || "";
|
|
95
|
+
return card;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
function questionItem(el) {
|
|
@@ -19,6 +19,9 @@ export function imageFiles(dataTransfer) {
|
|
|
19
19
|
// would (spec/web/images_spec.rb pins both): ImageStore::MAX_TURN_REFS
|
|
20
20
|
// images a message, Web::App::MAX_IMAGE_UPLOAD_BYTES a file.
|
|
21
21
|
export const MAX_TURN_IMAGES = 20;
|
|
22
|
+
// Why the composer takes no image (composer_mount.js imagesOff) for a viewer
|
|
23
|
+
// without images (viewer.js): a paste, drop or pick toasts it.
|
|
24
|
+
export const IMAGES_NOT_HERE = "Images can't go in from here yet: describe what the image shows.";
|
|
22
25
|
export const MAX_IMAGE_MB = 20;
|
|
23
26
|
const MAX_IMAGE_BYTES = MAX_IMAGE_MB * 1024 * 1024;
|
|
24
27
|
|
|
@@ -75,8 +78,11 @@ export function imageUrl(sessionId, ref) {
|
|
|
75
78
|
|
|
76
79
|
// Thumbnails for a bubble or a tool row; nothing for none. `src` may be
|
|
77
80
|
// given (a blob: URL while the upload is on its way). A redraw with the
|
|
78
|
-
// same images keeps the <img> elements (no reload).
|
|
81
|
+
// same images keeps the <img> elements (no reload). A number is a count of
|
|
82
|
+
// images the viewer gets no refs to (another participant's: chi web's
|
|
83
|
+
// ParticipantView): a muted "N images" line instead.
|
|
79
84
|
export function thumbsTemplate(sessionId, images) {
|
|
85
|
+
if (typeof images === "number") return images > 0 ? html`<div class="thumbs-hidden">${images === 1 ? "1 image" : `${images} images`}</div>` : nothing;
|
|
80
86
|
const list = (images || []).filter((i) => i && (i.src || i.file));
|
|
81
87
|
if (!list.length) return nothing;
|
|
82
88
|
const thumbs = list.map((img) => {
|