@cotal-ai/web 0.133.13 → 0.135.1

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/dist/web/graph.js +40 -6
  2. package/package.json +3 -3
package/dist/web/graph.js CHANGED
@@ -92,7 +92,8 @@
92
92
  }
93
93
  /** Expand an agent's {live patterns, durable channels} → { channels: channel→kind, wide }. Bounded
94
94
  * wildcards (`team.>`) expand against the KNOWN channel set (registry hubs); concrete patterns stand
95
- * alone; `live` wins over `durable`. A WHOLE-BREADTH pattern (`>` or `*` — e.g. the default persona's
95
+ * alone; `live` wins over `durable`. A durable family row (`team.>`) expands only over the known hubs
96
+ * whose class is durable, the channels it stores copies for. A WHOLE-BREADTH pattern (`>` or `*` — e.g. the default persona's
96
97
  * read-everything grant) is NOT expanded to a spoke per hub (that's a dandelion); it sets `wide`, and
97
98
  * the agent renders as a "reads-all" node badge instead — truthful without per-channel noise. */
98
99
  function memberChannels(live, durable, known) {
@@ -103,7 +104,10 @@
103
104
  if (isWild(pat)) { for (const ch of known) if (patternMatches(pat, ch)) out.set(ch, "live"); }
104
105
  else out.set(pat, "live");
105
106
  }
106
- for (const ch of durable || []) if (!out.has(ch)) out.set(ch, "durable");
107
+ for (const ch of durable || []) {
108
+ if (!isWild(ch)) { if (!out.has(ch)) out.set(ch, "durable"); }
109
+ else for (const k of known) if (!out.has(k) && hubs.get(k)?.deliveryClass === "durable" && patternMatches(ch, k)) out.set(k, "durable");
110
+ }
107
111
  return { channels: out, wide };
108
112
  }
109
113
 
@@ -213,6 +217,10 @@
213
217
  let toName = null;
214
218
  if (mode === "chat" && msg.channel) {
215
219
  const h = ensureHub(msg.channel);
220
+ if (h) {
221
+ if (!h.deliveryClass && !h.heard) rereadChannels();
222
+ h.heard = true;
223
+ }
216
224
  if (from) chatHit(from, msg.channel, now()).heat = 1;
217
225
  // inbound: sender → hub, then the hub flashes and fans the post back out to every other member on
218
226
  // the channel (their spokes glow as the wave reaches them) — a real broadcast.
@@ -299,15 +307,24 @@
299
307
  feed.asOf = snap.asOf;
300
308
  feed.available = snap.asOf !== undefined || (Array.isArray(snap.members) && snap.members.length > 0);
301
309
  setFeed();
310
+ lastMembers = snap.members || [];
311
+ drawMembers(lastMembers);
312
+ }
313
+ // A durable family row reaches only the hubs whose class is durable (`memberChannels`), and a class can
314
+ // land after the snapshot naming the family: the feed's first snapshot comes before `/api/channels`
315
+ // answers, and a channel first seen in a member's row or a message has no class until that read runs
316
+ // again. So the last snapshot's members are kept and drawn again whenever classes land.
317
+ let lastMembers = null;
318
+ function drawMembers(members) {
302
319
  const known = [...hubs.keys()];
303
320
  const present = new Set();
304
- for (const m of snap.members || []) {
321
+ for (const m of members) {
305
322
  const a = ensureAgent({ id: m.id });
306
323
  present.add(a.id);
307
324
  a.live = m.live || []; a.durable = m.durable || [];
308
325
  const mc = memberChannels(a.live, a.durable, known);
309
326
  a.memberOf = mc.channels; a.wideReader = mc.wide;
310
- for (const [ch, kind] of mc.channels) { ensureHub(ch); const e = ensureEdge(a, ch); e.mem = true; e.durableOnly = kind === "durable"; }
327
+ for (const [ch, kind] of mc.channels) { if (!hubs.has(ch)) rereadChannels(); ensureHub(ch); const e = ensureEdge(a, ch); e.mem = true; e.durableOnly = kind === "durable"; }
311
328
  pruneMemberEdges(a, mc.channels);
312
329
  }
313
330
  // An agent that dropped out of the feed entirely is no longer a member of anything (incl. a wide reader,
@@ -737,6 +754,24 @@
737
754
  }
738
755
 
739
756
  // ── boot ──
757
+ const channelsSource = { name: "channels", read: async () => window.COTAL_SNAPSHOT.readJson(await fetch("/api/channels"), "channels"),
758
+ apply: (chans) => {
759
+ for (const c of chans) { const h = ensureHub(c.channel); h.msgs = c.messages || 0; h.desc = c.description || ""; h.deliveryClass = c.deliveryClass; h.replay = c.replay; h.replayWindow = c.replayWindow; }
760
+ if (lastMembers) drawMembers(lastMembers);
761
+ } };
762
+ // A hub that appears in a member's row or a message reads `/api/channels` again for its class, and so
763
+ // does the first post on a hub still without one, since a post can put a channel on that list. A
764
+ // channel the list never names is read for once, not once per post. One read answers for every hub
765
+ // that appears within the wait.
766
+ let channelsReread = 0;
767
+ function rereadChannels() {
768
+ if (channelsReread) return;
769
+ channelsReread = setTimeout(async () => {
770
+ channelsReread = 0;
771
+ const stale = await window.COTAL_SNAPSHOT.refreshAll([channelsSource]);
772
+ markStale("channels", stale[0] || null);
773
+ }, 250);
774
+ }
740
775
  async function load() {
741
776
  // ── ONE REFUSED READ MUST NOT EMPTY THE PAGE ────────────────────────────────────────────────
742
777
  //
@@ -756,8 +791,7 @@
756
791
  const stale = await SNAP.refreshAll([
757
792
  { name: "space", read: async () => SNAP.readJson(await fetch("/api/meta"), "space"),
758
793
  apply: (meta) => { $("space").textContent = "· " + meta.space; } },
759
- { name: "channels", read: async () => SNAP.readJson(await fetch("/api/channels"), "channels"),
760
- apply: (chans) => { for (const c of chans) { const h = ensureHub(c.channel); h.msgs = c.messages || 0; h.desc = c.description || ""; h.deliveryClass = c.deliveryClass; h.replay = c.replay; h.replayWindow = c.replayWindow; } } },
794
+ channelsSource,
761
795
  { name: "peers", read: async () => SNAP.readJson(await fetch("/api/roster"), "peers"),
762
796
  apply: supersededByFeed("peers", (roster) => updateRoster(roster)) },
763
797
  // `.catch(() => ({members: []}))` here turned a failed fetch into an empty snapshot, which the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cotal-ai/web",
3
3
  "description": "Cotal browser observability dashboard as an owned service preset.",
4
- "version": "0.133.13",
4
+ "version": "0.135.1",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -22,9 +22,9 @@
22
22
  "@cotal-ai/workspace": "*"
23
23
  },
24
24
  "devDependencies": {
25
- "@cotal-ai/core": "0.133.13",
25
+ "@cotal-ai/core": "0.135.1",
26
26
  "@cotal-ai/smoke-kit": "0.0.0",
27
- "@cotal-ai/workspace": "0.133.13",
27
+ "@cotal-ai/workspace": "0.135.1",
28
28
  "dompurify": "^3.4.12",
29
29
  "marked": "^18.0.6"
30
30
  },