@slack/radar-mcp 1.25.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 (37) hide show
  1. package/README.md +39 -2
  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 +1 -1
  6. package/dist/mcp/index.js +14 -8
  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 +8 -4
  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 +14 -5
  25. package/dist/shared/feature-flags.js +23 -6
  26. package/dist/shared/radar-token.d.ts +5 -5
  27. package/dist/shared/radar-token.js +24 -10
  28. package/dist/shared/switchboard-report.js +3 -0
  29. package/dist/shared/transport.d.ts +18 -0
  30. package/dist/web/public/index.html +1 -0
  31. package/dist/web/public/next/feature-flags.js +23 -6
  32. package/dist/web/public/next/feed.js +2 -2
  33. package/dist/web/public/next/flags.js +5 -3
  34. package/dist/web/public/next/store.js +1 -1
  35. package/dist/web/public/next/voice-model.js +13 -1
  36. package/dist/web/public/next/voice.js +8 -3
  37. package/package.json +1 -1
@@ -118,6 +118,26 @@ export interface AndroidTransportDependencies {
118
118
  /** Start the `ps` listing that labels log rows with their package. */
119
119
  spawnProcessList?: SpawnAndroidProcessList;
120
120
  }
121
+ /** First `versionName` / `versionCode` in a `dumpsys package` dump (one block per user repeats them). */
122
+ export declare function parsePackageVersion(dump: string): {
123
+ version_name: string | null;
124
+ version_code: string | null;
125
+ };
126
+ /**
127
+ * The foreground component from a `dumpsys activity activities` dump. Newer builds print
128
+ * `topResumedActivity`, older ones `mResumedActivity`; the new form wins when both show.
129
+ */
130
+ export declare function parseResumedActivity(dump: string): string | null;
131
+ /** `adb shell date +%s` output as epoch ms, or null when it is not whole seconds. */
132
+ export declare function parseDeviceClockMs(out: string): number | null;
133
+ /**
134
+ * Reads the device and app facts through `run`, which takes adb argv and returns stdout or
135
+ * throws. Split out so a test can feed canned output without a device.
136
+ */
137
+ export declare function readDeviceFacts(run: (args: string[]) => string, pkg: string, serial: string | null): {
138
+ device: Record<string, string | boolean | null>;
139
+ app: Record<string, string | null>;
140
+ };
121
141
  export declare class AndroidTransport implements DeviceTransport {
122
142
  readonly platform = "android";
123
143
  get logPackage(): string;
@@ -202,6 +222,11 @@ export declare class AndroidTransport implements DeviceTransport {
202
222
  recordScreen(durationS: number): string;
203
223
  getAppState(): string;
204
224
  getRecentLogs(tag: string, limit: number, grep?: string): LogResult;
225
+ getDeviceFacts(): {
226
+ device: Record<string, string | boolean | null>;
227
+ app: Record<string, string | null>;
228
+ };
229
+ deviceClockMs(): number | null;
205
230
  stopLogCapture(): void;
206
231
  listProfiles(): {
207
232
  userId: string;
@@ -470,6 +470,75 @@ function spawnAndroidLogcat() {
470
470
  stdio: ["ignore", "pipe", "ignore"],
471
471
  });
472
472
  }
473
+ /** First `versionName` / `versionCode` in a `dumpsys package` dump (one block per user repeats them). */
474
+ export function parsePackageVersion(dump) {
475
+ const name = /versionName=(\S+)/.exec(dump)?.[1] ?? null;
476
+ const code = /versionCode=(\d+)/.exec(dump)?.[1] ?? null;
477
+ return { version_name: name, version_code: code };
478
+ }
479
+ /**
480
+ * The foreground component from a `dumpsys activity activities` dump. Newer builds print
481
+ * `topResumedActivity`, older ones `mResumedActivity`; the new form wins when both show.
482
+ */
483
+ export function parseResumedActivity(dump) {
484
+ for (const key of ["topResumedActivity", "mResumedActivity"]) {
485
+ const line = dump.split("\n").find((l) => l.includes(key));
486
+ const m = line ? /([A-Za-z0-9_.$]+\/[A-Za-z0-9_.$]+)/.exec(line) : null;
487
+ if (m)
488
+ return m[1];
489
+ }
490
+ return null;
491
+ }
492
+ /** `adb shell date +%s` output as epoch ms, or null when it is not whole seconds. */
493
+ export function parseDeviceClockMs(out) {
494
+ const t = out.trim();
495
+ return /^\d{1,12}$/.test(t) ? Number(t) * 1000 : null;
496
+ }
497
+ /**
498
+ * Reads the device and app facts through `run`, which takes adb argv and returns stdout or
499
+ * throws. Split out so a test can feed canned output without a device.
500
+ */
501
+ export function readDeviceFacts(run, pkg, serial) {
502
+ const attempt = (fn) => {
503
+ try {
504
+ return fn();
505
+ }
506
+ catch {
507
+ return null;
508
+ }
509
+ };
510
+ // One shell round trip for the six props; getprop prints an empty line for an unset one, so
511
+ // the lines stay in step with the names.
512
+ const propNames = ["ro.product.model", "ro.product.manufacturer", "ro.build.version.release", "ro.build.version.sdk", "ro.kernel.qemu", "ro.boot.qemu"];
513
+ const propOut = attempt(() => run(["shell", `for p in ${propNames.join(" ")}; do getprop $p; done`]));
514
+ const props = propOut === null ? [] : propOut.split("\n");
515
+ const prop = (name) => props[propNames.indexOf(name)]?.trim() || null;
516
+ // Older images set ro.kernel.qemu, newer ones only ro.boot.qemu.
517
+ const isEmulator = propOut === null ? null : prop("ro.kernel.qemu") === "1" || prop("ro.boot.qemu") === "1";
518
+ // `adb shell` re-parses its args on the device, so a package name with shell characters
519
+ // is never sent; it only ever comes from config, and a dot-separated name is all it needs.
520
+ // Both dumps are large, so grep keeps only the lines the parsers read on the device side.
521
+ const pkgDump = /^[A-Za-z0-9_.]+$/.test(pkg)
522
+ ? attempt(() => run(["shell", `dumpsys package ${pkg} | grep -E 'versionName|versionCode'`]))
523
+ : null;
524
+ const actDump = attempt(() => run(["shell", "dumpsys activity activities | grep -E 'topResumedActivity|mResumedActivity'"]));
525
+ const version = pkgDump ? parsePackageVersion(pkgDump) : { version_name: null, version_code: null };
526
+ return {
527
+ device: {
528
+ model: prop("ro.product.model"),
529
+ manufacturer: prop("ro.product.manufacturer"),
530
+ android_release: prop("ro.build.version.release"),
531
+ sdk: prop("ro.build.version.sdk"),
532
+ emulator: isEmulator,
533
+ serial,
534
+ },
535
+ app: {
536
+ package: pkg,
537
+ ...version,
538
+ resumed_activity: actDump ? parseResumedActivity(actDump) : null,
539
+ },
540
+ };
541
+ }
473
542
  export class AndroidTransport {
474
543
  platform = "android";
475
544
  get logPackage() { return slackDebugPackage(); }
@@ -951,6 +1020,34 @@ export class AndroidTransport {
951
1020
  source: "logcat_ring",
952
1021
  };
953
1022
  }
1023
+ getDeviceFacts() {
1024
+ const run = (args) => {
1025
+ if (!ADB)
1026
+ throw new Error("adb not found");
1027
+ return execFileSync(ADB, args, {
1028
+ timeout: 5000,
1029
+ encoding: "utf-8",
1030
+ maxBuffer: 32 * 1024 * 1024,
1031
+ stdio: ["ignore", "pipe", "ignore"],
1032
+ });
1033
+ };
1034
+ return readDeviceFacts(run, slackDebugPackage(), this.getSelectedDevice()?.serial ?? null);
1035
+ }
1036
+ deviceClockMs() {
1037
+ if (!ADB)
1038
+ return null;
1039
+ try {
1040
+ const out = execFileSync(ADB, ["shell", "date", "+%s"], {
1041
+ timeout: 5000,
1042
+ encoding: "utf-8",
1043
+ stdio: ["ignore", "pipe", "ignore"],
1044
+ });
1045
+ return parseDeviceClockMs(out);
1046
+ }
1047
+ catch {
1048
+ return null;
1049
+ }
1050
+ }
954
1051
  stopLogCapture() {
955
1052
  stopCapture();
956
1053
  this.logSession.stop();
@@ -6,13 +6,22 @@
6
6
  */
7
7
  export declare function friendlyFeatureFlagError(error: unknown): string;
8
8
  /**
9
- * The one sentence for a flag whose latest value differs from what the app runs. A flag the app
10
- * read once keeps that value until restart, so `enabled` (latest or override) can differ from
11
- * `session_enabled`. Only two real booleans that differ earn a note: an absent or non-boolean
12
- * session_enabled is "not known", and saying nothing there is the honest answer.
9
+ * The sentence (`note`) and the short tab text (`label`) for a flag whose latest value differs from
10
+ * what the app runs. An experiment's label names the group itself, since a group has no ON/OFF to
11
+ * flip. A flag the app read once keeps that value until restart, so the latest value (`enabled` on a toggle,
12
+ * `group_name` on an experiment; fetched or override) can differ from the session value
13
+ * (`session_enabled`, `session_group_name`). Only two real values of
14
+ * the right type that differ earn a note: an absent or mistyped session value is "not known", and
15
+ * saying nothing there is the honest answer. An experiment's "" is a read that found no group, and
16
+ * its note is hedged because read-once code may still use the session group, not that it must.
13
17
  */
14
18
  export declare function flagRestartNote(row: {
15
19
  enabled?: unknown;
16
20
  session_enabled?: unknown;
21
+ group_name?: unknown;
22
+ session_group_name?: unknown;
17
23
  is_overridden?: unknown;
18
- }): string | undefined;
24
+ }): {
25
+ note: string;
26
+ label: string;
27
+ } | undefined;
@@ -18,15 +18,32 @@ export function friendlyFeatureFlagError(error) {
18
18
  return error;
19
19
  }
20
20
  /**
21
- * The one sentence for a flag whose latest value differs from what the app runs. A flag the app
22
- * read once keeps that value until restart, so `enabled` (latest or override) can differ from
23
- * `session_enabled`. Only two real booleans that differ earn a note: an absent or non-boolean
24
- * session_enabled is "not known", and saying nothing there is the honest answer.
21
+ * The sentence (`note`) and the short tab text (`label`) for a flag whose latest value differs from
22
+ * what the app runs. An experiment's label names the group itself, since a group has no ON/OFF to
23
+ * flip. A flag the app read once keeps that value until restart, so the latest value (`enabled` on a toggle,
24
+ * `group_name` on an experiment; fetched or override) can differ from the session value
25
+ * (`session_enabled`, `session_group_name`). Only two real values of
26
+ * the right type that differ earn a note: an absent or mistyped session value is "not known", and
27
+ * saying nothing there is the honest answer. An experiment's "" is a read that found no group, and
28
+ * its note is hedged because read-once code may still use the session group, not that it must.
25
29
  */
26
30
  export function flagRestartNote(row) {
31
+ const source = row.is_overridden === true ? "override" : "fetched";
32
+ const { group_name: group, session_group_name: sessionGroup } = row;
33
+ if (typeof group === "string" && typeof sessionGroup === "string") {
34
+ if (group === sessionGroup)
35
+ return undefined;
36
+ const used = sessionGroup || "no group";
37
+ return {
38
+ note: `read-once code may still use ${used} until restart, ${source} ${group || "no group"}`,
39
+ label: `read-once may use ${used}`,
40
+ };
41
+ }
27
42
  const { enabled, session_enabled: session } = row;
28
43
  if (typeof enabled !== "boolean" || typeof session !== "boolean" || enabled === session)
29
44
  return undefined;
30
- const source = row.is_overridden === true ? "override" : "fetched";
31
- return `app uses ${session} until restart, ${source} ${enabled}`;
45
+ return {
46
+ note: `app uses ${session} until restart, ${source} ${enabled}`,
47
+ label: `runs ${session ? "ON" : "OFF"} until restart`,
48
+ };
32
49
  }
@@ -1,6 +1,6 @@
1
1
  import type { DeviceTransport } from "./transport.js";
2
2
  export declare const RADAR_TOKEN_HEADER = "X-Radar-Token";
3
- export type TokenSurface = "mcp" | "dashboard";
3
+ export type TokenSurface = "mcp" | "dashboard" | "cli";
4
4
  export type TokenFileSurface = TokenSurface | "profile";
5
5
  export declare class TokenFileError extends Error {
6
6
  readonly problem: string;
@@ -12,14 +12,14 @@ export declare function getOrCreateRadarToken(): string;
12
12
  export declare function clearRadarTokenCache(): void;
13
13
  export declare function radarTokenHeader(): Record<string, string>;
14
14
  export type RadarTokenSender = Pick<DeviceTransport, "sendsRadarToken"> | null | undefined;
15
- export declare const TOKEN_MISMATCH_MESSAGE = "The device holds a different token than this session's. Check these, then run /radar-enable here. Another machine or OS user enabled Radar on this device: stop that session. Radar was enabled in a different profile: make sure the Slack debug build runs in the profile you want (list_profiles shows which profiles have it). Another Radar session on this machine still uses a token file you deleted: run /radar-enable there too.";
15
+ export declare const TOKEN_MISMATCH_MESSAGE: string;
16
16
  export declare const TOKEN_MISMATCH_DASHBOARD_MESSAGE = "This device answered to a different Radar token. Stop any other Radar session using it, or run /radar-enable there if you deleted the token file, then press Reconnect.";
17
17
  export declare const DEVICE_401_MESSAGE = "The device refused the request (HTTP 401). Run /radar-enable to try again.";
18
18
  export declare const DEVICE_401_DASHBOARD_MESSAGE = "The device refused the request (HTTP 401). Press Reconnect to try again.";
19
19
  export declare function lastHeaderBuildFailure(): TokenFileError | null;
20
20
  export declare function unauthorizedMessageFor(sender: RadarTokenSender, surface?: TokenSurface): string;
21
21
  export declare function radarTokenHeaderFor(transport: RadarTokenSender, surface?: TokenSurface): Record<string, string>;
22
- export declare const OPEN_MODE_WARNING = "The device is in open mode, so anything that reaches the forwarded port can read and change its Radar data. An older Radar MCP or dashboard, or a manual enable broadcast, turned the token check off. If an older Radar MCP or dashboard is still running, stop it, then run /radar-enable.";
22
+ export declare const OPEN_MODE_WARNING: string;
23
23
  export declare const OPEN_MODE_PROFILE_WARNING = "The device is in open mode even though this enable sent the token, so the broadcast did not reach the server that answered: it likely runs in a different profile and was enabled without a token. Anything that reaches the forwarded port can read and change its Radar data. Run list_profiles, then activate_for_user for the profile you want, or stop the older Radar MCP or dashboard that enabled it.";
24
- export declare function openModeWarning(tokenRequired: unknown): string | undefined;
25
- export declare function openModeWarningAfterEnable(tokenRequired: unknown, activateError: string | null): string | undefined;
24
+ export declare function openModeWarning(tokenRequired: unknown, surface?: TokenSurface): string | undefined;
25
+ export declare function openModeWarningAfterEnable(tokenRequired: unknown, activateError: string | null, surface?: TokenSurface): string | undefined;
@@ -24,9 +24,17 @@ export class TokenFileError extends Error {
24
24
  }
25
25
  }
26
26
  export function tokenFileMessage(error, surface = "mcp") {
27
- const act = surface === "dashboard" ? "press Reconnect" : surface === "profile" ? "run activate_for_user again" : "run /radar-enable";
27
+ const act = surface === "dashboard"
28
+ ? "press Reconnect"
29
+ : surface === "profile"
30
+ ? "run activate_for_user again"
31
+ : `run ${enableCommand(surface)}`;
28
32
  return `${error.problem}. ${error.fix}, then ${act}.`;
29
33
  }
34
+ /** What the user types to arm Radar again on a surface. */
35
+ function enableCommand(surface) {
36
+ return surface === "cli" ? "radar-mcp snapshot" : "/radar-enable";
37
+ }
30
38
  let cachedToken = null;
31
39
  function code(error) {
32
40
  return error?.code;
@@ -108,11 +116,12 @@ export function radarTokenHeader() {
108
116
  return { [RADAR_TOKEN_HEADER]: getOrCreateRadarToken() };
109
117
  }
110
118
  const PROFILE_FIX = "make sure the Slack debug build runs in the profile you want (list_profiles shows which profiles have it)";
111
- const MISMATCH_TAIL = `Check these, then run /radar-enable here. Another machine or OS user enabled Radar on this device: stop that session. Radar was enabled in a different profile: ${PROFILE_FIX}. Another Radar session on this machine still uses a token file you deleted: run /radar-enable there too.`;
119
+ const mismatchTail = (cmd) => `Check these, then run ${cmd} here. Another machine or OS user enabled Radar on this device: stop that session. Radar was enabled in a different profile: ${PROFILE_FIX}. Another Radar session on this machine still uses a token file you deleted: run ${cmd} there too.`;
112
120
  const DASHBOARD_TAIL = "Stop any other Radar session using it, or run /radar-enable there if you deleted the token file, then press Reconnect.";
113
- export const TOKEN_MISMATCH_MESSAGE = `The device holds a different token than this session's. ${MISMATCH_TAIL}`;
121
+ export const TOKEN_MISMATCH_MESSAGE = `The device holds a different token than this session's. ${mismatchTail("/radar-enable")}`;
114
122
  export const TOKEN_MISMATCH_DASHBOARD_MESSAGE = `This device answered to a different Radar token. ${DASHBOARD_TAIL}`;
115
123
  export const DEVICE_401_MESSAGE = "The device refused the request (HTTP 401). Run /radar-enable to try again.";
124
+ const DEVICE_401_CLI_MESSAGE = "The device refused the request (HTTP 401). Run radar-mcp snapshot to try again.";
116
125
  export const DEVICE_401_DASHBOARD_MESSAGE = "The device refused the request (HTTP 401). Press Reconnect to try again.";
117
126
  export function lastHeaderBuildFailure() {
118
127
  return lastHeaderFailure;
@@ -121,9 +130,13 @@ export function unauthorizedMessageFor(sender, surface = "mcp") {
121
130
  if (sender?.sendsRadarToken) {
122
131
  if (lastHeaderFailure)
123
132
  return tokenFileMessage(lastHeaderFailure, surface);
124
- return surface === "dashboard" ? TOKEN_MISMATCH_DASHBOARD_MESSAGE : TOKEN_MISMATCH_MESSAGE;
133
+ if (surface === "dashboard")
134
+ return TOKEN_MISMATCH_DASHBOARD_MESSAGE;
135
+ return surface === "cli"
136
+ ? `The device holds a different token than this session's. ${mismatchTail(enableCommand(surface))}`
137
+ : TOKEN_MISMATCH_MESSAGE;
125
138
  }
126
- return surface === "dashboard" ? DEVICE_401_DASHBOARD_MESSAGE : DEVICE_401_MESSAGE;
139
+ return surface === "dashboard" ? DEVICE_401_DASHBOARD_MESSAGE : surface === "cli" ? DEVICE_401_CLI_MESSAGE : DEVICE_401_MESSAGE;
127
140
  }
128
141
  // Never throws: an empty header lets the request go out so an open-mode device can answer.
129
142
  export function radarTokenHeaderFor(transport, surface = "mcp") {
@@ -150,15 +163,16 @@ export function radarTokenHeaderFor(transport, surface = "mcp") {
150
163
  return {};
151
164
  }
152
165
  }
153
- export const OPEN_MODE_WARNING = "The device is in open mode, so anything that reaches the forwarded port can read and change its Radar data. An older Radar MCP or dashboard, or a manual enable broadcast, turned the token check off. If an older Radar MCP or dashboard is still running, stop it, then run /radar-enable.";
166
+ const openModeText = (cmd) => `The device is in open mode, so anything that reaches the forwarded port can read and change its Radar data. An older Radar MCP or dashboard, or a manual enable broadcast, turned the token check off. If an older Radar MCP or dashboard is still running, stop it, then run ${cmd}.`;
167
+ export const OPEN_MODE_WARNING = openModeText("/radar-enable");
154
168
  export const OPEN_MODE_PROFILE_WARNING = "The device is in open mode even though this enable sent the token, so the broadcast did not reach the server that answered: it likely runs in a different profile and was enabled without a token. Anything that reaches the forwarded port can read and change its Radar data. Run list_profiles, then activate_for_user for the profile you want, or stop the older Radar MCP or dashboard that enabled it.";
155
- export function openModeWarning(tokenRequired) {
156
- return tokenRequired === false ? OPEN_MODE_WARNING : undefined;
169
+ export function openModeWarning(tokenRequired, surface = "mcp") {
170
+ return tokenRequired === false ? openModeText(enableCommand(surface)) : undefined;
157
171
  }
158
- export function openModeWarningAfterEnable(tokenRequired, activateError) {
172
+ export function openModeWarningAfterEnable(tokenRequired, activateError, surface = "mcp") {
159
173
  if (tokenRequired !== false)
160
174
  return undefined;
161
175
  return activateError
162
- ? `The device is in open mode: this enable's broadcast failed (${activateError}) and a server enabled without a token answered instead. Anything that reaches the forwarded port can read and change its Radar data. Check the device connection, then run /radar-enable.`
176
+ ? `The device is in open mode: this enable's broadcast failed (${activateError}) and a server enabled without a token answered instead. Anything that reaches the forwarded port can read and change its Radar data. Check the device connection, then run ${enableCommand(surface)}.`
163
177
  : OPEN_MODE_PROFILE_WARNING;
164
178
  }
@@ -121,6 +121,9 @@ function recordLine(r) {
121
121
  parts.push(`gap ${gap} ms`);
122
122
  if (queued !== null)
123
123
  parts.push(`${queued} B queued`);
124
+ const dropped = num(r.dropped_chunks);
125
+ if (dropped !== null)
126
+ parts.push(`dropped ${dropped} mic chunk${dropped === 1 ? "" : "s"}`);
124
127
  return `${head} ${parts.join(", ")}`;
125
128
  }
126
129
  case "levels": {
@@ -233,6 +233,24 @@ export interface DeviceTransport {
233
233
  * Optional: omitted by platforms with no device log stream (webapp).
234
234
  */
235
235
  getRecentLogs?(tag: string, limit: number, grep?: string): LogResult;
236
+ /**
237
+ * Facts about the attached device and the app under test, for a snapshot header. Each field is
238
+ * read on its own, so one failed read leaves that field null and never throws.
239
+ *
240
+ * Optional: only Android (adb) has these today.
241
+ */
242
+ getDeviceFacts?(): {
243
+ device: Record<string, string | boolean | null>;
244
+ app: Record<string, string | null>;
245
+ };
246
+ /**
247
+ * The device's wall clock in epoch milliseconds (whole seconds times 1000), or null when it
248
+ * cannot be read. Event timestamps are device wall clock, so a run window must use this and
249
+ * not the host clock.
250
+ *
251
+ * Optional: only Android (adb) has this today.
252
+ */
253
+ deviceClockMs?(): number | null;
236
254
  /**
237
255
  * Returns the currently active user ID, or null if none is set. On Android
238
256
  * this is the profile (e.g. "0" for personal, "10" for work); on iOS it
@@ -409,6 +409,7 @@
409
409
  .voice-legend .st::before { width:3px; height:11px; border:0; border-radius:0; background:repeating-linear-gradient(to bottom, var(--warn-2) 0 4px, transparent 4px 7px); }
410
410
  .voice-legend .e::before { width:7px; height:14px; border-radius:0; background:radial-gradient(circle at 50% 3.5px, var(--error) 3.5px, transparent 4px), linear-gradient(var(--error),var(--error)) 50% 100%/3px 10px no-repeat; }
411
411
  .voice-legend .mx::before { width:6px; height:14px; border-radius:0; background:linear-gradient(var(--text),var(--text)) 50% 0/6px 6px no-repeat, linear-gradient(var(--text),var(--text)) 50% 100%/3px 6px no-repeat; }
412
+ .voice-legend .ys::before { background:var(--warn-2); height:4px; vertical-align:2px; }
412
413
  .voice-legend .mu::before { border:1px dashed var(--purple); background:repeating-linear-gradient(to bottom, var(--purple) 0 1px, transparent 1px 3px); }
413
414
  .voice-legend .mb::before { width:7px; height:11px; border-radius:3.5px; background:var(--muted); }
414
415
  /* A scale note, not a marker kind: a swatch would imply a marker colour that does not exist. */
@@ -19,15 +19,32 @@ export function friendlyFeatureFlagError(error) {
19
19
  return error;
20
20
  }
21
21
  /**
22
- * The one sentence for a flag whose latest value differs from what the app runs. A flag the app
23
- * read once keeps that value until restart, so `enabled` (latest or override) can differ from
24
- * `session_enabled`. Only two real booleans that differ earn a note: an absent or non-boolean
25
- * session_enabled is "not known", and saying nothing there is the honest answer.
22
+ * The sentence (`note`) and the short tab text (`label`) for a flag whose latest value differs from
23
+ * what the app runs. An experiment's label names the group itself, since a group has no ON/OFF to
24
+ * flip. A flag the app read once keeps that value until restart, so the latest value (`enabled` on a toggle,
25
+ * `group_name` on an experiment; fetched or override) can differ from the session value
26
+ * (`session_enabled`, `session_group_name`). Only two real values of
27
+ * the right type that differ earn a note: an absent or mistyped session value is "not known", and
28
+ * saying nothing there is the honest answer. An experiment's "" is a read that found no group, and
29
+ * its note is hedged because read-once code may still use the session group, not that it must.
26
30
  */
27
31
  export function flagRestartNote(row) {
32
+ const source = row.is_overridden === true ? "override" : "fetched";
33
+ const { group_name: group, session_group_name: sessionGroup } = row;
34
+ if (typeof group === "string" && typeof sessionGroup === "string") {
35
+ if (group === sessionGroup)
36
+ return undefined;
37
+ const used = sessionGroup || "no group";
38
+ return {
39
+ note: `read-once code may still use ${used} until restart, ${source} ${group || "no group"}`,
40
+ label: `read-once may use ${used}`,
41
+ };
42
+ }
28
43
  const { enabled, session_enabled: session } = row;
29
44
  if (typeof enabled !== "boolean" || typeof session !== "boolean" || enabled === session)
30
45
  return undefined;
31
- const source = row.is_overridden === true ? "override" : "fetched";
32
- return `app uses ${session} until restart, ${source} ${enabled}`;
46
+ return {
47
+ note: `app uses ${session} until restart, ${source} ${enabled}`,
48
+ label: `runs ${session ? "ON" : "OFF"} until restart`,
49
+ };
33
50
  }
@@ -205,8 +205,8 @@ export function switchboardSummary(ev) {
205
205
  return `${text(ev.phase)}${d != null ? ` ${fmtNum(d)} ms` : ""}`;
206
206
  }
207
207
  case "player": {
208
- const g = num(ev.gap_ms), q = num(ev.bytes_queued);
209
- return `${text(ev.event)}${g != null ? ` gap ${fmtNum(g)} ms` : ""}${q != null ? ` queued ${fmtNum(q)} B` : ""}`;
208
+ const g = num(ev.gap_ms), q = num(ev.bytes_queued), d = num(ev.dropped_chunks);
209
+ return `${text(ev.event)}${g != null ? ` gap ${fmtNum(g)} ms` : ""}${q != null ? ` queued ${fmtNum(q)} B` : ""}${d != null ? ` dropped ${fmtNum(d)} mic chunk${d === 1 ? "" : "s"}` : ""}`;
210
210
  }
211
211
  // Shows size, reach, and peak loudness, not averaged rms, since averaging would wash out
212
212
  // the one loud spike a debugger is usually looking for.
@@ -20,6 +20,8 @@
20
20
  // type "toggle" | "experiment"
21
21
  // enabled toggles only: the latest boolean (override if set, else the server value),
22
22
  // which the app may not run until restart.
23
+ // session_group_name experiments only: the group the app's first read returned (or a read returns
24
+ // now, if unread); read-once code may still use it until restart; "" is no group. Absent on older builds: not known, nothing shown.
23
25
  // session_enabled toggles only: the flag's own value the app runs this session. Absent on older
24
26
  // builds and experiments; absent or non-boolean means not known, so nothing is
25
27
  // shown.
@@ -97,10 +99,10 @@ const DIM_TITLE = "every row of this flag in this scope shows this same value";
97
99
  // Shown next to the pill when the app still runs an older value than the latest one. The visible
98
100
  // text says what the app runs; the title is the shared sentence.
99
101
  function restartMark(x) {
100
- const note = flagRestartNote(x);
101
- if (note === undefined)
102
+ const r = flagRestartNote(x);
103
+ if (r === undefined)
102
104
  return null;
103
- return html `<span class="flagrestart" title=${note}>runs ${x.session_enabled ? "ON" : "OFF"} until restart</span>`;
105
+ return html `<span class="flagrestart" title=${r.note}>${r.label}</span>`;
104
106
  }
105
107
  // Render a flag value. Booleans (toggles) show ON/OFF; a variant group-name string shows as a
106
108
  // text pill ("" / "control" read as the off/baseline arm). `dim` mutes a value that every row of
@@ -3005,7 +3005,7 @@ export function switchboardFields(ev) {
3005
3005
  case "state": return [kind, ev.state_kind, ev.from, ev.to, ev.cause];
3006
3006
  case "frame": return [kind, ev.direction, ev.frame_type, num(ev.bytes)];
3007
3007
  case "phase": return [kind, ev.phase, num(ev.duration_ms)];
3008
- case "player": return [kind, ev.event, num(ev.gap_ms), num(ev.bytes_queued)];
3008
+ case "player": return [kind, ev.event, num(ev.gap_ms), num(ev.bytes_queued), num(ev.dropped_chunks)];
3009
3009
  case "levels": return [kind, num(ev.sample_count)];
3010
3010
  // The raw clock token, not the row's words, the same way a frame keeps "unknown".
3011
3011
  case "turn": return [kind, ev.clock, num(ev.response_ms)];
@@ -294,6 +294,10 @@ export function markers(rows, window) {
294
294
  const cause = str(r.cause);
295
295
  out.push({ kind: "focus", t, label: cause ? `mic Paused (${cause})` : "mic Paused", record: r });
296
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
+ }
297
301
  else if (r.kind === "state" && r.state_kind === "connection" && r.to === "Failed") {
298
302
  const cause = str(r.cause);
299
303
  // A server ending that is a normal end (a limit, the model's goodbye) is not a fault, so it
@@ -667,6 +671,7 @@ export function windowStats(rows, from, to) {
667
671
  let jitterTrim = 0;
668
672
  let holdRefuse = 0;
669
673
  let preReadyDrop = 0;
674
+ let preReadyChunks = null;
670
675
  let framesIn = 0;
671
676
  let framesOut = 0;
672
677
  for (let i = rows.length - 1; i >= 0; i--) {
@@ -691,8 +696,12 @@ export function windowStats(rows, from, to) {
691
696
  jitterTrim++;
692
697
  else if (r.event === "hold_refuse")
693
698
  holdRefuse++;
694
- else if (r.event === "pre_ready_drop")
699
+ else if (r.event === "pre_ready_drop") {
695
700
  preReadyDrop++;
701
+ const c = num(r.dropped_chunks);
702
+ if (c !== null)
703
+ preReadyChunks = (preReadyChunks ?? 0) + c;
704
+ }
696
705
  }
697
706
  else if (r.kind === "frame") {
698
707
  if (r.direction === "incoming")
@@ -711,6 +720,7 @@ export function windowStats(rows, from, to) {
711
720
  jitterTrim,
712
721
  holdRefuse,
713
722
  preReadyDrop,
723
+ preReadyChunks,
714
724
  framesIn,
715
725
  framesOut,
716
726
  };
@@ -872,6 +882,8 @@ export function buildVoiceModel(rows, zoom, now, summaryServerSessionId, summary
872
882
  model: segments(modelRows, "speaking", "speaking", closeAt).filter(inWindow),
873
883
  you: segments(modelRows, "mic", "Capturing", closeAt).filter(inWindow),
874
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"),
875
887
  micEncoding: summaryMicEncoding ?? null,
876
888
  replyHolds: replyHolds(modelRows, closeAt).filter(inWindow),
877
889
  markers: markers(modelRows, { from: window.from, to: window.to, ended: endedAt !== null }),
@@ -281,7 +281,7 @@ function SessionStrip({ m }) {
281
281
  <div class="voice-card">
282
282
  <div class="voice-hd">Session</div>
283
283
  <div class="voice-strip">
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.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>
285
285
  ${m.ended ? html `<span class="voice-note voice-ended">ended</span>` : null}
286
286
  <span class="voice-kv">session <b>${String(m.sessionId)}</b></span>
287
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>
@@ -446,9 +446,12 @@ function Tracks({ m, title, rearms, onPick }) {
446
446
  }
447
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} />`;
448
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" />`;
449
451
  const model = mergeSegmentsByColumn(m.model, x);
450
452
  const you = mergeSegmentsByColumn(m.you, x);
451
453
  const youMuted = mergeSegmentsByColumn(m.youMuted, x);
454
+ const youSpeaking = mergeSegmentsByColumn(m.youSpeaking, x);
452
455
  const holds = mergeSegmentsByColumn(m.replyHolds, x);
453
456
  // Spans the playback rows only: the model row, plus the playback level row when levels are drawn.
454
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>`;
@@ -502,6 +505,7 @@ function Tracks({ m, title, rearms, onPick }) {
502
505
  ${model.map((s) => seg(s, "model", ROW_Y.model, "var(--blue)", ".45"))}
503
506
  ${you.map((s) => seg(s, "you", ROW_Y.you, "var(--accent)", ".4"))}
504
507
  ${youMuted.map(segMuted)}
508
+ ${youSpeaking.map(segSpeaking)}
505
509
  ${holds.map((s) => holdBand(s, ROW_Y.model, ROW_H))}
506
510
  ${m.hasLevels ? holds.map((s) => holdBand(s, ROW_Y.playbackLevel, LEVEL_ROW_H)) : null}
507
511
  ${drawn.map((k) => {
@@ -560,12 +564,13 @@ function Tracks({ m, title, rearms, onPick }) {
560
564
  <span class="m">model speaking</span>
561
565
  <span class="y">you capturing</span>
562
566
  <span class="mu">you (muted)</span>
567
+ ${m.hasUserSpeaking ? html `<span class="ys">likely speaking</span>` : null}
563
568
  ${holds.length > 0 ? html `<span class="hd" title=${HOLD_TITLE}>reply on hold (you paused it)</span>` : null}
564
569
  <span class="r">playback re-arm</span>
565
570
  <span class="s">tts.stop sent</span>
566
571
  <span class="st">player stall</span>
567
572
  <span class="e">connection failed</span>
568
- <span class="en">server ended the call</span>
573
+ <span class="en">call ended (server or swipe)</span>
569
574
  <span class="f">mic paused</span>
570
575
  ${hasCard ? html `<span class="cd">card</span>` : null}
571
576
  ${hasClipping ? html `<span class="clip">clipping</span>` : null}
@@ -603,7 +608,7 @@ function StatCards({ m }) {
603
608
  <div class="l">playback re-arms</div>
604
609
  </div>
605
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>
606
- <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 = audio landed before session.ready, 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>
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>
607
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>
608
613
  </div>
609
614
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.25.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",