shadok-ai 0.10.1 → 0.10.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/index.html +20 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test test/*.ts context/*/test/*.test.mjs",
package/public/index.html CHANGED
@@ -2190,7 +2190,20 @@
2190
2190
  }
2191
2191
  }
2192
2192
 
2193
- function createTab(groupId) {
2193
+ /**
2194
+ * `focus` says whether the new tab takes over the view. It defaults to true
2195
+ * because most callers ARE the user asking for a tab — the Start-agent
2196
+ * button, the phone's "new agent" entry, the Tweak CTA — and those must land
2197
+ * on what they just created.
2198
+ *
2199
+ * `syncChannels` is the exception, and the reason this option exists. It
2200
+ * creates a tab for every channel it DISCOVERS on the server, every four
2201
+ * seconds, so an agent spawned by another agent, from Telegram, from a cron
2202
+ * or on another machine used to yank every open browser onto it mid-sentence.
2203
+ * Delegating is this product's central action; it must not cost the user
2204
+ * their place in the conversation they are having.
2205
+ */
2206
+ function createTab(groupId, { focus = true } = {}) {
2194
2207
  seq++;
2195
2208
  const el = document.createElement("div");
2196
2209
  el.className = "transcript";
@@ -2335,7 +2348,7 @@
2335
2348
  });
2336
2349
  btn.addEventListener("dragend", () => endDrag());
2337
2350
  tabs.push(tab);
2338
- activate(tab);
2351
+ if (focus) activate(tab);
2339
2352
  return tab;
2340
2353
  }
2341
2354
 
@@ -3133,7 +3146,11 @@
3133
3146
  saveName(t, c.name);
3134
3147
  }
3135
3148
  } else if (!dismissedChannels.has(c.sessionId)) {
3136
- const nt = createTab(c.group);
3149
+ // Discovered, not asked for: never steal the view. The one exception is
3150
+ // an empty cockpit — with `active === null` the user is looking at
3151
+ // #emptyState (invariant 18), so this displaces nobody, and showing the
3152
+ // channel beats leaving them in front of nothing.
3153
+ const nt = createTab(c.group, { focus: !active });
3137
3154
  nt.sessionId = c.sessionId;
3138
3155
  nt.draft = savedDrafts[c.sessionId] || "";
3139
3156
  if (c.branch) nt.branch = c.branch;