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
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
// a reload agree whatever order the replay brings them in. One docked card
|
|
26
26
|
// shows at a time (+shown+: the one the pager is on, else the first). The
|
|
27
27
|
// fold (the docked card's own, stage_asking.js) is the folded card's key and
|
|
28
|
-
// how many cards waited when it was folded.
|
|
28
|
+
// how many cards waited when it was folded. That fold is this tab's own: it
|
|
29
|
+
// is kept in sessionStorage (one entry per session) so a reload or a resync
|
|
30
|
+
// mid-turn draws the card as the user left it, and it goes when the card is
|
|
31
|
+
// answered or cancelled, when the fold drops, and when the turn hands off.
|
|
29
32
|
import { ASKS, PENDING, WARN_CARD } from "./stage_cards.js";
|
|
33
|
+
import { readSession, removeSession, writeSession } from "./storage.js";
|
|
30
34
|
|
|
31
35
|
// The kinds: what blocks the turn (BLOCKING), a running turn's card with
|
|
32
36
|
// actions (check-in: "asks"), a plugin's warning ("warn": stays in sight,
|
|
@@ -46,6 +50,20 @@ export const CONTINUE_KEY = "continue";
|
|
|
46
50
|
export const questionKey = (qid) => (qid == null ? null : `q:${qid}`);
|
|
47
51
|
export const pluginCardKey = (id) => (id == null || id === "" ? null : `c:${id}`);
|
|
48
52
|
|
|
53
|
+
// The asking card's fold, kept for this tab (docs/internals/web-frontend.md
|
|
54
|
+
// Storage keys): one entry per session, JSON {key, with}.
|
|
55
|
+
export const FOLD_PREFIX = "chi_asking_fold:";
|
|
56
|
+
export const foldKey = (sessionId) => (sessionId ? `${FOLD_PREFIX}${sessionId}` : null);
|
|
57
|
+
|
|
58
|
+
// The fold's storage: the guarded sessionStorage (storage.js); the specs
|
|
59
|
+
// inject their own, so one test's fold is not another's (they all use session
|
|
60
|
+
// s1 and the same question ids).
|
|
61
|
+
const tabStorage = {
|
|
62
|
+
read: (key) => readSession(key),
|
|
63
|
+
write: (key, value) => writeSession(key, value),
|
|
64
|
+
remove: (key) => removeSession(key),
|
|
65
|
+
};
|
|
66
|
+
|
|
49
67
|
// +el+'s key, null: not a card the stage keeps.
|
|
50
68
|
export function waitingKey(el) {
|
|
51
69
|
if (!el?.matches) return null;
|
|
@@ -79,13 +97,19 @@ export function cardIn(root, key) {
|
|
|
79
97
|
// +kind+'s rank in the stage's order: blocking cards before the rest.
|
|
80
98
|
const rank = (kind) => (BLOCKING.has(kind) ? 0 : 1);
|
|
81
99
|
|
|
82
|
-
|
|
100
|
+
// +sessionId+: the open session (a getter, as app.js and the harnesses pass
|
|
101
|
+
// it); +storage+: the fold's read/write/remove, guarded (the specs inject
|
|
102
|
+
// their own).
|
|
103
|
+
export function createStageWaiting({ sessionId = null, storage = tabStorage } = {}) {
|
|
83
104
|
const cards = new Map();
|
|
84
105
|
let seq = 0;
|
|
85
106
|
let folded = null;
|
|
86
107
|
let foldedWith = 0;
|
|
87
108
|
// The docked card the pager is on (null: the first).
|
|
88
109
|
let paged = null;
|
|
110
|
+
// The key this session's fold is stored under (null: no session, nothing
|
|
111
|
+
// to keep).
|
|
112
|
+
const at = () => foldKey(typeof sessionId === "function" ? sessionId() : sessionId);
|
|
89
113
|
|
|
90
114
|
const entries = () => [...cards.entries()].sort((a, b) => rank(a[1].kind) - rank(b[1].kind) || a[1].order - b[1].order);
|
|
91
115
|
const dockedKeys = () => entries().filter(([, e]) => e.docked).map(([key]) => key);
|
|
@@ -98,6 +122,28 @@ export function createStageWaiting() {
|
|
|
98
122
|
return n;
|
|
99
123
|
}
|
|
100
124
|
|
|
125
|
+
// The fold this tab kept for the open session: {key, with}, or null (no
|
|
126
|
+
// fold, nothing stored, or storage that can't be read).
|
|
127
|
+
function storedFold() {
|
|
128
|
+
const key = at();
|
|
129
|
+
if (!key) return null;
|
|
130
|
+
try {
|
|
131
|
+
const value = JSON.parse(storage.read(key) || "null");
|
|
132
|
+
return typeof value?.key === "string" ? { key: value.key, with: Number(value.with) || 0 } : null;
|
|
133
|
+
} catch (_) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// The stored fold says what the fold is: written with the count it was
|
|
139
|
+
// made at, removed when there is no fold.
|
|
140
|
+
function keepFold() {
|
|
141
|
+
const key = at();
|
|
142
|
+
if (!key) return;
|
|
143
|
+
if (folded) storage.write(key, JSON.stringify({ key: folded, with: foldedWith }));
|
|
144
|
+
else storage.remove(key);
|
|
145
|
+
}
|
|
146
|
+
|
|
101
147
|
return {
|
|
102
148
|
// +key+ came to the stage (again: its kind and flags change, its place in
|
|
103
149
|
// the order stays).
|
|
@@ -117,7 +163,9 @@ export function createStageWaiting() {
|
|
|
117
163
|
cards.delete(key);
|
|
118
164
|
return true;
|
|
119
165
|
},
|
|
120
|
-
// The stage let its turn go: nothing waits, nothing is folded
|
|
166
|
+
// The stage let its turn go: nothing waits, nothing is folded — the
|
|
167
|
+
// stored fold stays: a resync replays the same turn, and the fold is the
|
|
168
|
+
// user's.
|
|
121
169
|
reset() {
|
|
122
170
|
cards.clear();
|
|
123
171
|
seq = 0;
|
|
@@ -161,20 +209,40 @@ export function createStageWaiting() {
|
|
|
161
209
|
// Every entry in the stage's order (the tests' and the harness's read).
|
|
162
210
|
list: () => entries().map(([key, e]) => ({ key, ...e })),
|
|
163
211
|
// The asking form's fold: +key+ folded by hand (null: unfolded), with
|
|
164
|
-
// the blocking cards that wait now.
|
|
212
|
+
// the blocking cards that wait now. Kept for this tab, so the same card
|
|
213
|
+
// is folded again after a reload or a resync.
|
|
165
214
|
fold(key) {
|
|
166
215
|
folded = key ?? null;
|
|
167
216
|
foldedWith = count();
|
|
217
|
+
keepFold();
|
|
168
218
|
},
|
|
169
219
|
// The fold as it stands with +asking+ (the asking form's card key) now:
|
|
170
220
|
// a card answered meanwhile lowers the mark, one more waiting than at
|
|
171
|
-
// the fold drops it, and so does another form. The
|
|
221
|
+
// the fold drops it, and so does another form. The replay drew the card
|
|
222
|
+
// the tab folded: with nothing folded in memory, that fold comes back.
|
|
223
|
+
// The folded key, or null.
|
|
172
224
|
trackFold(asking) {
|
|
173
225
|
const now = count();
|
|
226
|
+
// Nothing folded in memory and the replay drew the card this tab
|
|
227
|
+
// folded (a reload, or a resync mid-turn): take that fold back.
|
|
228
|
+
if (!folded) {
|
|
229
|
+
const stored = storedFold();
|
|
230
|
+
if (stored?.key === asking) { folded = stored.key; foldedWith = stored.with; }
|
|
231
|
+
}
|
|
174
232
|
foldedWith = Math.min(foldedWith, now);
|
|
175
|
-
if (folded && (folded !== asking || now > foldedWith))
|
|
233
|
+
if (folded && (folded !== asking || now > foldedWith)) {
|
|
234
|
+
folded = null;
|
|
235
|
+
// Live unfolded it: a reload must not fold it again.
|
|
236
|
+
keepFold();
|
|
237
|
+
}
|
|
176
238
|
return folded;
|
|
177
239
|
},
|
|
240
|
+
// The folded card is done for good (answered, cancelled, the turn handed
|
|
241
|
+
// off): there is no fold to bring back.
|
|
242
|
+
clearFold() {
|
|
243
|
+
const key = at();
|
|
244
|
+
if (key) storage.remove(key);
|
|
245
|
+
},
|
|
178
246
|
folded: () => folded,
|
|
179
247
|
};
|
|
180
248
|
}
|
|
@@ -17,8 +17,8 @@ import { createStartToolkit, toolkitLabel, toolkitOverride } from "./start_toolk
|
|
|
17
17
|
// default in charge. The search list itself is model_picker.js'; a pick
|
|
18
18
|
// sends the focus to the message box.
|
|
19
19
|
//
|
|
20
|
-
// Beside it, the start page's ⚙ panel (start_settings.js): thinking
|
|
21
|
-
// context
|
|
20
|
+
// Beside it, the start page's ⚙ panel (start_settings.js): thinking and LLM
|
|
21
|
+
// context, each a choice for the next new session only
|
|
22
22
|
// (sent with its create, then dropped; never remembered: a reload or opening
|
|
23
23
|
// a session drops it too, a failed create keeps it). What is set shows as
|
|
24
24
|
// override chips on the row, each opening the panel (a dot on ⚙ on a phone).
|
|
@@ -29,8 +29,8 @@ export const START_PICK_TITLE = "The model the new session starts on";
|
|
|
29
29
|
|
|
30
30
|
// Used by app.js. Elements: +pickEl+ (the picker's button), +panelEl+,
|
|
31
31
|
// +searchEl+, +listEl+, +composerEl+, +centerEl+ (model_picker.js'),
|
|
32
|
-
// +settingsEl+ (⚙), +thinkingEl+ / +llmContextEl+
|
|
33
|
-
//
|
|
32
|
+
// +settingsEl+ (⚙), +thinkingEl+ / +llmContextEl+ (the override chips),
|
|
33
|
+
// +toolkitBtnEl+ (🧰) and
|
|
34
34
|
// +toolkitEl+ (its override chip; both optional).
|
|
35
35
|
// Hooks: +selected()+ the open session's id or null; +state()+ the open
|
|
36
36
|
// session's fields (session_state.js: model, continues…); +running()+ a turn
|
|
@@ -38,7 +38,7 @@ export const START_PICK_TITLE = "The model the new session starts on";
|
|
|
38
38
|
// (resolves true once the worker took it); +focusPrompt()+; +toast(text)+;
|
|
39
39
|
// +listModels()+ GET /api/models (data.js). +win+: the page's unload events.
|
|
40
40
|
export function createStartPage({
|
|
41
|
-
pickEl, panelEl, searchEl, listEl, composerEl, centerEl, settingsEl, llmContextEl, thinkingEl,
|
|
41
|
+
pickEl, panelEl, searchEl, listEl, composerEl, centerEl, settingsEl, llmContextEl, thinkingEl,
|
|
42
42
|
toolkitBtnEl = null, toolkitEl = null,
|
|
43
43
|
selected, state, running, sessions, run, focusPrompt, toast, listModels,
|
|
44
44
|
doc = globalThis.document, win = globalThis.window,
|
|
@@ -46,8 +46,6 @@ export function createStartPage({
|
|
|
46
46
|
// The new session's own choices (null: follow the picked model's).
|
|
47
47
|
let newChatLlmContext = null;
|
|
48
48
|
let newChatThinking = null;
|
|
49
|
-
// The files that make the new session a review session ([]: an ordinary one).
|
|
50
|
-
let newChatReview = [];
|
|
51
49
|
// The kit the new session starts on (null: Auto, nothing sent), and the
|
|
52
50
|
// models payload's toolkits (null: no 🧰).
|
|
53
51
|
let newChatToolkit = null;
|
|
@@ -72,7 +70,7 @@ export function createStartPage({
|
|
|
72
70
|
const settings = createStartSettings({
|
|
73
71
|
el: settingsEl,
|
|
74
72
|
button: settingsEl,
|
|
75
|
-
openers: [settingsEl, thinkingEl, llmContextEl
|
|
73
|
+
openers: [settingsEl, thinkingEl, llmContextEl].map((e) => `#${e.id}`).join(", "),
|
|
76
74
|
thinking: {
|
|
77
75
|
summary: newChatThinkingSummary,
|
|
78
76
|
choice: () => newChatThinking,
|
|
@@ -83,16 +81,11 @@ export function createStartPage({
|
|
|
83
81
|
choice: () => newChatLlmContext,
|
|
84
82
|
choose: (next) => { newChatLlmContext = next; renderOverrides(); },
|
|
85
83
|
},
|
|
86
|
-
review: reviewEl ? {
|
|
87
|
-
choice: () => newChatReview,
|
|
88
|
-
choose: (next) => { newChatReview = next; renderOverrides(); },
|
|
89
|
-
} : null,
|
|
90
84
|
doc,
|
|
91
85
|
win,
|
|
92
86
|
});
|
|
93
|
-
thinkingEl.addEventListener("click", () => settings.toggle(
|
|
94
|
-
llmContextEl.addEventListener("click", () => settings.toggle(
|
|
95
|
-
reviewEl?.addEventListener("click", () => settings.toggle("review", reviewEl));
|
|
87
|
+
thinkingEl.addEventListener("click", () => settings.toggle(thinkingEl));
|
|
88
|
+
llmContextEl.addEventListener("click", () => settings.toggle(llmContextEl));
|
|
96
89
|
const toolkitList = toolkitBtnEl ? createStartToolkit({
|
|
97
90
|
el: toolkitBtnEl,
|
|
98
91
|
button: toolkitBtnEl,
|
|
@@ -100,18 +93,16 @@ export function createStartPage({
|
|
|
100
93
|
toolkits: () => toolkits,
|
|
101
94
|
choice: () => newChatToolkit,
|
|
102
95
|
choose: (next) => { newChatToolkit = next; renderOverrides(); },
|
|
103
|
-
review: () => newChatReview.length > 0,
|
|
104
96
|
doc,
|
|
105
97
|
win,
|
|
106
98
|
}) : null;
|
|
107
99
|
toolkitEl?.addEventListener("click", () => toolkitList?.toggle(toolkitEl));
|
|
108
100
|
// The override chips (only what is set) and ⚙: its dot and label say
|
|
109
|
-
// what is set; hidden with nothing to show (no model values
|
|
101
|
+
// what is set; hidden with nothing to show (no model values).
|
|
110
102
|
function renderOverrides() {
|
|
111
103
|
const thinkingSummary = newChatThinkingSummary();
|
|
112
104
|
const llmContextSummary = newChatLlmSummary();
|
|
113
|
-
const over = overrides({ thinking: newChatThinking, llmContext: newChatLlmContext,
|
|
114
|
-
thinkingSummary, llmContextSummary });
|
|
105
|
+
const over = overrides({ thinking: newChatThinking, llmContext: newChatLlmContext, thinkingSummary, llmContextSummary });
|
|
115
106
|
const paint = (chipEl, chip) => {
|
|
116
107
|
if (!chipEl) return;
|
|
117
108
|
chipEl.hidden = !chip;
|
|
@@ -120,9 +111,8 @@ export function createStartPage({
|
|
|
120
111
|
};
|
|
121
112
|
paint(thinkingEl, over.thinking);
|
|
122
113
|
paint(llmContextEl, over.llmContext);
|
|
123
|
-
paint(reviewEl, over.review);
|
|
124
114
|
const label = settingsLabel(over);
|
|
125
|
-
settingsEl.hidden = !(thinkingSummary || llmContextSummary ||
|
|
115
|
+
settingsEl.hidden = !(thinkingSummary || llmContextSummary || label.set);
|
|
126
116
|
settingsEl.classList.toggle("set", label.set);
|
|
127
117
|
settingsEl.title = label.label;
|
|
128
118
|
settingsEl.setAttribute("aria-label", label.label);
|
|
@@ -239,7 +229,7 @@ export function createStartPage({
|
|
|
239
229
|
} catch (e) {
|
|
240
230
|
const text = modelsFailedText(e, { startPage: !selected(), asked, leaving: pageLeaving });
|
|
241
231
|
if (text) toast(text);
|
|
242
|
-
// ⚙ without the model's rows
|
|
232
|
+
// ⚙ without the model's rows, no 🧰.
|
|
243
233
|
toolkits = null;
|
|
244
234
|
renderOverrides();
|
|
245
235
|
return;
|
|
@@ -261,14 +251,12 @@ export function createStartPage({
|
|
|
261
251
|
// The create request's own choices (the ⚙ panel's).
|
|
262
252
|
function newChoices() {
|
|
263
253
|
return { llm_context: choiceWords(newChatLlmContext), thinking: newChatThinking || undefined,
|
|
264
|
-
review: newChatReview.length ? { subjects: newChatReview } : undefined,
|
|
265
254
|
toolkit: newChatToolkit || undefined };
|
|
266
255
|
}
|
|
267
256
|
// The choices were for that new session only: a create took them.
|
|
268
257
|
function clearChoices() {
|
|
269
258
|
newChatLlmContext = null;
|
|
270
259
|
newChatThinking = null;
|
|
271
|
-
newChatReview = [];
|
|
272
260
|
newChatToolkit = null;
|
|
273
261
|
renderOverrides();
|
|
274
262
|
}
|
|
@@ -283,15 +271,6 @@ export function createStartPage({
|
|
|
283
271
|
syncModelPick, commandRan, restoreStartPick, loadModels, chosenModel, newChoices, clearChoices, dropChoices,
|
|
284
272
|
// A fresh link's /model still in flight (a send waits for it), or null.
|
|
285
273
|
pendingPick: () => pendingPick,
|
|
286
|
-
// The start page's review files ([]: the new session isn't a review).
|
|
287
|
-
reviewSubjects: () => newChatReview,
|
|
288
|
-
// Start refused them (400 invalid_review): said in the ⚙ panel's review
|
|
289
|
-
// view, opened again. @return whether it was said there
|
|
290
|
-
reviewRefused: (message) => {
|
|
291
|
-
if (!reviewEl || !newChatReview.length) return false;
|
|
292
|
-
settings.refuse(message);
|
|
293
|
-
return true;
|
|
294
|
-
},
|
|
295
274
|
// Start refused the picked kit (400 toolkit_refused): said in the 🧰
|
|
296
275
|
// list, opened again. Without a pick it is config.yml's default that
|
|
297
276
|
// is broken: @return false (the caller's alert).
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// The start page's ⚙ panel: the new session's rarely used settings in one
|
|
2
|
-
// place (thinking, LLM context
|
|
2
|
+
// place (thinking, LLM context), each a choice for the next
|
|
3
3
|
// create only (start_page.js keeps them; never remembered). A pick applies
|
|
4
4
|
// at once and the panel stays open; a typed budget has its own Set. Rows
|
|
5
5
|
// the picked model has no values for are hidden, but a choice already made
|
|
6
|
-
// is still sent: the panel says so and offers to clear it.
|
|
7
|
-
// are a view of their own (‹ back to the settings).
|
|
6
|
+
// is still sent: the panel says so and offers to clear it.
|
|
8
7
|
//
|
|
9
8
|
// Beside ⚙ on the row, override chips name what is set (overrides(): "think
|
|
10
|
-
// high", "ctx stale"
|
|
9
|
+
// high", "ctx stale"); on a phone ⚙ carries a dot
|
|
11
10
|
// instead (settingsLabel()).
|
|
12
11
|
|
|
13
12
|
import { createChipPopover, SHEET_TALL } from "./chip_popover.js";
|
|
14
13
|
import { mergeChoice, ownValues } from "./llm_context_chip.js";
|
|
15
|
-
import { readSubjects, reviewChipModel, reviewFormTemplate } from "./review_start.js";
|
|
16
14
|
import {
|
|
17
15
|
contextSegments, contextWords, DEFAULT, settingsPanelTemplate, thinkingSegments,
|
|
18
16
|
} from "./settings_panel.js";
|
|
@@ -29,7 +27,7 @@ const NO_LLM_CONTEXT = "the picked model has no LLM context values; it is sent a
|
|
|
29
27
|
// The row's override chips: what is set for the new session, each
|
|
30
28
|
// {text, title} or null. A choice the picked model shows no row for (its
|
|
31
29
|
// summary is null) stays, its title saying it is sent anyway.
|
|
32
|
-
export function overrides({ thinking = null, llmContext = null,
|
|
30
|
+
export function overrides({ thinking = null, llmContext = null, thinkingSummary = null,
|
|
33
31
|
llmContextSummary = null } = {}) {
|
|
34
32
|
const ctx = contextWords(llmContext);
|
|
35
33
|
return {
|
|
@@ -45,22 +43,20 @@ export function overrides({ thinking = null, llmContext = null, review = [], thi
|
|
|
45
43
|
? `LLM context: ${ctx} for the new session (the model's: ${llmContextSummary.strategy}). Click to change it.`
|
|
46
44
|
: `LLM context: ${ctx} for the new session: ${NO_LLM_CONTEXT}. Click to change it.`,
|
|
47
45
|
} : null,
|
|
48
|
-
review: review?.length ? reviewChipModel(review) : null,
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// ⚙'s state: whether anything is set (its dot on a phone) and its tooltip
|
|
53
50
|
// and accessible name, which list what is.
|
|
54
51
|
export function settingsLabel(over) {
|
|
55
|
-
const set = [over.thinking, over.llmContext
|
|
52
|
+
const set = [over.thinking, over.llmContext].filter(Boolean);
|
|
56
53
|
return { set: set.length > 0, label: set.length ? `${PANEL_LABEL}: ${set.map((o) => o.text).join(", ")}` : PANEL_LABEL };
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
// The main view (settings_panel.js settingsPanelTemplate over the new
|
|
60
57
|
// session's choices). +state+: {thinking: {summary, choice}, llmContext:
|
|
61
|
-
// {summary, choice},
|
|
62
|
-
|
|
63
|
-
export function panelTemplate({ thinking, llmContext, review = null, more = false, error = null }) {
|
|
58
|
+
// {summary, choice}, more: the disclosure open, error: the context Set's}.
|
|
59
|
+
export function panelTemplate({ thinking, llmContext, more = false, error = null }) {
|
|
64
60
|
const think = thinkingSegments(thinking.summary, thinking.choice);
|
|
65
61
|
const ctx = contextSegments(llmContext.summary, llmContext.choice);
|
|
66
62
|
const ctxAnyway = !ctx && contextWords(llmContext.choice);
|
|
@@ -73,7 +69,6 @@ export function panelTemplate({ thinking, llmContext, review = null, more = fals
|
|
|
73
69
|
more: { open: more, summary: llmContext.summary, choice: llmContext.choice, error } } : null,
|
|
74
70
|
ctxAnyway ? { anyway: `Context ${ctxAnyway}: ${NO_LLM_CONTEXT}.`, act: "ctx-clear" } : null,
|
|
75
71
|
],
|
|
76
|
-
review,
|
|
77
72
|
note: NOTE,
|
|
78
73
|
});
|
|
79
74
|
}
|
|
@@ -83,49 +78,32 @@ export function panelTemplate({ thinking, llmContext, review = null, more = fals
|
|
|
83
78
|
// and focus goes back to it whichever opener was clicked); +openers+: the
|
|
84
79
|
// selector of every element that opens it (⚙ and the override chips: a click
|
|
85
80
|
// there is not a click outside). +thinking+ / +llmContext+: {summary(),
|
|
86
|
-
// choice(), choose(next)}
|
|
87
|
-
// (
|
|
88
|
-
|
|
89
|
-
export function createStartSettings({ el, button, openers = `#${button.id}`, thinking, llmContext, review = null,
|
|
81
|
+
// choice(), choose(next)}.
|
|
82
|
+
// @return {open(), toggle(), close, refresh, isOpen}
|
|
83
|
+
export function createStartSettings({ el, button, openers = `#${button.id}`, thinking, llmContext,
|
|
90
84
|
doc = document, win = window }) {
|
|
91
|
-
//
|
|
92
|
-
// form's error and text as typed.
|
|
93
|
-
let view = "main";
|
|
85
|
+
// The disclosure; the context Set's error.
|
|
94
86
|
let more = false;
|
|
95
87
|
let error = null;
|
|
96
|
-
let reviewError = null;
|
|
97
|
-
let reviewText = null;
|
|
98
88
|
|
|
99
89
|
function draw() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
llmContext: { summary: llmContext.summary(), choice: llmContext.choice() },
|
|
106
|
-
review: review ? review.choice() : null, more, error,
|
|
107
|
-
}), shell.pop);
|
|
108
|
-
}
|
|
90
|
+
render(panelTemplate({
|
|
91
|
+
thinking: { summary: thinking.summary(), choice: thinking.choice() },
|
|
92
|
+
llmContext: { summary: llmContext.summary(), choice: llmContext.choice() },
|
|
93
|
+
more, error,
|
|
94
|
+
}), shell.pop);
|
|
109
95
|
shell.replace();
|
|
110
96
|
}
|
|
111
97
|
|
|
112
98
|
// Focus inside on open (the popover sits at the end of <body>, so Tab
|
|
113
99
|
// from ⚙ wouldn't reach it): the pressed segment of the first row, else
|
|
114
|
-
// the first button
|
|
100
|
+
// the first button.
|
|
115
101
|
function focusInside() {
|
|
116
102
|
const pop = shell.pop;
|
|
117
|
-
const at =
|
|
118
|
-
: pop.querySelector(".sset-seg [aria-pressed=true]") || pop.querySelector(".sset-link, .sset-seg button");
|
|
103
|
+
const at = pop.querySelector(".sset-seg [aria-pressed=true]") || pop.querySelector(".sset-link, .sset-seg button");
|
|
119
104
|
at?.focus();
|
|
120
105
|
}
|
|
121
106
|
|
|
122
|
-
function switchTo(next) {
|
|
123
|
-
view = next;
|
|
124
|
-
draw();
|
|
125
|
-
if (next === "review") focusInside();
|
|
126
|
-
else shell.pop.querySelector("[data-act=review]")?.focus();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
107
|
function pickContext(changes) {
|
|
130
108
|
const initial = ownValues({ own: llmContext.choice() });
|
|
131
109
|
let next;
|
|
@@ -155,17 +133,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
155
133
|
else if (what === "ctx") return pickContext({ strategy: value });
|
|
156
134
|
else if (what === "ctx-clear") llmContext.choose(null);
|
|
157
135
|
else if (what === "ctx-more") more = !more;
|
|
158
|
-
else
|
|
159
|
-
else if (what === "back") {
|
|
160
|
-
reviewError = null;
|
|
161
|
-
reviewText = null;
|
|
162
|
-
return switchTo("main");
|
|
163
|
-
} else if (what === "review-clear" || what === "clear") {
|
|
164
|
-
review.choose([]);
|
|
165
|
-
reviewError = null;
|
|
166
|
-
reviewText = null;
|
|
167
|
-
if (view === "review") return switchTo("main");
|
|
168
|
-
} else return;
|
|
136
|
+
else return;
|
|
169
137
|
draw();
|
|
170
138
|
}
|
|
171
139
|
|
|
@@ -173,23 +141,12 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
173
141
|
if (form.classList.contains("sset-ctx-form")) {
|
|
174
142
|
return pickContext({ apply: form.elements.apply.value, budget: form.elements.budget.value });
|
|
175
143
|
}
|
|
176
|
-
const typed = form.elements.subjects?.value || "";
|
|
177
|
-
const read = readSubjects(typed);
|
|
178
|
-
if (read.error) {
|
|
179
|
-
reviewError = read.error;
|
|
180
|
-
reviewText = typed;
|
|
181
|
-
return draw();
|
|
182
|
-
}
|
|
183
|
-
review.choose(read.subjects);
|
|
184
|
-
reviewError = null;
|
|
185
|
-
reviewText = null;
|
|
186
|
-
switchTo("main");
|
|
187
144
|
}
|
|
188
145
|
|
|
189
146
|
const shell = createChipPopover({
|
|
190
147
|
id: "startSettingsPopover", className: "ctx-popover start-settings", width: 440, el, anchor: `#${button.id}`, openers,
|
|
191
|
-
// Taller than a plain sheet: the Apply and budget fields
|
|
192
|
-
//
|
|
148
|
+
// Taller than a plain sheet: the Apply and budget fields would push the
|
|
149
|
+
// note under the edge of a 60 % one.
|
|
193
150
|
summary: () => ({}), sheet: true, sheetShare: SHEET_TALL, label: PANEL_LABEL, doc, win,
|
|
194
151
|
show: (_data, opening) => {
|
|
195
152
|
if (opening) {
|
|
@@ -200,10 +157,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
200
157
|
},
|
|
201
158
|
onOpen: focusInside,
|
|
202
159
|
onClose: () => {
|
|
203
|
-
view = "main";
|
|
204
160
|
error = null;
|
|
205
|
-
reviewError = null;
|
|
206
|
-
reviewText = null;
|
|
207
161
|
},
|
|
208
162
|
onSubmit: submit,
|
|
209
163
|
onAct: act,
|
|
@@ -217,8 +171,7 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
217
171
|
});
|
|
218
172
|
|
|
219
173
|
// +from+: the opener clicked (focus goes back to it), ⚙ by default.
|
|
220
|
-
function open(
|
|
221
|
-
view = review ? at : "main";
|
|
174
|
+
function open(from = button) {
|
|
222
175
|
if (shell.isOpen()) {
|
|
223
176
|
draw();
|
|
224
177
|
focusInside();
|
|
@@ -229,18 +182,11 @@ export function createStartSettings({ el, button, openers = `#${button.id}`, thi
|
|
|
229
182
|
|
|
230
183
|
return {
|
|
231
184
|
open,
|
|
232
|
-
// An override chip's click: opens the panel
|
|
233
|
-
toggle: (
|
|
185
|
+
// An override chip's click: opens the panel, or closes it.
|
|
186
|
+
toggle: (from = button) => (shell.isOpen() ? shell.close() : open(from)),
|
|
234
187
|
close: () => shell.close(),
|
|
235
188
|
isOpen: () => shell.isOpen(),
|
|
236
189
|
// The picked model changed (its default labels, which rows show).
|
|
237
190
|
refresh: () => { if (shell.isOpen()) draw(); },
|
|
238
|
-
// Start refused the review files (400 invalid_review): said in the
|
|
239
|
-
// review view, opened at the files chosen.
|
|
240
|
-
refuse: (message) => {
|
|
241
|
-
reviewError = message;
|
|
242
|
-
reviewText = null;
|
|
243
|
-
open("review");
|
|
244
|
-
},
|
|
245
191
|
};
|
|
246
192
|
}
|
|
@@ -68,9 +68,8 @@ export function toolkitLabel(choice) {
|
|
|
68
68
|
return { set: !!choice, label: choice ? `${LIST_LABEL}: ${choice}` : LIST_LABEL };
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// +state+: {toolkits, choice,
|
|
72
|
-
|
|
73
|
-
export function listTemplate({ toolkits, choice, review = false, error = null }) {
|
|
71
|
+
// +state+: {toolkits, choice, error: Start's refusal}.
|
|
72
|
+
export function listTemplate({ toolkits, choice, error = null }) {
|
|
74
73
|
const rows = toolkitRows(toolkits, choice);
|
|
75
74
|
return html`<div class="ctx-pop-head"><strong>Toolkit · new session</strong
|
|
76
75
|
><button type="button" class="ctx-pop-close" data-act="close" aria-label="Close">×</button></div
|
|
@@ -78,9 +77,7 @@ export function listTemplate({ toolkits, choice, review = false, error = null })
|
|
|
78
77
|
data-act=${`kit:${r.value}`} aria-pressed=${r.pressed ? "true" : "false"} title=${r.title || nothing}
|
|
79
78
|
><span class="st-check" aria-hidden="true">${r.pressed ? "✓" : ""}</span><span class="st-name">${r.label}</span
|
|
80
79
|
><span class="st-detail">${r.detail}</span></button>`)}</div
|
|
81
|
-
|
|
82
|
-
toolkits.default} unless you pick a kit.</div>` : nothing
|
|
83
|
-
}<div class="ctx-pop-error" role="alert" ?hidden=${!error}>${error || ""}</div
|
|
80
|
+
><div class="ctx-pop-error" role="alert" ?hidden=${!error}>${error || ""}</div
|
|
84
81
|
><div class="ctx-pop-meta">${NOTE}</div>`;
|
|
85
82
|
}
|
|
86
83
|
|
|
@@ -88,16 +85,15 @@ export function listTemplate({ toolkits, choice, review = false, error = null })
|
|
|
88
85
|
// where 🧰 is; +button+: 🧰 (the list opens at it; focus goes back to it);
|
|
89
86
|
// +openers+: the selector of every element that opens it (🧰 and the
|
|
90
87
|
// override chip). Hooks: +toolkits()+ the payload's toolkits (null: nothing
|
|
91
|
-
// opens), +choice()+, +choose(next)
|
|
92
|
-
// set.
|
|
88
|
+
// opens), +choice()+, +choose(next)+.
|
|
93
89
|
// @return {open, toggle, close, refresh, refuse(message), isOpen}
|
|
94
90
|
export function createStartToolkit({ el, button, openers = `#${button.id}`, toolkits, choice, choose,
|
|
95
|
-
|
|
91
|
+
doc = document, win = window }) {
|
|
96
92
|
// Start's refusal of the picked kit (400 toolkit_refused), until a pick.
|
|
97
93
|
let error = null;
|
|
98
94
|
|
|
99
95
|
function draw() {
|
|
100
|
-
render(listTemplate({ toolkits: toolkits(), choice: choice(),
|
|
96
|
+
render(listTemplate({ toolkits: toolkits(), choice: choice(), error }), shell.pop);
|
|
101
97
|
shell.replace();
|
|
102
98
|
}
|
|
103
99
|
|
|
@@ -4,6 +4,28 @@
|
|
|
4
4
|
// globalThis.localStorage at each call, never at import (the specs install
|
|
5
5
|
// their own).
|
|
6
6
|
|
|
7
|
+
// The same guards on sessionStorage: this tab only, so a reload or a resync
|
|
8
|
+
// of it keeps what is written, and another tab or device never sees it.
|
|
9
|
+
// Reads globalThis.sessionStorage at each call (the specs install their own).
|
|
10
|
+
|
|
11
|
+
// The stored string, or +fallback+ when there is none or it can't be read.
|
|
12
|
+
export function readSession(key, fallback = null) {
|
|
13
|
+
try {
|
|
14
|
+
const value = globalThis.sessionStorage?.getItem(key);
|
|
15
|
+
return value == null ? fallback : value;
|
|
16
|
+
} catch (_) {
|
|
17
|
+
return fallback;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function writeSession(key, value) {
|
|
22
|
+
try { globalThis.sessionStorage?.setItem(key, value); } catch (_) {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function removeSession(key) {
|
|
26
|
+
try { globalThis.sessionStorage?.removeItem(key); } catch (_) {}
|
|
27
|
+
}
|
|
28
|
+
|
|
7
29
|
// The stored string, or +fallback+ when there is none or it can't be read.
|
|
8
30
|
export function readStored(key, fallback = null) {
|
|
9
31
|
try {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// capabilities() the page's capabilities (card.js shownElsewhere)
|
|
20
20
|
// historyEl the history element (keepFollowing, the failed-turn redraw)
|
|
21
21
|
// liveTurn, turnDom, shownTexts, questionCards, contextChips the page's views
|
|
22
|
+
// (contextChips null for a viewer without them, viewer.js)
|
|
22
23
|
// workingSet the stage view's working set (web.working_set),
|
|
23
24
|
// null when off
|
|
24
25
|
// participantsControl the owner's participants panel (participants_panel.js),
|
|
@@ -57,7 +58,7 @@ import {
|
|
|
57
58
|
} from "./turn_events.js";
|
|
58
59
|
import { commandView, drawCommandBubble, historyHasCommandBubble } from "./commands.js";
|
|
59
60
|
import { keepEarlyRestore, restoreAction } from "./restore.js";
|
|
60
|
-
import {
|
|
61
|
+
import { setBadgeMode } from "./participant_names.js";
|
|
61
62
|
import { isParticipantAuthor } from "./participant_model.js";
|
|
62
63
|
import { stillOn } from "./latest.js";
|
|
63
64
|
|
|
@@ -164,12 +165,8 @@ export function createStreamHandlers(deps) {
|
|
|
164
165
|
if (when && promptBubble?.setAttribute && !promptBubble.title) promptBubble.title = when;
|
|
165
166
|
liveTurn.cutAfter = data.cut_after ?? null;
|
|
166
167
|
liveTurn.serverGen = null;
|
|
167
|
-
// A participant's review turn: its id and author, for Apply at its end
|
|
168
|
-
// (turn_completed names neither). A pair turn acted itself: no Apply.
|
|
169
168
|
const author = data.author || data.origin?.author;
|
|
170
169
|
const participant = isParticipantAuthor(author);
|
|
171
|
-
const pair = data.participant_mode === PAIR;
|
|
172
|
-
liveTurn.review = participant && data.turn_id && !pair ? { turn_id: data.turn_id, author, author_name: data.author_name } : null;
|
|
173
170
|
// Its prompt drawn while queued takes the turn's mode now.
|
|
174
171
|
if (data.participant_mode) setBadgeMode(promptBubble, data.participant_mode);
|
|
175
172
|
// The owner's input queues behind it (the composer's delivery line).
|
|
@@ -219,10 +216,6 @@ export function createStreamHandlers(deps) {
|
|
|
219
216
|
// the hand-off never moves it before its links swap in.
|
|
220
217
|
if (display) await display.promise;
|
|
221
218
|
turnDom.answerReady();
|
|
222
|
-
// A participant's review turn: Apply under its reply, as a reload shows it.
|
|
223
|
-
const review = liveTurn.review;
|
|
224
|
-
liveTurn.review = null;
|
|
225
|
-
if (review && !data.turn_summary?.empty_answer) deps.placeApply?.(review);
|
|
226
219
|
},
|
|
227
220
|
// An after_turn hook presented the answer (AnswerDisplay) or attached
|
|
228
221
|
// refs to it (AnswerRefs: refs, a count; display null when only refs):
|
|
@@ -370,7 +363,7 @@ export function createStreamHandlers(deps) {
|
|
|
370
363
|
gapBefore(at);
|
|
371
364
|
addNoteBubble({ label: data.label, content: data.text || "", at, objectives: data.objectives });
|
|
372
365
|
// An attached context source's note: its chip changed.
|
|
373
|
-
if (data.context_source) contextChips
|
|
366
|
+
if (data.context_source) contextChips?.refresh();
|
|
374
367
|
},
|
|
375
368
|
// The session's list changed (objectives_strip.js): an edit waiting, a
|
|
376
369
|
// list note in, a turn's moves.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* The web UI's colour tokens,
|
|
1
|
+
/* The web UI's colour tokens, read by the page (index.html, every viewer's): the dark :root (the default) and the light set under prefers-color-scheme: light. Everything else reads them through var(). */
|
|
2
2
|
:root{color-scheme:dark;--bg:#0b0d11;--bg-top:#131d29;--bg-panel:#151821;--bg-inset:#0f1115;--bg-raised:#22262f;--bg-hover:#1b1f27;--border:#1f232b;--border-strong:#2d333f;--text:#e6e8eb;--text-bright:#f0f3f6;--text-2:#c9d1d9;--text-3:#9aa4b2;--text-muted:#8b949e;--text-faint:#6e7681;--accent:#5aa9ff;--accent-strong:#0071e3;--accent-bg:#0f2340;--accent-ring:rgba(90,169,255,.18);--primary:#0071e3;--ok:#3fb950;--ok-text:#7ee787;--ok-bg:#1a2e1a;--warn:#d29922;--warn-text:#e3b341;--warn-bright:#f2cc60;--warn-bg:#2b2108;--warn-border:#6b5416;--danger:#f85149;--danger-bg:#da3633;--danger-text:#ff7b72;--danger-bg-dim:#3d1f1f;--think:#8957e5;--think-text:#d2a8ff;--accent-border:#1a3458;--pick-border:#79c0ff;--accent-tint:color-mix(in srgb,var(--accent) 7%,transparent);--narr:color-mix(in srgb,var(--accent) 38%,var(--text-muted));
|
|
3
3
|
--glass-bg:color-mix(in srgb,var(--bg-panel) 70%,transparent);--glass-border:rgba(255,255,255,.08);--glass-highlight:rgba(255,255,255,.05);--glass-shadow:0 8px 30px rgba(0,0,0,.35);
|
|
4
4
|
--diff-add-bg:rgba(63,185,80,.14);--diff-add-text:#aff5b4;--diff-del-bg:rgba(248,81,73,.14);--diff-del-text:#ffc1bc;
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
// removed at the end: the answer bubble takes its place. A lone step that
|
|
23
23
|
// closed with text keeps its chrome: a line steered in after it left it alone
|
|
24
24
|
// in the block when the answer went, and its summary is the way to its text.
|
|
25
|
-
import { authorBadge,
|
|
25
|
+
import { authorBadge, READ_ONLY } from "./participant_names.js";
|
|
26
26
|
import { isParticipantAuthor } from "./participant_model.js";
|
|
27
|
-
import { applyRowTemplate } from "./review_apply.js";
|
|
28
27
|
import { html, nothing, render } from "./vendor/lit-html.js";
|
|
29
28
|
import { answerRefsOf, setAnswerRefs } from "./answer_refs.js";
|
|
30
29
|
import { bindRowRefs } from "./refs.js";
|
|
@@ -1000,7 +999,7 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1000
999
|
const userTemplate = (m, opts = {}) => {
|
|
1001
1000
|
const shell = shellCommandMessage(m?.content);
|
|
1002
1001
|
if (shell) return commandBubbleTemplate({ ...shell, at: m?.at });
|
|
1003
|
-
return userBubbleTemplate(m, { label: sourceLabel(m?.source), thumbs: thumbs(m.images), author: authorBadge(m?.author, m?.author_name, m?.participant_mode), ...opts });
|
|
1002
|
+
return userBubbleTemplate(m, { label: sourceLabel(m?.source), thumbs: thumbs(m.images), author: authorBadge(m?.author, m?.author_name, m?.participant_mode || READ_ONLY), ...opts });
|
|
1004
1003
|
};
|
|
1005
1004
|
// The first text after a delegate report merged mid-turn, unless it is
|
|
1006
1005
|
// the turn's answer (shown anyway). Its key (answer_fold.js): the turn's
|
|
@@ -1026,7 +1025,6 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1026
1025
|
blockTurns.push(ordinal);
|
|
1027
1026
|
}
|
|
1028
1027
|
const lineKey = (i) => (items[i]?.source === "delegate_report" ? `${group.turnId}:input:${i - (group.user ?? i)}` : null);
|
|
1029
|
-
const reviewer = group.answer !== null && prompt?.turn_id && prompt.participant_mode !== PAIR ? authorBadge(prompt.author, prompt.author_name) : null;
|
|
1030
1028
|
const pieces = turnPieces({
|
|
1031
1029
|
prompt: prompt ? (prompt.role === "note" ? noteBubbleTemplate(prompt) : userTemplate(prompt)) : null,
|
|
1032
1030
|
block: drawn.block,
|
|
@@ -1035,7 +1033,6 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
|
|
|
1035
1033
|
: null)),
|
|
1036
1034
|
answer: drawn.answer,
|
|
1037
1035
|
timing: timingTemplate(group),
|
|
1038
|
-
apply: reviewer ? applyRowTemplate(prompt.turn_id, reviewer) : null,
|
|
1039
1036
|
end: drawn.end,
|
|
1040
1037
|
kept: drawn.kept,
|
|
1041
1038
|
});
|