@slack/radar-mcp 1.24.0 → 1.26.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.
Files changed (51) hide show
  1. package/README.md +41 -4
  2. package/dist/mcp/dispatch.d.ts +1 -0
  3. package/dist/mcp/dispatch.js +4 -2
  4. package/dist/mcp/flags-tools.d.ts +1 -0
  5. package/dist/mcp/flags-tools.js +3 -9
  6. package/dist/mcp/index.js +16 -40
  7. package/dist/mcp/json-rows.d.ts +6 -0
  8. package/dist/mcp/json-rows.js +10 -0
  9. package/dist/mcp/radar-response.d.ts +2 -2
  10. package/dist/mcp/radar-response.js +2 -2
  11. package/dist/mcp/redact.d.ts +14 -0
  12. package/dist/mcp/redact.js +71 -0
  13. package/dist/mcp/session-enable.d.ts +1 -0
  14. package/dist/mcp/session-enable.js +8 -6
  15. package/dist/mcp/snapshot-cli.d.ts +52 -0
  16. package/dist/mcp/snapshot-cli.js +316 -0
  17. package/dist/mcp/snapshot-summary.d.ts +1 -0
  18. package/dist/mcp/snapshot-summary.js +254 -0
  19. package/dist/mcp/snapshot.d.ts +32 -3
  20. package/dist/mcp/snapshot.js +347 -102
  21. package/dist/mcp/tools.js +11 -7
  22. package/dist/shared/android.d.ts +25 -0
  23. package/dist/shared/android.js +97 -0
  24. package/dist/shared/feature-flags.d.ts +20 -0
  25. package/dist/shared/feature-flags.js +35 -4
  26. package/dist/shared/radar-token.d.ts +5 -5
  27. package/dist/shared/radar-token.js +24 -10
  28. package/dist/shared/switchboard-note.d.ts +19 -0
  29. package/dist/shared/switchboard-note.js +76 -0
  30. package/dist/shared/switchboard-report.js +43 -4
  31. package/dist/shared/switchboard.d.ts +1 -1
  32. package/dist/shared/switchboard.js +14 -2
  33. package/dist/shared/transport.d.ts +18 -0
  34. package/dist/shared/wire.d.ts +2 -0
  35. package/dist/web/install-app-cli.d.ts +2 -0
  36. package/dist/web/install-app-cli.js +60 -0
  37. package/dist/web/install-app.d.ts +16 -7
  38. package/dist/web/install-app.js +92 -39
  39. package/dist/web/macapp/RadarApp.swift +12 -11
  40. package/dist/web/public/index.html +5 -2
  41. package/dist/web/public/next/feature-flags.js +50 -0
  42. package/dist/web/public/next/feed.js +15 -4
  43. package/dist/web/public/next/flags.js +17 -3
  44. package/dist/web/public/next/registry.js +4 -4
  45. package/dist/web/public/next/store.js +90 -4
  46. package/dist/web/public/next/switchboard-note.js +76 -0
  47. package/dist/web/public/next/voice-model.js +209 -15
  48. package/dist/web/public/next/voice.js +73 -10
  49. package/dist/web/spec.d.ts +1 -1
  50. package/dist/web/spec.js +1 -1
  51. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { CACHE_TTL_MS } from "./registry.js";
2
- import { CLIP_PEAK, SAVED_TURN_OUTCOMES, savedTurnCountEntries } from "./switchboard-note.js";
2
+ import { CLIP_PEAK, SAVED_TURN_OUTCOMES, SERVER_SESSION_ID_CAP, cardLabel, openCards, savedTurnCountEntries, serverEndedNormally } from "./switchboard-note.js";
3
3
  // Re-exported so a model test can assert the clamp without importing the registry module itself.
4
4
  export { CACHE_TTL_MS };
5
5
  export { CLIP_PEAK };
@@ -159,6 +159,28 @@ export function segments(rows, stateKind, onValue, now) {
159
159
  out.push({ from: openAt, to: Math.max(now, openAt), open: true });
160
160
  return out;
161
161
  }
162
+ // Spans where the user held the reply: a `player` reply_hold opens one, the next reply_unhold
163
+ // closes it, and a hold still open runs to `endT` (the session's end, or now on a live call). A
164
+ // repeated hold while one is open and an unhold with nothing open say nothing new, so they are
165
+ // ignored.
166
+ export function replyHolds(rows, endT) {
167
+ const out = [];
168
+ let openAt = null;
169
+ for (const r of rows) {
170
+ if (r.kind !== "player")
171
+ continue;
172
+ const t = recordTime(r);
173
+ if (r.event === "reply_hold" && openAt === null)
174
+ openAt = t;
175
+ else if (r.event === "reply_unhold" && openAt !== null) {
176
+ out.push({ from: openAt, to: Math.max(t, openAt), open: false });
177
+ openAt = null;
178
+ }
179
+ }
180
+ if (openAt !== null)
181
+ out.push({ from: openAt, to: Math.max(endT, openAt), open: true });
182
+ return out;
183
+ }
162
184
  // A tts.stop marker's own label needs to know what happened after it: whether the model actually
163
185
  // went quiet before the next stop was sent, and how long that took. Scans forward from the stop's
164
186
  // own position rather than the whole array, so an earlier stop never borrows a later stop's quiet.
@@ -265,13 +287,27 @@ export function markers(rows, window) {
265
287
  const wasSpeaking = lastSpeakingTo !== "quiet";
266
288
  out.push({ kind: "stop", t, label: stopFollowUpLabel(rows, i, t, wasSpeaking, ended), record: r });
267
289
  }
290
+ else if (r.kind === "card") {
291
+ out.push({ kind: "card", t, label: cardLabel(r.card_kind, r.event, r.by), record: r });
292
+ }
268
293
  else if (r.kind === "state" && r.state_kind === "mic" && r.to === "Paused") {
269
294
  const cause = str(r.cause);
270
295
  out.push({ kind: "focus", t, label: cause ? `mic Paused (${cause})` : "mic Paused", record: r });
271
296
  }
297
+ else if (r.kind === "state" && r.state_kind === "connection" && r.to === "Disconnected" && r.cause === "SwipedAway") {
298
+ // The user's own swipe, so the neutral kind the server-ended tick uses, not an error.
299
+ out.push({ kind: "ending", t, label: "app swiped away", record: r });
300
+ }
272
301
  else if (r.kind === "state" && r.state_kind === "connection" && r.to === "Failed") {
273
302
  const cause = str(r.cause);
274
- out.push({ kind: "error", t, label: cause ? `connection Failed (${cause})` : "connection Failed", record: r });
303
+ // A server ending that is a normal end (a limit, the model's goodbye) is not a fault, so it
304
+ // gets its own neutral kind instead of the red error.
305
+ if (serverEndedNormally(cause)) {
306
+ out.push({ kind: "ending", t, label: `server ended the call (${cause})`, record: r });
307
+ }
308
+ else {
309
+ out.push({ kind: "error", t, label: cause ? `connection Failed (${cause})` : "connection Failed", record: r });
310
+ }
275
311
  }
276
312
  }
277
313
  return out;
@@ -279,10 +315,15 @@ export function markers(rows, window) {
279
315
  // `pending` requires evidence the build reports ids at all (a ready or levels record, or the
280
316
  // summary key present). A ready record with no id settles it as "no id"; a null summary does
281
317
  // not, since the summary is a snapshot rather than the one-shot event.
282
- export function serverSessionId(rows, ended, summaryServerSessionId) {
318
+ export function serverSessionId(rows, ended, summaryServerSessionId, summaryServerSessionIds) {
283
319
  let id = null;
284
320
  let knownNewBuild = false;
285
321
  let seenReady = false;
322
+ const all = summaryServerSessionIds ? [...new Set(summaryServerSessionIds)] : [];
323
+ // The refill holds up to 2000 rows but the summary list only the newest 8, so a ready row for an
324
+ // id before the list's last one is older than the list. Only rows after that id's row extend it.
325
+ const listLast = all.length > 0 ? all[all.length - 1] : null;
326
+ let pastListLast = listLast === null;
286
327
  for (const r of rows) {
287
328
  if (r.kind === "levels")
288
329
  knownNewBuild = true;
@@ -291,15 +332,22 @@ export function serverSessionId(rows, ended, summaryServerSessionId) {
291
332
  knownNewBuild = true;
292
333
  seenReady = true;
293
334
  const v = str(r.server_session_id);
294
- if (v !== null)
335
+ if (v !== null) {
295
336
  id = v;
337
+ if (summaryServerSessionIds && !all.includes(v) && pastListLast)
338
+ all.push(v);
339
+ if (v === listLast)
340
+ pastListLast = true;
341
+ }
296
342
  }
343
+ if (all.length > SERVER_SESSION_ID_CAP)
344
+ all.splice(0, all.length - SERVER_SESSION_ID_CAP);
297
345
  if (summaryServerSessionId !== undefined) {
298
346
  knownNewBuild = true;
299
347
  if (id === null && summaryServerSessionId !== null)
300
348
  id = summaryServerSessionId;
301
349
  }
302
- return { id, pending: knownNewBuild && id === null && !ended && !seenReady };
350
+ return { id, pending: knownNewBuild && id === null && !ended && !seenReady, all };
303
351
  }
304
352
  // Whether the rows prove the device had no server id: a held ready record, and none of them named
305
353
  // one. A null summary id is not proof, since a refill taken at begin reads null before the ready
@@ -462,18 +510,31 @@ export function downlinkRate(rows, now, windowMs = RATE_WINDOW_MS, sessionBeginA
462
510
  // past this many unknown-order entries the waterfall reads as noise, not a chart, so the rest
463
511
  // collapse into one "+N more" entry rather than drawing all of them.
464
512
  const MAX_EXTRA_PHASES = 8;
465
- // One entry per phase name in handshake order, the latest record of a name winning; names the
513
+ // One entry per phase name in handshake order, the latest record of a name winning (socket and
514
+ // session_ready read the handshake's own, the first ready and the socket before it); names the
466
515
  // order does not know go after, in arrival order, capped at MAX_EXTRA_PHASES with a trailing
467
516
  // "+N more" entry. A phase without a numeric duration is skipped.
468
- export function phases(rows) {
517
+ // The handshake ends at the first timed session_ready; a reconnect repeats socket and
518
+ // session_ready after it. -1 when there is none yet.
519
+ export function firstReadyIndex(rows) {
520
+ return rows.findIndex((r) => r.kind === "phase" && str(r.phase) === "session_ready" && num(r.duration_ms) !== null);
521
+ }
522
+ export function phases(rows, firstReady = firstReadyIndex(rows)) {
469
523
  const byName = new Map();
470
- for (const r of rows) {
524
+ // Letting a reconnect's socket or session_ready win would time the start off the last
525
+ // reconnect, so only those two names stop at the first ready; every other name still takes its
526
+ // latest record.
527
+ for (const [i, r] of rows.entries()) {
471
528
  if (r.kind !== "phase")
472
529
  continue;
473
530
  const name = str(r.phase);
474
531
  const ms = num(r.duration_ms);
475
532
  if (name === null || ms === null)
476
533
  continue;
534
+ if (firstReady !== -1 && name === "socket" && i > firstReady)
535
+ continue;
536
+ if (firstReady !== -1 && name === "session_ready" && i !== firstReady)
537
+ continue;
477
538
  byName.set(name, ms);
478
539
  }
479
540
  const known = PHASE_ORDER.filter((n) => byName.has(n));
@@ -488,6 +549,109 @@ export function phases(rows) {
488
549
  list.push({ name: `+${overflow} more`, ms: 0, slow: false, overflow: true });
489
550
  return { list, totalMs: list.reduce((a, p) => a + p.ms, 0) };
490
551
  }
552
+ // What happened after the handshake's first session_ready, read only off the socket and
553
+ // session_ready phase records so it works even when no Reconnecting state ever arrived. A socket
554
+ // opens a reconnect and the next session_ready closes it; a ready with no socket open stands
555
+ // alone, and a socket still open at the end has no ready yet.
556
+ export function reconnects(rows, firstReady = firstReadyIndex(rows)) {
557
+ const after = rows.slice(firstReady + 1);
558
+ // The device's own try records stand without the first ready: a long call's cache can hold a
559
+ // recent try after the handshake rows aged out. Phase-only guessing still needs the ready.
560
+ if (after.some((r) => r.kind === "reconnect_try")) {
561
+ const rowsFromTries = reconnectsFromTries(after);
562
+ if (firstReady === -1)
563
+ for (const rc of rowsFromTries)
564
+ rc.unnumbered = true;
565
+ return capReconnects(rowsFromTries, true);
566
+ }
567
+ if (firstReady === -1)
568
+ return [];
569
+ const recs = after.filter(isReconnectPhase);
570
+ const out = [];
571
+ let open = null;
572
+ for (const r of recs) {
573
+ const ms = num(r.duration_ms);
574
+ const at = recordTime(r);
575
+ if (str(r.phase) === "socket") {
576
+ // A second socket before any ready means the open try gave up; it stays listed as abandoned.
577
+ if (open)
578
+ open.abandoned = true;
579
+ open = { n: out.length + 1, socketMs: ms, readyMs: null, at };
580
+ out.push(open);
581
+ }
582
+ else if (open) {
583
+ open.readyMs = ms;
584
+ open = null;
585
+ }
586
+ else {
587
+ out.push({ n: out.length + 1, socketMs: null, readyMs: ms, at });
588
+ }
589
+ }
590
+ return capReconnects(out);
591
+ }
592
+ // A timed socket or session_ready phase, the two a reconnect repeats.
593
+ function isReconnectPhase(r) {
594
+ const phase = str(r.phase);
595
+ return r.kind === "phase" && (phase === "socket" || phase === "session_ready") && num(r.duration_ms) !== null;
596
+ }
597
+ function capReconnects(out, tries = false) {
598
+ if (out.length <= MAX_EXTRA_PHASES)
599
+ return out;
600
+ // Keep the newest, so the try still in flight stays in view.
601
+ const hidden = out.length - MAX_EXTRA_PHASES;
602
+ const lead = { n: hidden, socketMs: null, readyMs: null, at: 0, overflow: true };
603
+ if (tries)
604
+ lead.tries = true;
605
+ return [lead, ...out.slice(hidden)];
606
+ }
607
+ // With reconnect_try records the device says how each try ended, so a try record decides its row
608
+ // (a replaced socket shows as that try's retry, never as abandoned). The socket and session_ready
609
+ // phases since the previous try record join the row. n counts reconnects: a try 1, or a gave_up
610
+ // after 0 tries, opens a new one. Phases after the last try record make one open row.
611
+ function reconnectsFromTries(rows) {
612
+ const out = [];
613
+ let reconnectNo = 0;
614
+ let socketMs = null;
615
+ let readyMs = null;
616
+ let pendingAt = null;
617
+ let lastOutcome = null;
618
+ for (const r of rows) {
619
+ if (isReconnectPhase(r)) {
620
+ const ms = num(r.duration_ms);
621
+ if (pendingAt === null)
622
+ pendingAt = recordTime(r);
623
+ if (str(r.phase) === "socket")
624
+ socketMs = ms;
625
+ else
626
+ readyMs = ms;
627
+ }
628
+ else if (r.kind === "reconnect_try") {
629
+ const tryN = num(r.try);
630
+ const outcome = str(r.outcome) ?? "?";
631
+ const gaveUp = outcome === "gave_up";
632
+ if (reconnectNo === 0 || (gaveUp ? tryN === 0 : tryN === 1))
633
+ reconnectNo++;
634
+ const row = {
635
+ n: reconnectNo,
636
+ socketMs: gaveUp ? null : socketMs,
637
+ readyMs: gaveUp ? null : readyMs,
638
+ at: (gaveUp ? null : pendingAt) ?? recordTime(r) ?? 0,
639
+ trigger: str(r.trigger) ?? "?",
640
+ outcome,
641
+ };
642
+ if (tryN !== null)
643
+ row.tryN = tryN;
644
+ out.push(row);
645
+ socketMs = readyMs = pendingAt = null;
646
+ lastOutcome = outcome;
647
+ }
648
+ }
649
+ if (pendingAt !== null) {
650
+ // After a retry the open try belongs to the same reconnect; after anything else it is a new one.
651
+ out.push({ n: lastOutcome === "retry" ? reconnectNo : reconnectNo + 1, socketMs, readyMs, at: pendingAt });
652
+ }
653
+ return out;
654
+ }
491
655
  // Nearest-rank percentile: the value at ceil(p * n), 1-based, of the sorted sample. 0 for an
492
656
  // empty sample, so a card can print 0 rather than a dash.
493
657
  export function percentile(values, p) {
@@ -505,7 +669,9 @@ export function windowStats(rows, from, to) {
505
669
  let rearmsStarved = 0;
506
670
  const gaps = [];
507
671
  let jitterTrim = 0;
672
+ let holdRefuse = 0;
508
673
  let preReadyDrop = 0;
674
+ let preReadyChunks = null;
509
675
  let framesIn = 0;
510
676
  let framesOut = 0;
511
677
  for (let i = rows.length - 1; i >= 0; i--) {
@@ -528,8 +694,14 @@ export function windowStats(rows, from, to) {
528
694
  }
529
695
  else if (r.event === "jitter_trim")
530
696
  jitterTrim++;
531
- else if (r.event === "pre_ready_drop")
697
+ else if (r.event === "hold_refuse")
698
+ holdRefuse++;
699
+ else if (r.event === "pre_ready_drop") {
532
700
  preReadyDrop++;
701
+ const c = num(r.dropped_chunks);
702
+ if (c !== null)
703
+ preReadyChunks = (preReadyChunks ?? 0) + c;
704
+ }
533
705
  }
534
706
  else if (r.kind === "frame") {
535
707
  if (r.direction === "incoming")
@@ -544,9 +716,11 @@ export function windowStats(rows, from, to) {
544
716
  gapP50: percentile(gaps, 0.5),
545
717
  gapP95: percentile(gaps, 0.95),
546
718
  gapSamples: gaps.length,
547
- dropped: jitterTrim + preReadyDrop,
719
+ dropped: jitterTrim + holdRefuse + preReadyDrop,
548
720
  jitterTrim,
721
+ holdRefuse,
549
722
  preReadyDrop,
723
+ preReadyChunks,
550
724
  framesIn,
551
725
  framesOut,
552
726
  };
@@ -588,7 +762,7 @@ export function tickStepMs(spanMs) {
588
762
  // session (no switchboard record at all, or only ones missing session_id / timestamp).
589
763
  // The caller resolves `summaryServerSessionId`, `summarySavedTurnCounts` and `savedTurnOutcomes`
590
764
  // so this module stays store-free.
591
- export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes) {
765
+ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes, summaryServerSessionIds, summaryMicEncoding) {
592
766
  const sessionId = newestSessionId(rows);
593
767
  if (sessionId === null)
594
768
  return null;
@@ -602,7 +776,8 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
602
776
  const closeAt = endedAt !== null ? endedAt : now;
603
777
  const window = windowFor(modelRows, zoom, closeAt);
604
778
  const inWindow = (s) => s.to >= window.from && s.from <= window.to;
605
- const ph = phases(modelRows);
779
+ const firstReady = firstReadyIndex(modelRows);
780
+ const ph = phases(modelRows, firstReady);
606
781
  const hasReady = ph.list.some((p) => p.name === "session_ready");
607
782
  const socketIdx = ph.list.findIndex((p) => p.name === "socket");
608
783
  const socketRec = [...modelRows].filter((r) => r.kind === "phase" && r.phase === "socket").pop();
@@ -611,9 +786,19 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
611
786
  // The last `to: "Failed"` connection record, not just the latest connection state: a trailing
612
787
  // Disconnected (or any other state) after the real Failed(Timeout) must not hide it.
613
788
  let lastFailed = null;
789
+ // Whether only Disconnected moves came after that Failed. The goodbye can still be playing
790
+ // when the controller settles to Disconnected, so that keeps the normal ending; any other move
791
+ // means the call went on.
792
+ let settledSinceFailed = false;
614
793
  for (const r of modelRows) {
615
- if (r.kind === "state" && r.state_kind === "connection" && str(r.to) === "Failed") {
794
+ if (r.kind !== "state" || r.state_kind !== "connection")
795
+ continue;
796
+ if (str(r.to) === "Failed") {
616
797
  lastFailed = { to: "Failed", cause: str(r.cause), at: recordTime(r) };
798
+ settledSinceFailed = true;
799
+ }
800
+ else if (str(r.to) !== "Disconnected") {
801
+ settledSinceFailed = false;
617
802
  }
618
803
  }
619
804
  const failedAt = lastFailed ? lastFailed.at : null;
@@ -665,7 +850,7 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
665
850
  // phase record's own timestamp, when both exist, rather than the phase durations' sum -- two
666
851
  // phases can overlap or leave a gap the durations alone never show. Falls back to the sum when
667
852
  // either is missing.
668
- const readyRec = modelRows.filter((r) => r.kind === "phase" && str(r.phase) === "session_ready" && num(r.duration_ms) !== null).pop();
853
+ const readyRec = firstReady === -1 ? undefined : modelRows[firstReady];
669
854
  const phaseWallIsSum = !(readyRec && beginRec);
670
855
  const phaseWallMs = phaseWallIsSum ? ph.totalMs : recordTime(readyRec) - recordTime(beginRec);
671
856
  let connection = latestConn;
@@ -678,12 +863,15 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
678
863
  return {
679
864
  sessionId,
680
865
  connection,
866
+ endedNormally: settledSinceFailed && serverEndedNormally(lastFailed?.cause),
681
867
  mic: latestState(modelRows, "mic"),
682
868
  speaking: latestState(modelRows, "speaking"),
683
869
  uplink: uplinkRate(modelRows, closeAt, RATE_WINDOW_MS, beginAt),
684
870
  downlink: downlinkRate(modelRows, closeAt, RATE_WINDOW_MS, beginAt),
685
871
  sessionAgeMs: beginAt !== null ? closeAt - beginAt : null,
686
872
  phases: ph.list,
873
+ reconnects: reconnects(modelRows, firstReady),
874
+ beginAt,
687
875
  phaseTotalMs: ph.totalMs,
688
876
  phaseTimedOut,
689
877
  phaseWallMs,
@@ -694,6 +882,10 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
694
882
  model: segments(modelRows, "speaking", "speaking", closeAt).filter(inWindow),
695
883
  you: segments(modelRows, "mic", "Capturing", closeAt).filter(inWindow),
696
884
  youMuted: segments(modelRows, "mic", "Muted", closeAt).filter(inWindow),
885
+ youSpeaking: segments(modelRows, "user_speaking", "speaking", closeAt).filter(inWindow),
886
+ hasUserSpeaking: modelRows.some((r) => r.kind === "state" && r.state_kind === "user_speaking"),
887
+ micEncoding: summaryMicEncoding ?? null,
888
+ replyHolds: replyHolds(modelRows, closeAt).filter(inWindow),
697
889
  markers: markers(modelRows, { from: window.from, to: window.to, ended: endedAt !== null }),
698
890
  stats: windowStats(modelRows, window.from, window.to),
699
891
  hasBegin,
@@ -702,9 +894,11 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
702
894
  // real to have been clamped away from, whatever its earliest surviving record's own age is.
703
895
  wholeSpanClamped: hasBegin && whole.clamped,
704
896
  ended: endedAt !== null,
705
- serverSession: serverSessionId(modelRows, endedAt !== null, summaryServerSessionId),
897
+ serverSession: serverSessionId(modelRows, endedAt !== null, summaryServerSessionId, summaryServerSessionIds),
706
898
  serverSessionNone: readyNamedNoServerId(modelRows),
707
899
  savedTurns: savedTurnCounts(modelRows, summarySavedTurnCounts, savedTurnOutcomes),
900
+ openCards: modelRows.some((r) => r.kind === "card") ? openCards(modelRows) : null,
901
+ cardsPartial: !hasBegin,
708
902
  hasLevels,
709
903
  micLevels: hasLevels ? micLevelPoints(modelRows, window.from, window.to) : [],
710
904
  playbackLevels: hasLevels ? playbackLevelPoints(modelRows, window.from, window.to) : [],
@@ -8,7 +8,7 @@ import { useMemo, useRef, useState } from "preact/hooks";
8
8
  import { useStorePulse } from "./hooks.js";
9
9
  import { store } from "./store.js";
10
10
  import { showToast } from "./toast.js";
11
- import { capitalizeSwitchboardNote, SAVED_TURN_KEPT_OUTCOMES, savedTurnCountWord } from "./switchboard-note.js";
11
+ import { capitalizeSwitchboardNote, cardKindWord, micEncodingNote, reconnectOutcomeWord, reconnectTriggerWord, SAVED_TURN_KEPT_OUTCOMES, savedTurnCountWord } from "./switchboard-note.js";
12
12
  import { buildVoiceModel, CLIP_PEAK, dbfsHeight, GAP_P95_BAD_MS, phaseLabel, RATE_MIN_DIVISOR_MS, tickStepMs, ZOOMS } from "./voice-model.js";
13
13
  // The stream view draws the panel only on the Switchboard tab and only while the spec keeps the
14
14
  // voice key, so a custom spec on that source can leave it out.
@@ -39,10 +39,14 @@ const MARKER_COLOUR = {
39
39
  stop: "var(--purple)",
40
40
  focus: "var(--muted-2)",
41
41
  error: "var(--error)",
42
+ // Neutral on purpose: --muted-2 is focus, and a normal ending is not a fault.
43
+ ending: "var(--muted)",
42
44
  // --warn-2 exists in both themes (unlike --warn-text, which is light-only), so the stall gets
43
45
  // its own shade rather than reusing --warn; the dashed stroke below keeps it further apart from
44
46
  // a re-arm still.
45
47
  stall: "var(--warn-2)",
48
+ // A shade of blue none of the other markers use, so a card tick is not read as a fault.
49
+ card: "var(--blue-2)",
46
50
  // Distinct from `focus`'s var(--muted-2): a collapsed group of mixed-kind markers is its own
47
51
  // thing, not another shade of the same "quiet" colour.
48
52
  mixed: "var(--text)",
@@ -63,11 +67,35 @@ function phaseInlineText(p) {
63
67
  return html `${phaseLabel(p.name)}`;
64
68
  return p.timedOut ? html `${phaseLabel(p.name)} timed out after ${(p.ms / 1000).toFixed(1)} s` : html `${phaseLabel(p.name)} <b>${p.ms}</b>`;
65
69
  }
66
- function dotClass(state) {
70
+ function reconnectText(rc, ended, beginAt) {
71
+ if (rc.overflow)
72
+ return html `+${rc.n} earlier${rc.tries ? (rc.n === 1 ? " try" : " tries") : ""}`;
73
+ const label = rc.unnumbered ? "reconnect" : `reconnect #${rc.n}`;
74
+ const at = beginAt !== null ? ` · at ${((rc.at - beginAt) / 1000).toFixed(1)} s` : "";
75
+ const socket = rc.socketMs !== null ? html ` · socket <b>${rc.socketMs}</b>` : null;
76
+ const readyPart = rc.readyMs !== null ? html ` · session.ready <b>${rc.readyMs}</b>` : null;
77
+ if (rc.outcome !== undefined) {
78
+ // The model always sets trigger next to outcome.
79
+ const trigger = rc.trigger;
80
+ const after = `after a ${reconnectTriggerWord(trigger)}`;
81
+ if (rc.outcome === "gave_up") {
82
+ return html `${label} · ${after} · gave up after ${rc.tryN ?? "?"} ${rc.tryN === 1 ? "try" : "tries"}${at}`;
83
+ }
84
+ return html `${label} · ${after} · try ${rc.tryN ?? "?"}${socket}${readyPart} · ${reconnectOutcomeWord(rc.outcome)}${at}`;
85
+ }
86
+ const ready = readyPart ??
87
+ (rc.abandoned
88
+ ? " · no session.ready, the next try replaced it"
89
+ : ended
90
+ ? " · session.ready never came"
91
+ : " · waiting on session.ready");
92
+ return html `${label}${socket}${ready}${at}`;
93
+ }
94
+ function dotClass(state, endedNormally = false) {
67
95
  if (state === "Connected")
68
96
  return "ok";
69
97
  if (state === "Failed")
70
- return "bad";
98
+ return endedNormally ? "" : "bad";
71
99
  // Disconnected is a settled, unremarkable state (the session ended, or never got going yet
72
100
  // some other way): a warn dot there reads as an ongoing problem it is not. Connecting and
73
101
  // Reconnecting keep the warn colour, still mid-transition.
@@ -169,16 +197,18 @@ export function VoicePanel({ onInspect, now = () => Date.now() }) {
169
197
  const rows = store.switchboardRunRows();
170
198
  const sid = store.switchboardNewestSessionId();
171
199
  const summaryServerSessionId = sid !== null ? store.switchboardSummaryServerId(sid) : undefined;
200
+ const summaryServerSessionIds = sid !== null ? store.switchboardSummaryServerIds(sid) : undefined;
201
+ const summaryMicEncoding = sid !== null ? store.switchboardSummaryMicEncoding(sid) : undefined;
172
202
  const summarySavedTurnCounts = sid !== null ? store.switchboardSummarySavedTurnCounts(sid) : undefined;
173
203
  // Mutated in place as saved_turn rows land; each new one of the drawn run also lands in `rows`,
174
204
  // which rebuilds the model.
175
205
  const savedTurnOutcomes = sid !== null ? store.switchboardSavedTurnOutcomes(sid) : undefined;
176
206
  const clockKey = ended.current ? 0 : Math.floor(now() / 1000);
177
207
  const m = useMemo(() => {
178
- const model = buildVoiceModel(rows, zoom, now(), summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes);
208
+ const model = buildVoiceModel(rows, zoom, now(), summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes, summaryServerSessionIds, summaryMicEncoding);
179
209
  ended.current = model !== null && model.ended;
180
210
  return model;
181
- }, [rows, zoom, summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes, clockKey]);
211
+ }, [rows, zoom, summaryServerSessionId, summaryServerSessionIds, summaryMicEncoding, summarySavedTurnCounts, savedTurnOutcomes, clockKey]);
182
212
  // Records exist but none names a session, or there is no switchboard record at all: draw
183
213
  // nothing. The feed's own empty state already tells the person what to do next.
184
214
  if (!m)
@@ -240,23 +270,25 @@ function SessionStrip({ m }) {
240
270
  // never there to begin with), not the "nothing has happened yet" case a brand-new session reads
241
271
  // as, so it gets its own wording rather than reusing "no session yet".
242
272
  const connText = conn ? conn.to : m.ended ? "connection unknown" : "no session yet";
273
+ // After a normal server ending the goodbye is still playing out, so a quiet downlink is expected.
243
274
  // A downlink pill reading 0/s while the model is speaking is not a problem in a session too
244
275
  // young to have cleared the rate's own minimum divisor yet -- that is exactly what sessionAgeMs
245
276
  // guards against. No begin record at all means the age itself is unknown, so it reads the same
246
277
  // as "too young" rather than assuming the worst. Past that age, 0 audio frames arriving while
247
278
  // the model is supposedly speaking is the downlink itself running dry, not a startup artifact.
248
- const downlinkWarn = m.speaking?.to === "speaking" && m.sessionAgeMs !== null && m.sessionAgeMs > RATE_MIN_DIVISOR_MS && m.downlink.perSec === 0;
279
+ const downlinkWarn = !m.endedNormally && m.speaking?.to === "speaking" && m.sessionAgeMs !== null && m.sessionAgeMs > RATE_MIN_DIVISOR_MS && m.downlink.perSec === 0;
249
280
  return html `
250
281
  <div class="voice-card">
251
282
  <div class="voice-hd">Session</div>
252
283
  <div class="voice-strip">
253
- <span class="voice-pill"><i class=${"voice-dot " + (conn ? dotClass(conn.to) : "")} aria-hidden="true"></i>${connText}${conn && conn.to === "Failed" && conn.cause ? html ` <span class="voice-note">(${conn.cause})</span>` : null}</span>
284
+ <span class="voice-pill" title=${m.endedNormally ? "the server ended the call normally (a limit or the model's goodbye)" : undefined}><i class=${"voice-dot " + (conn ? dotClass(conn.to, m.endedNormally) : "")} aria-hidden="true"></i>${connText}${conn && (conn.to === "Failed" || conn.to === "Reconnecting" || conn.to === "Disconnected") && conn.cause ? html ` <span class="voice-note">(${conn.cause})</span>` : null}</span>
254
285
  ${m.ended ? html `<span class="voice-note voice-ended">ended</span>` : null}
255
286
  <span class="voice-kv">session <b>${String(m.sessionId)}</b></span>
256
287
  <span class="voice-pill"><i class=${"voice-dot " + micClass(m.mic?.to)} aria-hidden="true"></i>mic ${m.mic ? m.mic.to : "unknown"}</span>
288
+ ${m.micEncoding ? html `<span class="voice-kv" title=${micEncodingNote(m.micEncoding) ?? undefined}>codec <b>${m.micEncoding}</b></span>` : null}
257
289
  <span class="voice-pill"><i class=${"voice-dot " + (m.speaking?.to === "speaking" ? "ok" : "")} aria-hidden="true"></i>model ${m.speaking ? m.speaking.to : "unknown"}</span>
258
290
  ${m.serverSession.id
259
- ? html `<button type="button" class="voice-pill voice-pill-server" title="server session id, click to copy" onClick=${() => copyServerSessionId(m.serverSession.id)}>server <b>${m.serverSession.id}</b></button>`
291
+ ? html `<button type="button" class="voice-pill voice-pill-server" title=${m.serverSession.all.length > 1 ? `server session ids: ${m.serverSession.all.join(", ")}. Click copies the newest.` : "server session id, click to copy"} onClick=${() => copyServerSessionId(m.serverSession.id)}>server <b>${m.serverSession.id}</b>${m.serverSession.all.length > 1 ? ` +${m.serverSession.all.length - 1}` : ""}</button>`
260
292
  : m.serverSession.pending
261
293
  ? html `<span class="voice-pill voice-pill-server voice-note" title="waiting on the device's session.ready record">server id pending</span>`
262
294
  : m.savedTurns?.some((c) => c.outcome === "other_session" && c.count > 0)
@@ -267,7 +299,10 @@ function SessionStrip({ m }) {
267
299
  ${m.savedTurns
268
300
  ? html `<span class=${"voice-kv" + (m.savedTurns.some((c) => !SAVED_TURN_KEPT_OUTCOMES.includes(c.outcome) && c.count > 0) ? " warn" : "")} title="what happened to each spoken turn, by outcome: the device count when this tab loaded the session, plus the turns seen since (or the turns this tab has seen, when those are more); saved (line moved on) is a late save whose line already moved on, still kept; the dropped ones, and any outcome this dashboard does not know, are the ones to look into">turns ${m.savedTurns.map((c, i) => html `${i ? " · " : ""}${savedTurnCountWord(c.outcome)} <b>${c.count}</b>`)}</span>`
269
301
  : null}
270
- <span class="voice-kv" title=${`outgoing frames per second over the ${m.ended ? "last 10 s before the session ended" : "last 10 s"}, or the session's own age when younger, counting ${m.uplink.rule} frames`}>uplink <b>${m.uplink.perSec.toFixed(1)}/s</b> ${m.uplink.rule === "audio" ? "audio frames" : "frames"}${m.ended ? " at close" : ""}</span>
302
+ ${m.openCards
303
+ ? html `<span class="voice-kv" title=${cardsTitle(m)}>cards up <b>${m.openCards.length}</b>${m.cardsPartial ? " seen" : ""}${m.ended ? " at close" : ""}</span>`
304
+ : null}
305
+ <span class="voice-kv" title=${`outgoing frames per second over the ${m.ended ? "last 10 s before the session ended" : "last 10 s"}, or the session's own age when younger, counting ${m.uplink.rule} frames${m.micEncoding && micEncodingNote(m.micEncoding) ? `; mic codec ${m.micEncoding}: ${micEncodingNote(m.micEncoding)}` : ""}`}>uplink <b>${m.uplink.perSec.toFixed(1)}/s</b> ${m.uplink.rule === "audio" ? "audio frames" : "frames"}${m.ended ? " at close" : ""}</span>
271
306
  <span class=${"voice-kv" + (downlinkWarn ? " warn" : "")} title=${`incoming ${m.downlink.rule === "audio" ? "audio frames" : "frames"} per second over the ${m.ended ? "last 10 s before the session ended" : "last 10 s"}, or the session's own age when younger; 0 while the model is speaking and the session is older than ${RATE_MIN_DIVISOR_MS / 1000} s means no audio frames are arriving`}>downlink <b>${m.downlink.perSec.toFixed(1)}/s</b> ${m.downlink.rule === "audio" ? "audio frames" : "frames"}${m.ended ? " at close" : ""}</span>
272
307
  </div>
273
308
  ${m.phases.length
@@ -294,6 +329,9 @@ function SessionStrip({ m }) {
294
329
  </div>
295
330
  `
296
331
  : html `<div class="voice-note">no phase records yet</div>`}
332
+ ${
333
+ // Outside the phases block: a long call can hold reconnect rows after the startup rows aged out.
334
+ m.reconnects.map((rc) => html `<div class="voice-note voice-reconnect">${reconnectText(rc, m.ended, m.beginAt)}</div>`)}
297
335
  </div>
298
336
  `;
299
337
  }
@@ -385,6 +423,7 @@ function levelBars(points, y, h, x, colour, rowClass) {
385
423
  </g>`;
386
424
  });
387
425
  }
426
+ const HOLD_TITLE = "reply on hold: audio kept arriving and queued, the mic stayed open with the uplink muted; silence here is the pause, not loss";
388
427
  function Tracks({ m, title, rearms, onPick }) {
389
428
  const H = plotHeight(m.hasLevels);
390
429
  const { from, to } = m.window;
@@ -407,11 +446,18 @@ function Tracks({ m, title, rearms, onPick }) {
407
446
  }
408
447
  const seg = (s, row, y, fill, opacity) => html `<rect class=${"voice-seg voice-seg-" + row} x=${x(s.from)} y=${y} width=${Math.max(2, x(s.to) - x(s.from))} height=${ROW_H} rx="3" fill=${fill} opacity=${opacity} />`;
409
448
  const segMuted = (s) => html `<rect class="voice-seg voice-seg-muted" x=${x(s.from)} y=${ROW_Y.you} width=${Math.max(2, x(s.to) - x(s.from))} height=${ROW_H} rx="3" fill="url(#voice-hatch)" opacity=".9" stroke="var(--purple)" stroke-width="1.5" vector-effect="non-scaling-stroke" />`;
449
+ // A thin band along the bottom of the you row, so it reads on top of capturing and muted spans.
450
+ const segSpeaking = (s) => html `<rect class="voice-seg voice-seg-speaking" x=${x(s.from)} y=${ROW_Y.you + ROW_H - 4} width=${Math.max(2, x(s.to) - x(s.from))} height="4" fill="var(--warn-2)" opacity=".9" />`;
410
451
  const model = mergeSegmentsByColumn(m.model, x);
411
452
  const you = mergeSegmentsByColumn(m.you, x);
412
453
  const youMuted = mergeSegmentsByColumn(m.youMuted, x);
454
+ const youSpeaking = mergeSegmentsByColumn(m.youSpeaking, x);
455
+ const holds = mergeSegmentsByColumn(m.replyHolds, x);
456
+ // Spans the playback rows only: the model row, plus the playback level row when levels are drawn.
457
+ const holdBand = (s, y, h) => html `<rect class="voice-seg voice-seg-hold" x=${x(s.from)} y=${y} width=${Math.max(2, x(s.to) - x(s.from))} height=${h} fill="var(--muted-2)" opacity=".25"><title>${HOLD_TITLE}</title></rect>`;
413
458
  const drawn = collapseMarkers(m.markers, x);
414
459
  const hasMixed = drawn.some((k) => k.kind === "mixed");
460
+ const hasCard = drawn.some((k) => k.kind === "card");
415
461
  // A burst reads differently from a plain mixed collapse: still one kind throughout, just more
416
462
  // than one record of it landed in the same spot (see DrawMarker.multi).
417
463
  const hasBurst = drawn.some((k) => k.multi && k.kind !== "mixed");
@@ -459,6 +505,9 @@ function Tracks({ m, title, rearms, onPick }) {
459
505
  ${model.map((s) => seg(s, "model", ROW_Y.model, "var(--blue)", ".45"))}
460
506
  ${you.map((s) => seg(s, "you", ROW_Y.you, "var(--accent)", ".4"))}
461
507
  ${youMuted.map(segMuted)}
508
+ ${youSpeaking.map(segSpeaking)}
509
+ ${holds.map((s) => holdBand(s, ROW_Y.model, ROW_H))}
510
+ ${m.hasLevels ? holds.map((s) => holdBand(s, ROW_Y.playbackLevel, LEVEL_ROW_H)) : null}
462
511
  ${drawn.map((k) => {
463
512
  const c = MARKER_COLOUR[k.kind];
464
513
  // The stroke width is the burst cue: same-kind bursts read 8, wider than a plain
@@ -515,11 +564,15 @@ function Tracks({ m, title, rearms, onPick }) {
515
564
  <span class="m">model speaking</span>
516
565
  <span class="y">you capturing</span>
517
566
  <span class="mu">you (muted)</span>
567
+ ${m.hasUserSpeaking ? html `<span class="ys">likely speaking</span>` : null}
568
+ ${holds.length > 0 ? html `<span class="hd" title=${HOLD_TITLE}>reply on hold (you paused it)</span>` : null}
518
569
  <span class="r">playback re-arm</span>
519
570
  <span class="s">tts.stop sent</span>
520
571
  <span class="st">player stall</span>
521
572
  <span class="e">connection failed</span>
573
+ <span class="en">call ended (server or swipe)</span>
522
574
  <span class="f">mic paused</span>
575
+ ${hasCard ? html `<span class="cd">card</span>` : null}
523
576
  ${hasClipping ? html `<span class="clip">clipping</span>` : null}
524
577
  ${hasMixed ? html `<span class="mx">multiple markers</span>` : null}
525
578
  ${hasBurst ? html `<span class="mb">burst (several at one spot, hover for the count)</span>` : null}
@@ -528,6 +581,16 @@ function Tracks({ m, title, rearms, onPick }) {
528
581
  </div>
529
582
  `;
530
583
  }
584
+ // Partial rows cannot say no card is waiting, so the title owns up to what the tab holds.
585
+ function cardsTitle(m) {
586
+ const open = m.openCards ?? [];
587
+ const partial = m.cardsPartial
588
+ ? "this tab holds only the newest records of this call, so a card shown before them is not counted; export the session for every record. "
589
+ : "";
590
+ if (open.length === 0)
591
+ return m.cardsPartial ? partial.trim() : "no card is waiting";
592
+ return `${partial}shown or carried with no later record: ${open.map((c) => `${cardKindWord(c.kind)} ${c.id}`).join("; ")}`;
593
+ }
531
594
  function StatCards({ m }) {
532
595
  const s = m.stats;
533
596
  // gapSamples, not p50/p95 > 0: a re-arm with no usable gap_ms (see markers()'s own "unusable
@@ -545,7 +608,7 @@ function StatCards({ m }) {
545
608
  <div class="l">playback re-arms</div>
546
609
  </div>
547
610
  <div class=${"voice-stat" + gapClass} title=${`p95 over ${GAP_P95_BAD_MS} ms reads as choppy`}><div class="v">${gapText}</div><div class="l">gap at re-arm p50 / p95 (bad > ${GAP_P95_BAD_MS} ms)</div></div>
548
- <div class=${"voice-stat" + (s.preReadyDrop > 0 ? " warn" : "")} title="jitter trim = the player skipped buffered audio to catch up, expected in small numbers; pre-ready = audio landed before session.ready, check the handshake"><div class="v">${s.jitterTrim} / ${s.preReadyDrop}</div><div class="l">drops: jitter trim / pre-ready</div></div>
611
+ <div class=${"voice-stat" + (s.holdRefuse > 0 || s.preReadyDrop > 0 ? " warn" : "")} title=${`jitter trim = the player skipped buffered audio to catch up, expected in small numbers; hold refuse = a held reply's queue was full, so the newest audio was dropped; pre-ready = mic audio held before session.ready was dropped${s.preReadyChunks !== null ? ` (${s.preReadyChunks} chunk${s.preReadyChunks === 1 ? "" : "s"})` : ""}, check the handshake`}><div class="v">${s.jitterTrim} / ${s.holdRefuse} / ${s.preReadyDrop}</div><div class="l">drops: jitter trim / hold refuse / pre-ready</div></div>
549
612
  <div class="voice-stat" title="includes control frames; the uplink and downlink pills count audio frames only when the device tags them"><div class="v">${s.framesIn} / ${s.framesOut}</div><div class="l">frames in / out this window (all types)</div></div>
550
613
  </div>
551
614
  `;
@@ -14,7 +14,7 @@
14
14
  * Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
15
15
  * their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
16
16
  * streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
17
- * own event stream (session / state / frame / phase / player / levels / turn / saved_turn records),
17
+ * own event stream (session / state / frame / phase / player / levels / turn / saved_turn / card records),
18
18
  * device-produced like rtm.
19
19
  */
20
20
  export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
package/dist/web/spec.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
15
15
  * their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
16
16
  * streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
17
- * own event stream (session / state / frame / phase / player / levels / turn / saved_turn records),
17
+ * own event stream (session / state / frame / phase / player / levels / turn / saved_turn / card records),
18
18
  * device-produced like rtm.
19
19
  */
20
20
  export const SOURCES = ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.24.0",
3
+ "version": "1.26.0",
4
4
  "description": "MCP server and web dashboard for debugging Slack on Android and iOS Simulator",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",