From 617ab469aeffaba05696ad34933c9bbd8114cf9d Mon Sep 17 00:00:00 2001 From: oliver Date: Fri, 7 Aug 2026 17:40:39 +0800 Subject: [PATCH] Restore NE count badges as real subtree totals instead of map-count P labels. Co-authored-by: Cursor --- web/src/pages/TopologyPage.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/web/src/pages/TopologyPage.tsx b/web/src/pages/TopologyPage.tsx index f8c1a5e..9529266 100644 --- a/web/src/pages/TopologyPage.tsx +++ b/web/src/pages/TopologyPage.tsx @@ -297,6 +297,19 @@ function regionDisplayName( return raw; } +/** Real NE count under a folder (own views + nested children). Backend node_count already excludes region icons. */ +function folderNeCount(folder: TopologyTreeFolderItem | null | undefined): number { + if (!folder) return 0; + const own = (folder.views || []).reduce((sum, v) => sum + (Number(v.node_count) || 0), 0); + const nested = (folder.children || []).reduce((sum, c) => sum + folderNeCount(c), 0); + return own + nested; +} + +function formatNeCount(count: number): string { + const n = Math.max(0, Math.floor(Number(count) || 0)); + return `${n}N`; +} + function formatUpdatedAt(value?: string | null): string { if (!value) return ""; try { @@ -2368,6 +2381,7 @@ export function TopologyPage() { {displayViewName(v.name, t)} {viewActive && dirty ? " *" : ""} + {formatNeCount(v.node_count)} {!umeNav ? ( @@ -2452,6 +2466,7 @@ export function TopologyPage() { {regionDisplayName(folder, t)} + {formatNeCount(folderNeCount(folder))} {(() => { @@ -4751,6 +4766,7 @@ export function TopologyPage() { {regionDisplayName(region, t)} + {formatNeCount(folderNeCount(region))} ))} @@ -4795,6 +4811,9 @@ export function TopologyPage() { {regionDisplayName(umeWorldHexModules.drill, t)} + + {formatNeCount(folderNeCount(umeWorldHexModules.drill))} + ) : null} @@ -4825,6 +4844,9 @@ export function TopologyPage() { {umeWorldHexModules.flatView.name} + + {formatNeCount(umeWorldHexModules.flatView.node_count)} + ) : null} @@ -4850,6 +4872,7 @@ export function TopologyPage() { {regionDisplayName(region, t)} + {formatNeCount(folderNeCount(region))} ))} @@ -4875,6 +4898,7 @@ export function TopologyPage() { {displayViewName(v.name, t)} + {formatNeCount(v.node_count)} );