From ca9d51d56a80604dae4cbfcbf2e6f07c7771bdbf Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:48:55 -0500 Subject: [PATCH] fix(diagnostics): show a route label only when its topology is known --- src/client/channel/components/channel-connection-data.ts | 7 ++++--- tests/channel-connections.test.ts | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/channel/components/channel-connection-data.ts b/src/client/channel/components/channel-connection-data.ts index a2cadf3bc..8778a4612 100644 --- a/src/client/channel/components/channel-connection-data.ts +++ b/src/client/channel/components/channel-connection-data.ts @@ -7,8 +7,8 @@ import { EMPTY_METRICS } from "../../types"; type Translate = (key: CopyKey, vars?: Record) => string; -function hopRoute(topology: ChannelTopology | null, from: string, to: string, presentation = false): "p2p" | "sfu" { - return !presentation && [from, to].includes(topology?.transitSession ?? "") ? "sfu" : "p2p"; +function hopRoute(topology: ChannelTopology, from: string, to: string, presentation = false): "p2p" | "sfu" { + return !presentation && (from === topology.transitSession || to === topology.transitSession) ? "sfu" : "p2p"; } export function hasSelectedLocalDisplay(topology: ChannelTopology | null, sessionId: string): boolean { @@ -87,7 +87,8 @@ export function channelConnectionRows(state: ChannelSnapshot, sessionId: string, : t("voice.details.sendTo", { name: peer }); // Without picture topology, a sample may be the App's local display hop. return [{ key: `${sample.ownerSessionId}/${sample.flowId}/${sample.metrics.rtpStatsId}`, connectionId: sample.connectionId, - media: publication.kind === "voice" ? "audio" : "video", direction: sample.direction, route: hopRoute(topology, from, to, localDisplay), label, metrics, + media: publication.kind === "voice" ? "audio" : "video", direction: sample.direction, + route: topology ? hopRoute(topology, from, to, localDisplay) : undefined, label, metrics, detailOnly: publication.kind === "screen" && !topology?.screen || localDisplay || !sample.selected || undefined }]; }); } diff --git a/tests/channel-connections.test.ts b/tests/channel-connections.test.ts index f691a84ec..6f5c9b73f 100644 --- a/tests/channel-connections.test.ts +++ b/tests/channel-connections.test.ts @@ -93,6 +93,10 @@ describe("channel connection presentation", () => { const rows = channelConnectionRows(routed.state, routed.sessionId, routed.topology, [sample], t); expect(rows).toHaveLength(1); expect(rows[0].route).toBe("sfu"); + const withoutTopology = channelConnectionRows(routed.state, routed.sessionId, null, [sample], t); + expect(withoutTopology).toHaveLength(1); + expect(withoutTopology[0].metrics).toEqual(rows[0].metrics); + expect(withoutTopology[0].route).toBeUndefined(); expect(renderToStaticMarkup(createElement(ChannelConnectionReport, routed))).toContain("is-sfu"); }); it("merges room audience by user without counting publishers, retired identities or relay paths", () => {