@agentsignalnet/claude-plugin 0.2.58 → 0.2.60

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentsignal",
3
3
  "displayName": "AgentSignal",
4
- "version": "0.2.58",
4
+ "version": "0.2.60",
5
5
  "description": "Page a human from inside Claude Code, or become an addressable agent that other agents can reach.",
6
6
  "author": {
7
7
  "name": "Data Group AI",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsignalnet/claude-plugin",
3
- "version": "0.2.58",
3
+ "version": "0.2.60",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -68,7 +68,10 @@ function borrowFromMcpConfig() {
68
68
  try {
69
69
  config = JSON.parse(readFileSync(join(homedir(), '.claude.json'), 'utf8'));
70
70
  } catch {
71
- return null;
71
+ // An empty list, not null: every caller now treats this as "the servers
72
+ // that hold a key", and no file is none of them rather than an absence of
73
+ // an answer.
74
+ return [];
72
75
  }
73
76
 
74
77
  const found = [];
@@ -88,10 +91,24 @@ function borrowFromMcpConfig() {
88
91
  };
89
92
  walk(config);
90
93
 
91
- // More than one and there is no principled way to choose: they may be
92
- // different accounts, and picking wrong shows somebody else's conversation.
93
- if (found.length !== 1) return found.length > 1 ? { ambiguous: found.map((f) => f.name) } : null;
94
- return found[0];
94
+ /**
95
+ * ALL OF THEM, and the caller decides.
96
+ *
97
+ * This used to answer "ambiguous" above one and the viewer exited, on the
98
+ * reasoning that there is no principled way to CHOOSE -- which was true and
99
+ * is no longer the question. Nothing chooses now: every key this machine
100
+ * holds becomes a channel in the rail, named, and the reader picks by
101
+ * clicking. Refusing to start was only ever the right answer while showing
102
+ * one of them silently was the alternative.
103
+ *
104
+ * Two servers may be two ACCOUNTS rather than two channels of one, which is
105
+ * a real difference and not one that matters here: either way they are
106
+ * conversations this machine has the key for, and either way the rail says
107
+ * which is which. What DOES matter is the base URL, and the caller filters
108
+ * on it -- a key for a local API and a key for production are not two
109
+ * channels, they are two different APIs.
110
+ */
111
+ return found;
95
112
  }
96
113
 
97
114
  /**
@@ -126,21 +143,16 @@ const port = Number(process.env.PORT ?? 8899);
126
143
  */
127
144
  const token = randomUUID();
128
145
 
129
- if (!apiKey) {
130
- const borrowed = borrowFromMcpConfig();
131
- if (borrowed?.ambiguous) {
132
- console.error(
133
- `Several AgentSignal MCP servers hold a key (${borrowed.ambiguous.join(', ')}).\n` +
134
- 'They may be different accounts, so set AGENTSIGNAL_API_KEY to say which.',
135
- );
136
- process.exit(1);
137
- }
138
- if (borrowed) {
139
- apiKey = borrowed.key;
140
- baseUrl ??= borrowed.baseUrl;
141
- console.log(`Using the API key from MCP server "${borrowed.name}" in ~/.claude.json.`);
142
- }
143
- }
146
+ /**
147
+ * Servers configured in ~/.claude.json that hold a key.
148
+ *
149
+ * Collected before the base URL is settled, because the first of them is
150
+ * allowed to decide it: somebody running the viewer against a local API has
151
+ * said so once, in the server they added, and should not have to say it again
152
+ * in the environment.
153
+ */
154
+ const borrowed = apiKey ? [] : borrowFromMcpConfig();
155
+ if (borrowed.length) baseUrl ??= borrowed[0].baseUrl;
144
156
 
145
157
  baseUrl = (baseUrl ?? 'https://api.agentsignal.net').replace(/\/+$/, '');
146
158
 
@@ -266,6 +278,35 @@ if (apiKey) {
266
278
  * separately rather than silently merging it with something it may not be.
267
279
  */
268
280
  const byChannel = new Map();
281
+
282
+ /**
283
+ * CONFIGURED SERVERS FIRST, then identities.
284
+ *
285
+ * A key somebody put in a config is a key they chose; a key found in an
286
+ * identity file is one this machine minted for itself. When both open the
287
+ * same channel the chosen one wins, which is the same precedence the
288
+ * environment already gets over everything.
289
+ *
290
+ * Filtered on base URL, and this is the one place the difference bites: two
291
+ * servers may be two accounts, which is fine and shows as two channels, but
292
+ * a server pointed at a local API is not a channel of the production one.
293
+ * Mixing those would put a development conversation in the same rail as a
294
+ * real one, named identically, with no way to tell them apart.
295
+ */
296
+ for (const server of borrowed) {
297
+ const at = (server.baseUrl ?? baseUrl).replace(/\/+$/, '');
298
+ if (at !== baseUrl) continue;
299
+ const ref = channelOfKey(server.key);
300
+ if (byChannel.has(ref ?? server.key)) continue;
301
+ byChannel.set(ref ?? server.key, {
302
+ key: server.key,
303
+ via: `MCP server "${server.name}"`,
304
+ from: join(homedir(), '.claude.json'),
305
+ ref,
306
+ name: null,
307
+ });
308
+ }
309
+
269
310
  for (const holder of everyHolder()) {
270
311
  const key = keyOf(holder);
271
312
  if (!key) continue;
@@ -525,6 +566,37 @@ const PAGE = `<!doctype html>
525
566
  /* The two names, stacked. min-width:0 is what lets the ellipsis inside
526
567
  actually happen -- a flex child defaults to min-width:auto and refuses to
527
568
  shrink below its content, so the row overflows instead of trimming. */
569
+ /* A CHANNEL AND ITS CONTENTS, which is what the nesting is for. The rule
570
+ that matters is the left border on the body: without a line, an indent
571
+ alone reads as ragged alignment rather than as containment. */
572
+ /* The company a group of channels belongs to. Quieter than the rail title
573
+ above it and louder than the channel rows beneath, so it reads as a
574
+ heading for them rather than as another thing to click. */
575
+ .company + .company { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
576
+ .company-name {
577
+ font-size: 12px; font-weight: 600; color: var(--fg);
578
+ margin: 0 0 6px; padding: 0 2px;
579
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
580
+ }
581
+ .chan { margin-bottom: 4px; }
582
+ .chan-head { display: flex; align-items: center; gap: 2px; }
583
+ .twist {
584
+ flex: 0 0 auto; width: 20px; height: 24px; padding: 0; cursor: pointer;
585
+ border: 1px solid transparent; border-radius: 6px; background: transparent;
586
+ color: var(--dim); font: inherit; font-size: 11px; line-height: 1;
587
+ }
588
+ .twist:hover { background: var(--accent-soft); color: var(--fg); }
589
+ .twist:focus-visible { outline: none; box-shadow: var(--focus); }
590
+ .chan-name { flex: 1; min-width: 0; }
591
+ .chan-body {
592
+ margin-left: 9px; padding-left: 10px; border-left: 1px solid var(--line);
593
+ margin-top: 1px;
594
+ }
595
+ /* The channel being read, said once and quietly. Every other row in here is
596
+ a link too, so the marker has to be weight rather than another colour. */
597
+ nav a.chan-name.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
598
+ .chan-body .none { font-size: 12px; color: var(--dim); font-style: italic; margin: 4px 8px; }
599
+
528
600
  .stack { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
529
601
  .alias {
530
602
  font-size: 11px; color: var(--dim); line-height: 1.3;
@@ -770,9 +842,8 @@ const PAGE = `<!doctype html>
770
842
  <span class="meta" style="margin-left:auto"><span class="dot" id="dot"></span> <span id="count">0</span> messages</span>
771
843
  </header>
772
844
  <div id="shell">
773
- <aside id="side" aria-label="Channel">
774
- <div id="channels" hidden><p class="rail-title">Channels</p><nav id="chan-nav"></nav></div>
775
- <p class="rail-title">In this channel</p>
845
+ <aside id="side" aria-label="Channels">
846
+ <p class="rail-title">Channels</p>
776
847
  <nav id="who-nav"></nav>
777
848
  <details id="setup"><summary>This machine</summary><div id="setupbody">reading…</div></details>
778
849
  </aside>
@@ -987,6 +1058,15 @@ const PAGE = `<!doctype html>
987
1058
  const T = new URLSearchParams(location.search).get('t') || '';
988
1059
  const q = (path) => path + (path.includes('?') ? '&' : '?') + 't=' + encodeURIComponent(T);
989
1060
 
1061
+ /** Every channel the server can open, from the poll. */
1062
+ let CHANNELS = [];
1063
+ /** Which of them are expanded in the rail. */
1064
+ const OPEN = new Set();
1065
+ /** The rendered agent tree per channel, so reopening one costs nothing. */
1066
+ const BRANCHES = new Map();
1067
+ /** Whether the channel being read has been opened for the first time yet. */
1068
+ let OPENED_ONCE = false;
1069
+
990
1070
  async function post(path, payload) {
991
1071
  const response = await fetch(q(path), {
992
1072
  method: 'POST',
@@ -1001,17 +1081,24 @@ const PAGE = `<!doctype html>
1001
1081
  // answers to one question on one screen.
1002
1082
  let ROSTER = [];
1003
1083
 
1004
- async function roster() {
1084
+ /**
1085
+ * ONE CHANNEL'S ROSTER, fetched and turned into a branch of the rail.
1086
+ *
1087
+ * Takes the channel rather than reading the URL, because the rail can now
1088
+ * show the members of a channel you are NOT looking at -- that is what
1089
+ * expanding one means. The active flag says whether this is the channel whose log
1090
+ * is on screen, which decides two things it would be wrong to do for the
1091
+ * others: filling the send box, and holding ROSTER for the log to read
1092
+ * names out of.
1093
+ */
1094
+ async function roster(ref, active) {
1005
1095
  let list;
1006
1096
  try {
1007
- // Same channel the log is showing, carried from the URL for the same
1008
- // reason the poll carries it.
1009
- const on = new URLSearchParams(location.search).get('channel');
1010
- list = await (await fetch(q('/agents' + (on ? '?channel=' + encodeURIComponent(on) : '')))).json();
1097
+ list = await (await fetch(q('/agents' + (ref ? '?channel=' + encodeURIComponent(ref) : '')))).json();
1011
1098
  } catch {
1012
1099
  return;
1013
1100
  }
1014
- ROSTER = list.recipients ?? [];
1101
+ if (active) ROSTER = list.recipients ?? [];
1015
1102
  // People are listed too, and a person has no chat to open -- nothing is
1016
1103
  // sent FROM a phone. Agents only.
1017
1104
  const everyone = list.recipients ?? [];
@@ -1020,7 +1107,10 @@ const PAGE = `<!doctype html>
1020
1107
  // a person's conversation -- nothing is sent from a phone -- but notifying
1021
1108
  // one is the most useful thing this box does.
1022
1109
  const to = document.getElementById('to');
1023
- for (const r of everyone) {
1110
+ // Only for the channel on screen. Expanding another channel to see who is
1111
+ // in it must not quietly add its members to the box that sends -- picking
1112
+ // one would deliver into a channel the composer is not looking at.
1113
+ for (const r of active ? everyone : []) {
1024
1114
  const option = document.createElement('option');
1025
1115
  option.value = r.key;
1026
1116
  option.textContent = (who(r) || r.key) + (r.is_agent ? '' : ' (person)');
@@ -1079,8 +1169,13 @@ const PAGE = `<!doctype html>
1079
1169
  * the top and this still caught me.
1080
1170
  */
1081
1171
  const alias = a.name && a.name !== a.handle ? a.name : null;
1082
- return '<a href="/a/' + encodeURIComponent(at) + '" data-agent="' + esc(at) +
1083
- '" data-key="' + esc(a.key) + '" class="' + state + on +
1172
+ // The channel this agent is in, carried on the link so the rail can tell
1173
+ // a filter (same channel, no request) from a navigation (another
1174
+ // channel, which has no traffic loaded to filter). The href carries it
1175
+ // too, because following it must land on the right conversation.
1176
+ const at_channel = ref ? '?channel=' + encodeURIComponent(ref) : '';
1177
+ return '<a href="/a/' + encodeURIComponent(at) + at_channel + '" data-agent="' + esc(at) +
1178
+ '" data-channel="' + esc(ref ?? '') + '" data-key="' + esc(a.key) + '" class="' + state + on +
1084
1179
  '" title="' + esc(name) + ' — last seen ' + esc(when) + '"><i></i>' +
1085
1180
  '<span class="stack"><span class="nm">' + esc(a.handle ?? name) + '</span>' +
1086
1181
  (alias ? '<small class="alias">' + esc(alias) + '</small>' : '') +
@@ -1137,11 +1232,17 @@ const PAGE = `<!doctype html>
1137
1232
  .join('');
1138
1233
  };
1139
1234
 
1140
- document.getElementById('who-nav').innerHTML =
1141
- '<a href="/" data-agent="" data-key="" class="whole' + (AGENT ? '' : ' on') + '">' +
1142
- '<span class="nm">' + esc((list.channel && list.channel.name) || 'whole channel') + '</span>' +
1143
- '<em>everything</em></a>' +
1144
- branch(null, 0);
1235
+ /**
1236
+ * Keyed by the ref the SERVER resolved, not the one we asked with.
1237
+ *
1238
+ * At boot there is no channel in the URL and no channel list yet, so the
1239
+ * fetch goes out unqualified and the server answers about its default.
1240
+ * Caching that under the empty string left the rail looking up the real
1241
+ * ref, finding nothing, and showing "reading..." forever under a channel
1242
+ * whose roster had already arrived.
1243
+ */
1244
+ BRANCHES.set(list.channel?.ref ?? ref ?? '', branch(null, 0));
1245
+ drawRail();
1145
1246
  }
1146
1247
 
1147
1248
  /**
@@ -1158,25 +1259,147 @@ const PAGE = `<!doctype html>
1158
1259
  * carried through, because dropping it is what made the agent links
1159
1260
  * answer "Not found" before they stopped being links at all.
1160
1261
  */
1161
- function renderChannels(list) {
1162
- const box = document.getElementById('channels');
1163
- if (!box) return;
1164
- if (!list || list.length < 2) {
1165
- box.hidden = true;
1262
+ /**
1263
+ * ONE TREE: every channel, each opening to show who is in it.
1264
+ *
1265
+ * It was two lists -- the channels, then "in this channel" -- which said the
1266
+ * same relationship twice and made the members look like a separate thing
1267
+ * rather than the contents of the row above them. Nesting is the honest
1268
+ * shape: an agent belongs to exactly one channel, and the rail should say so
1269
+ * by where it puts it.
1270
+ *
1271
+ * A channel you are not looking at can be opened. That costs one roster
1272
+ * fetch, once, and answers "who is in the other one" without leaving the
1273
+ * conversation you are reading.
1274
+ */
1275
+ function drawRail() {
1276
+ const nav = document.getElementById('who-nav');
1277
+ if (!nav) return;
1278
+
1279
+ /**
1280
+ * SECTIONED BY COMPANY, because a channel name means little on its own.
1281
+ *
1282
+ * "Default" is the name almost every account's first channel has, so two
1283
+ * companies produce two rows called the same thing and the rail becomes a
1284
+ * list you have to decode. Grouped under whose they are, the same two rows
1285
+ * read at a glance.
1286
+ *
1287
+ * Grouped on the account ID and LABELLED with the name: two companies may
1288
+ * choose the same name, and one renamed mid-session must not split into
1289
+ * two sections. A channel whose account is not known yet -- the key
1290
+ * context is cached for a minute, so this happens right after the column
1291
+ * was added -- groups under its own ref rather than being hidden.
1292
+ *
1293
+ * The heading is dropped when everything belongs to one company. A section
1294
+ * label that is the same for every row underneath it is furniture.
1295
+ */
1296
+ const groups = [];
1297
+ for (const c of CHANNELS) {
1298
+ /**
1299
+ * UNKNOWN ACCOUNTS SHARE ONE BUCKET, they do not each get their own.
1300
+ *
1301
+ * The account arrives from the API, and an older one does not send it at
1302
+ * all -- as does a key whose context was cached before the field
1303
+ * existed. Keying those on the channel instead would give every channel
1304
+ * a section of its own, each headed "Unnamed company", which is the flat
1305
+ * list back again with a wrong label on every row.
1306
+ */
1307
+ const at = c.account ?? '';
1308
+ let group = groups.find((g) => g.at === at);
1309
+ if (!group) {
1310
+ group = { at, company: c.company ?? null, channels: [] };
1311
+ groups.push(group);
1312
+ }
1313
+ // The first non-null name wins, so one channel answering before another
1314
+ // does not leave the section unlabelled.
1315
+ group.company = group.company ?? c.company ?? null;
1316
+ group.channels.push(c);
1317
+ }
1318
+
1319
+ // Headings only when they distinguish something. One company, or a server
1320
+ // that does not say, and the rail stays the plain list it was.
1321
+ const sectioned = groups.length > 1 && groups.every((g) => g.at);
1322
+
1323
+ const rows = (list) => list.map((c) => {
1324
+ const ref = c.ref ?? '';
1325
+ const open = OPEN.has(ref);
1326
+ const branch = BRANCHES.get(ref);
1327
+ const href = c.ref ? q('/?channel=' + encodeURIComponent(c.ref)) : q('/');
1328
+
1329
+ const head =
1330
+ '<div class="chan-head">' +
1331
+ '<button type="button" class="twist" data-open="' + ref + '" ' +
1332
+ 'aria-expanded="' + (open ? 'true' : 'false') + '" ' +
1333
+ 'aria-label="' + (open ? 'Collapse ' : 'Expand ') + esc(c.name || ref) + '">' +
1334
+ (open ? '▾' : '▸') + '</button>' +
1335
+ '<a class="chan-name' + (c.active ? ' on' : '') + '" href="' + esc(href) + '" data-channel="' + ref + '">' +
1336
+ '<span class="stack"><span class="nm">' + esc(c.name || ref || 'channel') + '</span>' +
1337
+ (ref ? '<small class="alias">' + esc(ref) + '</small>' : '') +
1338
+ '</span></a></div>';
1339
+
1340
+ if (!open) return '<div class="chan">' + head + '</div>';
1341
+
1342
+ // "everything" clears the agent filter, and only means anything in the
1343
+ // channel being read -- in any other it is the link that switches to it.
1344
+ const all =
1345
+ '<a href="' + esc(href) + '" data-agent="" data-key="" data-channel="' + ref + '" ' +
1346
+ 'class="whole' + (c.active && !AGENT ? ' on' : '') + '">' +
1347
+ '<span class="nm">everything here</span></a>';
1348
+
1349
+ const body = branch === undefined ? '<p class="none">reading…</p>' : all + branch;
1350
+ return '<div class="chan">' + head + '<div class="chan-body">' + body + '</div></div>';
1351
+ }).join('');
1352
+
1353
+ nav.innerHTML = groups
1354
+ .map((g) =>
1355
+ sectioned
1356
+ ? '<div class="company"><p class="company-name">' +
1357
+ esc(g.company || 'Unnamed company') +
1358
+ '</p>' + rows(g.channels) + '</div>'
1359
+ : rows(g.channels),
1360
+ )
1361
+ .join('');
1362
+
1363
+ markNav();
1364
+ }
1365
+
1366
+ /**
1367
+ * Open a channel, fetching its roster the first time.
1368
+ *
1369
+ * Drawn twice on purpose: once immediately so the twisty turns and a
1370
+ * "reading…" line appears, and again when the roster lands. Waiting for the
1371
+ * network before showing anything makes a click feel like it missed.
1372
+ */
1373
+ async function openChannel(ref) {
1374
+ if (OPEN.has(ref)) {
1375
+ OPEN.delete(ref);
1376
+ drawRail();
1166
1377
  return;
1167
1378
  }
1168
- box.hidden = false;
1169
- document.getElementById('chan-nav').innerHTML = list
1170
- .map((c) => {
1171
- const href = c.ref ? q('/?channel=' + encodeURIComponent(c.ref)) : q('/');
1172
- return (
1173
- '<a href="' + esc(href) + '" class="' + (c.active ? 'on' : '') + '">' +
1174
- '<span class="stack"><span class="nm">' + esc(c.name || c.ref || 'channel') + '</span>' +
1175
- (c.ref ? '<small class="alias">' + esc(c.ref) + '</small>' : '') +
1176
- '</span></a>'
1177
- );
1178
- })
1179
- .join('');
1379
+ OPEN.add(ref);
1380
+ drawRail();
1381
+ if (!BRANCHES.has(ref)) {
1382
+ await roster(ref, ref === activeRef());
1383
+ }
1384
+ }
1385
+
1386
+ /** The channel whose log is on screen. */
1387
+ function activeRef() {
1388
+ return new URLSearchParams(location.search).get('channel') ?? (CHANNELS[0]?.ref ?? '');
1389
+ }
1390
+
1391
+ /** Keep the rail in step with what the poll says exists. */
1392
+ function renderChannels(list) {
1393
+ if (!list) return;
1394
+ CHANNELS = list;
1395
+ const active = list.find((c) => c.active);
1396
+ // The channel being read starts open, because its members are the ones
1397
+ // the log is about. The rest stay shut until asked for.
1398
+ if (active && !OPENED_ONCE) {
1399
+ OPEN.add(active.ref ?? '');
1400
+ OPENED_ONCE = true;
1401
+ }
1402
+ drawRail();
1180
1403
  }
1181
1404
 
1182
1405
  /** Whether a nav link is the one currently filtering. Key or handle, either may be in the URL. */
@@ -1187,10 +1410,26 @@ const PAGE = `<!doctype html>
1187
1410
  return AGENT === at || ( AGENT !== '' && AGENT === key );
1188
1411
  }
1189
1412
 
1413
+ /**
1414
+ * Whether a rail link is an agent filter at all.
1415
+ *
1416
+ * A channel row has no data-agent, and reading a missing one as the empty
1417
+ * string made every channel match the unfiltered view -- so both channels
1418
+ * lit up as selected at once, which is the one thing the highlight exists
1419
+ * to prevent.
1420
+ */
1421
+ function isFilter(link) {
1422
+ return link.dataset.agent !== undefined;
1423
+ }
1424
+
1190
1425
  /** Move the highlight without re-rendering the roster, which would refetch /agents. */
1191
1426
  function markNav() {
1192
1427
  for (const link of document.querySelectorAll('#who-nav a')) {
1193
- link.classList.toggle('on', matchesNav(link));
1428
+ if (!isFilter(link)) continue;
1429
+ // Only within the channel being read: an agent link in a channel you are
1430
+ // peeking into is a way to go there, not the current selection.
1431
+ const here = (link.dataset.channel ?? '') === activeRef();
1432
+ link.classList.toggle('on', here && matchesNav(link));
1194
1433
  }
1195
1434
  }
1196
1435
 
@@ -2014,10 +2253,30 @@ const PAGE = `<!doctype html>
2014
2253
  // nothing a new tab could show that this does not. Somebody who wants one can copy the
2015
2254
  // address bar, which has the token.
2016
2255
  document.getElementById('who-nav').addEventListener('click', (event) => {
2017
- const link = event.target.closest('a');
2256
+ // The twisty opens and closes without going anywhere. Checked first
2257
+ // because it sits inside the same row as the link beside it.
2258
+ const twist = event.target.closest('.twist');
2259
+ if (twist) {
2260
+ event.preventDefault();
2261
+ openChannel(twist.dataset.open ?? '');
2262
+ return;
2263
+ }
2018
2264
 
2265
+ const link = event.target.closest('a');
2019
2266
  if (!link) return;
2020
2267
 
2268
+ /**
2269
+ * AN AGENT IN ANOTHER CHANNEL IS A NAVIGATION, not a filter.
2270
+ *
2271
+ * Filtering in place is right within the channel on screen -- no request,
2272
+ * nothing to drop. It is wrong for a channel you are only peeking into:
2273
+ * there is no traffic loaded to filter, so the log would empty and look
2274
+ * broken. Let the browser follow the link instead; the page comes back on
2275
+ * that channel with that agent selected.
2276
+ */
2277
+ const belongsTo = link.dataset.channel ?? '';
2278
+ if (belongsTo !== activeRef()) return;
2279
+
2021
2280
  event.preventDefault();
2022
2281
  filterTo(link.dataset.agent ?? '', true);
2023
2282
  });
@@ -2026,7 +2285,7 @@ const PAGE = `<!doctype html>
2026
2285
  // the navigations they replaced. No push: this IS the pop.
2027
2286
  addEventListener('popstate', () => filterTo(agentFromPath(location.pathname), false));
2028
2287
 
2029
- roster();
2288
+ roster(activeRef(), true);
2030
2289
  setup();
2031
2290
  pending();
2032
2291
  setInterval(pending, 2000);
@@ -2933,6 +3192,12 @@ const server = createServer(async (req, res) => {
2933
3192
  on.ref = body.channel.ref;
2934
3193
  on.name = body.channel.name ?? on.name;
2935
3194
  }
3195
+ // Whose channel it is, for the rail's sections. Kept on the channel
3196
+ // rather than looked up again: one poll already answered it.
3197
+ if (body.account?.id) {
3198
+ on.account = body.account.id;
3199
+ on.company = body.account.name ?? on.company;
3200
+ }
2936
3201
  channelRef = on.ref ?? channelRef;
2937
3202
 
2938
3203
  const fresh = (body.messages ?? []).map(keepable).filter(Boolean);
@@ -2948,6 +3213,8 @@ const server = createServer(async (req, res) => {
2948
3213
  ref: c.ref,
2949
3214
  name: c.name ?? c.via,
2950
3215
  via: c.via,
3216
+ account: c.account ?? null,
3217
+ company: c.company ?? null,
2951
3218
  active: c === on,
2952
3219
  }));
2953
3220
  // What this call actually cost, so the page can say so rather than
@@ -3047,12 +3314,16 @@ async function nameChannels() {
3047
3314
  // already on its way, and it breaks the property that a viewer watching
3048
3315
  // one channel makes exactly one call to fetch and one to keep up.
3049
3316
  channels.slice(1).map(async (c) => {
3050
- if (c.name) return;
3317
+ if (c.name && c.account) return;
3051
3318
  const body = await upstream(`/v1/messages?limit=1&since=${encodeURIComponent(now)}`, c.key);
3052
3319
  if (body?.channel?.name) {
3053
3320
  c.name = body.channel.name;
3054
3321
  c.ref = body.channel.ref ?? c.ref;
3055
3322
  }
3323
+ if (body?.account?.id) {
3324
+ c.account = body.account.id;
3325
+ c.company = body.account.name ?? null;
3326
+ }
3056
3327
  }),
3057
3328
  );
3058
3329
  }