shadok-ai 0.19.83 → 0.19.84

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.
package/README.md CHANGED
@@ -594,9 +594,14 @@ Enter to skip; you can add it later from the web UI).
594
594
  Telegram, sound, and what the ⋯ holds), the people buttons (Users, Reports,
595
595
  Security), the quota bars, and the cockpit's name and settings menu. Skip and
596
596
  Escape end it at any point; ⋯ → *Guided tour* replays it. A step whose target
597
- isn't on screen is **dropped rather than faked** — an empty cockpit has no
598
- agent menu, a cockpit with no group has no groups column, a member has no
599
- Reports button — so it gets a shorter tour instead of a spotlight on nothing.
597
+ isn't on screen is **dropped rather than faked** — a member has no Reports
598
+ button, a phone has no groups column — so it gets a shorter tour instead of a
599
+ spotlight on nothing. One case is staged instead: a cockpit with **no agent
600
+ at all**, which is every first visit (the tour runs before the sign-in). The
601
+ tour then shows an **example scene** — example agents in the list, the real
602
+ agent bar and composer over an example conversation, example groups — tagged
603
+ as an example on every surface, never saved, and removed when the tour ends
604
+ or the moment a real agent takes the screen.
600
605
  Which steps exist is **re-read from the page at every step**, and the first
601
606
  count waits (4s at most) for the agents and the account to load — a tour that
602
607
  filtered its list once, at start, played five stops on a cockpit that has eleven.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.83",
3
+ "version": "0.19.84",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test --test-timeout=120000 test/*.ts context/*/test/*.test.mjs",
package/public/index.html CHANGED
@@ -2365,6 +2365,14 @@
2365
2365
  /* Above the other popins: during the tour it is the thing being interacted
2366
2366
  with, and the sign-in card may already be on screen behind it. */
2367
2367
  #tourOverlay { z-index: 60; }
2368
+ /* The tour's example scene (tourDemoOn). The rows borrow `.tab` for their
2369
+ look and nothing else; the note stays on screen for the whole tour. */
2370
+ #tourDemoList .tab { cursor: default; }
2371
+ #tourDemoList .tab .lastat, #tourDemoChat .tour-demo-note { font-style: italic; }
2372
+ #tourDemoChat .tour-demo-note {
2373
+ align-self: center; margin: 4px 0 14px; padding: 6px 12px; border-radius: 999px;
2374
+ font-size: 12px; color: var(--text-dim); background: var(--bg-inset); text-align: center;
2375
+ }
2368
2376
  #tourBubble {
2369
2377
  max-width: 340px;
2370
2378
  background: var(--bg-raised);
@@ -4753,7 +4761,7 @@
4753
4761
  import { shrinkToFit, nameReads, chanOverflowIds, chanOverflowItems } from "/bar-overflow.js?v=__ASSET_V__";
4754
4762
  import { echoAuthor, isOwnPrompt } from "/echo-author.js?v=__ASSET_V__";
4755
4763
  import { dialPos, dialColor, dialTitle } from "/gauge-dial.js?v=__ASSET_V__";
4756
- import { TOUR_STEPS, bubblePlacement, tourStanding, unionRect, visibleSteps } from "/tour-steps.js?v=__ASSET_V__";
4764
+ import { TOUR_DEMO, TOUR_STEPS, bubblePlacement, tourNeedsDemo, tourStanding, unionRect, visibleSteps } from "/tour-steps.js?v=__ASSET_V__";
4757
4765
  import { pickChannelSource, dirKey, serverSwapped } from "/channel-store.js?v=__ASSET_V__";
4758
4766
  import { MODEL_CHOICES, composeModel } from "/model-choice.js?v=__ASSET_V__";
4759
4767
  import { EFFORT_CHOICES, effortLabel } from "/effort-choice.js?v=__ASSET_V__";
@@ -4847,6 +4855,8 @@
4847
4855
  window.unionRect = unionRect;
4848
4856
  window.visibleSteps = visibleSteps;
4849
4857
  window.tourStanding = tourStanding;
4858
+ window.TOUR_DEMO = TOUR_DEMO;
4859
+ window.tourNeedsDemo = tourNeedsDemo;
4850
4860
  window.extractLiveText = extractLiveText;
4851
4861
  window.livePreviewDecision = livePreviewDecision;
4852
4862
  window.profileBlurb = profileBlurb;
@@ -5055,6 +5065,8 @@
5055
5065
  unionRect: () => null,
5056
5066
  visibleSteps: (steps) => steps ?? [],
5057
5067
  tourStanding: () => ({ step: null, index: 0, total: 0 }),
5068
+ // No bridge, no set: an example scene must never be staged on a guess.
5069
+ tourNeedsDemo: () => false,
5058
5070
  // The viewer is opened by a click, so the module is long since loaded —
5059
5071
  // but a stub is still the rule (invariant 10), and the honest one here
5060
5072
  // shows the table UNFILTERED rather than an empty panel that reads as
@@ -5324,6 +5336,11 @@
5324
5336
  // One channel = one WebSocket connection = one claude session server-side
5325
5337
  // (sessions are shared: several clients can attach to the same id).
5326
5338
  let tabs = [];
5339
+ // True while the guided tour stages its example scene (tourDemoOn, far
5340
+ // below). Declared HERE because applyView / renderRail / refreshChrome read
5341
+ // it from the first paint on: beside its functions it would still be in its
5342
+ // temporal dead zone, and the boot would throw.
5343
+ let tourDemo = false;
5327
5344
  let active = null;
5328
5345
  let seq = 0;
5329
5346
  // The server's launch directory — the sensible default for new channels.
@@ -7432,7 +7449,7 @@
7432
7449
  function applyView() {
7433
7450
  const v = currentView();
7434
7451
  // No group → no column (invariant: the rail earns its space, see the CSS).
7435
- document.body.classList.toggle("has-groups", groups.length > 0);
7452
+ document.body.classList.toggle("has-groups", groups.length > 0 || tourDemo);
7436
7453
  tabbar.dataset.view = v;
7437
7454
  layoutFolders();
7438
7455
  for (const g of groups) {
@@ -7666,6 +7683,11 @@
7666
7683
  { view: "ungrouped", icon: "📥", name: "Main" },
7667
7684
  ...[...groupsEl.children].map((el) =>
7668
7685
  ({ view: String(el._group.id), icon: el._group.icon, name: el._group.nameEl.textContent, group: el._group })),
7686
+ // The guided tour's set (tourDemoOn): example groups, only when there is
7687
+ // none of your own. No `group` behind them, so nothing to rename or drag.
7688
+ ...(tourDemo && !groupsEl.children.length
7689
+ ? window.TOUR_DEMO.groups.map((g, i) => ({ view: "tour-demo-" + i, icon: g.icon, name: g.name }))
7690
+ : []),
7669
7691
  ];
7670
7692
  // The column mutates all the time (LEDs, timers, reconnects): rebuild only
7671
7693
  // when what the rail SHOWS changed, or every click would land on an item
@@ -8717,6 +8739,15 @@
8717
8739
  function rebuildChanSelect() {
8718
8740
  const led = $("pickerLed"), name = $("pickerName");
8719
8741
  if (!led || !name) return;
8742
+ // The guided tour's set stands in for the agent that is not there yet.
8743
+ // Here, not only in paintTourDemoChrome: this function has other callers,
8744
+ // and each one wrote the "—" back over the example's name.
8745
+ if (tourDemo && !active) {
8746
+ const lead = window.TOUR_DEMO.agents.find((a) => a.active) || window.TOUR_DEMO.agents[0];
8747
+ led.className = "led on";
8748
+ name.textContent = lead.name;
8749
+ return;
8750
+ }
8720
8751
  led.className = active && active.ledEl ? active.ledEl.className : "led";
8721
8752
  name.textContent = active ? (active.nameEl ? active.nameEl.textContent : "agent " + active.id) : "—";
8722
8753
  }
@@ -8748,6 +8779,11 @@
8748
8779
  function refreshChrome() {
8749
8780
  rebuildChanSelect(); // keeps the mobile selector in step (list + active)
8750
8781
  const t = active;
8782
+ // The guided tour's set: a real agent on screen strikes it; with none, the
8783
+ // set IS the chrome, and this function must not paint "no agent" over it
8784
+ // (the first-agent poll calls it every few seconds).
8785
+ if (tourDemo && t) tourDemoOff({ repaint: false });
8786
+ if (tourDemo) { paintTourDemoChrome(); return; }
8751
8787
  if (!t) {
8752
8788
  document.body.classList.remove("room-active");
8753
8789
  $("led").className = "led ";
@@ -17320,6 +17356,90 @@
17320
17356
  // every step (window.tourStanding), because the tour can start before the
17321
17357
  // agents and the account have landed.
17322
17358
  let tourId = null;
17359
+
17360
+ // ── The demo scene ──────────────────────────────────────────────────────
17361
+ // What the tour stages when the cockpit holds no agent — see TOUR_DEMO in
17362
+ // public/tour-steps.js for why. Three rules keep it harmless:
17363
+ // - it never goes through createTab: nothing here enters `tabs`, so it
17364
+ // cannot be persisted, resumed or counted (persistChannels keeps only
17365
+ // rows carrying a `_tab` with a session id, and these rows live in their
17366
+ // own container, outside the scopes the column lays out);
17367
+ // - it is text only (textContent), opens no socket and wires no handler —
17368
+ // the tour's overlay sits above it, so it cannot be clicked anyway;
17369
+ // - it is struck by endTour, and by refreshChrome the moment a real agent
17370
+ // takes the screen.
17371
+ function tourDemoEl(tag, cls, text) {
17372
+ const el = document.createElement(tag);
17373
+ if (cls) el.className = cls;
17374
+ if (text != null) el.textContent = text;
17375
+ return el;
17376
+ }
17377
+ function paintTourDemoChrome() {
17378
+ const demo = window.TOUR_DEMO;
17379
+ const lead = demo.agents.find((a) => a.active) || demo.agents[0];
17380
+ $("emptyState").classList.remove("visible");
17381
+ $("startingState").classList.remove("visible");
17382
+ document.body.classList.remove("room-active");
17383
+ $("chanBar").hidden = false;
17384
+ $("chanBarName").textContent = lead.name;
17385
+ $("chanBarName").title = "";
17386
+ paintTabAvatar($("chanAvatar"), $("chanAvatar"), lead.name);
17387
+ $("led").className = "led on";
17388
+ $("state").textContent = demo.tag;
17389
+ $("cwdView").textContent = "—";
17390
+ $("sessionView").textContent = "—";
17391
+ $("branchGauge").hidden = true;
17392
+ // Shown at full strength: a dimmed button reads as "not for you".
17393
+ for (const id of ["chanCron", "chanWebhooks", "chanGallery", "chanInfo"]) $(id).disabled = false;
17394
+ composer.hidden = false;
17395
+ promptInput.disabled = true;
17396
+ // The bar just came out of hiding: on a phone its icons must give way to
17397
+ // the name, exactly as for a real agent.
17398
+ scheduleReflow();
17399
+ }
17400
+ function tourDemoOn() {
17401
+ if (tourDemo) return;
17402
+ const demo = window.TOUR_DEMO;
17403
+ tourDemo = true;
17404
+ document.body.classList.add("tour-demo");
17405
+ const list = tourDemoEl("div");
17406
+ list.id = "tourDemoList";
17407
+ for (const a of demo.agents) {
17408
+ const row = tourDemoEl("div", "tab" + (a.active ? " active" : "") + (a.working ? " working" : ""));
17409
+ const avatar = tourDemoEl("span", "tav");
17410
+ const initials = tourDemoEl("span");
17411
+ avatar.append(initials, tourDemoEl("span", "led " + (a.working ? "busy" : "on")));
17412
+ paintTabAvatar(avatar, initials, a.name);
17413
+ const row1 = tourDemoEl("div", "tab-row1");
17414
+ row1.append(tourDemoEl("span", "name", a.name));
17415
+ const row2 = tourDemoEl("div", "tab-row2");
17416
+ row2.append(tourDemoEl("span", "lastat", demo.tag));
17417
+ row.append(avatar, row1, row2);
17418
+ list.append(row);
17419
+ }
17420
+ ungroupedEl.before(list);
17421
+ const chat = tourDemoEl("div", "transcript");
17422
+ chat.id = "tourDemoChat";
17423
+ chat.append(tourDemoEl("div", "tour-demo-note", demo.note));
17424
+ for (const m of demo.chat) {
17425
+ const turn = tourDemoEl("div", "turn " + m.role);
17426
+ turn.append(tourDemoEl("span", "label", m.who), tourDemoEl("div", "bubble", m.text));
17427
+ chat.append(turn);
17428
+ }
17429
+ transcripts.append(chat);
17430
+ paintTourDemoChrome();
17431
+ applyView(); // the rail: example groups, when there is none of your own
17432
+ }
17433
+ function tourDemoOff({ repaint = true } = {}) {
17434
+ if (!tourDemo) return;
17435
+ tourDemo = false;
17436
+ document.body.classList.remove("tour-demo");
17437
+ $("tourDemoList")?.remove();
17438
+ $("tourDemoChat")?.remove();
17439
+ promptInput.disabled = false;
17440
+ if (repaint) refreshChrome();
17441
+ applyView();
17442
+ }
17323
17443
  let tourOnEnd = null;
17324
17444
 
17325
17445
  /** Every element a step points at, in DOM order. */
@@ -17382,9 +17502,12 @@
17382
17502
  // window.visibleSteps comes from the ESM bridge, which runs AFTER this
17383
17503
  // classic script — so this must never be called at parse time (invariant 10).
17384
17504
  tourId = null;
17505
+ // No agent and no room on screen: stage the example scene, so the steps
17506
+ // about an agent have something to point at.
17507
+ if (window.tourNeedsDemo(tabs.length)) tourDemoOn();
17385
17508
  // Nothing to show (or the bridge never landed): hand over WITHOUT marking
17386
17509
  // the tour as seen — endTour would, and the person never saw it.
17387
- if (!window.tourStanding(window.TOUR_STEPS, null, tourVisible).step) { onEnd?.(); return; }
17510
+ if (!window.tourStanding(window.TOUR_STEPS, null, tourVisible).step) { tourDemoOff(); onEnd?.(); return; }
17388
17511
  tourOnEnd = onEnd ?? null;
17389
17512
  $("tourOverlay").hidden = false;
17390
17513
  paintTourStep();
@@ -17397,6 +17520,7 @@
17397
17520
  function endTour() {
17398
17521
  $("tourOverlay").hidden = true;
17399
17522
  $("tourOverlay").classList.remove("spotlight");
17523
+ tourDemoOff();
17400
17524
  savePref("tourSeen", true);
17401
17525
  const done = tourOnEnd;
17402
17526
  tourOnEnd = null;
@@ -218,6 +218,55 @@ export const TOUR_STEPS = [
218
218
  },
219
219
  ];
220
220
 
221
+ /**
222
+ * The demo scene: what the tour paints when the cockpit holds NO agent.
223
+ *
224
+ * The first visit is exactly that case — the tour runs before the sign-in, so
225
+ * before any agent can exist — and the tour's own rule ("a step whose target
226
+ * is absent is dropped") then left the newcomer five stops out of eleven, the
227
+ * five that are not about agents. The product is the agents.
228
+ *
229
+ * So the page stages one: example rows in the agents column, the REAL agent
230
+ * bar and composer shown over an example conversation, example groups in the
231
+ * rail. It is a set, and it says so — `note` is on screen for the whole tour
232
+ * and every row is tagged — because the rule this bends was about not lying:
233
+ * a spotlight on a button that is really there, over an agent announced as an
234
+ * example, points at something true. The set is struck when the tour ends,
235
+ * or the moment a real agent takes the screen.
236
+ *
237
+ * Data only. The page builds it with textContent, never through `createTab`:
238
+ * an example that entered the tab registry could be persisted as a channel.
239
+ */
240
+ export const TOUR_DEMO = {
241
+ note: "Example — nothing here is running. Your own agents take this place once Claude is connected.",
242
+ tag: "example",
243
+ agents: [
244
+ { name: "general", active: true },
245
+ { name: "nightly report", working: true },
246
+ { name: "docs" },
247
+ ],
248
+ groups: [
249
+ { icon: "🚀", name: "Product" },
250
+ { icon: "🧪", name: "Backend" },
251
+ ],
252
+ chat: [
253
+ { role: "user", who: "you", text: "Why did last night's import fail? Fix it and open a pull request." },
254
+ {
255
+ role: "claude",
256
+ who: "claude",
257
+ text:
258
+ "The import stopped on a date written as 31/02 in one row of the export. I made the parser " +
259
+ "reject that row with a clear message instead of crashing, added a test for it, and opened " +
260
+ "the pull request. The run now completes on last night's file.",
261
+ },
262
+ ],
263
+ };
264
+
265
+ /** Pure: stage the demo only when there is nothing real to point at. */
266
+ export function tourNeedsDemo(agentCount) {
267
+ return !(agentCount > 0);
268
+ }
269
+
221
270
  /** Pure: the steps whose target is on screen, in order. */
222
271
  export function visibleSteps(steps, isVisible) {
223
272
  return steps.filter((s) => s.target === null || isVisible(s.target));