Hide port names on aggregated topology links when hide-ports is on.

Bundle edges only keep a ×N count label; single-link ports stay fully hidden.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-04 14:11:46 +08:00
parent bee86eea0d
commit 1d742e58a1
2 changed files with 17 additions and 4 deletions

View file

@ -825,14 +825,20 @@ export function TopologyPage() {
return built.map((e) => { return built.map((e) => {
const d = (e.data || {}) as EdgeStyleData; const d = (e.data || {}) as EdgeStyleData;
const count = Number(d.member_count || 1); const count = Number(d.member_count || 1);
const keepCountLabel = !expandPhysicalLinks && count > 1;
const selected = const selected =
e.id === selectedEdgeId || e.id === selectedEdgeId ||
Boolean(d.members?.some((m: LinkMember) => m.id === selectedEdgeId)); Boolean(d.members?.some((m: LinkMember) => m.id === selectedEdgeId));
let label: string | undefined;
if (hidePorts) {
// Keep only the bundle count when ports are hidden — never leak port names.
label = !expandPhysicalLinks && count > 1 ? `×${count}` : undefined;
} else {
label = e.label ? String(e.label) : undefined;
}
return { return {
...e, ...e,
selected, selected,
label: hidePorts && !keepCountLabel ? undefined : e.label, label,
animated: edgeFlow, animated: edgeFlow,
}; };
}); });

View file

@ -43,8 +43,15 @@ export function formatPortPairLabel(aPort: string, bPort: string): string {
return a || b || ""; return a || b || "";
} }
export function formatBundleLabel(count: number, sample?: { a_port?: string; b_port?: string }): string { export function formatBundleLabel(
if (count <= 1) return formatPortPairLabel(sample?.a_port || "", sample?.b_port || ""); count: number,
sample?: { a_port?: string; b_port?: string },
opts?: { hidePorts?: boolean },
): string {
if (count <= 1) {
return opts?.hidePorts ? "" : formatPortPairLabel(sample?.a_port || "", sample?.b_port || "");
}
if (opts?.hidePorts) return `×${count}`;
const sampleLabel = formatPortPairLabel(sample?.a_port || "", sample?.b_port || ""); const sampleLabel = formatPortPairLabel(sample?.a_port || "", sample?.b_port || "");
return sampleLabel ? `×${count} · ${sampleLabel}` : `×${count}`; return sampleLabel ? `×${count} · ${sampleLabel}` : `×${count}`;
} }