feat(calls): clearer Teams on the web report (1p)
- SDP per m-line: kind, mid, direction, codecs - Requests from fetch and XHR to Teams and Skype hosts, grouped by path - Media table skips streams without packets Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -52,6 +52,15 @@ struct ShadowReport<'a> {
52
52
events: &'a [ShadowEvent],
53
53
}
54
54
55
#[derive(Default)]
56
struct RequestGroup {
57
first_ms: i64,
58
count: usize,
59
failed: usize,
60
total_ms: i64,
61
statuses: BTreeSet<i64>,
62
}
63
55
64
#[derive(Default)]
56
65
struct PeerSummary {
57
66
connected_ms: Option<i64>,
@@ -166,7 +175,10 @@ impl WebShadow {
166
175
let _ = writeln!(markdown, "\n## Media, last sample\n");
167
176
let _ = writeln!(markdown, "| Peer | Direction | Kind | Codec | Packets | Lost | Jitter | Fps | Size | Limited by |\n|---|---|---|---|---|---|---|---|---|---|");
168
177
for (peer, summary) in &peers {
169
for row in summary.last_rows.iter().filter(|row| text(row, "type") != "pair") {
178
let active = |row: &&Value| {
179
text(row, "type") != "pair" && row.get("packets").and_then(Value::as_f64).unwrap_or(0.) > 0.
180
};
181
for row in summary.last_rows.iter().filter(active) {
170
182
let size = match (row.get("frameWidth").and_then(Value::as_i64), row.get("frameHeight").and_then(Value::as_i64)) {
171
183
(Some(width), Some(height)) => format!("{width}x{height}"),
172
184
_ => String::new(),
@@ -200,22 +212,33 @@ impl WebShadow {
200
212
}
201
213
202
214
fn write_requests(&self, markdown: &mut String) {
203
let requests: Vec<&ShadowEvent> = self.events.iter().filter(|event| event.event == REQUEST_EVENT).collect();
204
let failed = requests
205
.iter()
206
.filter(|event| !(200..400).contains(&event.data.get("status").and_then(Value::as_i64).unwrap_or(0)))
207
.count();
208
let _ = writeln!(markdown, "\n## Signaling\n\n{} requests, {failed} failed\n", requests.len());
209
let _ = writeln!(markdown, "| At | Method | Path | Status | Took |\n|---|---|---|---|---|");
210
for event in requests.iter().take(MAX_TIMELINE_ROWS) {
215
let mut groups: BTreeMap<(String, String), RequestGroup> = BTreeMap::new();
216
for event in self.events.iter().filter(|event| event.event == REQUEST_EVENT) {
217
let key = (text(&event.data, "method"), text(&event.data, "path"));
218
let group = groups.entry(key).or_insert_with(|| RequestGroup { first_ms: event.at_ms, ..RequestGroup::default() });
219
let status = event.data.get("status").and_then(Value::as_i64).unwrap_or(0);
220
group.count += 1;
221
group.total_ms += event.data.get("ms").and_then(Value::as_i64).unwrap_or(0);
222
group.statuses.insert(status);
223
if !(200..400).contains(&status) {
224
group.failed += 1;
225
}
226
}
227
let total: usize = groups.values().map(|group| group.count).sum();
228
let failed: usize = groups.values().map(|group| group.failed).sum();
229
let mut ordered: Vec<_> = groups.into_iter().collect();
230
ordered.sort_by_key(|(_, group)| group.first_ms);
231
let _ = writeln!(markdown, "\n## Requests\n\n{total} requests, {failed} failed\n");
232
let _ = writeln!(markdown, "| First at | Method | Path | Count | Failed | Status | Avg took |\n|---|---|---|---|---|---|---|");
233
for ((method, path), group) in ordered.iter().take(MAX_TIMELINE_ROWS) {
234
let statuses = group.statuses.iter().map(i64::to_string).collect::<Vec<_>>().join(", ");
211
235
let _ = writeln!(
212
236
markdown,
213
"| {} | {} | {} | {} | {} ms |",
214
seconds(event.at_ms),
215
text(&event.data, "method"),
216
text(&event.data, "path"),
217
text(&event.data, "status"),
218
text(&event.data, "ms"),
237
"| {} | {method} | {path} | {} | {} | {statuses} | {} ms |",
238
seconds(group.first_ms),
239
group.count,
240
group.failed,
241
group.total_ms / group.count as i64,
219
242
);
220
243
}
221
244
}
@@ -52,6 +52,15 @@ struct ShadowReport<'a> {52
events: &'a [ShadowEvent],52
events: &'a [ShadowEvent],53
}53
}54
54
55
#[derive(Default)]56
struct RequestGroup {57
first_ms: i64,58
count: usize,59
failed: usize,60
total_ms: i64,61
statuses: BTreeSet<i64>,62
}63
55
#[derive(Default)]64
#[derive(Default)]56
struct PeerSummary {65
struct PeerSummary {57
connected_ms: Option<i64>,66
connected_ms: Option<i64>,@@ -166,7 +175,10 @@ impl WebShadow {166
let _ = writeln!(markdown, "\n## Media, last sample\n");175
let _ = writeln!(markdown, "\n## Media, last sample\n");167
let _ = writeln!(markdown, "| Peer | Direction | Kind | Codec | Packets | Lost | Jitter | Fps | Size | Limited by |\n|---|---|---|---|---|---|---|---|---|---|");176
let _ = writeln!(markdown, "| Peer | Direction | Kind | Codec | Packets | Lost | Jitter | Fps | Size | Limited by |\n|---|---|---|---|---|---|---|---|---|---|");168
for (peer, summary) in &peers {177
for (peer, summary) in &peers {169
for row in summary.last_rows.iter().filter(|row| text(row, "type") != "pair") {178
let active = |row: &&Value| {179
text(row, "type") != "pair" && row.get("packets").and_then(Value::as_f64).unwrap_or(0.) > 0.180
};181
for row in summary.last_rows.iter().filter(active) {170
let size = match (row.get("frameWidth").and_then(Value::as_i64), row.get("frameHeight").and_then(Value::as_i64)) {182
let size = match (row.get("frameWidth").and_then(Value::as_i64), row.get("frameHeight").and_then(Value::as_i64)) {171
(Some(width), Some(height)) => format!("{width}x{height}"),183
(Some(width), Some(height)) => format!("{width}x{height}"),172
_ => String::new(),184
_ => String::new(),@@ -200,22 +212,33 @@ impl WebShadow {200
}212
}201
213
202
fn write_requests(&self, markdown: &mut String) {214
fn write_requests(&self, markdown: &mut String) {203
let requests: Vec<&ShadowEvent> = self.events.iter().filter(|event| event.event == REQUEST_EVENT).collect();215
let mut groups: BTreeMap<(String, String), RequestGroup> = BTreeMap::new();204
let failed = requests216
for event in self.events.iter().filter(|event| event.event == REQUEST_EVENT) {205
.iter()217
let key = (text(&event.data, "method"), text(&event.data, "path"));206
.filter(|event| !(200..400).contains(&event.data.get("status").and_then(Value::as_i64).unwrap_or(0)))218
let group = groups.entry(key).or_insert_with(|| RequestGroup { first_ms: event.at_ms, ..RequestGroup::default() });207
.count();219
let status = event.data.get("status").and_then(Value::as_i64).unwrap_or(0);208
let _ = writeln!(markdown, "\n## Signaling\n\n{} requests, {failed} failed\n", requests.len());220
group.count += 1;209
let _ = writeln!(markdown, "| At | Method | Path | Status | Took |\n|---|---|---|---|---|");221
group.total_ms += event.data.get("ms").and_then(Value::as_i64).unwrap_or(0);210
for event in requests.iter().take(MAX_TIMELINE_ROWS) {222
group.statuses.insert(status);223
if !(200..400).contains(&status) {224
group.failed += 1;225
}226
}227
let total: usize = groups.values().map(|group| group.count).sum();228
let failed: usize = groups.values().map(|group| group.failed).sum();229
let mut ordered: Vec<_> = groups.into_iter().collect();230
ordered.sort_by_key(|(_, group)| group.first_ms);231
let _ = writeln!(markdown, "\n## Requests\n\n{total} requests, {failed} failed\n");232
let _ = writeln!(markdown, "| First at | Method | Path | Count | Failed | Status | Avg took |\n|---|---|---|---|---|---|---|");233
for ((method, path), group) in ordered.iter().take(MAX_TIMELINE_ROWS) {234
let statuses = group.statuses.iter().map(i64::to_string).collect::<Vec<_>>().join(", ");211
let _ = writeln!(235
let _ = writeln!(212
markdown,236
markdown,213
"| {} | {} | {} | {} | {} ms |",237
"| {} | {method} | {path} | {} | {} | {statuses} | {} ms |",214
seconds(event.at_ms),238
seconds(group.first_ms),215
text(&event.data, "method"),239
group.count,216
text(&event.data, "path"),240
group.failed,217
text(&event.data, "status"),241
group.total_ms / group.count as i64,218
text(&event.data, "ms"),219
);242
);220
}243
}221
}244
}@@ -4,17 +4,35 @@
4
4
}
5
5
window.__rustyCallShadow = true;
6
6
const STATS_INTERVAL_MS = 2000;
7
const SIGNALING_HOST = /(^|\.)skype\.com$/;
7
const WATCHED_HOST = /(^|\.)(skype\.com|teams\.microsoft\.com|teams\.cloud\.microsoft|office\.net)$/;
8
const STATIC_PATH = /\.(js|css|png|svg|jpg|jpeg|gif|woff2?|json|ico|mp3|wav)$/i;
8
9
const post = (event, data) => {
9
10
try {
10
11
window.chrome.webview.postMessage(JSON.stringify({ kind: "callShadow", at: Date.now(), event, data }));
11
12
} catch (_) {}
12
13
};
13
const sdpSummary = (sdp) =>
14
(sdp || "")
15
.split(/\r?\n/)
16
.filter((line) => /^(m=|a=rtpmap:|a=mid:|a=(sendrecv|sendonly|recvonly|inactive)$)/.test(line))
17
.map((line) => line.replace(/^m=(\w+) \d+/, "m=$1"));
14
const sdpSummary = (sdp) => {
15
const sections = [];
16
let current = null;
17
for (const line of (sdp || "").split(/\r?\n/)) {
18
if (line.startsWith("m=")) {
19
current = { kind: line.slice(2).split(" ")[0], mid: "", direction: "", codecs: [] };
20
sections.push(current);
21
} else if (!current) {
22
continue;
23
} else if (line.startsWith("a=mid:")) {
24
current.mid = line.slice(6);
25
} else if (/^a=(sendrecv|sendonly|recvonly|inactive)$/.test(line)) {
26
current.direction = line.slice(2);
27
} else if (line.startsWith("a=rtpmap:")) {
28
const codec = (line.split(" ")[1] || "").split("/")[0];
29
if (codec && codec.toLowerCase() !== "rtx" && !current.codecs.includes(codec)) {
30
current.codecs.push(codec);
31
}
32
}
33
}
34
return sections.map((section) => `${section.kind} mid ${section.mid} ${section.direction} [${section.codecs.join(",")}]`);
35
};
18
36
const statsSummary = (report) => {
19
37
const rows = [];
20
38
const codecs = {};
@@ -105,23 +123,43 @@
105
123
}
106
124
}
107
125
window.RTCPeerConnection = ShadowPeer;
126
const watchedTarget = (url) => {
127
try {
128
const target = new URL(url, location.href);
129
if (!WATCHED_HOST.test(target.hostname) || STATIC_PATH.test(target.pathname)) {
130
return null;
131
}
132
return target.hostname + target.pathname.replace(/[0-9a-f-]{16,}|[A-Za-z0-9_%:@.-]{32,}/g, "{id}");
133
} catch (_) {
134
return null;
135
}
136
};
108
137
const nativeFetch = window.fetch;
109
138
window.fetch = function (input, init) {
110
139
const started = performance.now();
111
let target;
112
try {
113
target = new URL(input instanceof Request ? input.url : String(input), location.href);
114
} catch (_) {}
115
const watched = target && SIGNALING_HOST.test(target.hostname);
140
const path = watchedTarget(input instanceof Request ? input.url : String(input));
116
141
const promise = nativeFetch.apply(this, arguments);
117
if (watched) {
118
const method = (init?.method || input?.method || "GET").toUpperCase();
119
const path = target.hostname + target.pathname.replace(/[0-9a-f-]{16,}|[A-Za-z0-9_-]{32,}/g, "{id}");
120
promise.then(
121
(response) => post("request", { method, path, status: response.status, ms: Math.round(performance.now() - started) }),
122
() => post("request", { method, path, status: 0, ms: Math.round(performance.now() - started) })
123
);
142
if (path) {
143
const method = (init?.method || (input instanceof Request ? input.method : "GET")).toUpperCase();
144
const done = (status) => post("request", { method, path, status, ms: Math.round(performance.now() - started) });
145
promise.then((response) => done(response.status), () => done(0));
124
146
}
125
147
return promise;
126
148
};
149
const nativeOpen = XMLHttpRequest.prototype.open;
150
const nativeSend = XMLHttpRequest.prototype.send;
151
XMLHttpRequest.prototype.open = function (method, url) {
152
this.__shadowRequest = { method: String(method).toUpperCase(), path: watchedTarget(String(url)) };
153
return nativeOpen.apply(this, arguments);
154
};
155
XMLHttpRequest.prototype.send = function () {
156
const request = this.__shadowRequest;
157
if (request?.path) {
158
const started = performance.now();
159
this.addEventListener("loadend", () =>
160
post("request", { method: request.method, path: request.path, status: this.status, ms: Math.round(performance.now() - started) })
161
);
162
}
163
return nativeSend.apply(this, arguments);
164
};
127
165
})();
@@ -4,17 +4,35 @@4
}4
}5
window.__rustyCallShadow = true;5
window.__rustyCallShadow = true;6
const STATS_INTERVAL_MS = 2000;6
const STATS_INTERVAL_MS = 2000;7
const SIGNALING_HOST = /(^|\.)skype\.com$/;7
const WATCHED_HOST = /(^|\.)(skype\.com|teams\.microsoft\.com|teams\.cloud\.microsoft|office\.net)$/;8
const STATIC_PATH = /\.(js|css|png|svg|jpg|jpeg|gif|woff2?|json|ico|mp3|wav)$/i;8
const post = (event, data) => {9
const post = (event, data) => {9
try {10
try {10
window.chrome.webview.postMessage(JSON.stringify({ kind: "callShadow", at: Date.now(), event, data }));11
window.chrome.webview.postMessage(JSON.stringify({ kind: "callShadow", at: Date.now(), event, data }));11
} catch (_) {}12
} catch (_) {}12
};13
};13
const sdpSummary = (sdp) =>14
const sdpSummary = (sdp) => {14
(sdp || "")15
const sections = [];15
.split(/\r?\n/)16
let current = null;16
.filter((line) => /^(m=|a=rtpmap:|a=mid:|a=(sendrecv|sendonly|recvonly|inactive)$)/.test(line))17
for (const line of (sdp || "").split(/\r?\n/)) {17
.map((line) => line.replace(/^m=(\w+) \d+/, "m=$1"));18
if (line.startsWith("m=")) {19
current = { kind: line.slice(2).split(" ")[0], mid: "", direction: "", codecs: [] };20
sections.push(current);21
} else if (!current) {22
continue;23
} else if (line.startsWith("a=mid:")) {24
current.mid = line.slice(6);25
} else if (/^a=(sendrecv|sendonly|recvonly|inactive)$/.test(line)) {26
current.direction = line.slice(2);27
} else if (line.startsWith("a=rtpmap:")) {28
const codec = (line.split(" ")[1] || "").split("/")[0];29
if (codec && codec.toLowerCase() !== "rtx" && !current.codecs.includes(codec)) {30
current.codecs.push(codec);31
}32
}33
}34
return sections.map((section) => `${section.kind} mid ${section.mid} ${section.direction} [${section.codecs.join(",")}]`);35
};18
const statsSummary = (report) => {36
const statsSummary = (report) => {19
const rows = [];37
const rows = [];20
const codecs = {};38
const codecs = {};@@ -105,23 +123,43 @@105
}123
}106
}124
}107
window.RTCPeerConnection = ShadowPeer;125
window.RTCPeerConnection = ShadowPeer;126
const watchedTarget = (url) => {127
try {128
const target = new URL(url, location.href);129
if (!WATCHED_HOST.test(target.hostname) || STATIC_PATH.test(target.pathname)) {130
return null;131
}132
return target.hostname + target.pathname.replace(/[0-9a-f-]{16,}|[A-Za-z0-9_%:@.-]{32,}/g, "{id}");133
} catch (_) {134
return null;135
}136
};108
const nativeFetch = window.fetch;137
const nativeFetch = window.fetch;109
window.fetch = function (input, init) {138
window.fetch = function (input, init) {110
const started = performance.now();139
const started = performance.now();111
let target;140
const path = watchedTarget(input instanceof Request ? input.url : String(input));112
try {113
target = new URL(input instanceof Request ? input.url : String(input), location.href);114
} catch (_) {}115
const watched = target && SIGNALING_HOST.test(target.hostname);116
const promise = nativeFetch.apply(this, arguments);141
const promise = nativeFetch.apply(this, arguments);117
if (watched) {142
if (path) {118
const method = (init?.method || input?.method || "GET").toUpperCase();143
const method = (init?.method || (input instanceof Request ? input.method : "GET")).toUpperCase();119
const path = target.hostname + target.pathname.replace(/[0-9a-f-]{16,}|[A-Za-z0-9_-]{32,}/g, "{id}");144
const done = (status) => post("request", { method, path, status, ms: Math.round(performance.now() - started) });120
promise.then(145
promise.then((response) => done(response.status), () => done(0));121
(response) => post("request", { method, path, status: response.status, ms: Math.round(performance.now() - started) }),122
() => post("request", { method, path, status: 0, ms: Math.round(performance.now() - started) })123
);124
}146
}125
return promise;147
return promise;126
};148
};149
const nativeOpen = XMLHttpRequest.prototype.open;150
const nativeSend = XMLHttpRequest.prototype.send;151
XMLHttpRequest.prototype.open = function (method, url) {152
this.__shadowRequest = { method: String(method).toUpperCase(), path: watchedTarget(String(url)) };153
return nativeOpen.apply(this, arguments);154
};155
XMLHttpRequest.prototype.send = function () {156
const request = this.__shadowRequest;157
if (request?.path) {158
const started = performance.now();159
this.addEventListener("loadend", () =>160
post("request", { method: request.method, path: request.path, status: this.status, ms: Math.round(performance.now() - started) })161
);162
}163
return nativeSend.apply(this, arguments);164
};127
})();165
})();