@slack/radar-mcp 1.9.1 → 1.10.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.
package/README.md CHANGED
@@ -40,10 +40,11 @@ slack-radar
40
40
 
41
41
  Opens `http://localhost:8100` automatically. Set `SLACK_RADAR_WEB_PORT` to use a different port. (`slack-radar-web` still works as a direct alias.) Tabs:
42
42
 
43
- * **Live** — network, RTM, analytics clogs, and Slack-app logcat in one timeline
43
+ * **Live** — network, RTM, analytics clogs, traces, and Slack-app logcat in one timeline
44
44
  * **Network** — calls per second vs response time, every call listed, slow ones flagged
45
45
  * **RTM** — real-time websocket events
46
46
  * **Clogs** — analytics events, click one to see its payload
47
+ * **Traces** — performance trace spans with durations, click one for its timing and tags
47
48
  * **Logs** — device logcat, filtered to the Slack app (switch app or clear the filter)
48
49
  * **Database** — read-only browser for the on-device SQLite stores (pick a database, then a table, or run a read-only query). See the data-handling note below.
49
50
  * **Custom** — a tab Claude builds on request. Ask a Claude Code session in your terminal for a view the pre-built tabs do not cover (e.g. "graph calls per second and flag the slow ones"); it authors the view via the `open_radar_dashboard` tool and it appears here. Persists until you refresh the page.
@@ -140,10 +141,10 @@ What gets captured depends on the in-app server implementation. The MCP server i
140
141
  * **Network calls**: OkHttp interceptor. Ring buffer: 400 calls.
141
142
  * **RTM events**: WebSocket listener. Ring buffer: 2000 events.
142
143
  * **Clogs**: Analytics interceptor. Ring buffer: 1000 events. Persists across radar activation cycles.
143
- * **Traces**: Performance span observer. Ring buffer: 1000 spans. Persists across radar activation cycles.
144
+ * **Traces**: Performance span observer. Ring buffer: 2000 spans. Persists across radar activation cycles.
144
145
  * **SQLite database** (Database tab, web dashboard only): when you open a database, a read-only **plaintext** copy of that on-device store (message text, request/response bodies, user/channel/team IDs) is pulled to a temp directory **on your own machine** (`os.tmpdir()/slack-radar-db-<port>`, files mode 0600). Auto-deleted when the dashboard process stops.
145
146
 
146
- The network, RTM, and clog captures are in-memory ring buffers. The Database tab is the exception: it writes a plaintext copy of the selected on-device database to a temp file on your host for the duration of the session. Review before sharing anything from it.
147
+ The network, RTM, clog, and trace captures are in-memory ring buffers. The Database tab is the exception: it writes a plaintext copy of the selected on-device database to a temp file on your host for the duration of the session. Review before sharing anything from it.
147
148
 
148
149
  ### What gets captured, in detail
149
150
 
package/dist/mcp/index.js CHANGED
@@ -668,7 +668,7 @@ async function runMcpServer() {
668
668
  }
669
669
  }
670
670
  // --- MCP Server ---
671
- const server = new Server({ name: "slack-radar", version: "1.9.1" }, { capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS });
671
+ const server = new Server({ name: "slack-radar", version: "1.10.0" }, { capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS });
672
672
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
673
673
  tools: TOOL_DEFINITIONS,
674
674
  }));
@@ -161,8 +161,16 @@ function matchesFilter(frame, f) {
161
161
  return false;
162
162
  if (f.channel !== undefined && e.channel !== f.channel)
163
163
  return false;
164
- if (f.name !== undefined && !includesCI(e.name, f.name))
165
- return false;
164
+ // "name" spans the per-source name fields: clogs carry event_name, traces carry
165
+ // trace_name/span_name; no source emits a literal `name` field. A hit on any counts.
166
+ if (f.name !== undefined) {
167
+ const nameHit = includesCI(e.name, f.name) ||
168
+ includesCI(e.event_name, f.name) ||
169
+ includesCI(e.trace_name, f.name) ||
170
+ includesCI(e.span_name, f.name);
171
+ if (!nameHit)
172
+ return false;
173
+ }
166
174
  // `text` searches the whole serialized frame, so it catches content in any field including the
167
175
  // clog detail payload, not just the named summary fields above.
168
176
  if (f.text !== undefined && !JSON.stringify(frame).toLowerCase().includes(f.text.toLowerCase())) {
package/dist/mcp/tools.js CHANGED
@@ -45,7 +45,7 @@ export const SERVER_INSTRUCTIONS = [
45
45
  "",
46
46
  "WEB DASHBOARD (/radar-ui):",
47
47
  "A browser-based dashboard (http://localhost:8100) shows the same live device data as",
48
- "tabs: Live (everything), Network, RTM, Clogs, and Logs, each with counters, a graph, a",
48
+ "tabs: Live (everything), Network, RTM, Clogs, Traces, and Logs, each with counters, a graph, a",
49
49
  "filterable feed, and a payload inspector. Launched via the /radar-ui skill, which runs",
50
50
  "`npx @slack/radar-mcp web` (a global install also exposes it as `slack-radar`).",
51
51
  "",
@@ -75,7 +75,7 @@ export const SERVER_INSTRUCTIONS = [
75
75
  "screen.installHint, so you can check before suggesting.",
76
76
  "",
77
77
  "CUSTOM DASHBOARD (open_radar_dashboard):",
78
- "The pre-built tabs (Live/Network/RTM/Clogs/Logs) cover the common cases. When the user",
78
+ "The pre-built tabs (Live/Network/RTM/Clogs/Traces/Logs) cover the common cases. When the user",
79
79
  "describes a live view the tabs do not show, SUGGEST building it; invoke open_radar_dashboard",
80
80
  "only after they agree or explicitly ask for a custom view/dashboard (same discipline as",
81
81
  "/radar-ui). To build, translate their words into a spec and call the tool; it renders your",
@@ -86,9 +86,10 @@ export const SERVER_INSTRUCTIONS = [
86
86
  '- "show only RTM events on channel C... and let me click each for its payload"',
87
87
  '- "watch network calls whose body contains <substring>"',
88
88
  "Authoring rules:",
89
- "- source is one of network/rtm/clog/log/all ('all' = one unified timeline).",
89
+ "- source is one of network/rtm/clog/trace/log/all ('all' = one unified timeline).",
90
90
  "- match filters on SUMMARY fields only, by source: network=url/method/status_code,",
91
- " rtm=event_type/direction/channel, clog=event_name, log=tag/level/message/pid/package.",
91
+ " rtm=event_type/direction/channel, clog=event_name, trace=trace_name/span_name,",
92
+ " log=tag/level/message/pid/package.",
92
93
  " NEVER invent a field; a match on a field the stream does not carry silently matches",
93
94
  " nothing. To filter on body text use bodyContains (network/all only), which fetches detail.",
94
95
  "- viz composes counter/rate/sparkline/feed/inspector/graph. graph needs a series array",
@@ -373,7 +374,7 @@ export const TOOL_DEFINITIONS = [
373
374
  {
374
375
  name: "open_radar_dashboard",
375
376
  description: "Build or refine a custom live dashboard tab in the Slack Radar web UI from a spec YOU author. " +
376
- "Suggest this when the user describes a live view the pre-built tabs (Live/Network/RTM/Clogs/Logs) do not cover " +
377
+ "Suggest this when the user describes a live view the pre-built tabs (Live/Network/RTM/Clogs/Traces/Logs) do not cover " +
377
378
  "(e.g. 'graph calls per second vs response time and flag slow ones', 'beep when I get a DM'); invoke it once they agree. " +
378
379
  "Translate the request into the spec fields below and call this tool; it ensures the web dashboard is " +
379
380
  "running (default http://localhost:8100) and renders your spec as a 'Custom' tab, then returns the URL to share. " +
@@ -390,12 +391,12 @@ export const TOOL_DEFINITIONS = [
390
391
  source: {
391
392
  type: "string",
392
393
  enum: [...SOURCES],
393
- description: "Which device stream to read. 'all' is a unified timeline mixing network, RTM, and clog.",
394
+ description: "Which device stream to read. 'all' is a unified timeline mixing network, RTM, clog, trace, and log.",
394
395
  },
395
396
  match: {
396
397
  type: "object",
397
398
  description: "Case-insensitive substring filter on SUMMARY fields, keyed by source. network: url/method/status_code; " +
398
- "rtm: event_type/direction/channel; clog: event_name; log: tag/level/package. NEVER invent a field " +
399
+ "rtm: event_type/direction/channel; clog: event_name; trace: trace_name/span_name; log: tag/level/package. NEVER invent a field " +
399
400
  "(a match on an absent field silently matches nothing). For body text use bodyContains instead.",
400
401
  },
401
402
  bodyContains: {
@@ -22,7 +22,7 @@
22
22
  --warn:#ffb454; --warn-2:#ffd479; --error:#ff6b60; --error-2:#ff5b50;
23
23
  --hover:#11202e; --sel:#1d3a52; --hover-soft:#172230; --sel-soft:#1d2c3e;
24
24
  --shadow:rgba(0,0,0,.5); --overlay:rgba(0,0,0,.45);
25
- --chip-net-bg:#13314a; --chip-rtm-bg:#2c1f47; --chip-clog-bg:#10332a; --chip-log-bg:#2a2a2a; --chip-log-fg:#b0b0b0;
25
+ --chip-net-bg:#13314a; --chip-rtm-bg:#2c1f47; --chip-clog-bg:#10332a; --chip-trace-bg:#3a2f10; --chip-log-bg:#2a2a2a; --chip-log-fg:#b0b0b0;
26
26
  --lvl-err-bg:#3a1513; --lvl-warn-bg:#3a2f10; --lvl-info-bg:#10283a; --lvl-dbg-bg:#222;
27
27
  --copybtn-bg:#172a1f; --copybtn-border:#2c5a3e; --copybtn-fg:#7fd6a3;
28
28
  --j-key:#7fb0ff; --j-str:#9fe8bd; --j-num:#ffd479; --j-bool:#c39bff; --j-null:#7e8a99;
@@ -37,7 +37,7 @@
37
37
  --warn:#b06c00; --warn-2:#8a5a00; --error:#d83a30; --error-2:#e0473d;
38
38
  --hover:#eaf1f8; --sel:#d4e6f7; --hover-soft:#eaf1f8; --sel-soft:#dbe9f7;
39
39
  --shadow:rgba(20,40,70,.18); --overlay:rgba(20,30,45,.28);
40
- --chip-net-bg:#dbeafe; --chip-rtm-bg:#ecddfb; --chip-clog-bg:#d6f3e6; --chip-log-bg:#e7ebf0; --chip-log-fg:#4a5666;
40
+ --chip-net-bg:#dbeafe; --chip-rtm-bg:#ecddfb; --chip-clog-bg:#d6f3e6; --chip-trace-bg:#faedcf; --chip-log-bg:#e7ebf0; --chip-log-fg:#4a5666;
41
41
  --lvl-err-bg:#fbdcd9; --lvl-warn-bg:#faedcf; --lvl-info-bg:#dbeafe; --lvl-dbg-bg:#e7ebf0;
42
42
  --copybtn-bg:#dcf3e7; --copybtn-border:#9cd6b8; --copybtn-fg:#0a7d56;
43
43
  --j-key:#1d6fd0; --j-str:#0a7d56; --j-num:#9a6700; --j-bool:#7a3fd0; --j-null:#8a96a3;
@@ -151,11 +151,14 @@
151
151
  .stchip { font-size:10px; font-weight:700; padding:1px 6px; border-radius:4px; font-variant-numeric:tabular-nums; }
152
152
  .stchip.st2 { background:var(--chip-clog-bg); color:var(--accent); } .stchip.st3 { background:var(--lvl-info-bg); color:var(--blue); }
153
153
  .stchip.st4 { background:var(--lvl-warn-bg); color:var(--warn-2); } .stchip.st5 { background:var(--lvl-err-bg); color:var(--error); }
154
- .t-network{ background:var(--chip-net-bg); color:var(--blue); } .t-rtm{ background:var(--chip-rtm-bg); color:var(--purple); } .t-clog{ background:var(--chip-clog-bg); color:var(--accent); } .t-log{ background:var(--chip-log-bg); color:var(--chip-log-fg); }
154
+ .t-network{ background:var(--chip-net-bg); color:var(--blue); } .t-rtm{ background:var(--chip-rtm-bg); color:var(--purple); } .t-clog{ background:var(--chip-clog-bg); color:var(--accent); } .t-trace{ background:var(--chip-trace-bg); color:var(--warn); } .t-log{ background:var(--chip-log-bg); color:var(--chip-log-fg); }
155
155
  .lvl { font-size:10px; font-weight:700; padding:1px 5px; border-radius:4px; }
156
156
  .lvl-ERROR,.lvl-FATAL{ background:var(--lvl-err-bg); color:var(--error); } .lvl-WARN{ background:var(--lvl-warn-bg); color:var(--warn-2); } .lvl-INFO{ background:var(--lvl-info-bg); color:var(--blue); } .lvl-DEBUG,.lvl-VERBOSE{ background:var(--lvl-dbg-bg); color:var(--muted-2); }
157
157
  .logpkg { color:var(--blue-2); background:var(--surface-3); font-size:10.5px; padding:1px 6px; border-radius:4px; white-space:nowrap; max-width:130px; overflow:hidden; text-overflow:ellipsis; }
158
158
  .logtag { color:var(--muted-2); font-weight:600; } .logmsg { color:var(--text-2); overflow:hidden; text-overflow:ellipsis; }
159
+ .durchip { font-size:10px; font-weight:700; padding:1px 6px; border-radius:4px; background:var(--chip-trace-bg); color:var(--warn); font-variant-numeric:tabular-nums; white-space:nowrap; }
160
+ .tracename { color:var(--text-2); font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:40%; }
161
+ .spanname { color:var(--muted-2); overflow:hidden; text-overflow:ellipsis; }
159
162
  .breachbadge { margin-left:auto; background:var(--lvl-err-bg); color:var(--error); font-weight:700; font-size:11.5px; padding:2px 9px; border-radius:999px; white-space:nowrap; }
160
163
  .pill { position:absolute; left:50%; transform:translateX(-50%); top:10px; background:var(--sel); color:var(--text); border:1px solid var(--accent); border-radius:18px; padding:5px 14px; cursor:pointer; box-shadow:0 2px 10px var(--shadow); font-size:12px; z-index:6; }
161
164
  .pill-bottom { top:auto; bottom:14px; background:var(--surface); border-color:var(--border-3); color:var(--muted-2); }
@@ -137,7 +137,7 @@ function StreamView({ spec }) {
137
137
  `;
138
138
  }
139
139
  function Blank() {
140
- return html `<div class="sub"><span class="summary">Pick a dashboard above.</span><span class="tech">Live, Network, RTM, Clogs, Logs — or ask a terminal Claude Code session to build a custom view.</span></div>`;
140
+ return html `<div class="sub"><span class="summary">Pick a dashboard above.</span><span class="tech">Live, Network, RTM, Clogs, Traces, Logs — or ask a terminal Claude Code session to build a custom view.</span></div>`;
141
141
  }
142
142
  function App() {
143
143
  const spec = useStoreValue(store, "spec", () => store.spec);
@@ -21,7 +21,7 @@ function sortOptionsFor(source) {
21
21
  { key: "oldest", label: "oldest first", get: (e) => e.timestamp || 0, dir: "asc" },
22
22
  ];
23
23
  if (source === "all")
24
- opts.push({ key: "type", label: "group by type", get: (e) => ({ network: 0, rtm: 1, clog: 2, log: 3 }[e._type || ""] ?? 9), dir: "asc" });
24
+ opts.push({ key: "type", label: "group by type", get: (e) => ({ network: 0, rtm: 1, clog: 2, trace: 3, log: 4 }[e._type || ""] ?? 9), dir: "asc" });
25
25
  if (source === "network") {
26
26
  opts.push({ key: "slow", label: "slowest (response time)", get: (e) => Number(e.duration_ms), dir: "desc" });
27
27
  opts.push({ key: "status", label: "status code (high→low)", get: (e) => Number(e.status_code), dir: "desc" });
@@ -32,6 +32,10 @@ function sortOptionsFor(source) {
32
32
  opts.push({ key: "evtype", label: "event type (A→Z)", get: (e) => e.event_type || "", dir: "asc" });
33
33
  if (source === "clog")
34
34
  opts.push({ key: "name", label: "clog name (A→Z)", get: (e) => e.event_name || "", dir: "asc" });
35
+ if (source === "trace") {
36
+ opts.push({ key: "slow", label: "slowest (duration)", get: (e) => Number(e.duration_ms), dir: "desc" });
37
+ opts.push({ key: "name", label: "trace name (A→Z)", get: (e) => e.trace_name || "", dir: "asc" });
38
+ }
35
39
  return opts;
36
40
  }
37
41
  // The spec of the tab `dir` steps away from the active one (clamped). Used by the filter box's
@@ -51,6 +55,8 @@ function neighborTabSpec(dir) {
51
55
  function searchText(ev) {
52
56
  if ((ev._type || "") === "log")
53
57
  return [ev.level, ev.package, ev.tag, ev.message].filter(Boolean).join(" ").toLowerCase();
58
+ if ((ev._type || "") === "trace")
59
+ return [ev.trace_name, ev.span_name].filter(Boolean).join(" ").toLowerCase();
54
60
  return [ev.direction, ev.method, ev.event_type, ev.event_name, shortUrl(ev.url), ev.channel].filter(Boolean).join(" ").toLowerCase();
55
61
  }
56
62
  // One raw copy line per frame (Logcat-style), pulled from the ring on copy.
@@ -60,6 +66,8 @@ function rawLine(ev) {
60
66
  return `${t} ${(ev.level || "").toUpperCase()}/${ev.tag || ""}: ${ev.message || ""}`;
61
67
  if (ev._type === "network")
62
68
  return `${t} ${ev.method || "GET"} ${shortUrl(ev.url)} ${ev.status_code ?? ""} ${ev.duration_ms ?? ""}ms`;
69
+ if (ev._type === "trace")
70
+ return `${t} ${ev.trace_name || ""} ${ev.span_name || ""} ${ev.duration_ms ?? ""}ms`;
63
71
  return `${t} ${ev._type} ${ev.event_type || ev.event_name || ""} ${ev.channel || ""}`.trimEnd();
64
72
  }
65
73
  function statusBand(c) {
@@ -90,6 +98,10 @@ function RowBody({ ev, source, highlight }) {
90
98
  const lv = (ev.level || "").toUpperCase();
91
99
  return html `<span class="t">${t}</span>${typeChip}<span class=${"lvl lvl-" + lv}>${lv || "LOG"}</span>${ev.package ? html `<span class="logpkg" title=${ev.package}>${shortPkg(ev.package)}</span>` : null}<span class="logtag">${ev.tag || ""}</span><span class="logmsg">${ev.message || ""}</span>`;
92
100
  }
101
+ if ((ev._type || source) === "trace") {
102
+ const breach = highlight && store.breaches(ev);
103
+ return html `<span class="t">${t}</span>${typeChip}${ev.duration_ms != null ? html `<span class="durchip">${fmtNum(Number(ev.duration_ms))} ms</span>` : null}<span class="tracename">${ev.trace_name || ""}</span><span class="spanname">${ev.span_name || ""}</span>${breach && highlight ? html `<span class="breachbadge">${breachBadge(ev, highlight)}</span>` : null}`;
104
+ }
93
105
  const breach = highlight && store.breaches(ev);
94
106
  const isNet = (ev._type || source) === "network" || ev.url != null;
95
107
  const code = Number(ev.status_code);
@@ -6,7 +6,7 @@ import { html } from "./html.js";
6
6
  import { useState, useEffect } from "preact/hooks";
7
7
  import { esc } from "./esc.js";
8
8
  import { shortUrl, store } from "./store.js";
9
- import { hasDetailEndpoint } from "./registry.js";
9
+ import { hasDetailEndpoint, SOURCES } from "./registry.js";
10
10
  function shq(s) {
11
11
  return "'" + String(s).replace(/'/g, "'\\''") + "'";
12
12
  }
@@ -141,7 +141,7 @@ export function Inspector({ ev, onClose }) {
141
141
  .then((d) => {
142
142
  if (!live)
143
143
  return;
144
- // {error:"Not Found"} = the id was evicted from the device ring (older than ~200). Do
144
+ // {error:"Not Found"} = the id was evicted from the device ring (see SOURCES ringSize). Do
145
145
  // NOT overwrite the good summary; keep the feed row + flag the body is gone.
146
146
  if (d && d.error && d.url == null && d.method == null) {
147
147
  setEvicted(true);
@@ -159,7 +159,7 @@ export function Inspector({ ev, onClose }) {
159
159
  }, [ev]);
160
160
  const kind = ev._type || "";
161
161
  const isNet = kind === "network" || detail.url != null || detail.method != null;
162
- const title = ev.event_name || ev.event_type || shortUrl(ev.url) || kind || "detail";
162
+ const title = ev.trace_name || ev.event_name || ev.event_type || shortUrl(ev.url) || kind || "detail";
163
163
  const copy = (which, e) => {
164
164
  let text = "";
165
165
  if (which === "json")
@@ -201,6 +201,12 @@ export function Inspector({ ev, onClose }) {
201
201
  if (ev.event_name)
202
202
  badges.push(html `<span class="ibadge">${ev.event_name}</span>`);
203
203
  }
204
+ else if (kind === "trace") {
205
+ if (detail.duration_ms != null)
206
+ badges.push(html `<span class="ibadge">${detail.duration_ms} ms</span>`);
207
+ if (ev.span_name)
208
+ badges.push(html `<span class="ibadge">${ev.span_name}</span>`);
209
+ }
204
210
  else if (kind === "log") {
205
211
  if (ev.level)
206
212
  badges.push(html `<span class=${"ibadge lvl-" + String(ev.level).toUpperCase()}>${ev.level}</span>`);
@@ -215,13 +221,19 @@ export function Inspector({ ev, onClose }) {
215
221
  const resHeaders = (detail.response_headers || detail.responseHeaders);
216
222
  const data = parseBody(detail.data);
217
223
  const logMessage = kind === "log" ? detail.message || ev.message : null;
224
+ // Trace tags arrive as a JSON object from the device detail; give them their own section so
225
+ // the interesting payload is not buried in the generic "other fields" dump.
226
+ const traceTags = kind === "trace" && detail.tags != null ? parseBody(detail.tags) : null;
218
227
  // generic "other fields" dump, minus the specially-rendered ones
219
228
  const omit = new Set([
220
229
  "_type", "id", "timestamp", "url", "method", "status_code", "duration_ms",
221
230
  "request_body", "requestBody", "response_body", "responseBody",
222
231
  "request_headers", "requestHeaders", "response_headers", "responseHeaders",
223
232
  "data", "message", "event_type", "event_name", "direction", "channel", "level", "tag", "package", "pid", "tid", "log_ts",
233
+ "trace_name", "span_name", // shown in the title + badges already
224
234
  ]);
235
+ if (traceTags)
236
+ omit.add("tags"); // rendered in its own section below
225
237
  const rest = {};
226
238
  for (const k of Object.keys(detail))
227
239
  if (!omit.has(k))
@@ -235,7 +247,7 @@ export function Inspector({ ev, onClose }) {
235
247
  </div>
236
248
  <div class="ibadges">${badges}</div>
237
249
  ${isNet && detail.url ? html `<div class="iurl" title=${detail.url}>${detail.url}</div>` : null}
238
- ${evicted ? html `<div class="trunc">This call scrolled off the device buffer (it keeps only the last ~200), so the full request/response body is no longer available. The summary above is from the live feed. Open a call sooner to capture its body.</div>` : null}
250
+ ${evicted ? html `<div class="trunc">This ${kind === "network" ? "call" : "record"} scrolled off the device buffer (it keeps the last ~${SOURCES[kind]?.ringSize ?? 200} ${kind} records), so ${SOURCES[kind]?.detailNoun ?? "the full detail"} is no longer available. The summary above is from the live feed.</div>` : null}
239
251
  <div class="copybar">
240
252
  <button class="copybtn" onClick=${(e) => copy("json", e)}>Copy JSON</button>
241
253
  ${isNet ? html `<button class="copybtn" onClick=${(e) => copy("body", e)}>Copy body</button><button class="copybtn" onClick=${(e) => copy("curl", e)}>Copy cURL</button>` : null}
@@ -248,6 +260,7 @@ export function Inspector({ ev, onClose }) {
248
260
  ${reqBody.value != null ? html `<${Section} title="request body"><${Body} parsed=${reqBody} /><//>` : null}
249
261
  ${resBody.value != null ? html `<${Section} title="response body"><${Body} parsed=${resBody} /><//>` : null}
250
262
  ${data.value != null ? html `<${Section} title="data"><${Body} parsed=${data} /><//>` : null}
263
+ ${traceTags && traceTags.value != null ? html `<${Section} title="tags"><${Body} parsed=${traceTags} /><//>` : null}
251
264
  ${reqHeaders ? html `<${Section} title="request headers" sub=${Object.keys(reqHeaders).length} open=${false}><${KV} map=${reqHeaders} /><//>` : null}
252
265
  ${resHeaders ? html `<${Section} title="response headers" sub=${Object.keys(resHeaders).length} open=${false}><${KV} map=${resHeaders} /><//>` : null}
253
266
  ${hasRest ? html `<${Section} title="other fields" open=${!isNet}><${Body} parsed=${{ value: rest, truncated: false }} /><//>` : null}
@@ -8,6 +8,7 @@ export const MATCH_FIELDS = {
8
8
  network: ["url", "method", "status_code"],
9
9
  rtm: ["event_type", "direction", "channel"],
10
10
  clog: ["event_name"],
11
+ trace: ["trace_name", "span_name"],
11
12
  log: ["tag", "level", "message", "pid", "package"],
12
13
  };
13
14
  // `all` = the union of every streaming source's fields (deduped, order-stable). Derived, not
@@ -15,7 +16,7 @@ export const MATCH_FIELDS = {
15
16
  MATCH_FIELDS.all = (() => {
16
17
  const seen = new Set();
17
18
  const out = [];
18
- for (const src of ["network", "rtm", "clog", "log"]) {
19
+ for (const src of ["network", "rtm", "clog", "trace", "log"]) {
19
20
  for (const f of MATCH_FIELDS[src])
20
21
  if (!seen.has(f)) {
21
22
  seen.add(f);
@@ -33,9 +34,10 @@ export const FIELD_VALUES = {
33
34
  // SOURCE registry: one row per source. `kind` routes the view (streaming feed vs the
34
35
  // point-in-time DB browser) without a hardcoded source check.
35
36
  export const SOURCES = {
36
- network: { label: "Network", kind: "stream", hasDetailEndpoint: true },
37
- rtm: { label: "RTM", kind: "stream", hasDetailEndpoint: true },
38
- clog: { label: "Clogs", kind: "stream", hasDetailEndpoint: true },
37
+ network: { label: "Network", kind: "stream", hasDetailEndpoint: true, eagerCapture: true, ringSize: 400, detailNoun: "the full request/response body" },
38
+ rtm: { label: "RTM", kind: "stream", hasDetailEndpoint: true, eagerCapture: true, ringSize: 2000, detailNoun: "the full payload" },
39
+ clog: { label: "Clogs", kind: "stream", hasDetailEndpoint: true, eagerCapture: true, ringSize: 1000, detailNoun: "the full payload" },
40
+ trace: { label: "Traces", kind: "stream", hasDetailEndpoint: true, ringSize: 2000, detailNoun: "the span timing and tag detail" },
39
41
  log: { label: "Logs", kind: "stream", hasDetailEndpoint: false },
40
42
  all: { label: "Live", kind: "stream" },
41
43
  db: { label: "Database", kind: "db" },
@@ -45,11 +47,16 @@ export const SOURCES = {
45
47
  export const STREAM_KINDS = Object.entries(SOURCES)
46
48
  .filter(([k, v]) => v.kind === "stream" && k !== "all")
47
49
  .map(([k]) => k);
48
- // The kinds that have a /detail endpoint (eager body capture + inspector fetch). Derived from
50
+ // The kinds that have a /detail endpoint (inspector click-fetch). Derived from
49
51
  // hasDetailEndpoint so adding a detailable source is one SOURCES edit.
50
52
  export const DETAILABLE_KINDS = Object.entries(SOURCES)
51
53
  .filter(([, v]) => v.hasDetailEndpoint)
52
54
  .map(([k]) => k);
55
+ // The kinds the store eagerly pre-fetches detail for (see eagerCapture above). A subset of
56
+ // DETAILABLE_KINDS; derived so the two flags cannot drift apart silently.
57
+ export const EAGER_CAPTURE_KINDS = Object.entries(SOURCES)
58
+ .filter(([, v]) => v.hasDetailEndpoint && v.eagerCapture)
59
+ .map(([k]) => k);
53
60
  export function hasDetailEndpoint(kind) {
54
61
  return !!SOURCES[kind]?.hasDetailEndpoint;
55
62
  }
@@ -58,7 +65,7 @@ export function hasDetailEndpoint(kind) {
58
65
  // see widgets.ts). A new widget = one key here + one component.
59
66
  export const WIDGETS = ["counter", "rate", "sparkline", "graph"];
60
67
  // Source order for the modebar / global tab-switch (matches the MODES preset order).
61
- export const SOURCE_ORDER = ["all", "network", "rtm", "clog", "log", "db"];
68
+ export const SOURCE_ORDER = ["all", "network", "rtm", "clog", "trace", "log", "db"];
62
69
  // The source options the Filters panel offers: every streaming source (db is its own container,
63
70
  // not a feed filter). Derived from SOURCES so adding a streaming source surfaces it in Filters
64
71
  // with no edit there. Ordered by SOURCE_ORDER (the modebar order) for a stable, familiar list.
@@ -1,4 +1,4 @@
1
- import { STREAM_KINDS, DETAILABLE_KINDS } from "./registry.js";
1
+ import { STREAM_KINDS, EAGER_CAPTURE_KINDS } from "./registry.js";
2
2
  // Logcat-scale retention. At the live firehose (~400+ events/sec on the unified Live tab) a
3
3
  // small ring recycles in seconds, so a rare signal (a once-per-5s heartbeat) gets evicted
4
4
  // before you can filter for it. Android Studio / Flipper keep the whole session and filter
@@ -10,7 +10,7 @@ import { STREAM_KINDS, DETAILABLE_KINDS } from "./registry.js";
10
10
  // the retention rationale stays attached to the numbers.
11
11
  const CACHE_CAP = 100000;
12
12
  const CACHE_TTL_MS = 60 * 60 * 1000;
13
- const DETAILABLE = new Set(DETAILABLE_KINDS); // sources with a server /detail endpoint
13
+ const EAGER_CAPTURE = new Set(EAGER_CAPTURE_KINDS); // sources whose detail is pre-fetched per frame
14
14
  const DETAIL_CACHE_CAP = 1500; // bounded full-detail cache (eager-captured + click-fetched)
15
15
  const CAPTURE_CONCURRENCY = 3; // max parallel background /detail fetches
16
16
  const CAP_SEEN_CAP = 4000; // bound on the dedup set for eager capture
@@ -19,16 +19,17 @@ const POLL_HEALTH_MS = 2000;
19
19
  const POLL_PROFILE_MS = 5000;
20
20
  const GRAPH_N = 60;
21
21
  const PERSEC_N = 30;
22
- const SUGGEST_FIELDS = ["event_type", "event_name", "tag", "status_code", "channel", "url", "package"];
22
+ const SUGGEST_FIELDS = ["event_type", "event_name", "tag", "status_code", "channel", "url", "package", "trace_name", "span_name"];
23
23
  const PACKAGE_CAP = 1000; // package values learned off the stream; bounded (was Infinity in the PoC, B4)
24
24
  // ---- pre-built dashboards: one tab each. Presets carry only generic placeholders; real
25
25
  // endpoints/channels/event-names are learned LIVE from the device stream. The one baked value
26
26
  // is com.Slack.internal.debug (the debug build's package), which is already public. ----
27
27
  export const MODES = [
28
- { key: "all", label: "Live", spec: { title: "Live", summary: "Live: network, RTM, analytics clogs, and Slack-app logcat in one timeline. (Logs filtered to the Slack app; clear the package chip for all apps.)", source: "all", viz: ["rate", "sparkline", "feed", "inspector"], match: { package: "com.Slack.internal.debug" } } },
28
+ { key: "all", label: "Live", spec: { title: "Live", summary: "Live: network, RTM, analytics clogs, traces, and Slack-app logcat in one timeline. (Logs filtered to the Slack app; clear the package chip for all apps.)", source: "all", viz: ["rate", "sparkline", "feed", "inspector"], match: { package: "com.Slack.internal.debug" } } },
29
29
  { key: "network", label: "Network", spec: { title: "Network", summary: "Network calls per second vs average response time, every call listed, slow ones flagged.", source: "network", viz: ["rate", "graph", "feed", "inspector"], series: [{ metric: "ratePerSec", label: "calls/s", unit: "/s" }, { metric: "avg", field: "duration_ms", label: "avg ms", unit: "ms" }], highlight: { field: "duration_ms", op: ">", value: 800, label: "slow (>800ms)" }, rateWindowSec: 10 } },
30
30
  { key: "rtm", label: "RTM", spec: { title: "RTM", summary: "Real-time websocket events as they happen.", source: "rtm", viz: ["rate", "feed", "inspector"] } },
31
31
  { key: "clog", label: "Clogs", spec: { title: "Clogs", summary: "Analytics clog events, click any to see its full payload.", source: "clog", viz: ["rate", "feed", "inspector"] } },
32
+ { key: "trace", label: "Traces", spec: { title: "Traces", summary: "Performance trace spans, click to see timing details and tags.", source: "trace", viz: ["rate", "graph", "feed", "inspector"], series: [{ metric: "ratePerSec", label: "spans/s", unit: "/s" }, { metric: "avg", field: "duration_ms", label: "avg ms", unit: "ms" }] } },
32
33
  { key: "log", label: "Logs", spec: { title: "Device Logs", summary: "Live Slack app logcat, color-coded by level. Scroll the full session buffer, select a range, copy raw lines.", source: "log", viz: ["feed", "inspector"], match: { package: "com.Slack.internal.debug" } } },
33
34
  { key: "db", label: "Database", spec: { title: "Device DB", summary: "Browse the on-device SQLite databases (read-only snapshot).", source: "db" } },
34
35
  ];
@@ -119,8 +120,8 @@ class Store {
119
120
  getDetail(kind, id) {
120
121
  return this.detailCache.get(kind + ":" + id);
121
122
  }
122
- // ---- eager body capture (any DETAILABLE tab, while it is open) ----
123
- // The device keeps only the last ~200 network calls, so a row clicked later is gone. While a
123
+ // ---- eager body capture (any EAGER_CAPTURE tab, while it is open) ----
124
+ // The device ring evicts old records (network keeps 400), so a row clicked later is gone. While a
124
125
  // detailable tab is active we proactively fetch each NEW frame's full body in the background
125
126
  // (concurrency-bounded) and cache it, so clicking an old row never hits eviction. Off on
126
127
  // every other tab (mirrors Flipper's shouldStripResponseBody). Forward-only: no backfill.
@@ -131,7 +132,7 @@ class Store {
131
132
  maybeCapture(ev) {
132
133
  const src = this.spec.source;
133
134
  const kind = ev._type || "";
134
- if (ev.id == null || !DETAILABLE.has(kind))
135
+ if (ev.id == null || !EAGER_CAPTURE.has(kind))
135
136
  return;
136
137
  if (src !== "all" && src !== kind)
137
138
  return;
@@ -30,6 +30,10 @@ export declare function seedInitialSpec(): void;
30
30
  */
31
31
  export declare function cleanupOnBind(): void;
32
32
  export declare function createServer(): http.Server;
33
+ export declare const DEVICE_SOURCES: Record<string, {
34
+ segment: string;
35
+ arrayKey: string;
36
+ }>;
33
37
  /**
34
38
  * Finish a /detail proxy response after an upstream error or timeout. The success
35
39
  * callback streams the upstream response, so headers may already be sent when a later
@@ -489,15 +489,20 @@ function handleEnable(res) {
489
489
  });
490
490
  probe.end();
491
491
  }
492
- const SOURCE_ARRAY_KEY = {
493
- network: "calls",
494
- rtm: "events",
495
- clog: "clogs",
492
+ // The device-buffered source kinds, in one table so a new source is one row here: the
493
+ // device API route segment (clog and trace pluralize; the rest match the kind name) and
494
+ // the array key its list response wraps the records in. Backfill and the /detail proxy
495
+ // both read this, so the two cannot drift apart. Logs are host-side and absent by design.
496
+ export const DEVICE_SOURCES = {
497
+ network: { segment: "network", arrayKey: "calls" },
498
+ rtm: { segment: "rtm", arrayKey: "events" },
499
+ clog: { segment: "clogs", arrayKey: "clogs" },
500
+ trace: { segment: "traces", arrayKey: "traces" },
496
501
  };
497
502
  /**
498
503
  * Replay the device's recent ring buffers for a source so a freshly-built tab
499
504
  * shows history immediately instead of filling only going forward. The device is
500
- * the source of truth. "all" pulls network+rtm+clog and merges them oldest->newest;
505
+ * the source of truth. "all" pulls network+rtm+clog+trace and merges them oldest->newest;
501
506
  * "log" is host-side (no device buffer) and so has nothing to replay. Returns
502
507
  * `[{type, event}]` frames mirroring the stream shape.
503
508
  */
@@ -506,10 +511,10 @@ function handleBackfill(req, res) {
506
511
  const src = u.searchParams.get("source") ?? "network";
507
512
  const limit = Math.min(500, Number(u.searchParams.get("limit")) || 200);
508
513
  const kinds = src === "all"
509
- ? ["network", "rtm", "clog"]
510
- : [src].filter((k) => k !== "log" && k in SOURCE_ARRAY_KEY);
514
+ ? Object.keys(DEVICE_SOURCES)
515
+ : [src].filter((k) => Object.hasOwn(DEVICE_SOURCES, k));
511
516
  const fetchKind = (kind) => new Promise((resolve) => {
512
- const apiPath = `/api/${kind === "clog" ? "clogs" : kind}?limit=${limit}`;
517
+ const apiPath = `/api/${DEVICE_SOURCES[kind].segment}?limit=${limit}`;
513
518
  const rq = http.request({
514
519
  host: RADAR_HOST,
515
520
  port: RADAR_PORT,
@@ -522,7 +527,7 @@ function handleBackfill(req, res) {
522
527
  up.on("end", () => {
523
528
  try {
524
529
  const j = JSON.parse(b);
525
- const arr = j[SOURCE_ARRAY_KEY[kind]] ?? [];
530
+ const arr = j[DEVICE_SOURCES[kind].arrayKey] ?? [];
526
531
  resolve(arr.map((e) => ({ type: kind, event: e })));
527
532
  }
528
533
  catch {
@@ -546,13 +551,6 @@ function handleBackfill(req, res) {
546
551
  })
547
552
  .catch(() => sendJson(res, 200, { frames: [] }));
548
553
  }
549
- // Detail kinds the inspector may request, mapped to their device route segment. The
550
- // device serves clog detail at /api/clogs/ (plural); the rest match the kind name.
551
- const DETAIL_ROUTES = {
552
- network: "network",
553
- rtm: "rtm",
554
- clog: "clogs",
555
- };
556
554
  /**
557
555
  * Finish a /detail proxy response after an upstream error or timeout. The success
558
556
  * callback streams the upstream response, so headers may already be sent when a later
@@ -578,7 +576,7 @@ function handleDetail(req, res) {
578
576
  const u = new URL(req.url ?? "", `http://localhost:${WEB_PORT}`);
579
577
  const id = u.searchParams.get("id");
580
578
  const kind = u.searchParams.get("kind") ?? "network";
581
- const route = DETAIL_ROUTES[kind];
579
+ const route = DEVICE_SOURCES[kind]?.segment;
582
580
  if (!id || !route) {
583
581
  res.writeHead(400, { "Content-Type": "application/json; charset=utf-8" });
584
582
  res.end("{}");
@@ -5,17 +5,17 @@
5
5
  * and the same validate/coerce pass runs on every push so a malformed spec surfaces
6
6
  * an error instead of rendering silent zeros.
7
7
  *
8
- * Most sources are live STREAMS (network/rtm/clog/log/all). `db` is the odd one out:
8
+ * Most sources are live STREAMS (network/rtm/clog/trace/log/all). `db` is the odd one out:
9
9
  * a read-only, point-in-time SQLite BROWSER over the on-device databases, with no viz /
10
10
  * series / match (it has its own list -> tables -> query-grid view). The coerce and
11
11
  * validate passes short-circuit for `db` accordingly.
12
12
  */
13
13
  /**
14
- * Sources the dashboard can read. The first five are live streams; "all" is their unified
14
+ * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
15
  * timeline. "db" is a read-only on-device SQLite browser (a point-in-time snapshot, not a
16
16
  * stream) and is handled as a distinct view.
17
17
  */
18
- export declare const SOURCES: readonly ["rtm", "network", "clog", "log", "all", "db"];
18
+ export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "all", "db"];
19
19
  export type Source = (typeof SOURCES)[number];
20
20
  /** Widgets a spec may compose. */
21
21
  export declare const VIZ: readonly ["counter", "rate", "sparkline", "feed", "inspector", "graph"];
package/dist/web/spec.js CHANGED
@@ -5,17 +5,17 @@
5
5
  * and the same validate/coerce pass runs on every push so a malformed spec surfaces
6
6
  * an error instead of rendering silent zeros.
7
7
  *
8
- * Most sources are live STREAMS (network/rtm/clog/log/all). `db` is the odd one out:
8
+ * Most sources are live STREAMS (network/rtm/clog/trace/log/all). `db` is the odd one out:
9
9
  * a read-only, point-in-time SQLite BROWSER over the on-device databases, with no viz /
10
10
  * series / match (it has its own list -> tables -> query-grid view). The coerce and
11
11
  * validate passes short-circuit for `db` accordingly.
12
12
  */
13
13
  /**
14
- * Sources the dashboard can read. The first five are live streams; "all" is their unified
14
+ * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
15
  * timeline. "db" is a read-only on-device SQLite browser (a point-in-time snapshot, not a
16
16
  * stream) and is handled as a distinct view.
17
17
  */
18
- export const SOURCES = ["rtm", "network", "clog", "log", "all", "db"];
18
+ export const SOURCES = ["rtm", "network", "clog", "trace", "log", "all", "db"];
19
19
  /** Widgets a spec may compose. */
20
20
  export const VIZ = [
21
21
  "counter",
@@ -65,7 +65,9 @@ export function coerceSpec(input) {
65
65
  ? "event_type"
66
66
  : s.source === "clog"
67
67
  ? "event_name"
68
- : "url";
68
+ : s.source === "trace"
69
+ ? "trace_name"
70
+ : "url";
69
71
  s.match = { [field]: s.match };
70
72
  }
71
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "MCP server and web dashboard for on-device debugging of the Slack Android app via ADB",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",