@slack/radar-mcp 1.20.0 → 1.22.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 +75 -17
- package/dist/mcp/api-paths.d.ts +11 -0
- package/dist/mcp/api-paths.js +56 -20
- package/dist/mcp/dashboard-identity.d.ts +6 -0
- package/dist/mcp/dashboard-identity.js +11 -0
- package/dist/mcp/index.js +138 -36
- package/dist/mcp/logs-result.d.ts +1 -0
- package/dist/mcp/logs-result.js +1 -0
- package/dist/mcp/network-detail.d.ts +5 -0
- package/dist/mcp/network-detail.js +86 -0
- package/dist/mcp/radar-export-get.d.ts +30 -0
- package/dist/mcp/radar-export-get.js +49 -0
- package/dist/mcp/radar-response.d.ts +11 -1
- package/dist/mcp/radar-response.js +23 -3
- package/dist/mcp/session-backfill.d.ts +9 -3
- package/dist/mcp/session-backfill.js +76 -17
- package/dist/mcp/session-detail.js +54 -2
- package/dist/mcp/session-enable.d.ts +1 -0
- package/dist/mcp/session-enable.js +146 -15
- package/dist/mcp/session-query.js +53 -11
- package/dist/mcp/snapshot.js +42 -26
- package/dist/mcp/sources-gate.js +5 -0
- package/dist/mcp/stale-dashboard.d.ts +23 -0
- package/dist/mcp/stale-dashboard.js +122 -0
- package/dist/mcp/switchboard-spool.d.ts +12 -0
- package/dist/mcp/switchboard-spool.js +107 -0
- package/dist/mcp/switchboard-tools.d.ts +18 -0
- package/dist/mcp/switchboard-tools.js +178 -0
- package/dist/mcp/tools.d.ts +4 -1
- package/dist/mcp/tools.js +114 -23
- package/dist/mcp/web-child-env.d.ts +4 -1
- package/dist/mcp/web-child-env.js +4 -1
- package/dist/shared/android.d.ts +43 -0
- package/dist/shared/android.js +227 -19
- package/dist/shared/constants.d.ts +19 -4
- package/dist/shared/constants.js +19 -4
- package/dist/shared/event-spool.js +3 -2
- package/dist/shared/feature-flags.d.ts +1 -0
- package/dist/shared/feature-flags.js +1 -0
- package/dist/shared/form-body.d.ts +18 -0
- package/dist/shared/form-body.js +251 -0
- package/dist/shared/ios-logs.d.ts +10 -0
- package/dist/shared/ios-logs.js +91 -0
- package/dist/shared/ios.d.ts +25 -2
- package/dist/shared/ios.js +157 -3
- package/dist/{web → shared}/log-session.d.ts +45 -31
- package/dist/shared/log-session.js +300 -0
- package/dist/shared/radar-request-raw.d.ts +7 -0
- package/dist/shared/radar-request-raw.js +89 -0
- package/dist/shared/radar-token.d.ts +25 -0
- package/dist/shared/radar-token.js +164 -0
- package/dist/shared/stream.d.ts +4 -1
- package/dist/shared/stream.js +107 -15
- package/dist/shared/switchboard-host-store.d.ts +21 -0
- package/dist/shared/switchboard-host-store.js +166 -0
- package/dist/shared/switchboard-note.d.ts +15 -0
- package/dist/shared/switchboard-note.js +92 -0
- package/dist/shared/switchboard-report-file.d.ts +5 -0
- package/dist/shared/switchboard-report-file.js +26 -0
- package/dist/shared/switchboard-report.d.ts +20 -0
- package/dist/shared/switchboard-report.js +406 -0
- package/dist/shared/switchboard.d.ts +118 -0
- package/dist/shared/switchboard.js +487 -0
- package/dist/shared/transport.d.ts +43 -3
- package/dist/shared/version.d.ts +2 -0
- package/dist/shared/version.js +18 -0
- package/dist/shared/wire.d.ts +46 -1
- package/dist/web/install-app.d.ts +57 -8
- package/dist/web/install-app.js +270 -60
- package/dist/web/macapp/RadarApp.swift +340 -22
- package/dist/web/public/index.html +216 -12
- package/dist/web/public/next/app.js +43 -22
- package/dist/web/public/next/db.js +4 -1
- package/dist/web/public/next/feed.js +604 -59
- package/dist/web/public/next/filters.js +158 -40
- package/dist/web/public/next/flags.js +3 -0
- package/dist/web/public/next/form-body.js +252 -0
- package/dist/web/public/next/inspector.js +171 -14
- package/dist/web/public/next/prefs.js +5 -2
- package/dist/web/public/next/registry.js +35 -3
- package/dist/web/public/next/store.js +947 -69
- package/dist/web/public/next/switchboard-note.js +93 -0
- package/dist/web/public/next/toast.js +9 -5
- package/dist/web/public/next/voice-model.js +712 -0
- package/dist/web/public/next/voice.js +552 -0
- package/dist/web/server.d.ts +20 -9
- package/dist/web/server.js +834 -174
- package/dist/web/spec.d.ts +11 -6
- package/dist/web/spec.js +62 -6
- package/package.json +4 -4
- package/dist/web/log-session.js +0 -166
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
// The voice panel on the Switchboard tab: one session's connection, mic and speaking state, the
|
|
2
|
+
// handshake waterfall, a tracks strip (model speaking, you capturing, markers) and four stat cards,
|
|
3
|
+
// all derived from the switchboard records the store already holds (voice-model.ts). It sits
|
|
4
|
+
// between the stats strip and the feed; the feed and the inspector below it are untouched, and a
|
|
5
|
+
// marker click hands the ORIGINAL record to the same inspector the feed uses.
|
|
6
|
+
import { html } from "./html.js";
|
|
7
|
+
import { useMemo, useRef, useState } from "preact/hooks";
|
|
8
|
+
import { useStorePulse } from "./hooks.js";
|
|
9
|
+
import { store } from "./store.js";
|
|
10
|
+
import { showToast } from "./toast.js";
|
|
11
|
+
import { capitalizeSwitchboardNote, SAVED_TURN_KEPT_OUTCOMES, savedTurnCountWord } from "./switchboard-note.js";
|
|
12
|
+
import { buildVoiceModel, CLIP_PEAK, dbfsHeight, GAP_P95_BAD_MS, phaseLabel, RATE_MIN_DIVISOR_MS, tickStepMs, ZOOMS } from "./voice-model.js";
|
|
13
|
+
// The stream view draws the panel only on the Switchboard tab and only while the spec keeps the
|
|
14
|
+
// voice key, so a custom spec on that source can leave it out.
|
|
15
|
+
export function showsVoicePanel(spec) {
|
|
16
|
+
return spec.source === "switchboard" && Array.isArray(spec.viz) && spec.viz.includes("voice");
|
|
17
|
+
}
|
|
18
|
+
// SVG geometry, shared with the design the panel was drawn from: a 1000-wide viewBox stretched to
|
|
19
|
+
// the card, so x is a plain fraction of the window. preserveAspectRatio="none" only stretches
|
|
20
|
+
// the x axis (the plot's CSS height matches H 1:1), which is why row and tick labels are drawn as
|
|
21
|
+
// plain HTML over the plot rather than inside the SVG: SVG text at a fixed font-size would
|
|
22
|
+
// stretch or squash with the x scale, and a stretched glyph reads as a bug, not a chart.
|
|
23
|
+
const W = 1000;
|
|
24
|
+
const ROW_Y = { model: 12, you: 40, mark: 80, micLevel: 108, playbackLevel: 140 };
|
|
25
|
+
const ROW_H = 18;
|
|
26
|
+
const LEVEL_ROW_H = 24;
|
|
27
|
+
// Matches .voice-ticklabels' height in index.html.
|
|
28
|
+
const TICK_BAND_H = 12;
|
|
29
|
+
function plotHeight(hasLevels) {
|
|
30
|
+
return hasLevels ? ROW_Y.playbackLevel + LEVEL_ROW_H + TICK_BAND_H : ROW_Y.mark + ROW_H + TICK_BAND_H;
|
|
31
|
+
}
|
|
32
|
+
// Markers (and, separately, model/you/muted segments) that land within this many viewBox units
|
|
33
|
+
// of each other (1/1000 of the width) collapse into one glyph, at every zoom, not just the
|
|
34
|
+
// whole-session one: a burst of re-arms a few frames apart is exactly as unreadable crammed into
|
|
35
|
+
// a 60 s window as it is crammed into an hour-long one.
|
|
36
|
+
const COLLAPSE_COL = 1;
|
|
37
|
+
const MARKER_COLOUR = {
|
|
38
|
+
rearm: "var(--warn)",
|
|
39
|
+
stop: "var(--purple)",
|
|
40
|
+
focus: "var(--muted-2)",
|
|
41
|
+
error: "var(--error)",
|
|
42
|
+
// --warn-2 exists in both themes (unlike --warn-text, which is light-only), so the stall gets
|
|
43
|
+
// its own shade rather than reusing --warn; the dashed stroke below keeps it further apart from
|
|
44
|
+
// a re-arm still.
|
|
45
|
+
stall: "var(--warn-2)",
|
|
46
|
+
// Distinct from `focus`'s var(--muted-2): a collapsed group of mixed-kind markers is its own
|
|
47
|
+
// thing, not another shade of the same "quiet" colour.
|
|
48
|
+
mixed: "var(--text)",
|
|
49
|
+
};
|
|
50
|
+
// A timed-out entry's `ms` is how long the panel waited, not a measured duration, so it reads as
|
|
51
|
+
// "timed out after" rather than sitting next to a real phase's plain number -- the two should
|
|
52
|
+
// never look interchangeable, or a slow-but-real session_ready reads as having failed. A
|
|
53
|
+
// neverReached entry (the phase never even started) carries no elapsed time worth showing at all.
|
|
54
|
+
function phaseBarTitle(p) {
|
|
55
|
+
return `${phaseLabel(p.name)} ${p.timedOut ? `timed out after ${(p.ms / 1000).toFixed(1)} s` : p.ms + " ms"}`;
|
|
56
|
+
}
|
|
57
|
+
function phaseInlineText(p) {
|
|
58
|
+
if (p.neverReached)
|
|
59
|
+
return html `${phaseLabel(p.name)} never reached`;
|
|
60
|
+
// The overflow entry's `ms` is a placeholder, not a real duration, so it prints just its own
|
|
61
|
+
// name ("+4 more"), never a bold 0 that would read as an actual measured phase.
|
|
62
|
+
if (p.overflow)
|
|
63
|
+
return html `${phaseLabel(p.name)}`;
|
|
64
|
+
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
|
+
}
|
|
66
|
+
function dotClass(state) {
|
|
67
|
+
if (state === "Connected")
|
|
68
|
+
return "ok";
|
|
69
|
+
if (state === "Failed")
|
|
70
|
+
return "bad";
|
|
71
|
+
// Disconnected is a settled, unremarkable state (the session ended, or never got going yet
|
|
72
|
+
// some other way): a warn dot there reads as an ongoing problem it is not. Connecting and
|
|
73
|
+
// Reconnecting keep the warn colour, still mid-transition.
|
|
74
|
+
if (state === "Disconnected")
|
|
75
|
+
return "";
|
|
76
|
+
return "warn";
|
|
77
|
+
}
|
|
78
|
+
// navigator.clipboard is absent in some embedded WebViews.
|
|
79
|
+
function copyServerSessionId(id) {
|
|
80
|
+
const clip = navigator.clipboard;
|
|
81
|
+
if (!clip?.writeText) {
|
|
82
|
+
showToast("copy not available in this browser");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
clip.writeText(id).then(() => showToast("server session id copied"), () => showToast("copy failed"));
|
|
86
|
+
}
|
|
87
|
+
// A hidden iframe navigation, as screen.ts does: in the dock app's WKWebView an <a> click or a
|
|
88
|
+
// Blob URL cannot save, while a Content-Disposition: attachment response can.
|
|
89
|
+
function triggerSwitchboardDownload(url) {
|
|
90
|
+
let frame = document.getElementById("sbdlframe");
|
|
91
|
+
if (!frame) {
|
|
92
|
+
frame = document.createElement("iframe");
|
|
93
|
+
frame.id = "sbdlframe";
|
|
94
|
+
frame.style.display = "none";
|
|
95
|
+
document.body.appendChild(frame);
|
|
96
|
+
}
|
|
97
|
+
frame.src = url;
|
|
98
|
+
}
|
|
99
|
+
// An all-caps first word (HTTP, ECONNREFUSED) is a code, so it keeps its case.
|
|
100
|
+
function lowerFirstLetterUnlessAllCapsWord(reason) {
|
|
101
|
+
if (reason.length === 0)
|
|
102
|
+
return reason;
|
|
103
|
+
const firstWord = reason.split(/\s/, 1)[0];
|
|
104
|
+
if (/[A-Z]/.test(firstWord) && firstWord === firstWord.toUpperCase())
|
|
105
|
+
return reason;
|
|
106
|
+
return reason.charAt(0).toLowerCase() + reason.slice(1);
|
|
107
|
+
}
|
|
108
|
+
// A reason starting "Failed to ..." folds in ("export failed to build ...") instead of doubling
|
|
109
|
+
// "failed".
|
|
110
|
+
function exportFailedToast(reason) {
|
|
111
|
+
const lowered = lowerFirstLetterUnlessAllCapsWord(reason);
|
|
112
|
+
if (/^failed\b/i.test(reason))
|
|
113
|
+
return `export ${lowered}`;
|
|
114
|
+
return `export failed: ${lowered}`;
|
|
115
|
+
}
|
|
116
|
+
// The route answers with a download URL, not the report body, since an iframe navigation cannot
|
|
117
|
+
// read a POST response.
|
|
118
|
+
async function exportSwitchboardSession(sessionId) {
|
|
119
|
+
try {
|
|
120
|
+
const res = await fetch("/switchboard/export", {
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: store.authoredHeaders({ "Content-Type": "application/json" }),
|
|
123
|
+
body: JSON.stringify({ id: sessionId }),
|
|
124
|
+
});
|
|
125
|
+
const body = await res.json().catch(() => null);
|
|
126
|
+
if (!res.ok || !body?.download) {
|
|
127
|
+
// "HTTP 502", not a bare "502", which would read like a session id.
|
|
128
|
+
const reason = body && typeof body.error === "string" ? body.error : `HTTP ${res.status}`;
|
|
129
|
+
showToast(exportFailedToast(reason));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
triggerSwitchboardDownload(body.download);
|
|
133
|
+
// Not showSaveToast: reveal-in-Finder needs a download-finished match this filename was
|
|
134
|
+
// never confirmed against.
|
|
135
|
+
const notes = Array.isArray(body.notes) ? body.notes : [];
|
|
136
|
+
const firstNote = typeof notes[0] === "string" ? notes[0] : null;
|
|
137
|
+
const capitalizedNote = firstNote ? capitalizeSwitchboardNote(firstNote) : null;
|
|
138
|
+
// Longer duration: the note is a whole extra sentence to read.
|
|
139
|
+
if (capitalizedNote)
|
|
140
|
+
showToast(`report downloading. ${capitalizedNote}`, 9000);
|
|
141
|
+
else
|
|
142
|
+
showToast("report downloading");
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
showToast("export failed: request did not complete");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function micClass(state) {
|
|
149
|
+
if (state === "Capturing")
|
|
150
|
+
return "ok";
|
|
151
|
+
if (state === "Paused")
|
|
152
|
+
return "warn";
|
|
153
|
+
if (state === "Muted")
|
|
154
|
+
return "muted";
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
export function VoicePanel({ onInspect, now = () => Date.now() }) {
|
|
158
|
+
useStorePulse(store, "tick");
|
|
159
|
+
const [zoom, setZoom] = useState("60s");
|
|
160
|
+
// One export at a time: each POST writes its own file server-side.
|
|
161
|
+
const [exporting, setExporting] = useState(false);
|
|
162
|
+
// The store keeps the newest run's rows (the ones the Switchboard feed shows) and hands back the
|
|
163
|
+
// same array until they change, so a render does not touch the shared cache and the model is
|
|
164
|
+
// rebuilt only when that array, the zoom or the run's server id changes. A live session also
|
|
165
|
+
// rebuilds once a second: its window slides with the clock. An ended session's does not (the
|
|
166
|
+
// model closes at the end record, wherever the clock is), so the clock leaves the key once the
|
|
167
|
+
// session ends.
|
|
168
|
+
const ended = useRef(false);
|
|
169
|
+
const rows = store.switchboardRunRows();
|
|
170
|
+
const sid = store.switchboardNewestSessionId();
|
|
171
|
+
const summaryServerSessionId = sid !== null ? store.switchboardSummaryServerId(sid) : undefined;
|
|
172
|
+
const summarySavedTurnCounts = sid !== null ? store.switchboardSummarySavedTurnCounts(sid) : undefined;
|
|
173
|
+
// Mutated in place as saved_turn rows land; each new one of the drawn run also lands in `rows`,
|
|
174
|
+
// which rebuilds the model.
|
|
175
|
+
const savedTurnOutcomes = sid !== null ? store.switchboardSavedTurnOutcomes(sid) : undefined;
|
|
176
|
+
const clockKey = ended.current ? 0 : Math.floor(now() / 1000);
|
|
177
|
+
const m = useMemo(() => {
|
|
178
|
+
const model = buildVoiceModel(rows, zoom, now(), summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes);
|
|
179
|
+
ended.current = model !== null && model.ended;
|
|
180
|
+
return model;
|
|
181
|
+
}, [rows, zoom, summaryServerSessionId, summarySavedTurnCounts, savedTurnOutcomes, clockKey]);
|
|
182
|
+
// Records exist but none names a session, or there is no switchboard record at all: draw
|
|
183
|
+
// nothing. The feed's own empty state already tells the person what to do next.
|
|
184
|
+
if (!m)
|
|
185
|
+
return null;
|
|
186
|
+
const z = ZOOMS.find((x) => x.key === zoom) ?? ZOOMS[0];
|
|
187
|
+
// Honest framing for the whole-session zoom when the begin record itself was never seen (an
|
|
188
|
+
// older build, or one the cache has since evicted): the panel does not know when the session
|
|
189
|
+
// actually started, only when its first surviving record showed up. A bounded zoom (60 s, 5
|
|
190
|
+
// min) on an ended session says so too, rather than implying the window still slides with now.
|
|
191
|
+
const zoomTitle = zoom === "whole"
|
|
192
|
+
? !m.hasBegin
|
|
193
|
+
? "Since first record seen"
|
|
194
|
+
: m.wholeSpanClamped
|
|
195
|
+
? `${z.title} (last hour)`
|
|
196
|
+
: z.title
|
|
197
|
+
: m.ended
|
|
198
|
+
? `last ${z.label} before end`
|
|
199
|
+
: z.title;
|
|
200
|
+
// The window's own stat, not a re-filter of m.markers: same set, one less place computing it.
|
|
201
|
+
const rearms = m.stats.rearms;
|
|
202
|
+
// Same tint rule as the re-arms stat card below: a re-arm on its own is routine, only a starved
|
|
203
|
+
// one (0 B queued) is worth the warn colour up here.
|
|
204
|
+
const rearmsStarved = m.stats.rearmsStarved;
|
|
205
|
+
return html `
|
|
206
|
+
<div class="voice">
|
|
207
|
+
<${SessionStrip} m=${m} />
|
|
208
|
+
<div class="voice-card">
|
|
209
|
+
<div class="voice-hd">
|
|
210
|
+
<span>${zoomTitle}${rearms > 0 ? html ` · <span class=${"voice-hd-rearms" + (rearmsStarved > 0 ? " warn" : "")}>${rearms} ${rearms === 1 ? "re-arm" : "re-arms"}</span>` : null}</span>
|
|
211
|
+
<span class="voice-hd-tools">
|
|
212
|
+
<span class="voice-zoom" role="group" aria-label="tracks window">
|
|
213
|
+
${ZOOMS.map((o) => html `<button type="button" class=${"voice-zoombtn" + (o.key === zoom ? " on" : "")} aria-pressed=${o.key === zoom ? "true" : "false"} onClick=${() => setZoom(o.key)}>${o.label}</button>`)}
|
|
214
|
+
</span>
|
|
215
|
+
<button
|
|
216
|
+
type="button"
|
|
217
|
+
class="voice-exportbtn"
|
|
218
|
+
aria-disabled=${exporting ? "true" : "false"}
|
|
219
|
+
aria-busy=${exporting ? "true" : "false"}
|
|
220
|
+
title="download this session as a text report, with every record the device still holds"
|
|
221
|
+
onClick=${() => {
|
|
222
|
+
// aria-disabled, not disabled, so the button stays in the tab order mid-export.
|
|
223
|
+
if (exporting)
|
|
224
|
+
return;
|
|
225
|
+
setExporting(true);
|
|
226
|
+
void exportSwitchboardSession(m.sessionId).finally(() => setExporting(false));
|
|
227
|
+
}}
|
|
228
|
+
>${exporting ? "exporting…" : "export"}</button>
|
|
229
|
+
</span>
|
|
230
|
+
</div>
|
|
231
|
+
<${Tracks} m=${m} title=${zoomTitle} rearms=${rearms} onPick=${onInspect} />
|
|
232
|
+
</div>
|
|
233
|
+
<${StatCards} m=${m} />
|
|
234
|
+
</div>
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
|
+
function SessionStrip({ m }) {
|
|
238
|
+
const conn = m.connection;
|
|
239
|
+
// Null after the session ended is a real state (the connection record itself is gone or was
|
|
240
|
+
// never there to begin with), not the "nothing has happened yet" case a brand-new session reads
|
|
241
|
+
// as, so it gets its own wording rather than reusing "no session yet".
|
|
242
|
+
const connText = conn ? conn.to : m.ended ? "connection unknown" : "no session yet";
|
|
243
|
+
// A downlink pill reading 0/s while the model is speaking is not a problem in a session too
|
|
244
|
+
// young to have cleared the rate's own minimum divisor yet -- that is exactly what sessionAgeMs
|
|
245
|
+
// guards against. No begin record at all means the age itself is unknown, so it reads the same
|
|
246
|
+
// as "too young" rather than assuming the worst. Past that age, 0 audio frames arriving while
|
|
247
|
+
// 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;
|
|
249
|
+
return html `
|
|
250
|
+
<div class="voice-card">
|
|
251
|
+
<div class="voice-hd">Session</div>
|
|
252
|
+
<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>
|
|
254
|
+
${m.ended ? html `<span class="voice-note voice-ended">ended</span>` : null}
|
|
255
|
+
<span class="voice-kv">session <b>${String(m.sessionId)}</b></span>
|
|
256
|
+
<span class="voice-pill"><i class=${"voice-dot " + micClass(m.mic?.to)} aria-hidden="true"></i>mic ${m.mic ? m.mic.to : "unknown"}</span>
|
|
257
|
+
<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
|
+
${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>`
|
|
260
|
+
: m.serverSession.pending
|
|
261
|
+
? html `<span class="voice-pill voice-pill-server voice-note" title="waiting on the device's session.ready record">server id pending</span>`
|
|
262
|
+
: m.savedTurns?.some((c) => c.outcome === "other_session" && c.count > 0)
|
|
263
|
+
? m.serverSessionNone
|
|
264
|
+
? html `<span class="voice-pill voice-pill-server voice-note" title="the device's ready record named no server session id, which usually explains the turns dropped as other session">no server id</span>`
|
|
265
|
+
: html `<span class="voice-pill voice-pill-server voice-note" title="this tab knows no server session id for the session, and some turns dropped as other session; the device may never have had one, or its ready record aged out of this tab, so check get_switchboard_session before reading the drops as a missing id">server id unknown</span>`
|
|
266
|
+
: null}
|
|
267
|
+
${m.savedTurns
|
|
268
|
+
? 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
|
+
: 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>
|
|
271
|
+
<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
|
+
</div>
|
|
273
|
+
${m.phases.length
|
|
274
|
+
? html `
|
|
275
|
+
<div class="voice-phases" title="Start phases, left to right, width proportional to time">
|
|
276
|
+
${
|
|
277
|
+
// A neverReached entry (branch A's synthetic session_ready, when the handshake
|
|
278
|
+
// never even reached the socket phase) carries no elapsed time worth a bar; nor
|
|
279
|
+
// does the "+N more" overflow entry, which has no real duration of its own either.
|
|
280
|
+
// Both still show up in the inline text below, just not here.
|
|
281
|
+
m.phases
|
|
282
|
+
.filter((p) => !p.neverReached && !p.overflow)
|
|
283
|
+
.map((p) => html `<div class=${"voice-phase" + (p.slow ? " slow" : "")} style=${`flex:${Math.max(p.ms, 60)} 0 0`} title=${phaseBarTitle(p)}></div>`)}
|
|
284
|
+
</div>
|
|
285
|
+
<div class="voice-note voice-phasetext" title=${m.phaseWallIsSum
|
|
286
|
+
? "start to ready is the sum of the phase durations (no begin or ready record to measure the clock from)"
|
|
287
|
+
: `start to ready is the clock from session begin to the session.ready record; the phase durations sum to ${(m.phaseTotalMs / 1000).toFixed(2)} s and can overlap or leave gaps`}>
|
|
288
|
+
${m.phases.map((p, i) => html `${i ? " · " : ""}<span class=${p.slow ? "voice-slowtxt" : ""}>${phaseInlineText(p)}</span>`)}
|
|
289
|
+
${" · start to ready "}${m.phaseTimedOut
|
|
290
|
+
? m.phaseTimedOutFromBegin
|
|
291
|
+
? html `never (failed ${(m.phaseTimedOutMs / 1000).toFixed(2)} s after start)`
|
|
292
|
+
: html `never (failed after ${(m.phaseTimedOutMs / 1000).toFixed(2)} s of handshake)`
|
|
293
|
+
: html `<b>${(m.phaseWallMs / 1000).toFixed(2)} s</b>`}
|
|
294
|
+
</div>
|
|
295
|
+
`
|
|
296
|
+
: html `<div class="voice-note">no phase records yet</div>`}
|
|
297
|
+
</div>
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
300
|
+
// Markers whose kind reads as an ongoing risk worth a faint full-height guide, not just a tick on
|
|
301
|
+
// the markers row: a rearm/stall/error's exact moment matters against the whole plot, not just
|
|
302
|
+
// against the other markers next to it. Declared ahead of collapseMarkers, which reads it to
|
|
303
|
+
// decide a collapsed group's own `guide`.
|
|
304
|
+
const GUIDE_KINDS = ["rearm", "stall", "error"];
|
|
305
|
+
function collapseMarkers(markers, x) {
|
|
306
|
+
const byCol = new Map();
|
|
307
|
+
for (const k of markers) {
|
|
308
|
+
const col = Math.round(x(k.t) / COLLAPSE_COL);
|
|
309
|
+
const group = byCol.get(col);
|
|
310
|
+
if (group)
|
|
311
|
+
group.push(k);
|
|
312
|
+
else
|
|
313
|
+
byCol.set(col, [k]);
|
|
314
|
+
}
|
|
315
|
+
const out = [];
|
|
316
|
+
for (const group of byCol.values()) {
|
|
317
|
+
if (group.length === 1) {
|
|
318
|
+
const k = group[0];
|
|
319
|
+
out.push({ kind: k.kind, x: x(k.t), label: k.label, record: k.record, multi: false, guide: GUIDE_KINDS.includes(k.kind) });
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const kinds = [...new Set(group.map((k) => k.kind))];
|
|
323
|
+
// A collapsed group that landed the same because it is genuinely the same kind keeps that
|
|
324
|
+
// kind (and its colour), just with a `.voice-marker-multi` class added below to say "more than
|
|
325
|
+
// one lives here" -- only a group of actually different kinds becomes "mixed". Clicking a
|
|
326
|
+
// collapsed group always opens the first record; the title says so once there is more than
|
|
327
|
+
// one to miss.
|
|
328
|
+
const openHint = ", click opens the first, zoom in for the rest";
|
|
329
|
+
if (kinds.length === 1) {
|
|
330
|
+
out.push({ kind: kinds[0], x: x(group[0].t), label: `${group.length} × ${group[0].label}${openHint}`, record: group[0].record, multi: true, guide: GUIDE_KINDS.includes(kinds[0]) });
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
out.push({ kind: "mixed", x: x(group[0].t), label: `${group.length} markers (${kinds.join(", ")})${openHint}`, record: group[0].record, multi: true, guide: kinds.some((k) => GUIDE_KINDS.includes(k)) });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
// Adjacent segments whose end and next start land in the same viewBox column (same rule as
|
|
339
|
+
// collapseMarkers) merge into one rect: hundreds of a-few-ms-apart state flips squeezed into a
|
|
340
|
+
// single column would otherwise draw hundreds of overlapping slivers nobody can see apart anyway.
|
|
341
|
+
function mergeSegmentsByColumn(segs, x) {
|
|
342
|
+
const out = [];
|
|
343
|
+
for (const s of segs) {
|
|
344
|
+
const last = out[out.length - 1];
|
|
345
|
+
if (last && Math.round(x(s.from) / COLLAPSE_COL) <= Math.round(x(last.to) / COLLAPSE_COL)) {
|
|
346
|
+
last.to = Math.max(last.to, s.to);
|
|
347
|
+
last.open = last.open || s.open;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
out.push({ ...s });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return out;
|
|
354
|
+
}
|
|
355
|
+
// Keeps the loudest sample per column rather than averaging, so a brief spike survives a
|
|
356
|
+
// whole-session zoom.
|
|
357
|
+
function bucketLevelPoints(points, x) {
|
|
358
|
+
const byCol = new Map();
|
|
359
|
+
for (const p of points) {
|
|
360
|
+
const col = Math.round(x(p.t) / COLLAPSE_COL);
|
|
361
|
+
const cur = byCol.get(col);
|
|
362
|
+
if (!cur) {
|
|
363
|
+
byCol.set(col, p);
|
|
364
|
+
}
|
|
365
|
+
else if (p.rms > cur.rms || p.peak > cur.peak) {
|
|
366
|
+
byCol.set(col, { t: cur.t, rms: Math.max(p.rms, cur.rms), peak: Math.max(p.peak, cur.peak) });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return [...byCol.values()].sort((a, b) => a.t - b.t);
|
|
370
|
+
}
|
|
371
|
+
// Bars, not a connected line, so a gap between batches does not draw a misleading slope. The
|
|
372
|
+
// clip cap is full opacity because the .3-opacity peak bar alone is easy to miss.
|
|
373
|
+
const CLIP_CAP_H = 2.5;
|
|
374
|
+
function levelBars(points, y, h, x, colour, rowClass) {
|
|
375
|
+
const bucketed = bucketLevelPoints(points, x);
|
|
376
|
+
return bucketed.map((p) => {
|
|
377
|
+
const cx = x(p.t);
|
|
378
|
+
const peakH = Math.max(1, dbfsHeight(p.peak) * h);
|
|
379
|
+
const rmsH = Math.max(1, dbfsHeight(p.rms) * h);
|
|
380
|
+
const clipping = p.peak >= CLIP_PEAK;
|
|
381
|
+
return html `<g class=${rowClass}>
|
|
382
|
+
<rect class="voice-levelpeak" x=${cx - 1.5} y=${y + h - peakH} width="3" height=${peakH} fill=${clipping ? "var(--error)" : colour} opacity=".3" />
|
|
383
|
+
<rect class="voice-levelrms" x=${cx - 1} y=${y + h - rmsH} width="2" height=${rmsH} fill=${colour} opacity=".9" />
|
|
384
|
+
${clipping ? html `<rect class="voice-levelclip" x=${cx - 1.5} y=${y} width="3" height=${CLIP_CAP_H} fill="var(--error)" opacity="1" />` : null}
|
|
385
|
+
</g>`;
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function Tracks({ m, title, rearms, onPick }) {
|
|
389
|
+
const H = plotHeight(m.hasLevels);
|
|
390
|
+
const { from, to } = m.window;
|
|
391
|
+
const span = Math.max(1, to - from);
|
|
392
|
+
const x = (t) => Math.min(W, Math.max(0, ((t - from) / span) * W));
|
|
393
|
+
const step = tickStepMs(span);
|
|
394
|
+
// Ticks run -step, -2 step, ... back to the left edge; the right edge is now and needs no
|
|
395
|
+
// label. tickStepMs already keeps the count at eight or fewer for any span this panel ever
|
|
396
|
+
// draws (the whole-session zoom is itself clamped to the cache TTL), so there is no separate
|
|
397
|
+
// cap to apply here. One unit reads seconds throughout, or minutes throughout, never mixed on
|
|
398
|
+
// the same axis.
|
|
399
|
+
const unitMinutes = step >= 60_000;
|
|
400
|
+
const ticks = [];
|
|
401
|
+
// Starting the loop at i = 1 already keeps off === 0 (which would sit at `to` itself, the right
|
|
402
|
+
// edge, already read as "now"/"end" below) out of the list, so there is nothing left to skip.
|
|
403
|
+
for (let i = 1; i * step <= span; i++) {
|
|
404
|
+
const off = i * step;
|
|
405
|
+
const label = unitMinutes ? `-${Math.round(off / 60_000)}m` : `-${Math.round(off / 1000)}s`;
|
|
406
|
+
ticks.push({ x: x(to - off), label });
|
|
407
|
+
}
|
|
408
|
+
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
|
+
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" />`;
|
|
410
|
+
const model = mergeSegmentsByColumn(m.model, x);
|
|
411
|
+
const you = mergeSegmentsByColumn(m.you, x);
|
|
412
|
+
const youMuted = mergeSegmentsByColumn(m.youMuted, x);
|
|
413
|
+
const drawn = collapseMarkers(m.markers, x);
|
|
414
|
+
const hasMixed = drawn.some((k) => k.kind === "mixed");
|
|
415
|
+
// A burst reads differently from a plain mixed collapse: still one kind throughout, just more
|
|
416
|
+
// than one record of it landed in the same spot (see DrawMarker.multi).
|
|
417
|
+
const hasBurst = drawn.some((k) => k.multi && k.kind !== "mixed");
|
|
418
|
+
// A raw peak check matches what bucketing draws, since a bucket keeps its loudest sample.
|
|
419
|
+
const hasClipping = m.hasLevels && (m.micLevels.some((p) => p.peak >= CLIP_PEAK) || m.playbackLevels.some((p) => p.peak >= CLIP_PEAK));
|
|
420
|
+
const stalls = m.markers.filter((k) => k.kind === "stall").length;
|
|
421
|
+
const failures = m.markers.filter((k) => k.kind === "error").length;
|
|
422
|
+
const label = `voice tracks, ${title.toLowerCase()}, ${m.model.length} model ${m.model.length === 1 ? "turn" : "turns"}, ${rearms} ${rearms === 1 ? "re-arm" : "re-arms"}${stalls > 0 ? `, ${stalls} ${stalls === 1 ? "stall" : "stalls"}` : ""}${failures > 0 ? `, ${failures} ${failures === 1 ? "failure" : "failures"}` : ""}`;
|
|
423
|
+
// Hit-target rects clamp to the midpoint with each neighbour (sorted by x, not draw order) so
|
|
424
|
+
// two markers close enough for their own rects to overlap instead meet exactly in between --
|
|
425
|
+
// whichever one the click lands nearer to is the one that gets it. The tick and guide lines
|
|
426
|
+
// carry pointer-events:none (below), so the rect really is the only shape a click can land on.
|
|
427
|
+
const hitHalf = (k) => (k.multi ? 14 : 12);
|
|
428
|
+
const byX = [...drawn].sort((a, b) => a.x - b.x);
|
|
429
|
+
const hitRange = new Map();
|
|
430
|
+
byX.forEach((k, i) => {
|
|
431
|
+
const half = hitHalf(k);
|
|
432
|
+
const prev = byX[i - 1];
|
|
433
|
+
const next = byX[i + 1];
|
|
434
|
+
const x1 = Math.max(k.x - half, prev ? (prev.x + k.x) / 2 : -Infinity);
|
|
435
|
+
const x2 = Math.min(k.x + half, next ? (k.x + next.x) / 2 : Infinity);
|
|
436
|
+
hitRange.set(k, { x1, x2 });
|
|
437
|
+
});
|
|
438
|
+
return html `
|
|
439
|
+
<div class="voice-tracks">
|
|
440
|
+
<div class="voice-trackrow">
|
|
441
|
+
<div class="voice-rowlabels" aria-hidden="true">
|
|
442
|
+
<span style=${`top:${(ROW_Y.model / H) * 100}%`}>model</span>
|
|
443
|
+
<span style=${`top:${(ROW_Y.you / H) * 100}%`}>you</span>
|
|
444
|
+
<span style=${`top:${(ROW_Y.mark / H) * 100}%`}>markers</span>
|
|
445
|
+
${m.hasLevels ? html `<span style=${`top:${(ROW_Y.micLevel / H) * 100}%`} title="dBFS, -60 (bottom) to 0 (top); light is peak, solid is rms">mic level</span>` : null}
|
|
446
|
+
${m.hasLevels ? html `<span style=${`top:${(ROW_Y.playbackLevel / H) * 100}%`} title="dBFS, -60 (bottom) to 0 (top); light is peak, solid is rms">playback level</span>` : null}
|
|
447
|
+
</div>
|
|
448
|
+
<div class="voice-plot">
|
|
449
|
+
<svg viewBox=${`0 0 ${W} ${H}`} style=${`height:${H}px`} preserveAspectRatio="none" role="img" aria-label=${label}>
|
|
450
|
+
<defs>
|
|
451
|
+
<!-- Horizontal bands, not a rotated line: patternTransform skews under the SVG's
|
|
452
|
+
x-only stretch (preserveAspectRatio="none") the same way a plain shape would,
|
|
453
|
+
so the hatch is built from a rect that never needs a transform to begin with. -->
|
|
454
|
+
<pattern id="voice-hatch" patternUnits="userSpaceOnUse" width="4" height="4">
|
|
455
|
+
<rect width="4" height="1.5" fill="var(--purple)" />
|
|
456
|
+
</pattern>
|
|
457
|
+
</defs>
|
|
458
|
+
${ticks.map((t) => html `<line x1=${t.x} x2=${t.x} y1="0" y2=${H} stroke="var(--border-2)" stroke-width="1" vector-effect="non-scaling-stroke" />`)}
|
|
459
|
+
${model.map((s) => seg(s, "model", ROW_Y.model, "var(--blue)", ".45"))}
|
|
460
|
+
${you.map((s) => seg(s, "you", ROW_Y.you, "var(--accent)", ".4"))}
|
|
461
|
+
${youMuted.map(segMuted)}
|
|
462
|
+
${drawn.map((k) => {
|
|
463
|
+
const c = MARKER_COLOUR[k.kind];
|
|
464
|
+
// The stroke width is the burst cue: same-kind bursts read 8, wider than a plain
|
|
465
|
+
// single tick; a mixed group's own tick stays 3 either way, its square head line
|
|
466
|
+
// above carrying the multi cue instead; stop reads its own thinner 2 when it is
|
|
467
|
+
// neither of those.
|
|
468
|
+
const strokeWidth = k.kind === "mixed" ? "3" : k.multi ? "8" : k.kind === "stop" ? "2" : "4";
|
|
469
|
+
// An error's line runs a little taller than the row, and a focus (mic-paused) tick
|
|
470
|
+
// only runs the row's own bottom half, so it reads as a lighter-weight event than
|
|
471
|
+
// the ones that span the full row.
|
|
472
|
+
const topY = k.kind === "error" ? ROW_Y.mark - 6 : k.kind === "focus" ? ROW_Y.mark + ROW_H / 2 : ROW_Y.mark;
|
|
473
|
+
// A stall's square cap plus dash reads as "stopped", distinct from every other
|
|
474
|
+
// marker's round cap -- a re-arm and a stall must never look interchangeable at a
|
|
475
|
+
// glance, colour aside.
|
|
476
|
+
const cap = k.kind === "stall" ? "butt" : "round";
|
|
477
|
+
const dash = k.kind === "stall" ? "4 3" : undefined;
|
|
478
|
+
const multiClass = k.multi ? " voice-marker-multi" : "";
|
|
479
|
+
const range = hitRange.get(k);
|
|
480
|
+
return html `<g class=${"voice-marker voice-marker-" + k.kind + multiClass} style="cursor:pointer" onClick=${() => onPick(k.record)}>
|
|
481
|
+
<rect x=${range.x1} y=${ROW_Y.mark - 10} width=${Math.max(0, range.x2 - range.x1)} height=${ROW_H + 12} fill="transparent" />
|
|
482
|
+
<title>${k.label}</title>
|
|
483
|
+
${k.guide ? html `<line class="voice-guide" x1=${k.x} x2=${k.x} y1="0" y2=${ROW_Y.mark} stroke=${c} stroke-width="1" vector-effect="non-scaling-stroke" pointer-events="none" />` : null}
|
|
484
|
+
<line x1=${k.x} x2=${k.x} y1=${topY} y2=${ROW_Y.mark + ROW_H} stroke=${c} stroke-width=${strokeWidth} stroke-linecap=${cap} stroke-dasharray=${dash} vector-effect="non-scaling-stroke" pointer-events="none" />
|
|
485
|
+
${
|
|
486
|
+
// A zero-length, round-capped, thick stroke reads as a dot without ever
|
|
487
|
+
// stretching under the SVG's x-only scale (preserveAspectRatio="none"): a real
|
|
488
|
+
// <circle> or <rect> would squash, since only strokes with vector-effect are
|
|
489
|
+
// safe under that stretch.
|
|
490
|
+
k.kind === "error"
|
|
491
|
+
? html `<line x1=${k.x} x2=${k.x} y1=${topY} y2=${topY} stroke=${c} stroke-width="7" stroke-linecap="round" vector-effect="non-scaling-stroke" />`
|
|
492
|
+
: k.kind === "mixed"
|
|
493
|
+
? html `<line x1=${k.x} x2=${k.x} y1=${topY - 6} y2=${topY - 6} stroke="var(--text)" stroke-width="6" stroke-linecap="square" vector-effect="non-scaling-stroke" />`
|
|
494
|
+
: null}
|
|
495
|
+
</g>`;
|
|
496
|
+
})}
|
|
497
|
+
${m.hasLevels ? levelBars(m.micLevels, ROW_Y.micLevel, LEVEL_ROW_H, x, "var(--accent)", "voice-miclevel") : null}
|
|
498
|
+
${m.hasLevels ? levelBars(m.playbackLevels, ROW_Y.playbackLevel, LEVEL_ROW_H, x, "var(--blue)", "voice-playbacklevel") : null}
|
|
499
|
+
</svg>
|
|
500
|
+
<div class="voice-ticklabels" aria-hidden="true">
|
|
501
|
+
${ticks.map((t) =>
|
|
502
|
+
// The leftmost tick sits at the plot's own left edge: centring it (the default,
|
|
503
|
+
// set in CSS) would draw half the glyph outside the container, so it anchors at
|
|
504
|
+
// its own start instead. `< 1` viewBox unit, not `=== 0`, because a window edge
|
|
505
|
+
// that lands a hair off zero from float division still reads as the left edge.
|
|
506
|
+
html `<span style=${`left:${(t.x / W) * 100}%${t.x < 1 ? ";transform:none" : ""}`}>${t.label}</span>`)}
|
|
507
|
+
<span style="left:100%;transform:translateX(-100%)">${m.ended ? "end" : "now"}</span>
|
|
508
|
+
</div>
|
|
509
|
+
${drawn.length === 0
|
|
510
|
+
? html `<div class="voice-note voice-nomarkers" style=${`top:${(ROW_Y.mark / H) * 100}%`}>no markers in window</div>`
|
|
511
|
+
: null}
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
<div class="voice-legend">
|
|
515
|
+
<span class="m">model speaking</span>
|
|
516
|
+
<span class="y">you capturing</span>
|
|
517
|
+
<span class="mu">you (muted)</span>
|
|
518
|
+
<span class="r">playback re-arm</span>
|
|
519
|
+
<span class="s">tts.stop sent</span>
|
|
520
|
+
<span class="st">player stall</span>
|
|
521
|
+
<span class="e">connection failed</span>
|
|
522
|
+
<span class="f">mic paused</span>
|
|
523
|
+
${hasClipping ? html `<span class="clip">clipping</span>` : null}
|
|
524
|
+
${hasMixed ? html `<span class="mx">multiple markers</span>` : null}
|
|
525
|
+
${hasBurst ? html `<span class="mb">burst (several at one spot, hover for the count)</span>` : null}
|
|
526
|
+
${m.hasLevels ? html `<span class="lv">level rows in dBFS (-60 to 0), light = peak, solid = rms</span>` : null}
|
|
527
|
+
</div>
|
|
528
|
+
</div>
|
|
529
|
+
`;
|
|
530
|
+
}
|
|
531
|
+
function StatCards({ m }) {
|
|
532
|
+
const s = m.stats;
|
|
533
|
+
// gapSamples, not p50/p95 > 0: a re-arm with no usable gap_ms (see markers()'s own "unusable
|
|
534
|
+
// gap" case) still counts toward rearms but leaves no sample, which used to read the same as a
|
|
535
|
+
// real gap of exactly 0 ms -- both percentiles are 0 either way, so only the sample count tells
|
|
536
|
+
// them apart.
|
|
537
|
+
const hasGapData = s.gapSamples > 0;
|
|
538
|
+
const gapText = s.rearms === 0 ? "0 / 0 ms" : hasGapData ? `${s.gapP50}/${s.gapP95} ms` : "no gap data";
|
|
539
|
+
const gapClass = s.rearms > 0 && hasGapData ? (s.gapP95 > GAP_P95_BAD_MS ? " bad" : " warn") : "";
|
|
540
|
+
return html `
|
|
541
|
+
<div class="voice-cards">
|
|
542
|
+
<div class=${"voice-stat" + (s.rearmsStarved > 0 ? " warn" : "")} title="a re-arm with 0 B queued had nothing left to play; if the downlink pill also reads 0/s the audio stopped arriving">
|
|
543
|
+
<div class="v">${s.rearms}</div>
|
|
544
|
+
${s.rearms > 0 ? html `<div class="sub">${s.rearmsStarved} starved (0 B queued)</div>` : null}
|
|
545
|
+
<div class="l">playback re-arms</div>
|
|
546
|
+
</div>
|
|
547
|
+
<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>
|
|
549
|
+
<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
|
+
</div>
|
|
551
|
+
`;
|
|
552
|
+
}
|
package/dist/web/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import http from "http";
|
|
2
2
|
import type { StatusReason } from "../shared/wire.js";
|
|
3
|
+
import { SWITCHBOARD_KIND, SWITCHBOARD_BACKFILL_DEADLINE_MS, SWITCHBOARD_BACKFILL_SESSIONS, type SwitchboardExportGet } from "../shared/switchboard.js";
|
|
3
4
|
import { type DashboardScreenController } from "../shared/dashboard-screen.js";
|
|
4
5
|
import type { ProcessState } from "../shared/transport.js";
|
|
5
|
-
import { type LogFrame } from "./log-session.js";
|
|
6
6
|
declare const WEB_PORT: number;
|
|
7
7
|
/**
|
|
8
8
|
* Decide whether to drop a log frame under backpressure. LIVE frames are dropped
|
|
@@ -320,6 +320,14 @@ export declare const DEVICE_SOURCES: Record<string, {
|
|
|
320
320
|
segment: string;
|
|
321
321
|
arrayKey: string;
|
|
322
322
|
}>;
|
|
323
|
+
export { SWITCHBOARD_KIND, SWITCHBOARD_BACKFILL_SESSIONS, SWITCHBOARD_BACKFILL_DEADLINE_MS };
|
|
324
|
+
export declare const BACKFILL_ROUTE_HEADROOM_MS = 250;
|
|
325
|
+
export declare function fetchSwitchboardBackfill(limit: number, deadlineMs: number, forwarded: boolean, onUnauthorized?: () => void): Promise<{
|
|
326
|
+
type: string;
|
|
327
|
+
event: Record<string, unknown>;
|
|
328
|
+
}[]>;
|
|
329
|
+
export declare const _switchboardExportGetForTest: SwitchboardExportGet;
|
|
330
|
+
export declare function _setSwitchboardExportStaleMsForTest(ms: number): void;
|
|
323
331
|
/**
|
|
324
332
|
* Finish a /detail proxy response after an upstream error or timeout. The success
|
|
325
333
|
* callback streams the upstream response, so headers may already be sent when a later
|
|
@@ -329,17 +337,20 @@ export declare const DEVICE_SOURCES: Record<string, {
|
|
|
329
337
|
* have not gone out yet; otherwise just end the already-started response. Exported for tests.
|
|
330
338
|
*/
|
|
331
339
|
export declare function failDetailResponse(res: Pick<http.ServerResponse, "headersSent" | "writeHead" | "end">, status: number): void;
|
|
332
|
-
type ParsedLog = LogFrame;
|
|
333
|
-
/**
|
|
334
|
-
* Parse one `adb logcat -v threadtime` line into a structured event, or null if it does
|
|
335
|
-
* not match the format. `resolvePkg` maps a pid to its package name (defaults to the
|
|
336
|
-
* live adb-backed resolver); injectable so this stays a pure, unit-testable function.
|
|
337
|
-
* Exported for tests.
|
|
338
|
-
*/
|
|
339
|
-
export declare function parseLogcat(line: string, resolvePkg?: (pid: number) => string | undefined): ParsedLog | null;
|
|
340
340
|
export declare function _setStreamResponseTimeoutForTest(ms: number | null): void;
|
|
341
341
|
export declare function _setOutageDiagnosisTtlForTest(ms: number | null): void;
|
|
342
|
+
export declare function _resetRefusalWakeForTest(): void;
|
|
342
343
|
export declare function _setOutageProbeForTest(probe: (() => Promise<"present" | "absent" | "unknown">) | null): void;
|
|
343
344
|
export declare function _diagnoseOutageForTest(): Promise<StatusReason | null>;
|
|
344
345
|
export declare function _invalidateOutageDiagnosisForTest(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Headers that cross from the dashboard server to the device Radar listener.
|
|
348
|
+
*
|
|
349
|
+
* The dashboard terminates the browser-facing HTTP hop, so its Host/Origin,
|
|
350
|
+
* hop-by-hop connection and transfer framing, and X-Radar-Dashboard credentials
|
|
351
|
+
* describe that hop rather than the device request. Forwarding them is especially
|
|
352
|
+
* unsafe for a strict iOS listener reached through a different authority. Preserve
|
|
353
|
+
* only representation negotiation and the body metadata needed to replay writes.
|
|
354
|
+
*/
|
|
355
|
+
export declare function radarProxyHeaders(method: string | undefined, incoming: http.IncomingHttpHeaders, forwarded: boolean): http.OutgoingHttpHeaders;
|
|
345
356
|
export { WEB_PORT };
|