@sleep2agi/agent-network-dashboard 0.4.6-preview.15 → 0.4.6-preview.151

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.
Files changed (355) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/diagnostics/route-bundle-stats.json +41 -41
  5. package/.next/fallback-build-manifest.json +3 -3
  6. package/.next/prerender-manifest.json +3 -3
  7. package/.next/routes-manifest.json +6 -0
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/server/app/_not-found.html +2 -2
  17. package/.next/server/app/_not-found.rsc +12 -12
  18. package/.next/server/app/_not-found.segments/_full.segment.rsc +12 -12
  19. package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  20. package/.next/server/app/_not-found.segments/_index.segment.rsc +7 -7
  21. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  22. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  23. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app/admin.html +2 -2
  26. package/.next/server/app/admin.rsc +14 -14
  27. package/.next/server/app/admin.segments/_full.segment.rsc +14 -14
  28. package/.next/server/app/admin.segments/_head.segment.rsc +4 -4
  29. package/.next/server/app/admin.segments/_index.segment.rsc +7 -7
  30. package/.next/server/app/admin.segments/_tree.segment.rsc +2 -2
  31. package/.next/server/app/admin.segments/admin/__PAGE__.segment.rsc +4 -4
  32. package/.next/server/app/admin.segments/admin.segment.rsc +3 -3
  33. package/.next/server/app/api/hub/servers/route/app-paths-manifest.json +3 -0
  34. package/.next/server/app/api/hub/servers/route/build-manifest.json +9 -0
  35. package/.next/server/app/api/hub/servers/route/server-reference-manifest.json +4 -0
  36. package/.next/server/app/api/hub/servers/route.js +7 -0
  37. package/.next/server/app/api/hub/servers/route.js.map +5 -0
  38. package/.next/server/app/api/hub/servers/route.js.nft.json +1 -0
  39. package/.next/server/app/api/hub/servers/route_client-reference-manifest.js +3 -0
  40. package/.next/server/app/index.html +2 -2
  41. package/.next/server/app/index.rsc +14 -14
  42. package/.next/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  43. package/.next/server/app/index.segments/_full.segment.rsc +14 -14
  44. package/.next/server/app/index.segments/_head.segment.rsc +4 -4
  45. package/.next/server/app/index.segments/_index.segment.rsc +7 -7
  46. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  47. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/login.html +2 -2
  49. package/.next/server/app/login.rsc +14 -14
  50. package/.next/server/app/login.segments/_full.segment.rsc +14 -14
  51. package/.next/server/app/login.segments/_head.segment.rsc +4 -4
  52. package/.next/server/app/login.segments/_index.segment.rsc +7 -7
  53. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  54. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  55. package/.next/server/app/login.segments/login.segment.rsc +3 -3
  56. package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/logs.html +2 -2
  58. package/.next/server/app/logs.rsc +14 -14
  59. package/.next/server/app/logs.segments/_full.segment.rsc +14 -14
  60. package/.next/server/app/logs.segments/_head.segment.rsc +4 -4
  61. package/.next/server/app/logs.segments/_index.segment.rsc +7 -7
  62. package/.next/server/app/logs.segments/_tree.segment.rsc +2 -2
  63. package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +4 -4
  64. package/.next/server/app/logs.segments/logs.segment.rsc +3 -3
  65. package/.next/server/app/messages/page_client-reference-manifest.js +1 -1
  66. package/.next/server/app/messages.html +2 -2
  67. package/.next/server/app/messages.rsc +14 -14
  68. package/.next/server/app/messages.segments/_full.segment.rsc +14 -14
  69. package/.next/server/app/messages.segments/_head.segment.rsc +4 -4
  70. package/.next/server/app/messages.segments/_index.segment.rsc +7 -7
  71. package/.next/server/app/messages.segments/_tree.segment.rsc +2 -2
  72. package/.next/server/app/messages.segments/messages/__PAGE__.segment.rsc +4 -4
  73. package/.next/server/app/messages.segments/messages.segment.rsc +3 -3
  74. package/.next/server/app/node/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/node.html +2 -2
  76. package/.next/server/app/node.rsc +14 -14
  77. package/.next/server/app/node.segments/_full.segment.rsc +14 -14
  78. package/.next/server/app/node.segments/_head.segment.rsc +4 -4
  79. package/.next/server/app/node.segments/_index.segment.rsc +7 -7
  80. package/.next/server/app/node.segments/_tree.segment.rsc +2 -2
  81. package/.next/server/app/node.segments/node/__PAGE__.segment.rsc +4 -4
  82. package/.next/server/app/node.segments/node.segment.rsc +3 -3
  83. package/.next/server/app/nodes/page_client-reference-manifest.js +1 -1
  84. package/.next/server/app/nodes.html +2 -2
  85. package/.next/server/app/nodes.rsc +14 -14
  86. package/.next/server/app/nodes.segments/_full.segment.rsc +14 -14
  87. package/.next/server/app/nodes.segments/_head.segment.rsc +4 -4
  88. package/.next/server/app/nodes.segments/_index.segment.rsc +7 -7
  89. package/.next/server/app/nodes.segments/_tree.segment.rsc +2 -2
  90. package/.next/server/app/nodes.segments/nodes/__PAGE__.segment.rsc +4 -4
  91. package/.next/server/app/nodes.segments/nodes.segment.rsc +3 -3
  92. package/.next/server/app/page_client-reference-manifest.js +1 -1
  93. package/.next/server/app/server-logs/page_client-reference-manifest.js +1 -1
  94. package/.next/server/app/server-logs.html +2 -2
  95. package/.next/server/app/server-logs.rsc +14 -14
  96. package/.next/server/app/server-logs.segments/_full.segment.rsc +14 -14
  97. package/.next/server/app/server-logs.segments/_head.segment.rsc +4 -4
  98. package/.next/server/app/server-logs.segments/_index.segment.rsc +7 -7
  99. package/.next/server/app/server-logs.segments/_tree.segment.rsc +2 -2
  100. package/.next/server/app/server-logs.segments/server-logs/__PAGE__.segment.rsc +4 -4
  101. package/.next/server/app/server-logs.segments/server-logs.segment.rsc +3 -3
  102. package/.next/server/app/settings/networks/page_client-reference-manifest.js +1 -1
  103. package/.next/server/app/settings/networks.html +2 -2
  104. package/.next/server/app/settings/networks.rsc +14 -14
  105. package/.next/server/app/settings/networks.segments/_full.segment.rsc +14 -14
  106. package/.next/server/app/settings/networks.segments/_head.segment.rsc +4 -4
  107. package/.next/server/app/settings/networks.segments/_index.segment.rsc +7 -7
  108. package/.next/server/app/settings/networks.segments/_tree.segment.rsc +2 -2
  109. package/.next/server/app/settings/networks.segments/settings/networks/__PAGE__.segment.rsc +4 -4
  110. package/.next/server/app/settings/networks.segments/settings/networks.segment.rsc +3 -3
  111. package/.next/server/app/settings/networks.segments/settings.segment.rsc +3 -3
  112. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  113. package/.next/server/app/settings/tokens/page_client-reference-manifest.js +1 -1
  114. package/.next/server/app/settings/tokens.html +2 -2
  115. package/.next/server/app/settings/tokens.rsc +14 -14
  116. package/.next/server/app/settings/tokens.segments/_full.segment.rsc +14 -14
  117. package/.next/server/app/settings/tokens.segments/_head.segment.rsc +4 -4
  118. package/.next/server/app/settings/tokens.segments/_index.segment.rsc +7 -7
  119. package/.next/server/app/settings/tokens.segments/_tree.segment.rsc +2 -2
  120. package/.next/server/app/settings/tokens.segments/settings/tokens/__PAGE__.segment.rsc +4 -4
  121. package/.next/server/app/settings/tokens.segments/settings/tokens.segment.rsc +3 -3
  122. package/.next/server/app/settings/tokens.segments/settings.segment.rsc +3 -3
  123. package/.next/server/app/settings.html +2 -2
  124. package/.next/server/app/settings.rsc +14 -14
  125. package/.next/server/app/settings.segments/_full.segment.rsc +14 -14
  126. package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
  127. package/.next/server/app/settings.segments/_index.segment.rsc +7 -7
  128. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  129. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
  130. package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
  131. package/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  132. package/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  133. package/.next/server/app/tasks.html +2 -2
  134. package/.next/server/app/tasks.rsc +14 -14
  135. package/.next/server/app/tasks.segments/_full.segment.rsc +14 -14
  136. package/.next/server/app/tasks.segments/_head.segment.rsc +4 -4
  137. package/.next/server/app/tasks.segments/_index.segment.rsc +7 -7
  138. package/.next/server/app/tasks.segments/_tree.segment.rsc +2 -2
  139. package/.next/server/app/tasks.segments/tasks/__PAGE__.segment.rsc +4 -4
  140. package/.next/server/app/tasks.segments/tasks.segment.rsc +3 -3
  141. package/.next/server/app-paths-manifest.json +1 -0
  142. package/.next/server/chunks/0ykm__next-internal_server_app_api_hub_servers_route_actions_08-m-cs.js +3 -0
  143. package/.next/server/chunks/0ykm__next-internal_server_app_api_hub_servers_route_actions_08-m-cs.js.map +1 -0
  144. package/.next/server/chunks/[root-of-the-server]__0tx8s8i._.js +3 -0
  145. package/.next/server/chunks/[root-of-the-server]__0tx8s8i._.js.map +1 -0
  146. package/.next/server/chunks/ssr/[root-of-the-server]__03b.f76._.js +1 -1
  147. package/.next/server/chunks/ssr/[root-of-the-server]__03b.f76._.js.map +1 -1
  148. package/.next/server/chunks/ssr/[root-of-the-server]__0fhoq8i._.js +1 -1
  149. package/.next/server/chunks/ssr/[root-of-the-server]__0fhoq8i._.js.map +1 -1
  150. package/.next/server/chunks/ssr/[root-of-the-server]__0nw~zhp._.js +1 -1
  151. package/.next/server/chunks/ssr/[root-of-the-server]__0nw~zhp._.js.map +1 -1
  152. package/.next/server/chunks/ssr/agent-network-dashboard_09kk21a._.js +4 -1
  153. package/.next/server/chunks/ssr/agent-network-dashboard_09kk21a._.js.map +1 -1
  154. package/.next/server/chunks/ssr/agent-network-dashboard_app_01jhlxz._.js +1 -1
  155. package/.next/server/chunks/ssr/agent-network-dashboard_app_01jhlxz._.js.map +1 -1
  156. package/.next/server/chunks/ssr/agent-network-dashboard_app_057q.ne._.js +1 -1
  157. package/.next/server/chunks/ssr/agent-network-dashboard_app_057q.ne._.js.map +1 -1
  158. package/.next/server/chunks/ssr/agent-network-dashboard_app_09d29my._.js +1 -1
  159. package/.next/server/chunks/ssr/agent-network-dashboard_app_09d29my._.js.map +1 -1
  160. package/.next/server/chunks/ssr/agent-network-dashboard_app_0_d45-d._.js +1 -1
  161. package/.next/server/chunks/ssr/agent-network-dashboard_app_0_d45-d._.js.map +1 -1
  162. package/.next/server/chunks/ssr/agent-network-dashboard_app_0i3759l._.js +1 -1
  163. package/.next/server/chunks/ssr/agent-network-dashboard_app_0i3759l._.js.map +1 -1
  164. package/.next/server/chunks/ssr/agent-network-dashboard_app_0xgney8._.js +1 -1
  165. package/.next/server/chunks/ssr/agent-network-dashboard_app_0xgney8._.js.map +1 -1
  166. package/.next/server/chunks/ssr/agent-network-dashboard_app_10hjgv4._.js +1 -1
  167. package/.next/server/chunks/ssr/agent-network-dashboard_app_10hjgv4._.js.map +1 -1
  168. package/.next/server/chunks/ssr/agent-network-dashboard_app_1153xeb._.js +1 -1
  169. package/.next/server/chunks/ssr/agent-network-dashboard_app_1153xeb._.js.map +1 -1
  170. package/.next/server/chunks/ssr/agent-network-dashboard_app_12l4oto._.js +1 -1
  171. package/.next/server/chunks/ssr/agent-network-dashboard_app_12l4oto._.js.map +1 -1
  172. package/.next/server/chunks/ssr/agent-network-dashboard_app_components_0mvyi-4._.js +1 -1
  173. package/.next/server/chunks/ssr/agent-network-dashboard_app_components_0mvyi-4._.js.map +1 -1
  174. package/.next/server/middleware-build-manifest.js +3 -3
  175. package/.next/server/pages/404.html +2 -2
  176. package/.next/server/pages/500.html +1 -1
  177. package/.next/server/server-reference-manifest.js +1 -1
  178. package/.next/server/server-reference-manifest.json +1 -1
  179. package/.next/static/chunks/0-mpa_947ipeq.js +1 -0
  180. package/.next/static/chunks/01lmbsd37fybu.js +1 -0
  181. package/.next/static/chunks/03o.h6kvmw4l_.js +1 -0
  182. package/.next/static/chunks/03~~oirxz7~vc.js +1 -0
  183. package/.next/static/chunks/05b69-7w4fvbn.css +2 -0
  184. package/.next/static/chunks/05uk96gc~9mni.js +1 -0
  185. package/.next/static/chunks/08kf-.bgs10ze.js +1 -0
  186. package/.next/static/chunks/0ax6wj36e_knr.js +7 -0
  187. package/.next/static/chunks/0d45f.svln5hm.js +1 -0
  188. package/.next/static/chunks/0f6m4wjhlakrw.js +1 -0
  189. package/.next/static/chunks/0g1ap~wkozy~6.js +4 -0
  190. package/.next/static/chunks/0glmrdj9112tc.js +7 -0
  191. package/.next/static/chunks/0rxrez_cjn.eh.js +1 -0
  192. package/.next/static/chunks/0x8x.29hkju5a.js +1 -0
  193. package/.next/static/chunks/174re5ar~kxne.js +1 -0
  194. package/.next/trace +2 -2
  195. package/.next/trace-build +1 -1
  196. package/.next/types/routes.d.ts +2 -1
  197. package/.next/types/validator.ts +9 -0
  198. package/app/api/hub/servers/route.ts +39 -0
  199. package/app/components/ChatPopover.tsx +38 -2
  200. package/app/components/CommandPalette.tsx +107 -0
  201. package/app/components/HelpOverlay.tsx +115 -0
  202. package/app/components/ServersDrawer.tsx +64 -27
  203. package/app/components/TopoGraph.tsx +2866 -190
  204. package/app/components/utils.ts +8 -7
  205. package/app/globals.css +27 -1
  206. package/app/lib/time.ts +36 -0
  207. package/package.json +1 -1
  208. package/scripts/help-overlay-topo-test.mjs +44 -0
  209. package/scripts/servers-drawer-live-test.mjs +96 -0
  210. package/scripts/topo-active-filter-pill-test.mjs +101 -0
  211. package/scripts/topo-active-links-chip-hover-test.mjs +103 -0
  212. package/scripts/topo-active-links-chip-nav-test.mjs +117 -0
  213. package/scripts/topo-active-links-chip-test.mjs +73 -0
  214. package/scripts/topo-active-links-tooltip-test.mjs +79 -0
  215. package/scripts/topo-arrival-ping-test.mjs +87 -0
  216. package/scripts/topo-arrow-tier-test.mjs +61 -0
  217. package/scripts/topo-auto-fit-test.mjs +73 -0
  218. package/scripts/topo-chat-focus-ring-test.mjs +77 -0
  219. package/scripts/topo-chat-target-breath-test.mjs +84 -0
  220. package/scripts/topo-chip-pin-mirror-test.mjs +113 -0
  221. package/scripts/topo-click-ripple-test.mjs +66 -0
  222. package/scripts/topo-cmdk-edge-clear-test.mjs +109 -0
  223. package/scripts/topo-cmdk-layout-view-test.mjs +108 -0
  224. package/scripts/topo-cmdk-pin-test.mjs +123 -0
  225. package/scripts/topo-cmdk-vendor-clear-test.mjs +133 -0
  226. package/scripts/topo-cmdk-vendor-pin-test.mjs +103 -0
  227. package/scripts/topo-cwd-tooltip-test.mjs +64 -0
  228. package/scripts/topo-dblclick-reset-test.mjs +74 -0
  229. package/scripts/topo-dispatch-pulse-test.mjs +83 -0
  230. package/scripts/topo-edge-badge-click-pin-test.mjs +94 -0
  231. package/scripts/topo-edge-badge-hot-test.mjs +115 -0
  232. package/scripts/topo-edge-badge-hover-test.mjs +85 -0
  233. package/scripts/topo-edge-count-badge-test.mjs +86 -0
  234. package/scripts/topo-edge-endpoint-highlight-test.mjs +111 -0
  235. package/scripts/topo-edge-focus-test.mjs +113 -0
  236. package/scripts/topo-edge-hover-test.mjs +93 -0
  237. package/scripts/topo-edge-pill-test.mjs +105 -0
  238. package/scripts/topo-edge-tooltip-test.mjs +70 -0
  239. package/scripts/topo-endpoint-ring-test.mjs +93 -0
  240. package/scripts/topo-esc-clears-pin-test.mjs +98 -0
  241. package/scripts/topo-filter-pill-aliases-test.mjs +121 -0
  242. package/scripts/topo-filter-pill-body-click-test.mjs +112 -0
  243. package/scripts/topo-filter-pill-count-test.mjs +110 -0
  244. package/scripts/topo-filter-pill-mobile-test.mjs +90 -0
  245. package/scripts/topo-fit-key-test.mjs +106 -0
  246. package/scripts/topo-freshness-chip-test.mjs +74 -0
  247. package/scripts/topo-group-box-pinned-state-test.mjs +95 -0
  248. package/scripts/topo-group-count-test.mjs +68 -0
  249. package/scripts/topo-group-hover-test.mjs +82 -0
  250. package/scripts/topo-group-label-hover-test.mjs +119 -0
  251. package/scripts/topo-group-label-tint-test.mjs +99 -0
  252. package/scripts/topo-group-label-title-test.mjs +83 -0
  253. package/scripts/topo-group-pin-test.mjs +119 -0
  254. package/scripts/topo-group-status-pips-test.mjs +103 -0
  255. package/scripts/topo-groupbox-hover-lift-test.mjs +127 -0
  256. package/scripts/topo-groupbox-live-test.mjs +100 -0
  257. package/scripts/topo-groupbox-march-busyness-test.mjs +155 -0
  258. package/scripts/topo-groupbox-test.mjs +4 -2
  259. package/scripts/topo-help-overlay-r109-test.mjs +67 -0
  260. package/scripts/topo-help-overlay-r118-test.mjs +69 -0
  261. package/scripts/topo-help-overlay-r123-test.mjs +69 -0
  262. package/scripts/topo-help-overlay-r134-test.mjs +74 -0
  263. package/scripts/topo-help-overlay-r137-test.mjs +81 -0
  264. package/scripts/topo-help-overlay-r141-test.mjs +86 -0
  265. package/scripts/topo-help-overlay-r59-test.mjs +67 -0
  266. package/scripts/topo-help-overlay-r65-test.mjs +64 -0
  267. package/scripts/topo-help-overlay-r70-test.mjs +63 -0
  268. package/scripts/topo-help-overlay-r78-test.mjs +59 -0
  269. package/scripts/topo-help-overlay-r81-test.mjs +58 -0
  270. package/scripts/topo-help-overlay-r87-test.mjs +64 -0
  271. package/scripts/topo-help-overlay-r91-test.mjs +65 -0
  272. package/scripts/topo-hub-busyness-test.mjs +100 -0
  273. package/scripts/topo-hub-click-fit-test.mjs +137 -0
  274. package/scripts/topo-hub-hover-ring-test.mjs +82 -0
  275. package/scripts/topo-hub-title-test.mjs +93 -0
  276. package/scripts/topo-hub-working-count-test.mjs +99 -0
  277. package/scripts/topo-ingroup-edge-test.mjs +103 -0
  278. package/scripts/topo-label-lift-test.mjs +119 -0
  279. package/scripts/topo-label-scale-test.mjs +78 -0
  280. package/scripts/topo-lastseen-tooltip-test.mjs +59 -0
  281. package/scripts/topo-layout-key-test.mjs +91 -0
  282. package/scripts/topo-legend-count-test.mjs +88 -0
  283. package/scripts/topo-legend-hover-test.mjs +113 -0
  284. package/scripts/topo-legend-panel-header-test.mjs +83 -0
  285. package/scripts/topo-legend-pin-test.mjs +128 -0
  286. package/scripts/topo-legend-row-hover-lift-test.mjs +109 -0
  287. package/scripts/topo-legend-row-tint-test.mjs +95 -0
  288. package/scripts/topo-minimap-test.mjs +68 -0
  289. package/scripts/topo-mobile-chips-test.mjs +103 -0
  290. package/scripts/topo-node-hover-lift-test.mjs +85 -0
  291. package/scripts/topo-node-title-test.mjs +101 -0
  292. package/scripts/topo-offline-dim-test.mjs +70 -0
  293. package/scripts/topo-online-chip-nav-test.mjs +143 -0
  294. package/scripts/topo-orbit-busyness-test.mjs +96 -0
  295. package/scripts/topo-overlap-test.mjs +32 -5
  296. package/scripts/topo-pan-cursor-test.mjs +62 -0
  297. package/scripts/topo-panel-elevation-test.mjs +76 -0
  298. package/scripts/topo-panel-hover-elevation-test.mjs +118 -0
  299. package/scripts/topo-particle-stagger-test.mjs +82 -0
  300. package/scripts/topo-pin-intersection-empty-test.mjs +129 -0
  301. package/scripts/topo-pin-intersection-test.mjs +121 -0
  302. package/scripts/topo-pin-persistence-test.mjs +105 -0
  303. package/scripts/topo-popover-meta-test.mjs +78 -0
  304. package/scripts/topo-pressure-bar-test.mjs +69 -0
  305. package/scripts/topo-pressure-hover-test.mjs +123 -0
  306. package/scripts/topo-pressure-pin-test.mjs +119 -0
  307. package/scripts/topo-pressure-seg-tooltip-test.mjs +98 -0
  308. package/scripts/topo-pulse-rate-test.mjs +71 -0
  309. package/scripts/topo-recent-panel-count-test.mjs +72 -0
  310. package/scripts/topo-recent-panel-hot-header-test.mjs +132 -0
  311. package/scripts/topo-recent-panel-more-nav-test.mjs +127 -0
  312. package/scripts/topo-recent-panel-more-test.mjs +106 -0
  313. package/scripts/topo-recent-row-hot-test.mjs +110 -0
  314. package/scripts/topo-recent-row-hover-lift-test.mjs +128 -0
  315. package/scripts/topo-recent-row-hover-test.mjs +122 -0
  316. package/scripts/topo-recent-row-pin-test.mjs +126 -0
  317. package/scripts/topo-recent-row-tint-test.mjs +91 -0
  318. package/scripts/topo-recent-row-ts-test.mjs +95 -0
  319. package/scripts/topo-recent-row-typography-test.mjs +119 -0
  320. package/scripts/topo-recent-signal-empty-hint-test.mjs +73 -0
  321. package/scripts/topo-recent-signal-empty-test.mjs +63 -0
  322. package/scripts/topo-reduced-motion-test.mjs +77 -0
  323. package/scripts/topo-status-chip-hover-test.mjs +101 -0
  324. package/scripts/topo-status-chip-tooltip-test.mjs +95 -0
  325. package/scripts/topo-tier-ring-occupancy-test.mjs +87 -0
  326. package/scripts/topo-tier-ring-test.mjs +69 -0
  327. package/scripts/topo-tier-ring-tint-test.mjs +110 -0
  328. package/scripts/topo-tier-stagger-test.mjs +89 -0
  329. package/scripts/topo-tz-ghost-test.mjs +69 -0
  330. package/scripts/topo-vendor-chip-hover-test.mjs +111 -0
  331. package/scripts/topo-vendor-letter-tooltip-test.mjs +92 -0
  332. package/scripts/topo-vendor-pill-test.mjs +125 -0
  333. package/scripts/topo-vendor-pin-test.mjs +125 -0
  334. package/scripts/topo-wheel-zoom-test.mjs +79 -0
  335. package/scripts/topo-working-chip-pin-test.mjs +148 -0
  336. package/scripts/topo-working-halo-breath-test.mjs +86 -0
  337. package/scripts/topo-zoom-keys-test.mjs +89 -0
  338. package/.next/static/chunks/0-7iowzu4.798.js +0 -1
  339. package/.next/static/chunks/02t5jr4shh.hy.js +0 -1
  340. package/.next/static/chunks/0_qfg5s5uzs7..js +0 -7
  341. package/.next/static/chunks/0e8tvxp4z.y4s.js +0 -1
  342. package/.next/static/chunks/0elalb9n_.~di.js +0 -1
  343. package/.next/static/chunks/0fqy_0wj_1xa7.js +0 -7
  344. package/.next/static/chunks/0j_q__o8p6g83.js +0 -1
  345. package/.next/static/chunks/0jl6_w50zh4l5.js +0 -1
  346. package/.next/static/chunks/0nia.a1mfg7q1.js +0 -1
  347. package/.next/static/chunks/0r4q73.-1bkyl.js +0 -1
  348. package/.next/static/chunks/0r_c8eccg3z2o.js +0 -1
  349. package/.next/static/chunks/10oi7l-tycgl9.js +0 -1
  350. package/.next/static/chunks/11uk1izuv3~0t.js +0 -1
  351. package/.next/static/chunks/13vw-ubg-9pjp.css +0 -2
  352. package/.next/static/chunks/14m.l5k.wx7cx.js +0 -1
  353. /package/.next/static/{-hO5QrBL0EPsoBbzcd662 → jNoJAOY9PpVhTslXxUvqQ}/_buildManifest.js +0 -0
  354. /package/.next/static/{-hO5QrBL0EPsoBbzcd662 → jNoJAOY9PpVhTslXxUvqQ}/_clientMiddlewareManifest.js +0 -0
  355. /package/.next/static/{-hO5QrBL0EPsoBbzcd662 → jNoJAOY9PpVhTslXxUvqQ}/_ssgManifest.js +0 -0
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
 
3
- import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
+ import { useRouter } from 'next/navigation';
4
5
  import { Session } from './types';
5
6
  import { aliasAvatarColors, aliasInitial } from './AliasAvatar';
6
7
  import { ChatPopover } from './ChatPopover';
7
8
  import { vendorForModel, runtimeIdentity, identityLine } from '../lib/vendorIdentity';
9
+ import { parseHubTime, relativeAgo } from '../lib/time';
8
10
 
9
11
  interface MessageFlow {
10
12
  from_alias: string;
@@ -32,6 +34,9 @@ interface FlowLink {
32
34
  to: string;
33
35
  count: number;
34
36
  content: string;
37
+ /** ISO timestamp of the most recent message on this edge — drives
38
+ * the Round 10 freshness fade so dormant links recede visually. */
39
+ last_at: string;
35
40
  }
36
41
 
37
42
  const cx = 500;
@@ -85,36 +90,118 @@ function truncate(value: string, max: number) {
85
90
  return value.length > max ? `${value.slice(0, max - 1)}...` : value;
86
91
  }
87
92
 
93
+ /** Round 46 / Loop: SWR-freshness chip.
94
+ *
95
+ * TopoGraph's data refreshes every 5 s via SWR but the user has no
96
+ * visible signal that the canvas they're looking at is current. The
97
+ * flow particles and chips (R42 active-links, R43 hub) tell you when
98
+ * the FLEET last did something, not when the DATA last syncing. This
99
+ * chip ticks `live · Ns` against a 1-second interval so the operator
100
+ * can trust freshness without doing internal math.
101
+ *
102
+ * Owns its own setInterval so the parent topology doesn't re-render
103
+ * every second (only this small chip does). lastSyncRef is updated
104
+ * whenever the `sessions` prop reference changes — that's the SWR
105
+ * refresh signal. */
106
+ function FreshnessChip({ sessions }: { sessions: unknown }) {
107
+ const lastSyncRef = useRef<number>(Date.now());
108
+ const [now, setNow] = useState(() => Date.now());
109
+ useEffect(() => {
110
+ // sessions reference changed → SWR just delivered a new payload.
111
+ lastSyncRef.current = Date.now();
112
+ }, [sessions]);
113
+ useEffect(() => {
114
+ const id = setInterval(() => setNow(Date.now()), 1000);
115
+ return () => clearInterval(id);
116
+ }, []);
117
+ const sec = Math.max(0, Math.floor((now - lastSyncRef.current) / 1000));
118
+ // Tint the chip warmer when the data goes stale (>10s since last sync).
119
+ // SWR's default refreshInterval here is 5s, so anything past ~10s is
120
+ // either a poll miss or a network hiccup.
121
+ const stale = sec > 10;
122
+ return (
123
+ <span
124
+ className={stale
125
+ ? "hidden sm:inline px-2.5 py-1 rounded-md bg-amber-500/10 text-amber-300 border border-amber-500/20 font-mono"
126
+ : "hidden sm:inline px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20 font-mono"}
127
+ title={stale ? `Last sync ${sec}s ago — SWR refresh may be lagging` : `Live data · refreshes every 5s · last sync ${sec}s ago`}
128
+ data-freshness-chip
129
+ >
130
+ live · {sec}s
131
+ </span>
132
+ );
133
+ }
134
+
135
+ /** Round 36 / Loop: prefers-reduced-motion hook.
136
+ *
137
+ * Round 29's a11y sweep zeroed CSS animations via media query, but SVG
138
+ * SMIL `<animate>` / `<animateMotion>` elements aren't reachable from CSS
139
+ * — they need JS to opt out. This hook reads the media query and listens
140
+ * for changes so the topology's flow particles, pulses, click ripple
141
+ * and hub breath honour the OS-level preference. */
142
+ function useReducedMotion(): boolean {
143
+ const [reduced, setReduced] = useState(false);
144
+ useEffect(() => {
145
+ if (typeof window === 'undefined' || !window.matchMedia) return;
146
+ const mq = window.matchMedia('(prefers-reduced-motion: reduce)');
147
+ setReduced(mq.matches);
148
+ const onChange = (e: MediaQueryListEvent) => setReduced(e.matches);
149
+ mq.addEventListener('change', onChange);
150
+ return () => mq.removeEventListener('change', onChange);
151
+ }, []);
152
+ return reduced;
153
+ }
154
+
155
+ // Round 38 / Loop: parseHubTime + relativeAgo factored to app/lib/time.ts
156
+ // — the Round 35 fix lives there now alongside the Round 37 mirror so
157
+ // any future TZ-safe parse update happens in one place.
158
+
159
+ /** Round 12 / Loop: status trio audit.
160
+ *
161
+ * Each (status × theme) cell returns a {primary, halo, text} trio. The trio
162
+ * invariant — keep it when adding states or tweaking shades:
163
+ *
164
+ * light: primary = <hue>-600 halo = <hue>-100 * text = <hue>-800/900
165
+ * dark: primary = <hue>-400/500 halo = <hue>-900 text = <hue>-100
166
+ *
167
+ * * offline.halo light deviates intentionally to slate-200 (#e2e8f0):
168
+ * slate-100 (#f1f5f9) is too close to the panel bg (#f8fafc) and the
169
+ * halo would vanish. The other three rows keep the 100-shade.
170
+ *
171
+ * Audit caught one cross-family drift before this round: online-other halo
172
+ * light was #dbeafe (blue-100) while its primary (#0284c7 sky-600) and text
173
+ * (#0c4a6e sky-900) were sky-family — now sky-100 (#e0f2fe). Tiny visual
174
+ * difference; large hygiene win — every trio is now mono-hue. */
88
175
  function nodeStatus(session: Session, isOnline: boolean, isLight: boolean) {
89
176
  if (!isOnline) {
90
177
  return {
91
178
  label: 'offline',
92
- primary: isLight ? '#94a3b8' : '#6b7280',
93
- halo: isLight ? '#e2e8f0' : '#111827',
94
- text: isLight ? '#475569' : '#9ca3af',
179
+ primary: isLight ? '#94a3b8' : '#6b7280', // slate-400 / gray-500
180
+ halo: isLight ? '#e2e8f0' : '#111827', // slate-200* / gray-900
181
+ text: isLight ? '#475569' : '#9ca3af', // slate-600 / gray-400
95
182
  };
96
183
  }
97
184
  if (session.status === 'working') {
98
185
  return {
99
186
  label: 'working',
100
- primary: isLight ? '#059669' : '#22c55e',
101
- halo: isLight ? '#d1fae5' : '#14532d',
102
- text: isLight ? '#065f46' : '#dcfce7',
187
+ primary: isLight ? '#059669' : '#22c55e', // emerald-600 / green-500
188
+ halo: isLight ? '#d1fae5' : '#14532d', // emerald-100 / green-900
189
+ text: isLight ? '#065f46' : '#dcfce7', // emerald-800 / green-100
103
190
  };
104
191
  }
105
192
  if (session.status === 'idle') {
106
193
  return {
107
194
  label: 'idle',
108
- primary: isLight ? '#0d9488' : '#2dd4bf',
109
- halo: isLight ? '#ccfbf1' : '#134e4a',
110
- text: isLight ? '#115e59' : '#ccfbf1',
195
+ primary: isLight ? '#0d9488' : '#2dd4bf', // teal-600 / teal-400
196
+ halo: isLight ? '#ccfbf1' : '#134e4a', // teal-100 / teal-900
197
+ text: isLight ? '#115e59' : '#ccfbf1', // teal-800 / teal-100
111
198
  };
112
199
  }
113
200
  return {
114
201
  label: session.status || 'online',
115
- primary: isLight ? '#0284c7' : '#38bdf8',
116
- halo: isLight ? '#dbeafe' : '#0c4a6e',
117
- text: isLight ? '#0c4a6e' : '#e0f2fe',
202
+ primary: isLight ? '#0284c7' : '#38bdf8', // sky-600 / sky-400
203
+ halo: isLight ? '#e0f2fe' : '#0c4a6e', // sky-100 / sky-900 (was blue-100 — drift fixed Round 12)
204
+ text: isLight ? '#0c4a6e' : '#e0f2fe', // sky-900 / sky-100
118
205
  };
119
206
  }
120
207
 
@@ -312,12 +399,20 @@ function buildFlowLinks(messages: MessageFlow[], positions: Record<string, Point
312
399
  const key = `${message.from_alias}->${message.to_alias}`;
313
400
  const current = links.get(key);
314
401
 
402
+ // Keep the most-recent timestamp per pair so the render can fade
403
+ // dormant edges (Round 10 freshness fade).
404
+ const incoming = message.created_at || '';
405
+ const last_at = !current
406
+ ? incoming
407
+ : (incoming > current.last_at ? incoming : current.last_at);
408
+
315
409
  links.set(key, {
316
410
  key,
317
411
  from: message.from_alias,
318
412
  to: message.to_alias,
319
413
  count: (current?.count || 0) + 1,
320
414
  content: current?.content || message.content,
415
+ last_at,
321
416
  });
322
417
  });
323
418
 
@@ -327,9 +422,16 @@ function buildFlowLinks(messages: MessageFlow[], positions: Record<string, Point
327
422
  export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProps) {
328
423
  const theme = useTheme();
329
424
  const isLight = theme === 'light';
425
+ const reducedMotion = useReducedMotion();
330
426
  const pal = isLight ? LIGHT_PALETTE : DARK_PALETTE;
331
427
  const brand = useBrand();
332
428
  const isIntern = brand === 'intern';
429
+ // R133: Next.js client-router for the recent-signal panel "+N more"
430
+ // navigation. TopoGraph hasn't needed routing before — every other
431
+ // affordance composes back into the canvas's own state — but the
432
+ // truncated-flow footer is the one place where the user logically
433
+ // wants to leave: "show me the rest of the flows" → /messages.
434
+ const router = useRouter();
333
435
  const [messages, setMessages] = useState<MessageFlow[]>([]);
334
436
  // Issue #87: ring | grid layout toggle. Ring is the tiered-radial default;
335
437
  // grid arranges nodes in an N×M grid (better for 30+ nodes). Persisted to
@@ -388,6 +490,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
388
490
  activeAliases,
389
491
  groupKeys,
390
492
  groupBoxes,
493
+ gridContentBottom,
391
494
  } = useMemo(() => {
392
495
  const sseCount = (s: { alias: string; network_id?: string }) =>
393
496
  (s.network_id ? sseSessions[`${s.network_id}:${s.alias}`] : undefined) ?? sseSessions[s.alias];
@@ -397,17 +500,25 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
397
500
  // index, so contiguous-in-array becomes contiguous-in-ring, i.e.
398
501
  // each team visually clusters. localeCompare keeps CJK ordering sane.
399
502
  const byAlias = (a: Session, b: Session) => a.alias.localeCompare(b.alias);
400
- // #112 umbrella: ghost age-out — an offline node not seen for over a day
401
- // is almost certainly a deleted node the server `/api/status` still
503
+ // #112 umbrella: ghost age-out — an offline node not seen recently is
504
+ // almost certainly a deleted node the server `/api/status` still
402
505
  // returns (#74 root cause is server-side; this is the dashboard-side
403
506
  // fallback so stale ghosts stop cluttering the topology). A missing
404
507
  // last_seen_at is kept (conservative — could be a legitimately new node).
405
- const GHOST_MS = 24 * 60 * 60 * 1000;
508
+ // Round 27 / P0: the 24h threshold was too lenient — Vincent's preview.29
509
+ // screenshot showed B站马 nodes deleted ~4 h earlier still visible. A
510
+ // healthy agent heartbeats every few seconds; if it's been silent for
511
+ // an hour it's effectively gone. 1 h gives a fresh disconnect time to
512
+ // come back while removing dead nodes well within an operator session.
513
+ const GHOST_MS = 60 * 60 * 1000;
406
514
  const now = Date.now();
407
515
  const isGhost = (s: Session) => {
408
516
  if (s.status !== 'offline' || sseCount(s) || !s.last_seen_at) return false;
409
- const t = Date.parse(s.last_seen_at);
410
- return !Number.isNaN(t) && now - t > GHOST_MS;
517
+ // Round 35 / Loop: parseHubTime normalises SQL-style timestamps to UTC
518
+ // before parsing so non-UTC browsers don't see a phantom 8-hour skew
519
+ // and ghost freshly-disconnected nodes.
520
+ const t = parseHubTime(s.last_seen_at);
521
+ return t !== null && now - t > GHOST_MS;
411
522
  };
412
523
  const online = sessions.filter(s => s.status !== 'offline' || sseCount(s)).sort(byAlias);
413
524
  const offline = sessions.filter(s => s.status === 'offline' && !sseCount(s) && !isGhost(s)).sort(byAlias);
@@ -470,11 +581,25 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
470
581
  // padding always fit and stacked group boxes never touch; past the
471
582
  // floor the grid overflows and zoom/pan handles it.
472
583
  const GROUP_TOP = nodeR + 20;
473
- // Row-height floor = the tightest of: a node + its label below it
474
- // (2·nodeR + ~22), and the label band + min box padding (GROUP_TOP + 12).
475
- // Below this, rows would overlap; past it the grid overflows and
476
- // zoom/pan covers the rest.
477
- const cellH = Math.max(2 * nodeR + 22, GROUP_TOP + 12, Math.min(100, (gy1 - gy0) / totalRows));
584
+ // Round 27 / P0 (Vincent screenshot preview.29): dense plain-text
585
+ // node labels (`pos.y + radius + denseDrop`, with a 3 px containerBg
586
+ // stroke halo for readability) at the BOTTOM row of band N would
587
+ // paint OVER the start of band N+1's group label, creating the
588
+ // "blueleap eleap", "agent-network-dashboard t-network / board"
589
+ // visual chopping. Geometry of the collision:
590
+ // dense label visual bottom = node_N.y + radius + denseDrop + halo
591
+ // group label glyph top = boxY + 4 (text y=boxY+14, ~10px ascent)
592
+ // = node_N+1.y - GROUP_TOP + 4
593
+ // node_N+1.y - node_N.y = cellH for consecutive rows, so no-collide:
594
+ // cellH ≥ radius + denseDrop + halo + GROUP_TOP - 4 + buffer
595
+ // With halo=3 buffer=4: cellH ≥ nodeR + denseDrop + GROUP_TOP + 3.
596
+ const denseDrop = nodeScale < 0.8 ? 12 : 14;
597
+ const cellH = Math.max(
598
+ 2 * nodeR + 22, // node + dense label within band
599
+ GROUP_TOP + 12, // group-label band + box padding
600
+ nodeR + denseDrop + GROUP_TOP + 3, // round-27 dense↔group label clearance
601
+ Math.min(100, (gy1 - gy0) / totalRows),
602
+ );
478
603
 
479
604
  // Pass 2 — place each band's members.
480
605
  for (const band of bands) {
@@ -505,14 +630,36 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
505
630
  const xs = pts.map(p => p.x);
506
631
  const ys = pts.map(p => p.y);
507
632
  const minX = Math.min(...xs), minY = Math.min(...ys);
633
+ // Round 58 / Loop: per-group status mix for the label pip strip.
634
+ // Working = status==='working'. Idle = online but not working.
635
+ // Offline = !isOnline (either status==='offline' AND no SSE, or
636
+ // ghost-purged elsewhere — but ghosts never reach groupBoxes
637
+ // since they're filtered out upstream). Counts feed the label
638
+ // tspans directly so the strip stays inside the label's bbox,
639
+ // preserving the node↔label overlap-test guarantee from R19.
640
+ let w = 0, i = 0, o = 0;
641
+ for (const s of band.members) {
642
+ const isOn = s.status !== 'offline' || !!sseCount(s);
643
+ if (s.status === 'working') w++;
644
+ else if (isOn) i++;
645
+ else o++;
646
+ }
508
647
  return {
509
648
  key: band.members.length ? groupKeys[band.members[0].alias] : '',
649
+ count: band.members.length,
650
+ statuses: { working: w, idle: i, offline: o },
510
651
  x: minX - GROUP_PAD,
511
652
  y: minY - GROUP_TOP,
512
653
  w: Math.max(...xs) - minX + GROUP_PAD * 2,
513
654
  h: Math.max(...ys) - minY + GROUP_TOP + GROUP_PAD,
514
655
  };
515
656
  });
657
+ // Round 28 / Loop: surface the grid's natural content bottom so the
658
+ // mount effect can auto-fit zoom when the layout would overflow the
659
+ // viewBox. = bottom of the last node row + its label drop + a small
660
+ // breathing buffer. Round 27's cellH bump makes this overflow more
661
+ // common (30-node fleets reach ~774 px, viewBox is 680).
662
+ const gridContentBottom = gy0 + totalRows * cellH + 8;
516
663
  return {
517
664
  onlineNodes: online,
518
665
  offlineNodes: offline,
@@ -521,6 +668,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
521
668
  activeAliases: active,
522
669
  groupKeys,
523
670
  groupBoxes,
671
+ gridContentBottom,
524
672
  };
525
673
  }
526
674
 
@@ -602,7 +750,9 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
602
750
  groupKeys,
603
751
  // #111: group boxes are a grid-layout feature only — radially scattered
604
752
  // ring nodes can't be cleanly boxed. Ring keeps the #83 prefix hue.
605
- groupBoxes: [] as { key: string; x: number; y: number; w: number; h: number }[],
753
+ groupBoxes: [] as { key: string; count: number; statuses: { working: number; idle: number; offline: number }; x: number; y: number; w: number; h: number }[],
754
+ // ring fits within VIEWBOX_H by construction (offlineRadius=325 + centre at y=330)
755
+ gridContentBottom: 0,
606
756
  };
607
757
  }, [messages, sessions, sseSessions, layout, nodeScale]);
608
758
 
@@ -626,6 +776,217 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
626
776
  // label cards. 16 ≈ where the triple-tier rings start to crowd.
627
777
  const denseLayout = onlineNodes.length + offlineNodes.length > 16;
628
778
  const [hoveredAlias, setHoveredAlias] = useState<string | null>(null);
779
+ // Round 86 / Loop: pointer-over-label preview. R63 wired the group
780
+ // label to click-pin but hover gave no preview — the same hover/click
781
+ // gap R83 closed for pressure-bar segments. This state lets the
782
+ // label trigger the same dim mechanism a node hover already drives,
783
+ // independently of whether the cursor happens to be over a member
784
+ // node. ORs into hoveredGroup below so the existing derivation logic
785
+ // (which composes with hoveredAlias, activeGroup, R85 marching ants)
786
+ // keeps working unchanged.
787
+ const [hoveredGroupLabel, setHoveredGroupLabel] = useState<string | null>(null);
788
+ // Round 8 / Loop: which group is currently focused. Nodes outside this
789
+ // group + other group boxes fade so the eye locks onto the team you're
790
+ // pointing at. Singletons use their own alias as the group key.
791
+ const hoveredGroup = hoveredGroupLabel
792
+ ?? (hoveredAlias ? (groupKeys[hoveredAlias] ?? hoveredAlias) : null);
793
+ // Round 63 / Loop: sticky group focus. R8 dims non-group nodes while
794
+ // a member is hovered, but releasing the hover lets the focus fade.
795
+ // Clicking the group label pins the group key here; activeGroup =
796
+ // hoveredGroup ?? pinnedGroup so hover transiently overrides the
797
+ // pin (handy for spot-comparing teams). Same compose pattern as
798
+ // R60/R61 pinnedStatus.
799
+ const [pinnedGroup, setPinnedGroup] = useState<string | null>(() => {
800
+ // R66: same per-tab persistence treatment as pinnedStatus above.
801
+ // The group key is opaque text (could be any prefix), so the init
802
+ // reader can't validate it against a known enum — it just reads
803
+ // whatever's stored. A useEffect below clears it if the value no
804
+ // longer matches any current group (sessions changed since save).
805
+ if (typeof window === 'undefined') return null;
806
+ try { return sessionStorage.getItem('anet-topo-pinned-group'); } catch { return null; }
807
+ });
808
+ const activeGroup = hoveredGroup ?? pinnedGroup;
809
+ // R66: sync pinnedGroup into sessionStorage when it changes; clear
810
+ // it if it no longer matches any current group (the session set
811
+ // can change between loads). The pinnedStatus sync sits next to
812
+ // its declaration further down.
813
+ useEffect(() => {
814
+ try {
815
+ if (pinnedGroup) sessionStorage.setItem('anet-topo-pinned-group', pinnedGroup);
816
+ else sessionStorage.removeItem('anet-topo-pinned-group');
817
+ } catch {}
818
+ }, [pinnedGroup]);
819
+ useEffect(() => {
820
+ if (!pinnedGroup) return;
821
+ const known = new Set(Object.values(groupKeys));
822
+ if (!known.has(pinnedGroup)) setPinnedGroup(null);
823
+ }, [pinnedGroup, groupKeys]);
824
+ // Round 49 / Loop: reverse-direction of R40's edge-on-node-hover linkage.
825
+ // R48 widened the flow hitbox to 16 px, so edges are precise enough to
826
+ // serve as a state trigger. When the user hovers a flow edge, light up its
827
+ // two endpoint nodes and dim the rest — "who is this edge between" becomes
828
+ // visible without reading the tooltip. The set is the link's two aliases
829
+ // (null when no edge hovered); node opacity composes this after inFocus.
830
+ const [hoveredEdgeKey, setHoveredEdgeKey] = useState<string | null>(null);
831
+ // Round 116 / Loop: sticky variant of hoveredEdgeKey. R56 made the
832
+ // recent-signal rows brighten the matching edge on hover, but the
833
+ // filter released on mouseleave — no way to lock a flow for a
834
+ // closer look. Click-to-pin closes that gap, matching the
835
+ // established hover→pin idiom (R60 status, R61 legend, R63 group,
836
+ // R88 vendor). activeEdgeKey = hoveredEdgeKey ?? pinnedEdgeKey
837
+ // below so hover still wins for spot-comparison while a pin is set.
838
+ const [pinnedEdgeKey, setPinnedEdgeKey] = useState<string | null>(null);
839
+ const activeEdgeKey = hoveredEdgeKey ?? pinnedEdgeKey;
840
+ // Round 77 / Loop: hovering the "N active links" header chip globally
841
+ // brightens every flow edge (1.5× opacity). Transient affordance — the
842
+ // chip already says HOW MANY active flows exist; this answers WHERE
843
+ // they are in one glance, without the user scanning the canvas for
844
+ // moving particles. Reset on mouse leave.
845
+ const [hoveredActiveLinks, setHoveredActiveLinks] = useState(false);
846
+ // Round 115 / Loop: hub-center hover state. R52 made the hub
847
+ // clickable (fit view) + cursor:pointer, but there was no
848
+ // hover-time visual feedback — the click target felt guessed at
849
+ // rather than confirmed. This state drives a subtle hint ring on
850
+ // hover so users see the affordance before committing the click.
851
+ const [hoveredHub, setHoveredHub] = useState(false);
852
+ // R133: hover state for the recent-signal panel's "+N more flows"
853
+ // navigation footer. Drives the on-hover opacity boost + underline
854
+ // that signals interactivity, mirroring the hoveredHub idiom above.
855
+ const [hoveredRecentMore, setHoveredRecentMore] = useState(false);
856
+ // R135: panel-wide hover-elevation. The recent-signal + legend
857
+ // panels both already host clickable rows (R56/R116 recent rows,
858
+ // R55/R61 legend rows) and a clickable footer (R133), so the
859
+ // chrome itself is interactive territory. Drop-shadow boost on
860
+ // mouseenter says "this whole panel is alive" — matches the R18
861
+ // KPI-card-hover idiom from the Overview page. Single state for
862
+ // both panels since they don't overlap; null when neither hovered.
863
+ const [hoveredPanel, setHoveredPanel] = useState<'recent' | 'legend' | null>(null);
864
+ // Round 80 / Loop: vendor-letter hover in the distribution chip. The
865
+ // chip already names vendor mix (`C:5 G:3 ?:1`); hover a letter and
866
+ // every node from OTHER vendors dims. Surfaces the breakdown spatially
867
+ // without inventing a new pin slot. Stores the vendor `initial`
868
+ // (single char or "?") that matches the tally key.
869
+ const [hoveredVendor, setHoveredVendor] = useState<string | null>(null);
870
+ // Round 88 / Loop: vendor filter pin. R80 added hover-to-dim on the
871
+ // vendor letters but the filter released as soon as the cursor left
872
+ // — vendor was the only filter dimension without a sticky variant
873
+ // (R60 status, R63 group, R69 Cmd+K all support pin). This state
874
+ // closes the gap. Same pattern as pinnedStatus / pinnedGroup:
875
+ // per-tab sessionStorage persistence, Esc clears, activeVendor =
876
+ // hoveredVendor ?? pinnedVendor so hover still wins for spot-
877
+ // comparison while a pin is active.
878
+ const [pinnedVendor, setPinnedVendor] = useState<string | null>(() => {
879
+ if (typeof window === 'undefined') return null;
880
+ try { return sessionStorage.getItem('anet-topo-pinned-vendor'); } catch { return null; }
881
+ });
882
+ const activeVendor = hoveredVendor ?? pinnedVendor;
883
+ useEffect(() => {
884
+ try {
885
+ if (pinnedVendor) sessionStorage.setItem('anet-topo-pinned-vendor', pinnedVendor);
886
+ else sessionStorage.removeItem('anet-topo-pinned-vendor');
887
+ } catch {}
888
+ }, [pinnedVendor]);
889
+ // R89: stale-purge. If the fleet's vendor distribution changes such
890
+ // that a previously-pinned vendor is gone (last node of that
891
+ // vendor disconnected), clear the pin so the chip row doesn't
892
+ // show "filter: A · 0" forever. Matches the same defensive purge
893
+ // pattern pinnedGroup uses higher up — sessionStorage survives
894
+ // reloads, but a stored value that no longer matches reality
895
+ // would paint with an impossible filter.
896
+ useEffect(() => {
897
+ if (pinnedVendor && !vendorDist.some(v => v.initial === pinnedVendor)) {
898
+ setPinnedVendor(null);
899
+ }
900
+ }, [pinnedVendor, vendorDist]);
901
+ // Round 55 / Loop: hovering a legend status row dims nodes whose status
902
+ // doesn't match. The legend was passive — "what does this colour mean".
903
+ // Now it answers "show me all of these" the same way R8 group-focus
904
+ // answers "show me this team". Three values match the legend rows.
905
+ const [hoveredStatus, setHoveredStatus] = useState<'working' | 'idle' | 'offline' | null>(null);
906
+ // Round 60 / Loop: sticky variant of `hoveredStatus`. R55 only filters
907
+ // while the user is actively hovering the legend; for sweeping a fleet
908
+ // you want to LOCK the filter. Each segment of the R31 pressure bar
909
+ // toggles a pin — click again on the same segment to release. The node
910
+ // opacity formula reads `activeStatus = hoveredStatus ?? pinnedStatus`
911
+ // so hover transiently overrides a pin (handy for spot-comparison)
912
+ // without nuking it.
913
+ // Round 66 / Loop: pin survives a page reload via sessionStorage —
914
+ // per-tab not per-browser (a new tab starts clean, intentionally).
915
+ // The init reader validates against the known status set so a stale
916
+ // / corrupt value can't paint the canvas with an impossible filter.
917
+ const [pinnedStatus, setPinnedStatus] = useState<'working' | 'idle' | 'offline' | null>(() => {
918
+ if (typeof window === 'undefined') return null;
919
+ try {
920
+ const v = sessionStorage.getItem('anet-topo-pinned-status');
921
+ return (v === 'working' || v === 'idle' || v === 'offline') ? v : null;
922
+ } catch { return null; }
923
+ });
924
+ const activeStatus = hoveredStatus ?? pinnedStatus;
925
+ // R66: sync pinnedStatus into sessionStorage when it changes. Paired
926
+ // with the matching effect for pinnedGroup higher up.
927
+ useEffect(() => {
928
+ try {
929
+ if (pinnedStatus) sessionStorage.setItem('anet-topo-pinned-status', pinnedStatus);
930
+ else sessionStorage.removeItem('anet-topo-pinned-status');
931
+ } catch {}
932
+ }, [pinnedStatus]);
933
+ // R69: listen for Cmd+K palette pin actions. The palette can't reach
934
+ // this component's state directly so it dispatches a CustomEvent;
935
+ // we react by setting pinnedStatus / pinnedGroup. The palette also
936
+ // writes to sessionStorage in lockstep, so the R66 init readers
937
+ // would pick it up on reload — the event handler is what keeps the
938
+ // currently-mounted canvas in sync without one.
939
+ useEffect(() => {
940
+ const onPin = (e: Event) => {
941
+ const detail = (e as CustomEvent).detail || {};
942
+ if (detail.kind === 'clear') {
943
+ // R90: extend the universal clear to vendor. R69 only cleared
944
+ // status + group because pinnedVendor didn't exist yet; R88
945
+ // shipped the third pin and R90 closes the palette gap so
946
+ // "Clear topology filters" really means all of them.
947
+ // R117: extend again to pinnedEdgeKey — R116 added the 4th
948
+ // pin dim and this command must clear it too or the edge stays
949
+ // bright in the canvas while every other pill clears.
950
+ setPinnedStatus(null);
951
+ setPinnedGroup(null);
952
+ setPinnedVendor(null);
953
+ setPinnedEdgeKey(null);
954
+ } else if (detail.kind === 'clear-vendor') {
955
+ // R90: granular vendor-only clear so power users can release
956
+ // just the vendor without disturbing status/group pins.
957
+ setPinnedVendor(null);
958
+ } else if (detail.kind === 'clear-edge') {
959
+ // R117: granular edge-only clear, mirror of R90 clear-vendor.
960
+ setPinnedEdgeKey(null);
961
+ } else if (detail.kind === 'status') {
962
+ const v = detail.value;
963
+ if (v === 'working' || v === 'idle' || v === 'offline') setPinnedStatus(v);
964
+ } else if (detail.kind === 'group' && typeof detail.value === 'string') {
965
+ setPinnedGroup(detail.value);
966
+ } else if (detail.kind === 'vendor' && typeof detail.value === 'string') {
967
+ // R108: palette pin-vendor support. R69 added pin-status, R88
968
+ // added clickable vendor letters in the chip row, R90 added
969
+ // granular clear-vendor — but the palette never gained a
970
+ // PIN-vendor command. This branch listens for it; the matching
971
+ // commands live in CommandPalette R108. The stale-purge
972
+ // useEffect higher up already drops a pin whose vendor isn't
973
+ // in the current distribution, so commands for an absent
974
+ // vendor are harmless.
975
+ setPinnedVendor(detail.value);
976
+ }
977
+ };
978
+ window.addEventListener('anet:topo-pin', onPin);
979
+ return () => window.removeEventListener('anet:topo-pin', onPin);
980
+ }, []);
981
+ // R74 listener for layout + view palette commands lives below
982
+ // fitView's declaration — see further down in the file.
983
+ const hoveredEdgeEndpoints = useMemo<Set<string> | null>(() => {
984
+ // R116: compose hover ?? pin so pinning a row via click keeps the
985
+ // endpoint ring + edge ladder lit after mouseleave.
986
+ if (!activeEdgeKey) return null;
987
+ const link = flowLinks.find(l => l.key === activeEdgeKey);
988
+ return link ? new Set([link.from, link.to]) : null;
989
+ }, [activeEdgeKey, flowLinks]);
629
990
 
630
991
  // --- Round 103 (issue #81): fullscreen + zoom + pan interaction layer ---
631
992
  // DIY native (no d3 / svg-pan-zoom): wrap the topology content in a single
@@ -645,6 +1006,15 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
645
1006
  // Issue #100: singleton chat popover. One alias at a time — clicking
646
1007
  // another node swaps the target and the conversation switches in place.
647
1008
  const [chatAlias, setChatAlias] = useState<string | null>(null);
1009
+ // Round 14 / Loop: one-shot click ripple — fades outward from the clicked
1010
+ // node so the click registers physically before the popover snaps in.
1011
+ // Pairs with the Round 11 chat-focus ring: ripple expands, ring locks on.
1012
+ // Keyed by ts so re-clicking the same node remounts the <circle> and the
1013
+ // SMIL <animate> replays. Cleared 600ms after click (longer than the
1014
+ // 500ms animation so a final frame at opacity 0 is still in the tree).
1015
+ const [clickRipple, setClickRipple] = useState<{
1016
+ ts: number; x: number; y: number; r0: number; color: string;
1017
+ } | null>(null);
648
1018
  // #84: when a node is renamed while its chat popover is open, follow the
649
1019
  // rename so the conversation keeps targeting a live alias.
650
1020
  useEffect(() => {
@@ -675,6 +1045,42 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
675
1045
  } catch {}
676
1046
  }, []);
677
1047
 
1048
+ // Round 28 / Loop: first-paint auto-fit. Round 27's cellH bump means
1049
+ // dense grids (≥6-7 rows) overflow the 680-px viewBox at the natural
1050
+ // 100% zoom — a new user sees the topology with its bottom rows
1051
+ // clipped and no hint that there's more below. Auto-fit on first
1052
+ // paint (and only if the user has no persisted view) sets the
1053
+ // initial zoom so all content fits. Subsequent zoom changes persist
1054
+ // and override the auto-fit on reload; explicit reset (0 key) still
1055
+ // goes back to 100% so the gesture's "reset to natural size" semantic
1056
+ // is preserved.
1057
+ //
1058
+ // Capture pre-mount persistence in a useState initializer — the
1059
+ // existing `persist` effect (declared below) runs on first render
1060
+ // with the default {1,0,0} view and writes it to localStorage before
1061
+ // the auto-fit effect (deps on async-arriving sessions) gets a turn.
1062
+ // Reading localStorage from the effect would see that write and
1063
+ // skip the fit. The useState snapshot fires once, before any effects.
1064
+ const [hadPersistedViewOnMount] = useState<boolean>(
1065
+ () => typeof window !== 'undefined' && !!localStorage.getItem('anet-topo-view'),
1066
+ );
1067
+ const autoFitDoneRef = useRef(false);
1068
+ useEffect(() => {
1069
+ if (autoFitDoneRef.current) return;
1070
+ if (hadPersistedViewOnMount) {
1071
+ autoFitDoneRef.current = true;
1072
+ return;
1073
+ }
1074
+ if (layout !== 'grid' || sessions.length === 0 || !gridContentBottom) return;
1075
+ if (gridContentBottom <= VIEWBOX_H) {
1076
+ autoFitDoneRef.current = true; // no overflow → no fit needed
1077
+ return;
1078
+ }
1079
+ const fitZoom = Math.max(ZOOM_MIN, Math.min(1, VIEWBOX_H / gridContentBottom));
1080
+ setView({ zoom: fitZoom, x: 0, y: 0 });
1081
+ autoFitDoneRef.current = true;
1082
+ }, [layout, sessions.length, gridContentBottom, hadPersistedViewOnMount]);
1083
+
678
1084
  // persist view
679
1085
  useEffect(() => {
680
1086
  try { localStorage.setItem('anet-topo-view', JSON.stringify(view)); } catch {}
@@ -694,6 +1100,14 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
694
1100
  const svg = svgRef.current;
695
1101
  if (!svg) return;
696
1102
  const onWheel = (e: WheelEvent) => {
1103
+ // Round 23 / Loop: only zoom on Ctrl/Meta+wheel when inline; plain
1104
+ // wheel over the canvas keeps scrolling the page (the topo sits at
1105
+ // the top of /; trapping page scroll mid-page is the classic
1106
+ // "scroll-jail" anti-pattern). In fullscreen the canvas owns the
1107
+ // viewport so any wheel zooms — no page scroll to preserve. Pinch-
1108
+ // zoom on a trackpad surfaces as ctrlKey=true natively, which is
1109
+ // also what we want (zoom the canvas, not the browser).
1110
+ if (!isFullscreen && !e.ctrlKey && !e.metaKey) return;
697
1111
  e.preventDefault();
698
1112
  const rect = svg.getBoundingClientRect();
699
1113
  const mx = ((e.clientX - rect.left) / rect.width) * VIEWBOX_W;
@@ -714,8 +1128,17 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
714
1128
  };
715
1129
  svg.addEventListener('wheel', onWheel, { passive: false });
716
1130
  return () => svg.removeEventListener('wheel', onWheel);
717
- }, []);
1131
+ // Re-attach when the fullscreen flag toggles so the handler's
1132
+ // closure picks up the new value (capture-by-closure means we'd
1133
+ // otherwise read the stale boolean forever).
1134
+ }, [isFullscreen]);
718
1135
 
1136
+ // Round 21 / Loop: pan-aware cursor. Static `grab` gave no tactile cue
1137
+ // that the canvas was actually being dragged — "grabbing" while
1138
+ // dragRef.current.active = true tells the hand it's moving the
1139
+ // viewport. Mirroring dragRef.active into state is the only way to
1140
+ // re-render the SVG style; the ref itself doesn't trigger renders.
1141
+ const [isPanning, setIsPanning] = useState(false);
719
1142
  const onPointerDown = (e: React.PointerEvent<SVGSVGElement>) => {
720
1143
  if (e.button !== 0) return;
721
1144
  (e.currentTarget as Element).setPointerCapture?.(e.pointerId);
@@ -726,6 +1149,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
726
1149
  baseX: viewRef.current.x,
727
1150
  baseY: viewRef.current.y,
728
1151
  };
1152
+ setIsPanning(true);
729
1153
  };
730
1154
  const onPointerMove = (e: React.PointerEvent<SVGSVGElement>) => {
731
1155
  const d = dragRef.current;
@@ -740,6 +1164,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
740
1164
  const onPointerUp = (e: React.PointerEvent<SVGSVGElement>) => {
741
1165
  if (!dragRef.current.active) return;
742
1166
  dragRef.current.active = false;
1167
+ setIsPanning(false);
743
1168
  try {
744
1169
  (e.currentTarget as Element).releasePointerCapture?.(e.pointerId);
745
1170
  } catch {}
@@ -757,6 +1182,91 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
757
1182
  };
758
1183
  const resetView = () => setView({ zoom: 1, x: 0, y: 0 });
759
1184
 
1185
+ // Round 29 / Loop: `f` = fit-to-content. Shared by the Round 28
1186
+ // first-paint auto-fit effect and the keyboard handler so the math is
1187
+ // in one place. When content already fits at natural zoom, this is
1188
+ // effectively a "recenter" — `f` always lands on a known good view.
1189
+ const fitView = useCallback(() => {
1190
+ const zoom = !gridContentBottom || gridContentBottom <= VIEWBOX_H
1191
+ ? 1
1192
+ : Math.max(ZOOM_MIN, Math.min(1, VIEWBOX_H / gridContentBottom));
1193
+ setView({ zoom, x: 0, y: 0 });
1194
+ }, [gridContentBottom]);
1195
+
1196
+ // R74: listen for layout + view palette commands. Sister to R69's
1197
+ // pin listener — palette dispatches a CustomEvent, the reducer here
1198
+ // calls toggleLayout / fitView. Sits below fitView's declaration so
1199
+ // the deps list resolves cleanly.
1200
+ useEffect(() => {
1201
+ const onLayout = (e: Event) => {
1202
+ const detail = (e as CustomEvent).detail || {};
1203
+ if (detail.kind === 'toggle') toggleLayout();
1204
+ };
1205
+ const onView = (e: Event) => {
1206
+ const detail = (e as CustomEvent).detail || {};
1207
+ if (detail.kind === 'fit') fitView();
1208
+ };
1209
+ window.addEventListener('anet:topo-layout', onLayout);
1210
+ window.addEventListener('anet:topo-view', onView);
1211
+ return () => {
1212
+ window.removeEventListener('anet:topo-layout', onLayout);
1213
+ window.removeEventListener('anet:topo-view', onView);
1214
+ };
1215
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1216
+ }, [fitView]);
1217
+
1218
+ // Round 22 / Loop: keyboard zoom — +/= zoom in, - zoom out, 0 reset.
1219
+ // Round 29 / Loop: +f to fit content.
1220
+ // Listen on window so the user doesn't need to focus the SVG first,
1221
+ // but only act when no text input has focus (otherwise typing "-" in
1222
+ // a chat would zoom the topology — surprising and bad). Modifier keys
1223
+ // pass through so Cmd/Ctrl combos still hit their owners. The button
1224
+ // titles below document these shortcuts so users discover them.
1225
+ useEffect(() => {
1226
+ const onKey = (e: KeyboardEvent) => {
1227
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
1228
+ const ae = document.activeElement as HTMLElement | null;
1229
+ if (ae) {
1230
+ const tag = ae.tagName;
1231
+ if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || ae.isContentEditable) return;
1232
+ }
1233
+ if (e.key === '+' || e.key === '=') { zoomBy(1.2); e.preventDefault(); }
1234
+ else if (e.key === '-' || e.key === '_') { zoomBy(1 / 1.2); e.preventDefault(); }
1235
+ else if (e.key === '0') { resetView(); e.preventDefault(); }
1236
+ else if (e.key === 'f' || e.key === 'F') { fitView(); e.preventDefault(); }
1237
+ // Round 32 / Loop: `l` toggles ring|grid. The vim-style `g l` route
1238
+ // (Audit Log) requires a preceding `g` within 1500ms; a bare `l`
1239
+ // outside that window is free for topology use.
1240
+ else if (e.key === 'l' || e.key === 'L') { toggleLayout(); e.preventDefault(); }
1241
+ // Round 62 / Loop: Esc clears the R60/R61 pinned status filter so
1242
+ // users have a universal-cancel keyboard out. Esc on an open chat
1243
+ // is owned by ChatPopover (which only mounts when chatAlias is
1244
+ // set), so this handler is effectively scoped to "no chat open".
1245
+ // We additionally guard on chatAlias to be explicit — if the chat
1246
+ // closed mid-cycle, the pin can still be cleared on the next Esc.
1247
+ // R63: extends to pinnedGroup too. Clears WHATEVER pin is active
1248
+ // (one Esc collapses all topology pins) so the keyboard escape
1249
+ // route stays a single key, not "Esc maybe Esc again".
1250
+ else if (e.key === 'Escape' && !chatAlias && (pinnedStatus || pinnedGroup || pinnedVendor || pinnedEdgeKey)) {
1251
+ // R88/R116: extend the universal-cancel to vendor + edge too.
1252
+ // One Esc collapses every topology pin (matches R62/R63's
1253
+ // "single key, not Esc-maybe-Esc-again" promise).
1254
+ if (pinnedStatus) setPinnedStatus(null);
1255
+ if (pinnedGroup) setPinnedGroup(null);
1256
+ if (pinnedVendor) setPinnedVendor(null);
1257
+ if (pinnedEdgeKey) setPinnedEdgeKey(null);
1258
+ e.preventDefault();
1259
+ }
1260
+ };
1261
+ window.addEventListener('keydown', onKey);
1262
+ return () => window.removeEventListener('keydown', onKey);
1263
+ // zoomBy / resetView are stable wrt setView callback; fitView changes
1264
+ // with gridContentBottom so deps list catches it. R62 adds chatAlias
1265
+ // and pinnedStatus so the Escape branch reads fresh state (re-binding
1266
+ // the listener on these state changes is sub-ms — cheaper than refs).
1267
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1268
+ }, [fitView, chatAlias, pinnedStatus, pinnedGroup, pinnedVendor, pinnedEdgeKey]);
1269
+
760
1270
  const toggleFullscreen = () => {
761
1271
  const el = containerRef.current;
762
1272
  if (!el) return;
@@ -784,6 +1294,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
784
1294
  <button
785
1295
  onClick={() => { if (layout !== 'ring') toggleLayout(); }}
786
1296
  aria-pressed={layout === 'ring'}
1297
+ title="Ring layout (l to toggle)"
787
1298
  className={`px-2.5 py-1 transition-colors ${layout === 'ring' ? 'bg-cyan-500/15 text-cyan-300' : 'text-gray-500 hover:text-gray-400'}`}
788
1299
  >
789
1300
  Ring
@@ -791,33 +1302,661 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
791
1302
  <button
792
1303
  onClick={() => { if (layout !== 'grid') toggleLayout(); }}
793
1304
  aria-pressed={layout === 'grid'}
1305
+ title="Grid layout (l to toggle)"
794
1306
  className={`px-2.5 py-1 border-l border-gray-500/25 transition-colors ${layout === 'grid' ? 'bg-cyan-500/15 text-cyan-300' : 'text-gray-500 hover:text-gray-400'}`}
795
1307
  >
796
1308
  Grid
797
1309
  </button>
798
1310
  </div>
799
- <span className="px-2.5 py-1 rounded-md bg-green-500/10 text-green-300 border border-green-500/20">
800
- {workingCount} working
801
- </span>
802
- <span className="px-2.5 py-1 rounded-md bg-cyan-500/10 text-cyan-300 border border-cyan-500/20">
803
- {onlineNodes.length} online
804
- </span>
805
- {vendorDist.length > 1 && (
1311
+ {/* R79: working + online count chips become hover affordances —
1312
+ extends R77's chip-hover pattern to status counts. Hover the
1313
+ working chip → setHoveredStatus('working') so the R55 dim
1314
+ mechanic kicks in (same as hovering the SVG legend "working"
1315
+ row, just a different surface for the same gesture).
1316
+ The online chip uses the same setHoveredStatus('idle') path
1317
+ when there's idle but no working — falling back to working
1318
+ if any working node exists; "online" without a single bucket
1319
+ isn't part of the R55 type set, so this chip routes to the
1320
+ dominant online sub-tier instead of inventing a new state.
1321
+ Cursor only flips when there's anything to highlight. */}
1322
+ {/* R82: pin-mirror. R60 pressure-bar segments visualise the
1323
+ pinned status via an inset boxShadow; R61 legend rows via a
1324
+ concentric r=8 ring; the chip-row chips next to them did
1325
+ not — so a user who pinned via Cmd+K (R69) or the legend
1326
+ had no chip-row signal that "working" was the current
1327
+ filter. Mirror the pressure-bar treatment here so all
1328
+ status surfaces sing in unison. The online chip mirrors
1329
+ for idle pins (working ⊆ online; the routing in
1330
+ onMouseEnter already treats online as the idle fallback). */}
1331
+ {(() => {
1332
+ // R113 / Loop: extend the R97-R102/R101 alias-list tooltip
1333
+ // sweep to the remaining chip-row affordances. R79 made
1334
+ // these chips hoverable; their generic "Hover to highlight"
1335
+ // titles never said WHICH nodes match. Compute the alias
1336
+ // lists once for both chips to share.
1337
+ const workingAliases = onlineNodes.filter(s => s.status === 'working').map(s => s.alias);
1338
+ const onlineAliases = onlineNodes.map(s => s.alias);
1339
+ const truncate = (list: string[]) => {
1340
+ const head = list.slice(0, 8).join(', ');
1341
+ const tail = list.length > 8 ? ` + ${list.length - 8} more` : '';
1342
+ return head + tail;
1343
+ };
1344
+ const workingTitle = workingCount === 0
1345
+ ? undefined
1346
+ : pinnedStatus === 'working'
1347
+ ? `${truncate(workingAliases)} — pinned, Esc to clear`
1348
+ : `${truncate(workingAliases)} — hover highlights, click to pin`;
1349
+ // R140: online chip title gains a "click to open /nodes" tail
1350
+ // when interactive. R79 made the cursor pointer-shaped but
1351
+ // wired nothing; R136 + R139 closed the same lie on two
1352
+ // sibling chips by wiring real actions. The online chip
1353
+ // can't pin a single status (online = working + idle,
1354
+ // not a single pinnedStatus value), so a pin idiom would
1355
+ // be semantically wrong. /nodes is the natural full-list
1356
+ // destination — same "click chip for the full list" idiom
1357
+ // the active-links chip uses (R136 → /messages).
1358
+ const onlineTitle = onlineNodes.length === 0
1359
+ ? undefined
1360
+ : pinnedStatus === 'idle'
1361
+ ? `${truncate(onlineAliases)} — pinned, Esc to clear`
1362
+ : `${truncate(onlineAliases)} — hover highlights · click to open /nodes`;
1363
+ return (
1364
+ <>
1365
+ <span
1366
+ className="px-2.5 py-1 rounded-md bg-green-500/10 text-green-300 border border-green-500/20"
1367
+ data-working-chip
1368
+ data-working-chip-aliases={workingAliases.join(',')}
1369
+ data-pin-mirror={pinnedStatus === 'working' ? 'true' : 'false'}
1370
+ data-working-chip-clickable={workingCount > 0 ? 'true' : 'false'}
1371
+ title={workingTitle}
1372
+ role={workingCount > 0 ? 'button' : undefined}
1373
+ tabIndex={workingCount > 0 ? 0 : undefined}
1374
+ aria-pressed={workingCount > 0 ? (pinnedStatus === 'working') : undefined}
1375
+ style={{
1376
+ cursor: workingCount > 0 ? 'pointer' : undefined,
1377
+ boxShadow: pinnedStatus === 'working' ? 'inset 0 0 0 1px #4ade80, inset 0 0 0 2px rgba(255,255,255,0.45)' : undefined,
1378
+ }}
1379
+ onMouseEnter={() => { if (workingCount > 0) setHoveredStatus('working'); }}
1380
+ onMouseLeave={() => setHoveredStatus(prev => prev === 'working' ? null : prev)}
1381
+ // R139: the title hover-text has been promising "click to
1382
+ // pin" since R79 but no onClick was ever wired. The cursor:
1383
+ // pointer at line 1363 set up the same lie R136 fixed on
1384
+ // the active-links chip. Wire it now: click toggles the
1385
+ // status pin to 'working', composing with R60 (pressure-
1386
+ // bar segments) and R61 (legend rows) — three different
1387
+ // surfaces that all toggle the same pinnedStatus. boxShadow
1388
+ // pin-mirror at line 1364 already reflects the state; aria-
1389
+ // pressed now exposes it for screen readers too.
1390
+ onClick={() => {
1391
+ if (workingCount > 0) setPinnedStatus(prev => prev === 'working' ? null : 'working');
1392
+ }}
1393
+ onKeyDown={(e) => {
1394
+ if (workingCount === 0) return;
1395
+ if (e.key === 'Enter' || e.key === ' ') {
1396
+ e.preventDefault();
1397
+ setPinnedStatus(prev => prev === 'working' ? null : 'working');
1398
+ }
1399
+ }}
1400
+ >
1401
+ {workingCount} working
1402
+ </span>
1403
+ <span
1404
+ className="px-2.5 py-1 rounded-md bg-cyan-500/10 text-cyan-300 border border-cyan-500/20"
1405
+ data-online-chip
1406
+ data-online-chip-aliases={onlineAliases.join(',')}
1407
+ data-pin-mirror={pinnedStatus === 'idle' ? 'true' : 'false'}
1408
+ data-online-chip-clickable={onlineNodes.length > 0 ? 'true' : 'false'}
1409
+ title={onlineTitle}
1410
+ role={onlineNodes.length > 0 ? 'link' : undefined}
1411
+ tabIndex={onlineNodes.length > 0 ? 0 : undefined}
1412
+ style={{
1413
+ cursor: onlineNodes.length > 0 ? 'pointer' : undefined,
1414
+ boxShadow: pinnedStatus === 'idle' ? 'inset 0 0 0 1px #67e8f9, inset 0 0 0 2px rgba(255,255,255,0.45)' : undefined,
1415
+ }}
1416
+ onMouseEnter={() => {
1417
+ // If a working filter would isolate nothing, route to idle.
1418
+ const idleCount = onlineNodes.length - workingCount;
1419
+ if (workingCount > 0) setHoveredStatus('working');
1420
+ else if (idleCount > 0) setHoveredStatus('idle');
1421
+ }}
1422
+ onMouseLeave={() => setHoveredStatus(prev => prev === 'working' || prev === 'idle' ? null : prev)}
1423
+ // R140: click → /nodes. Mirrors R136 active-links→/messages
1424
+ // idiom. The chip's hover semantics (R79 highlight all
1425
+ // online) keep their meaning — hover for canvas preview,
1426
+ // click for the full list. Pinning idle here would
1427
+ // semantically misrepresent the chip (which means
1428
+ // working+idle), so we navigate instead of pin.
1429
+ onClick={() => {
1430
+ if (onlineNodes.length > 0) router.push('/nodes');
1431
+ }}
1432
+ onKeyDown={(e) => {
1433
+ if (onlineNodes.length === 0) return;
1434
+ if (e.key === 'Enter' || e.key === ' ') {
1435
+ e.preventDefault();
1436
+ router.push('/nodes');
1437
+ }
1438
+ }}
1439
+ >
1440
+ {onlineNodes.length} online
1441
+ </span>
1442
+ </>
1443
+ );
1444
+ })()}
1445
+ {/* Round 31 / Loop: fleet-health pressure bar. The "X working /
1446
+ Y online" chips already carry the raw counts; the bar lets
1447
+ the eye get the working/idle/offline RATIO in one glance
1448
+ without mental math. Stacked 3-segment chip, ~64 px wide. */}
1449
+ {(() => {
1450
+ const w = workingCount;
1451
+ const i = onlineNodes.length - workingCount; // idle = online - working
1452
+ const o = offlineNodes.length;
1453
+ const total = w + i + o;
1454
+ if (total === 0) return null;
1455
+ // Round 60 / Loop: each segment toggles a sticky filter via
1456
+ // `pinnedStatus`. Click the working segment → all non-working
1457
+ // nodes dim; click again → release. Segments share width with
1458
+ // their proportion of `total`, so a 1-node working share is
1459
+ // ~3 px wide on a 64-px bar. We pad the click target with a
1460
+ // negative-margin overlay wrapper to give thin slices a
1461
+ // 14-px minimum hit area without disturbing the rendered
1462
+ // chip width. cursor:pointer + a one-line title hint at the
1463
+ // affordance.
1464
+ const seg = (n: number, color: string, key: 'working' | 'idle' | 'offline', label: string) => {
1465
+ if (n === 0) return null;
1466
+ const isPinned = pinnedStatus === key;
1467
+ // R102: list the aliases that match this segment's bucket
1468
+ // so the title answers WHICH n, not just HOW MANY. Closes
1469
+ // the last "info-density gap" in the chip-row surfaces
1470
+ // (R97 pills / R99 group labels / R101 vendor letters all
1471
+ // already enumerate). Truncates at 8 with "+N more".
1472
+ const matchAliases = key === 'working'
1473
+ ? onlineNodes.filter(s => s.status === 'working').map(s => s.alias)
1474
+ : key === 'idle'
1475
+ ? onlineNodes.filter(s => s.status !== 'working').map(s => s.alias)
1476
+ : offlineNodes.map(s => s.alias);
1477
+ const previewList = matchAliases.slice(0, 8).join(', ');
1478
+ const suffix = matchAliases.length > 8 ? ` + ${matchAliases.length - 8} more` : '';
1479
+ const titleAction = isPinned ? 'click to release filter' : 'click to highlight';
1480
+ return (
1481
+ <span
1482
+ key={key}
1483
+ data-pressure-seg={key}
1484
+ data-pressure-seg-aliases={matchAliases.join(',')}
1485
+ role="button"
1486
+ tabIndex={0}
1487
+ aria-pressed={isPinned}
1488
+ title={`${n} ${label}\n${previewList}${suffix}\n${titleAction}`}
1489
+ style={{
1490
+ width: `${(n / total) * 100}%`,
1491
+ background: color,
1492
+ height: '100%',
1493
+ cursor: 'pointer',
1494
+ boxShadow: isPinned ? `inset 0 0 0 1px ${color}, inset 0 0 0 2px rgba(255,255,255,0.6)` : undefined,
1495
+ }}
1496
+ onClick={(e) => {
1497
+ e.stopPropagation();
1498
+ setPinnedStatus(prev => prev === key ? null : key);
1499
+ }}
1500
+ onKeyDown={(e) => {
1501
+ if (e.key === 'Enter' || e.key === ' ') {
1502
+ e.preventDefault();
1503
+ setPinnedStatus(prev => prev === key ? null : key);
1504
+ }
1505
+ }}
1506
+ // R83: hover preview — segments now match the R55 legend,
1507
+ // R79 working/online chips, and R80 vendor letters in
1508
+ // offering a hover-transient highlight before the click
1509
+ // commits to a pin. Users get to feel what the filter
1510
+ // does before they lock it in. Same activeStatus =
1511
+ // hoveredStatus ?? pinnedStatus formula; releasing the
1512
+ // pointer falls back to the pin if one is set, or to
1513
+ // baseline. Thin (3-px) segments still hit-test fine
1514
+ // because the chip itself is a flex row — span doesn't
1515
+ // need any extra hit padding for hover.
1516
+ onMouseEnter={() => setHoveredStatus(key)}
1517
+ onMouseLeave={() => setHoveredStatus(prev => prev === key ? null : prev)}
1518
+ />
1519
+ );
1520
+ };
1521
+ // Round 47 / Loop: hidden on mobile — at <640px the chip row
1522
+ // wraps to multiple lines and crowds the topology header;
1523
+ // pressure ratio is best read with the working+online raw
1524
+ // counts (kept visible) anyway.
1525
+ return (
1526
+ <span
1527
+ className="hidden sm:inline-flex items-center gap-2 px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20 font-mono"
1528
+ title={`${w} working · ${i} idle · ${o} offline`}
1529
+ data-fleet-pressure
1530
+ >
1531
+ <span className="text-[10px] tracking-wide">pressure</span>
1532
+ <span className="inline-flex h-1.5 w-16 rounded-full overflow-hidden" style={{ background: 'rgb(75 85 99 / 0.25)' }}>
1533
+ {seg(w, isLight ? '#059669' : '#22c55e', 'working', 'working')}
1534
+ {seg(i, isLight ? '#0d9488' : '#2dd4bf', 'idle', 'idle')}
1535
+ {seg(o, isLight ? '#94a3b8' : '#6b7280', 'offline', 'offline')}
1536
+ </span>
1537
+ </span>
1538
+ );
1539
+ })()}
1540
+ {/* Round 64 / Loop: active-filter pills. When pinnedStatus or
1541
+ pinnedGroup is set, show a small "filter: <key> ×" pill so
1542
+ the user can see the pin from the chip row even if they
1543
+ scrolled the canvas off-screen. × button clears the
1544
+ specific pin (Esc still clears all — both paths are
1545
+ valid). pinnedStatus and pinnedGroup pin independently so
1546
+ both pills may render simultaneously. */}
1547
+ {/* R67: pills enter via anet-fade-in so they appear softly
1548
+ instead of popping. The "filter: " prefix collapses below
1549
+ sm — at narrow viewports the chip row is precious real
1550
+ estate (R47 already hides pressure / vendor / freshness),
1551
+ so dropping the redundant label keeps the working/idle/
1552
+ alpha keys readable without overflow. */}
1553
+ {/* R71: each pill picks up a "· N" match count tail. Tells the
1554
+ user at a glance how many sessions the active filter
1555
+ matches without scanning the canvas. Counts come from the
1556
+ already-computed workingCount + onlineNodes + offlineNodes
1557
+ for status, and groupKeys for group. */}
1558
+ {/* R73: entire pill body is a click-to-clear target — matches
1559
+ the Notion / Linear tag UX (the whole chip releases). The
1560
+ × keeps its dedicated <button> + aria-label for screen
1561
+ readers; the outer span just adds an extra mouse-friendly
1562
+ hit area with a title hint. ×'s onClick stopPropagation
1563
+ so the redundant outer onClick doesn't double-fire (no
1564
+ functional difference since both clear, but cleaner
1565
+ event flow). */}
1566
+ {pinnedStatus && (() => {
1567
+ const matchCount = pinnedStatus === 'working' ? workingCount
1568
+ : pinnedStatus === 'idle' ? (onlineNodes.length - workingCount)
1569
+ : offlineNodes.length;
1570
+ // Round 97 / Loop: the pill says HOW MANY but not WHICH.
1571
+ // Hovering it now shows the matched alias list in the
1572
+ // tooltip — answers "exactly who is this filtering to"
1573
+ // without forcing the user to scan the dim mask on the
1574
+ // canvas. Truncates at 8 names so a 50-node working
1575
+ // bucket doesn't produce a 12-line tooltip; the count
1576
+ // chip already answers "how many overall".
1577
+ const matchAliases = pinnedStatus === 'working'
1578
+ ? onlineNodes.filter(s => s.status === 'working').map(s => s.alias)
1579
+ : pinnedStatus === 'idle'
1580
+ ? onlineNodes.filter(s => s.status !== 'working').map(s => s.alias)
1581
+ : offlineNodes.map(s => s.alias);
1582
+ const matchPreview = matchAliases.slice(0, 8).join(', ');
1583
+ const matchSuffix = matchAliases.length > 8 ? ` + ${matchAliases.length - 8} more` : '';
1584
+ return (
1585
+ <span
1586
+ data-active-filter="status"
1587
+ data-filter-match-count={matchCount}
1588
+ data-filter-match-aliases={matchAliases.join(',')}
1589
+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md font-mono text-xs border anet-fade-in"
1590
+ title={matchCount > 0 ? `${matchPreview}${matchSuffix} — click to clear` : 'Click to clear filter'}
1591
+ onClick={() => setPinnedStatus(null)}
1592
+ style={{
1593
+ background: pinnedStatus === 'working' ? (isLight ? '#05966914' : '#22c55e1f')
1594
+ : pinnedStatus === 'idle' ? (isLight ? '#0d948814' : '#2dd4bf1f')
1595
+ : (isLight ? '#94a3b814' : '#6b72801f'),
1596
+ color: pinnedStatus === 'working' ? (isLight ? '#047857' : '#86efac')
1597
+ : pinnedStatus === 'idle' ? (isLight ? '#0f766e' : '#5eead4')
1598
+ : (isLight ? '#475569' : '#9ca3af'),
1599
+ borderColor: 'currentColor',
1600
+ cursor: 'pointer',
1601
+ }}
1602
+ >
1603
+ <span><span className="hidden sm:inline" data-filter-prefix>filter: </span>{pinnedStatus}<span className="opacity-70"> · {matchCount}</span></span>
1604
+ <button
1605
+ type="button"
1606
+ aria-label={`Clear ${pinnedStatus} filter`}
1607
+ onClick={(e) => { e.stopPropagation(); setPinnedStatus(null); }}
1608
+ className="ml-0.5 leading-none hover:opacity-70"
1609
+ style={{ background: 'transparent', color: 'inherit', cursor: 'pointer', padding: 0 }}
1610
+ >×</button>
1611
+ </span>
1612
+ );
1613
+ })()}
1614
+ {pinnedGroup && (() => {
1615
+ const matchCount = Object.values(groupKeys).filter(k => k === pinnedGroup).length;
1616
+ // R97: list group members in the tooltip.
1617
+ const matchAliases = Object.entries(groupKeys)
1618
+ .filter(([, key]) => key === pinnedGroup)
1619
+ .map(([alias]) => alias);
1620
+ const matchPreview = matchAliases.slice(0, 8).join(', ');
1621
+ const matchSuffix = matchAliases.length > 8 ? ` + ${matchAliases.length - 8} more` : '';
1622
+ return (
1623
+ <span
1624
+ data-active-filter="group"
1625
+ data-filter-match-count={matchCount}
1626
+ data-filter-match-aliases={matchAliases.join(',')}
1627
+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md font-mono text-xs border anet-fade-in"
1628
+ title={matchCount > 0 ? `${matchPreview}${matchSuffix} — click to clear` : 'Click to clear filter'}
1629
+ onClick={() => setPinnedGroup(null)}
1630
+ style={{
1631
+ background: isLight ? '#67e8f914' : '#67e8f91f',
1632
+ color: pal.legendAccent,
1633
+ borderColor: 'currentColor',
1634
+ cursor: 'pointer',
1635
+ }}
1636
+ >
1637
+ <span><span className="hidden sm:inline" data-filter-prefix>filter: </span>{pinnedGroup}<span className="opacity-70"> · {matchCount}</span></span>
1638
+ <button
1639
+ type="button"
1640
+ aria-label={`Clear group filter ${pinnedGroup}`}
1641
+ onClick={(e) => { e.stopPropagation(); setPinnedGroup(null); }}
1642
+ className="ml-0.5 leading-none hover:opacity-70"
1643
+ style={{ background: 'transparent', color: 'inherit', cursor: 'pointer', padding: 0 }}
1644
+ >×</button>
1645
+ </span>
1646
+ );
1647
+ })()}
1648
+ {/* R89: vendor pin gets its own filter pill, matching the R64
1649
+ status + group pattern. R88 added the pin but only the
1650
+ letter itself carried the state; the chip-row had no
1651
+ "filter: A · 2 ×" affordance the other two pins have. The
1652
+ pill colour borrows the vendor's own swatch so each pin
1653
+ still reads in its native hue (A green, O cyan, 书 blue,
1654
+ ? slate). Same body-click-clears + × button pattern as
1655
+ R64. */}
1656
+ {pinnedVendor && (() => {
1657
+ const matchEntry = vendorDist.find(v => v.initial === pinnedVendor);
1658
+ const matchCount = matchEntry?.count ?? 0;
1659
+ const vendorColor = matchEntry?.color ?? pal.legendText;
1660
+ // R97: list vendor users in the tooltip. The vendorIdentity
1661
+ // resolver maps model strings to a vendor initial — match
1662
+ // any session whose initial equals the pinned letter (with
1663
+ // unknowns folded to '?').
1664
+ const matchAliases = [...onlineNodes, ...offlineNodes]
1665
+ .filter(s => {
1666
+ const v = vendorForModel(s.model);
1667
+ return (v.id === 'unknown' ? '?' : v.initial) === pinnedVendor;
1668
+ })
1669
+ .map(s => s.alias);
1670
+ const matchPreview = matchAliases.slice(0, 8).join(', ');
1671
+ const matchSuffix = matchAliases.length > 8 ? ` + ${matchAliases.length - 8} more` : '';
1672
+ return (
806
1673
  <span
807
- className="inline-flex items-center gap-2 px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20 font-mono"
808
- title="Fleet by model vendor"
1674
+ data-active-filter="vendor"
1675
+ data-filter-match-count={matchCount}
1676
+ data-filter-match-aliases={matchAliases.join(',')}
1677
+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md font-mono text-xs border anet-fade-in"
1678
+ title={matchCount > 0 ? `${matchPreview}${matchSuffix} — click to clear` : 'Click to clear vendor filter'}
1679
+ onClick={() => setPinnedVendor(null)}
1680
+ style={{
1681
+ background: `${vendorColor}1f`,
1682
+ color: vendorColor,
1683
+ borderColor: 'currentColor',
1684
+ cursor: 'pointer',
1685
+ }}
809
1686
  >
810
- {vendorDist.map(v => (
811
- <span key={v.initial} className="inline-flex items-baseline gap-0.5">
812
- <span style={{ color: v.color }}>{v.initial}</span>
813
- <span className="text-gray-500">:{v.count}</span>
1687
+ <span><span className="hidden sm:inline" data-filter-prefix>filter: </span>{pinnedVendor}<span className="opacity-70"> · {matchCount}</span></span>
1688
+ <button
1689
+ type="button"
1690
+ aria-label={`Clear vendor filter ${pinnedVendor}`}
1691
+ onClick={(e) => { e.stopPropagation(); setPinnedVendor(null); }}
1692
+ className="ml-0.5 leading-none hover:opacity-70"
1693
+ style={{ background: 'transparent', color: 'inherit', cursor: 'pointer', padding: 0 }}
1694
+ >×</button>
1695
+ </span>
1696
+ );
1697
+ })()}
1698
+ {/* R119: edge pin filter pill — completes the R64 / R89 pill
1699
+ pattern across all four pin dimensions. R116 added
1700
+ pinnedEdgeKey but the chip row never grew the matching
1701
+ pill, leaving the locked flow visible only on the canvas +
1702
+ recent-signal row tint. This pill shows "filter:
1703
+ alpha→beta · 3" so the locked flow appears in the same
1704
+ row as the other three pin types. Body-click + × button
1705
+ clear, same pattern as R64. */}
1706
+ {pinnedEdgeKey && (() => {
1707
+ const link = flowLinks.find(l => l.key === pinnedEdgeKey);
1708
+ if (!link) return null;
1709
+ return (
1710
+ <span
1711
+ data-active-filter="edge"
1712
+ data-filter-match-count={link.count}
1713
+ data-filter-match-aliases={`${link.from},${link.to}`}
1714
+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md font-mono text-xs border anet-fade-in"
1715
+ title={`${link.from} → ${link.to} (${link.count} msg${link.count === 1 ? '' : 's'}) — click to clear`}
1716
+ onClick={() => setPinnedEdgeKey(null)}
1717
+ style={{
1718
+ background: isLight ? `${pal.flowEdge}14` : `${pal.flowEdge}1f`,
1719
+ color: pal.flowEdge,
1720
+ borderColor: 'currentColor',
1721
+ cursor: 'pointer',
1722
+ }}
1723
+ >
1724
+ <span><span className="hidden sm:inline" data-filter-prefix>filter: </span>{link.from}→{link.to}<span className="opacity-70"> · {link.count}</span></span>
1725
+ <button
1726
+ type="button"
1727
+ aria-label={`Clear edge filter ${link.from} → ${link.to}`}
1728
+ onClick={(e) => { e.stopPropagation(); setPinnedEdgeKey(null); }}
1729
+ className="ml-0.5 leading-none hover:opacity-70"
1730
+ style={{ background: 'transparent', color: 'inherit', cursor: 'pointer', padding: 0 }}
1731
+ >×</button>
1732
+ </span>
1733
+ );
1734
+ })()}
1735
+ {/* Round 124 / Loop: pin-intersection summary chip. The four
1736
+ filter pills (R64 status, R63 group, R89 vendor, R119
1737
+ edge) each report their own dim's match count in
1738
+ isolation — that answers "what does THIS filter catch"
1739
+ but not "what survives ALL pins". Since the node-opacity
1740
+ chain AND-composes the four pin dimensions, two active
1741
+ pins routinely produce an intersection smaller than
1742
+ either individual count. With three or four pins active
1743
+ the gap widens further. This chip appears ONLY when
1744
+ ≥ 2 pin dims are active (a single pin's pill already
1745
+ tells the whole story) and shows the count of nodes
1746
+ that satisfy every active pin simultaneously. Color is
1747
+ deliberately neutral (gray) since the chip represents
1748
+ the AND of mixed-color filters — borrowing any one of
1749
+ the pill hues would mis-signal which dim dominates.
1750
+ Tooltip lists the surviving aliases with the same
1751
+ 8-truncate + "+N more" pattern as the individual pill
1752
+ tooltips (R97). No click handler — it's a pure readout;
1753
+ Esc / per-pill × are still the cancel paths. */}
1754
+ {(() => {
1755
+ const pinDimCount =
1756
+ (pinnedStatus ? 1 : 0) +
1757
+ (pinnedGroup ? 1 : 0) +
1758
+ (pinnedVendor ? 1 : 0) +
1759
+ (pinnedEdgeKey ? 1 : 0);
1760
+ if (pinDimCount < 2) return null;
1761
+ const edgeLink = pinnedEdgeKey
1762
+ ? flowLinks.find(l => l.key === pinnedEdgeKey)
1763
+ : null;
1764
+ const edgeEndpoints: Set<string> | null = edgeLink
1765
+ ? new Set([edgeLink.from, edgeLink.to])
1766
+ : null;
1767
+ const allSessions = [...onlineNodes, ...offlineNodes];
1768
+ const survivors = allSessions.filter(s => {
1769
+ const isOnline = s.status !== 'offline';
1770
+ if (pinnedStatus === 'working' && s.status !== 'working') return false;
1771
+ if (pinnedStatus === 'idle' && !(isOnline && s.status !== 'working')) return false;
1772
+ if (pinnedStatus === 'offline' && isOnline) return false;
1773
+ if (pinnedGroup) {
1774
+ const gk = groupKeys[s.alias] ?? s.alias;
1775
+ if (gk !== pinnedGroup) return false;
1776
+ }
1777
+ if (pinnedVendor) {
1778
+ const v = vendorForModel(s.model);
1779
+ const initial = v.id === 'unknown' ? '?' : v.initial;
1780
+ if (initial !== pinnedVendor) return false;
1781
+ }
1782
+ if (edgeEndpoints && !edgeEndpoints.has(s.alias)) return false;
1783
+ return true;
1784
+ });
1785
+ const matchAliases = survivors.map(s => s.alias);
1786
+ const matchPreview = matchAliases.slice(0, 8).join(', ');
1787
+ const matchSuffix = matchAliases.length > 8 ? ` + ${matchAliases.length - 8} more` : '';
1788
+ const isEmpty = matchAliases.length === 0;
1789
+ const tooltip = !isEmpty
1790
+ ? `${matchPreview}${matchSuffix} — nodes passing all ${pinDimCount} pinned filters`
1791
+ : `No nodes pass all ${pinDimCount} pinned filters — release one to widen (Esc clears all)`;
1792
+ // R125: when the intersection drops to zero, the chip flips
1793
+ // from neutral gray to a warning amber. Zero-overlap is the
1794
+ // exact case users get confused — canvas dims to 0.28
1795
+ // everywhere, no positive signal explains why. The "· 0"
1796
+ // tail in neutral gray reads as just another number,
1797
+ // indistinguishable from "· 12". Amber + a ⚠ glyph lifts
1798
+ // it to "your filters cancel out" at a glance. Color
1799
+ // choice: amber (#d97706 light, #fbbf24 dark) — same hue
1800
+ // family as warning chips elsewhere in the dashboard,
1801
+ // distinct from any pill color (status green/teal/slate,
1802
+ // group cyan, vendor varies, edge cyan, neutral gray for
1803
+ // non-empty intersection) so the empty state stands out.
1804
+ const emptyColor = isLight ? '#d97706' : '#fbbf24';
1805
+ return (
1806
+ <span
1807
+ data-pin-intersection
1808
+ data-pin-dim-count={pinDimCount}
1809
+ data-pin-intersection-count={matchAliases.length}
1810
+ data-pin-intersection-empty={isEmpty ? 'true' : 'false'}
1811
+ data-pin-intersection-aliases={matchAliases.join(',')}
1812
+ className="hidden sm:inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md font-mono text-xs border anet-fade-in"
1813
+ title={tooltip}
1814
+ style={{
1815
+ background: isEmpty
1816
+ ? (isLight ? '#d97706' + '14' : '#fbbf24' + '1f')
1817
+ : (isLight ? '#94a3b814' : '#94a3b81f'),
1818
+ color: isEmpty
1819
+ ? emptyColor
1820
+ : (isLight ? '#475569' : '#9ca3af'),
1821
+ borderColor: 'currentColor',
1822
+ }}
1823
+ >
1824
+ <span>
1825
+ <span className="hidden sm:inline" data-pin-intersection-prefix>match: </span>
1826
+ {pinDimCount} pins<span className="opacity-70"> · {matchAliases.length}</span>
1827
+ {isEmpty && <span className="ml-1" aria-hidden>⚠</span>}
814
1828
  </span>
815
- ))}
1829
+ </span>
1830
+ );
1831
+ })()}
1832
+ {vendorDist.length > 1 && (
1833
+ <span
1834
+ className="hidden sm:inline-flex items-center gap-2 px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20 font-mono"
1835
+ title="Hover to highlight; click to pin"
1836
+ >
1837
+ {vendorDist.map(v => {
1838
+ const isPinned = pinnedVendor === v.initial;
1839
+ // R88: click toggles a sticky filter the same way R60
1840
+ // pressure-bar segments toggle pinnedStatus. Visual
1841
+ // mirror = inset boxShadow using the vendor's own
1842
+ // colour, so each pinned letter sings in its own hue
1843
+ // (Anthropic green / OpenAI cyan / 书 blue / ?).
1844
+ // R101: tooltip lists the aliases that use this vendor —
1845
+ // completes the info-density triple started by R97 pills,
1846
+ // R98 node titles, R99 group-label titles. Anywhere the
1847
+ // UI shows "A:3" should hover-explain which 3.
1848
+ const aliases = [...onlineNodes, ...offlineNodes]
1849
+ .filter(s => {
1850
+ const vid = vendorForModel(s.model);
1851
+ return (vid.id === 'unknown' ? '?' : vid.initial) === v.initial;
1852
+ })
1853
+ .map(s => s.alias);
1854
+ const preview = aliases.slice(0, 8).join(', ');
1855
+ const suffix = aliases.length > 8 ? ` + ${aliases.length - 8} more` : '';
1856
+ const tooltip = isPinned
1857
+ ? `${preview}${suffix} — click again or Esc to clear`
1858
+ : `${preview}${suffix} — click to pin`;
1859
+ return (
1860
+ <span
1861
+ key={v.initial}
1862
+ role="button"
1863
+ tabIndex={0}
1864
+ aria-pressed={isPinned}
1865
+ className="inline-flex items-baseline gap-0.5 px-1 rounded"
1866
+ data-vendor-letter={v.initial}
1867
+ data-vendor-pinned={isPinned ? 'true' : 'false'}
1868
+ data-vendor-aliases={aliases.join(',')}
1869
+ title={tooltip}
1870
+ style={{
1871
+ cursor: 'pointer',
1872
+ boxShadow: isPinned
1873
+ ? `inset 0 0 0 1px ${v.color}, inset 0 0 0 2px rgba(255,255,255,0.45)`
1874
+ : undefined,
1875
+ }}
1876
+ onMouseEnter={() => setHoveredVendor(v.initial)}
1877
+ onMouseLeave={() => setHoveredVendor(prev => prev === v.initial ? null : prev)}
1878
+ onClick={() => setPinnedVendor(prev => prev === v.initial ? null : v.initial)}
1879
+ onKeyDown={(e) => {
1880
+ if (e.key === 'Enter' || e.key === ' ') {
1881
+ e.preventDefault();
1882
+ setPinnedVendor(prev => prev === v.initial ? null : v.initial);
1883
+ }
1884
+ }}
1885
+ >
1886
+ <span style={{ color: v.color }}>{v.initial}</span>
1887
+ <span className="text-gray-500">:{v.count}</span>
1888
+ </span>
1889
+ );
1890
+ })}
816
1891
  </span>
817
1892
  )}
818
- <span className="px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20">
819
- {flowLinks.length} active links
820
- </span>
1893
+ {/* Round 42 / Loop: extend active-links chip with the timestamp
1894
+ of the most-recent flow event. Tells the operator at a glance
1895
+ whether the topology is currently humming (last 30s) or has
1896
+ been quiet for a while — the visual flow particles and
1897
+ edge brightness only show that there IS traffic, not when
1898
+ the last one was. Reuses Round 38's relativeAgo. */}
1899
+ {(() => {
1900
+ const recent = flowLinks.reduce<number | null>((acc, l) => {
1901
+ if (!l.last_at) return acc;
1902
+ const t = parseHubTime(l.last_at);
1903
+ if (t === null) return acc;
1904
+ return acc === null || t > acc ? t : acc;
1905
+ }, null);
1906
+ const rel = recent !== null ? relativeAgo(new Date(recent).toISOString()) : null;
1907
+ // R114: tooltip lists the actual flows. Closes the
1908
+ // info-density sweep on the last chip-row hover surface
1909
+ // (R97-R113 covered everything else). Format:
1910
+ // "alpha→beta (3), gamma→delta (1) — hover brightens all"
1911
+ // Truncates at 6 flows with "+N more" so a busy fleet
1912
+ // doesn't paint a tall tooltip; the recent-signal panel
1913
+ // already shows the top 3 in detail.
1914
+ const flowList = flowLinks
1915
+ .slice(0, 6)
1916
+ .map(l => `${l.from}→${l.to} (${l.count})`)
1917
+ .join(', ');
1918
+ const flowSuffix = flowLinks.length > 6 ? ` + ${flowLinks.length - 6} more` : '';
1919
+ // R136: the chip already had cursor:pointer when flowLinks
1920
+ // > 0 (line 1877) — but no onClick was wired. The cursor
1921
+ // lied; users got the affordance signal with no follow-
1922
+ // through. Wire it to /messages, mirroring R133's footer-
1923
+ // nav idiom. Hover (R77) keeps its semantic "preview all
1924
+ // flows on canvas"; click is the action "open the full
1925
+ // list". Two distinct gestures, both meaningful. The
1926
+ // tooltip grows a "click to open" tail when interactive.
1927
+ // Drop the chip out of click territory entirely when
1928
+ // flowLinks is empty — no flows = no list to open.
1929
+ const isInteractive = flowLinks.length > 0;
1930
+ const tooltip = !isInteractive
1931
+ ? undefined
1932
+ : `${flowList}${flowSuffix} — hover brightens all · click to open /messages`;
1933
+ return (
1934
+ <span
1935
+ className="hidden sm:inline px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20"
1936
+ data-active-links-chip
1937
+ data-active-links-flow-count={flowLinks.length}
1938
+ data-active-links-clickable={isInteractive ? 'true' : 'false'}
1939
+ title={tooltip}
1940
+ role={isInteractive ? 'link' : undefined}
1941
+ tabIndex={isInteractive ? 0 : undefined}
1942
+ style={{ cursor: isInteractive ? 'pointer' : undefined }}
1943
+ onMouseEnter={() => { if (isInteractive) setHoveredActiveLinks(true); }}
1944
+ onMouseLeave={() => setHoveredActiveLinks(false)}
1945
+ onClick={() => { if (isInteractive) router.push('/messages'); }}
1946
+ onKeyDown={(e) => {
1947
+ if (!isInteractive) return;
1948
+ if (e.key === 'Enter' || e.key === ' ') {
1949
+ e.preventDefault();
1950
+ router.push('/messages');
1951
+ }
1952
+ }}
1953
+ >
1954
+ {flowLinks.length} active link{flowLinks.length === 1 ? '' : 's'}
1955
+ {rel ? <span className="text-gray-500"> · last {rel}</span> : null}
1956
+ </span>
1957
+ );
1958
+ })()}
1959
+ <FreshnessChip sessions={sessions} />
821
1960
  </div>
822
1961
  </div>
823
1962
 
@@ -837,7 +1976,18 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
837
1976
  onPointerMove={onPointerMove}
838
1977
  onPointerUp={onPointerUp}
839
1978
  onPointerLeave={onPointerUp}
840
- style={{ cursor: 'grab', touchAction: 'none' }}
1979
+ // Round 41 / Loop: the reset-button title (R22) and the Help
1980
+ // overlay (R25) both advertise "double-click the canvas to
1981
+ // reset", but the handler was never actually wired. The text
1982
+ // was lying. Wire it here, guarded so dbl-clicking a node
1983
+ // (which would also trigger the SVG-level handler via event
1984
+ // bubbling) doesn't unexpectedly reset the view on the user.
1985
+ onDoubleClick={(e) => {
1986
+ const t = e.target as Element | null;
1987
+ if (t?.closest('g[data-node]')) return;
1988
+ resetView();
1989
+ }}
1990
+ style={{ cursor: isPanning ? 'grabbing' : 'grab', touchAction: 'none' }}
841
1991
  >
842
1992
  <defs>
843
1993
  <linearGradient id="topo-panel" x1="0" x2="1" y1="0" y2="1">
@@ -859,9 +2009,56 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
859
2009
  </feMerge>
860
2010
  </filter>
861
2011
  )}
862
- <marker id="topo-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse">
863
- <path d="M 0 0 L 10 5 L 0 10 z" fill={pal.arrowFill} />
864
- </marker>
2012
+ {/* R142 / Loop: drop-shadow filter for group-box hover-lift.
2013
+ Mirrors R135's panel hover-elevation idiom but applied
2014
+ at the per-group canvas level. R68 already gives a
2015
+ hovered/pinned group box a solid accent stroke; R142
2016
+ adds a soft outward shadow on top so the box visually
2017
+ "rises off the canvas" when selected — same visual
2018
+ vocabulary as the panels + the Overview KPI cards
2019
+ (R18). Theme-aware flood: darker shadow on cyber so
2020
+ it reads above the dark canvas, lighter for light
2021
+ theme. Bounding box of the group box is unchanged —
2022
+ filters only affect paint area, not bbox geometry, so
2023
+ the overlap-test invariant is preserved. */}
2024
+ <filter id="topo-groupbox-lift" x="-10%" y="-10%" width="120%" height="120%">
2025
+ <feDropShadow
2026
+ dx="0" dy="3" stdDeviation="4"
2027
+ floodColor={isLight ? '#0f172a' : '#000000'}
2028
+ floodOpacity={isLight ? 0.18 : 0.55}
2029
+ />
2030
+ </filter>
2031
+ {/* Round 16 / Loop: 3-tier flow-link arrow markers.
2032
+ The single marker had `markerUnits` defaulting to
2033
+ `strokeWidth`, so heavy edges (stroke=7) rendered 35-user-
2034
+ unit arrowheads — visually dominant, the head outweighed
2035
+ the line. Switching to `userSpaceOnUse` decouples arrow
2036
+ size from stroke; binning by count gives a clearer
2037
+ hierarchy than continuous linear scaling:
2038
+ s (count 1-2) → 12 user units
2039
+ m (count 3-4) → 16 user units (alias for `topo-arrow`)
2040
+ l (count 5+) → 22 user units
2041
+ `topo-arrow` stays bound to the medium tier so the legend
2042
+ swatch (line ~1500) renders without change. */}
2043
+ {[
2044
+ { id: 'topo-arrow-s', size: 12 },
2045
+ { id: 'topo-arrow', size: 16 },
2046
+ { id: 'topo-arrow-l', size: 22 },
2047
+ ].map(m => (
2048
+ <marker
2049
+ key={m.id}
2050
+ id={m.id}
2051
+ viewBox="0 0 10 10"
2052
+ refX="8"
2053
+ refY="5"
2054
+ markerWidth={m.size}
2055
+ markerHeight={m.size}
2056
+ markerUnits="userSpaceOnUse"
2057
+ orient="auto-start-reverse"
2058
+ >
2059
+ <path d="M 0 0 L 10 5 L 0 10 z" fill={pal.arrowFill} />
2060
+ </marker>
2061
+ ))}
865
2062
  {/* Round 45: radial radar sweep gradient — bright at center
866
2063
  (where it meets the hub) fading to leading edge. */}
867
2064
  <radialGradient id="topo-sweep" cx="0%" cy="50%" r="100%">
@@ -881,13 +2078,17 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
881
2078
  grid mode drops it so the concentric rings don't sit behind a
882
2079
  rectangular grid. */}
883
2080
  {layout === 'ring' && (<>
884
- <circle cx={cx} cy={cy} r="330" fill="url(#topo-radar)" />
2081
+ {/* R52: radar bg is pure decoration — drop its pointer events so
2082
+ the hub <g> under it (and any future inner-disk affordances)
2083
+ can receive clicks. Previously the r=330 disc intercepted
2084
+ the hub click outright. */}
2085
+ <circle cx={cx} cy={cy} r="330" fill="url(#topo-radar)" style={{ pointerEvents: 'none' }} />
885
2086
 
886
2087
  {/* Round 45: subtle star field — 24 deterministic dots scattered
887
2088
  across the canvas give the radar bg some depth. Skipped on
888
2089
  light theme so the white surface stays clean. */}
889
2090
  {!isLight && (
890
- <g opacity="0.5">
2091
+ <g opacity="0.5" style={{ pointerEvents: 'none' }}>
891
2092
  {Array.from({ length: 28 }).map((_, i) => {
892
2093
  // Deterministic pseudo-random scatter so positions are
893
2094
  // stable between renders (no JS hydration mismatch).
@@ -909,6 +2110,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
909
2110
  style={{
910
2111
  transformOrigin: `${cx}px ${cy}px`,
911
2112
  transformBox: 'view-box',
2113
+ pointerEvents: 'none',
912
2114
  }}
913
2115
  className="anet-topo-sweep"
914
2116
  opacity={isLight ? 0.7 : 1}
@@ -919,36 +2121,131 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
919
2121
  />
920
2122
  </g>
921
2123
 
922
- {/* radar rings */}
2124
+ {/* radar rings — pure decoration at fixed radii, independent of
2125
+ node positions so the radar aesthetic is preserved across tier
2126
+ changes. */}
923
2127
  {[90, 170, 250, 330].map(radius => (
924
2128
  <circle key={radius} cx={cx} cy={cy} r={radius} fill="none" stroke={pal.ringStroke} strokeWidth="1" opacity={isLight ? 0.6 : 0.35} />
925
2129
  ))}
926
2130
 
2131
+ {/* Round 54 / Loop: tier-radius guide rings. The radar rings above
2132
+ are decorative and don't match the actual tier radii nodes sit
2133
+ on (single 220 / dual 175,260 / triple 145,215,285). Drawing
2134
+ a faint dashed ring at each ACTIVE tier radius lets the eye
2135
+ anchor "this is the inner / outer ring" without inferring from
2136
+ node spacing. Picked based on online node count so only the
2137
+ tiers currently in use draw — empty tiers stay quiet. pointer-
2138
+ events:none so they never intercept hub or node clicks. The
2139
+ 0.7 stroke + dashed pattern reads as guide, not feature. */}
2140
+ {(() => {
2141
+ const tierRadii = onlineNodes.length > onlineTripleThreshold
2142
+ ? [onlineTripleInnerR, onlineTripleMidR, onlineTripleOuterR]
2143
+ : onlineNodes.length > onlineTierThreshold
2144
+ ? [onlineInnerRadius, onlineOuterRadius]
2145
+ : onlineNodes.length > 0
2146
+ ? [onlineRadius]
2147
+ : [];
2148
+ // Round 92 / Loop: tier-ring occupancy. R54 drew the guide
2149
+ // rings at fixed opacity regardless of how many nodes lived
2150
+ // on each tier. With pinned filters dimming most nodes to
2151
+ // 0.28, the ring at a deserted tier looked identical to a
2152
+ // crowded one — wasting a free piece of canvas. Count
2153
+ // online nodes whose hub-distance falls within ±15 px of
2154
+ // each ring (15 px = half the inter-tier gap, so each
2155
+ // node is assigned to exactly one ring). Empty tier → skip
2156
+ // entirely. Crowded tier → stronger opacity, says "look
2157
+ // here". Buckets so the ladder feels intentional, not
2158
+ // jittery as one node migrates between tiers.
2159
+ const occupancyOf = (r: number) => onlineNodes.reduce((acc, s) => {
2160
+ const p = nodePositions[s.alias];
2161
+ if (!p) return acc;
2162
+ const d = Math.hypot(p.x - cx, p.y - cy);
2163
+ return Math.abs(d - r) < 15 ? acc + 1 : acc;
2164
+ }, 0);
2165
+ // Round 93 / Loop: when any pin is active, tint the tier
2166
+ // rings to the legend accent so the spatial guide visually
2167
+ // shares the canvas's "filtered mode" colour. The chip
2168
+ // row already says WHICH filter is on (pills + letter
2169
+ // mirror); rings answering "we're filtered" reinforces
2170
+ // the state when the eye is on the canvas, not the chip
2171
+ // row. Composes cleanly with R92 occupancy — same opacity
2172
+ // bucket logic; just the stroke colour swaps.
2173
+ const anyPin = !!(pinnedStatus || pinnedGroup || pinnedVendor);
2174
+ const tierStroke = anyPin ? pal.legendAccent : pal.ringStroke;
2175
+ return tierRadii.map(r => {
2176
+ const n = occupancyOf(r);
2177
+ if (n === 0) return null;
2178
+ const bucket = n <= 2 ? 0 : n <= 6 ? 1 : 2;
2179
+ const opLight = [0.24, 0.36, 0.50][bucket];
2180
+ const opDark = [0.32, 0.46, 0.62][bucket];
2181
+ return (
2182
+ <circle
2183
+ key={`tier-${r}`}
2184
+ cx={cx} cy={cy} r={r}
2185
+ fill="none"
2186
+ stroke={tierStroke}
2187
+ strokeWidth="0.7"
2188
+ strokeDasharray="2 8"
2189
+ opacity={isLight ? opLight : opDark}
2190
+ style={{ pointerEvents: 'none', transition: 'stroke 200ms ease-out' }}
2191
+ data-tier-ring={r}
2192
+ data-tier-occupancy={n}
2193
+ data-tier-bucket={bucket}
2194
+ data-tier-tinted={anyPin ? 'true' : 'false'}
2195
+ />
2196
+ );
2197
+ });
2198
+ })()}
2199
+
927
2200
  {/* Round 50: 4 small particles slowly orbiting the outer ring
928
2201
  (r=330). Each starts at a different angle (offset 0/0.25/0.5/0.75
929
2202
  of the cycle) so they're evenly spaced. 16s per revolution is
930
2203
  slow enough to feel ambient, not noisy. Skipped on light theme
931
- so the white surface stays clean. */}
932
- {!isLight && [0, 0.25, 0.5, 0.75].map((phase, i) => (
933
- <g key={`orbit-${i}`}>
934
- <circle
935
- cx={cx + 330} cy={cy}
936
- r={i === 0 ? 2.8 : 2.2}
937
- fill="#22d3ee"
938
- opacity={0.9}
939
- filter="url(#topo-glow)"
2204
+ so the white surface stays clean.
2205
+
2206
+ R131 / Loop: orbit period now buckets on workingCount,
2207
+ mirroring R84's hub-busyness breath cadence. An idle
2208
+ fleet keeps the original 16s "calm sweep"; as work
2209
+ accumulates the orbit subtly accelerates (capped at
2210
+ 10s so it never feels frantic). Two-layer motion
2211
+ coordination now: R84 breathes the hub, R131 spins
2212
+ the outer ring — both reading the same underlying
2213
+ "is the network busy" signal, both visible
2214
+ simultaneously without competing. Same bucket
2215
+ thresholds (0 / 1-2 / 3-5 / 6+) the R84 block uses
2216
+ at line ~2702 so the two cadences stay in sync if
2217
+ a future refactor shifts buckets. */}
2218
+ {!isLight && (() => {
2219
+ const busy = workingCount === 0 ? 0
2220
+ : workingCount <= 2 ? 1
2221
+ : workingCount <= 5 ? 2
2222
+ : 3;
2223
+ const dur = [16, 14, 12, 10][busy];
2224
+ return [0, 0.25, 0.5, 0.75].map((phase, i) => (
2225
+ <g
2226
+ key={`orbit-${i}`}
2227
+ data-topo-orbit-bucket={busy}
2228
+ data-topo-orbit-dur={dur}
940
2229
  >
941
- <animateTransform
942
- attributeName="transform"
943
- type="rotate"
944
- from={`${phase * 360} ${cx} ${cy}`}
945
- to={`${phase * 360 + 360} ${cx} ${cy}`}
946
- dur="16s"
947
- repeatCount="indefinite"
948
- />
949
- </circle>
950
- </g>
951
- ))}
2230
+ <circle
2231
+ cx={cx + 330} cy={cy}
2232
+ r={i === 0 ? 2.8 : 2.2}
2233
+ fill="#22d3ee"
2234
+ opacity={0.9}
2235
+ filter="url(#topo-glow)"
2236
+ >
2237
+ <animateTransform
2238
+ attributeName="transform"
2239
+ type="rotate"
2240
+ from={`${phase * 360} ${cx} ${cy}`}
2241
+ to={`${phase * 360 + 360} ${cx} ${cy}`}
2242
+ dur={`${dur}s`}
2243
+ repeatCount="indefinite"
2244
+ />
2245
+ </circle>
2246
+ </g>
2247
+ ));
2248
+ })()}
952
2249
 
953
2250
  {[0, 30, 60, 90, 120, 150].map(angle => (
954
2251
  <line
@@ -993,32 +2290,210 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
993
2290
  only — groupBoxes is empty in ring mode. Rendered behind the
994
2291
  flow links + nodes; pointer-events off so they never intercept
995
2292
  a node click. Restrained dashed container + group-name label. */}
996
- {groupBoxes.map(box => (
997
- <g key={`grp-${box.key}`} data-group={box.key} style={{ pointerEvents: 'none' }}>
998
- <rect
999
- x={box.x}
1000
- y={box.y}
1001
- width={box.w}
1002
- height={box.h}
1003
- rx="14"
1004
- fill={isLight ? '#0f172a' : '#a5b4fc'}
1005
- fillOpacity={isLight ? 0.025 : 0.045}
1006
- stroke={pal.ringStroke}
1007
- strokeWidth="1.5"
1008
- strokeDasharray="6 6"
1009
- />
1010
- <text
1011
- x={box.x + 12}
1012
- y={box.y + 14}
1013
- fill={pal.legendText}
1014
- fontSize="13"
1015
- fontFamily="monospace"
1016
- fontWeight="700"
2293
+ {groupBoxes.map(box => {
2294
+ const isHovered = activeGroup === box.key;
2295
+ // R68: distinguish "locked by click" from "currently hovered".
2296
+ // R63 made pinned and hovered identical (both hit isHovered
2297
+ // via activeGroup). A user with one team pinned should see at
2298
+ // a glance which is the locked one even while their cursor
2299
+ // sweeps elsewhere. isPinned reads pinnedGroup directly
2300
+ // (NOT activeGroup) so the visual is specific to the sticky
2301
+ // state transient hover keeps the R63 isHovered styling.
2302
+ const isPinned = pinnedGroup === box.key;
2303
+ // Round 18 / Loop: group-box hover linkage. The Round 8 fade
2304
+ // already dropped OUT-of-focus groups to 0.28, but the IN-focus
2305
+ // group sat at its baseline appearance — no positive emphasis.
2306
+ // Hovering now upgrades the box to an "accent" treatment:
2307
+ // solid stroke (not dashed), thicker, accent-coloured; brighter
2308
+ // text and slightly stronger fill. Label and box read as one
2309
+ // selected unit. Geometry unchanged → overlap test untouched.
2310
+ // R132: per-group marching-ants duration computed once,
2311
+ // reused on the data attribute + the inline custom property.
2312
+ const w = box.statuses.working;
2313
+ const marchDur = w >= 6 ? 8 : w >= 4 ? 10 : w >= 2 ? 12 : 14;
2314
+ return (
2315
+ <g
2316
+ key={`grp-${box.key}`}
2317
+ data-group={box.key}
2318
+ className="transition-opacity"
2319
+ // R63: drop the blanket pointerEvents:'none' that
2320
+ // previously sat here. Chrome's SVG impl doesn't let a
2321
+ // child override a parent's `none` even though the spec
2322
+ // says it should — moving the property onto just the
2323
+ // rect (where it's needed so nodes underneath stay
2324
+ // clickable) lets the label text receive its own click.
2325
+ style={{ opacity: !activeGroup || isHovered ? 1 : 0.28 }}
1017
2326
  >
1018
- {box.key}
1019
- </text>
1020
- </g>
1021
- ))}
2327
+ <rect
2328
+ x={box.x}
2329
+ y={box.y}
2330
+ width={box.w}
2331
+ height={box.h}
2332
+ rx="14"
2333
+ fill={isLight ? '#0f172a' : '#a5b4fc'}
2334
+ // R68: 3-tier opacity + stroke ladder.
2335
+ // pinned → fill 0.08 / 0.13, stroke 3 px (locked)
2336
+ // hovered → fill 0.05 / 0.09, stroke 2 px (inspecting)
2337
+ // idle → fill 0.025 / 0.045, stroke 1.5 px dashed
2338
+ fillOpacity={isPinned ? (isLight ? 0.08 : 0.13)
2339
+ : isHovered ? (isLight ? 0.05 : 0.09)
2340
+ : (isLight ? 0.025 : 0.045)}
2341
+ stroke={(isPinned || isHovered) ? pal.legendAccent : pal.ringStroke}
2342
+ strokeWidth={isPinned ? 3 : isHovered ? 2 : 1.5}
2343
+ strokeDasharray={(isPinned || isHovered) ? 'none' : '6 6'}
2344
+ data-group-box-pinned={isPinned ? 'true' : 'false'}
2345
+ // R85: ambient "marching ants" drift on the perimeter
2346
+ // when this group has at least one working member, and
2347
+ // neither pin nor hover is active (those treatments
2348
+ // already shout for attention via solid stroke). 12s
2349
+ // cycle reads as ambient — the eye parses "live work
2350
+ // here" without registering the box as animating.
2351
+ // R132: per-group ant rate buckets on box.statuses.working
2352
+ // — the same coupling-to-busyness idiom R84 uses for the
2353
+ // hub and R131 uses for the outer-ring orbit, applied at
2354
+ // the GROUP scale. A team with one working member ambles;
2355
+ // a team with five working members visibly accelerates.
2356
+ // Bucket boundaries (1 / 2-3 / 4-5 / 6+) chosen to land
2357
+ // on the same 14/12/10/8 cadence ladder so the three
2358
+ // motion layers (hub / ring / group) keep a coherent
2359
+ // tempo grammar. Default 12s when working=0 doesn't
2360
+ // matter — the className is only applied when working>0.
2361
+ data-group-box-live={!isPinned && !isHovered && box.statuses.working > 0 ? 'true' : 'false'}
2362
+ data-group-box-march-dur={marchDur}
2363
+ data-group-box-lifted={(isPinned || isHovered) ? 'true' : 'false'}
2364
+ className={!isPinned && !isHovered && box.statuses.working > 0 ? 'anet-topo-groupbox-live' : undefined}
2365
+ // R142: drop-shadow filter when pinned or hovered. Box
2366
+ // visually "rises off the canvas" — same vocabulary
2367
+ // R18 KPI cards + R135 overlay panels use. Idle group
2368
+ // boxes carry no filter (purely flat dashed outline)
2369
+ // so the unstyled canvas stays uncluttered. Filter
2370
+ // affects paint area only, not the geometric bbox
2371
+ // the overlap-test reads, so zero-overlap invariant
2372
+ // is preserved.
2373
+ filter={(isPinned || isHovered) ? 'url(#topo-groupbox-lift)' : undefined}
2374
+ style={{
2375
+ transition: 'stroke 200ms ease-out, stroke-width 200ms ease-out, fill-opacity 200ms ease-out, filter 200ms ease-out',
2376
+ pointerEvents: 'none',
2377
+ // CSS var consumed by `.anet-topo-groupbox-live`
2378
+ // (line 877 of globals.css). React's CSSProperties
2379
+ // type doesn't model custom properties, so cast
2380
+ // through Record<string, string>.
2381
+ ...({['--march-dur']: `${marchDur}s`} as Record<string, string>),
2382
+ }}
2383
+ />
2384
+ {/* R63: wrap label in a clickable <g> with an invisible
2385
+ rect hitbox. The text alone wasn't getting hit-tested
2386
+ reliably — the SVG-wide topo-panel <rect> intercepts
2387
+ at the label's screen position when the label sits at
2388
+ a high viewBox-y (it lands below where the compositor
2389
+ expects the text to paint on top, same gotcha as the
2390
+ recent-signal panel rows in R56). Hitbox rect + the
2391
+ parent <g> taking the click + onPointerDown stop-
2392
+ propagation match the R55/R56/R61 pattern. */}
2393
+ <g
2394
+ role="button"
2395
+ tabIndex={0}
2396
+ aria-pressed={pinnedGroup === box.key}
2397
+ data-group-label-hit={box.key}
2398
+ style={{ pointerEvents: 'all', cursor: 'pointer' }}
2399
+ onPointerDown={(e) => e.stopPropagation()}
2400
+ onClick={() => setPinnedGroup(prev => prev === box.key ? null : box.key)}
2401
+ // R86: hover the label → transient group focus. Releases
2402
+ // on leave; activeGroup = hoveredGroup ?? pinnedGroup
2403
+ // formula already handles transient-over-pin so a
2404
+ // user can spot-compare teams without losing their
2405
+ // pinned one. Closes the same R83-style hover/click
2406
+ // gap (segments) — now group labels carry it too.
2407
+ onPointerEnter={() => setHoveredGroupLabel(box.key)}
2408
+ onPointerLeave={() => setHoveredGroupLabel(prev => prev === box.key ? null : prev)}
2409
+ >
2410
+ {/* R99: SVG <title> tooltip listing group members +
2411
+ status breakdown. Same info-density spirit as
2412
+ R97 pill tooltips + R98 node tooltips — anywhere
2413
+ a UI element says "alpha · 3" should hover-
2414
+ explain WHICH 3. Truncates at 8 aliases with a
2415
+ "+N more" suffix so a 20-member band doesn't
2416
+ paint a 22-line tooltip. */}
2417
+ {(() => {
2418
+ const members = Object.entries(groupKeys)
2419
+ .filter(([, key]) => key === box.key)
2420
+ .map(([alias]) => alias);
2421
+ const memberPreview = members.slice(0, 8).join(', ');
2422
+ const suffix = members.length > 8 ? ` + ${members.length - 8} more` : '';
2423
+ const statusSummary = [
2424
+ box.statuses.working > 0 ? `${box.statuses.working} working` : null,
2425
+ box.statuses.idle > 0 ? `${box.statuses.idle} idle` : null,
2426
+ box.statuses.offline > 0 ? `${box.statuses.offline} offline` : null,
2427
+ ].filter(Boolean).join(' · ');
2428
+ return (
2429
+ <title>{[
2430
+ `${box.key} (${members.length} member${members.length === 1 ? '' : 's'})`,
2431
+ statusSummary || null,
2432
+ `${memberPreview}${suffix}`,
2433
+ pinnedGroup === box.key ? 'click to release pin' : 'click to pin this group',
2434
+ ].filter(Boolean).join('\n')}</title>
2435
+ );
2436
+ })()}
2437
+ <rect
2438
+ x={box.x + 6}
2439
+ y={box.y + 2}
2440
+ width={Math.min(box.w - 12, 240)}
2441
+ height={20}
2442
+ rx="4"
2443
+ /* R107 / Loop: list-item tint extends to the SVG
2444
+ group labels — same idiom R104 added to recent-
2445
+ signal rows and R105 to the legend rows. The
2446
+ tint colour is pal.legendAccent (cyan) since
2447
+ groups don't carry an inherent swatch the way
2448
+ legend rows do; this matches R68's group-box
2449
+ isPinned/isHovered accent stroke for consistency.
2450
+ hover < pinned opacity so locked vs preview is
2451
+ discriminable at a glance. */
2452
+ fill={pinnedGroup === box.key || hoveredGroupLabel === box.key ? pal.legendAccent : 'transparent'}
2453
+ opacity={pinnedGroup === box.key ? (isLight ? 0.16 : 0.20)
2454
+ : hoveredGroupLabel === box.key ? (isLight ? 0.09 : 0.13)
2455
+ : 1}
2456
+ data-group-label-tinted={pinnedGroup === box.key ? 'pinned' : hoveredGroupLabel === box.key ? 'hover' : 'none'}
2457
+ style={{ transition: 'fill 150ms ease-out, opacity 150ms ease-out' }}
2458
+ />
2459
+ <text
2460
+ x={box.x + 12}
2461
+ y={box.y + 14}
2462
+ fill={isHovered ? pal.legendHeadline : pal.legendText}
2463
+ fontSize="13"
2464
+ fontFamily="monospace"
2465
+ fontWeight="700"
2466
+ style={{ transition: 'fill 200ms ease-out' }}
2467
+ data-group-label={box.key}
2468
+ >
2469
+ {box.key}
2470
+ {/* Round 19 / Loop: member-count chip. Inline tspan stays
2471
+ in the single <text> bbox the overlap test reads, so
2472
+ the node↔label guard still catches if the chip ever
2473
+ pushes the label far enough right to clip a node.
2474
+ Smaller + lighter weight reads as metadata, not name. */}
2475
+ <tspan dx="6" fill={pal.legendText} fontSize="11" fontWeight="400">· {box.count}</tspan>
2476
+ {/* Round 58 / Loop: status mix pip strip. Compact text-
2477
+ based chips (e.g. "2w 1i") so the strip stays inside
2478
+ the same <text> bbox the overlap-test reads — keeps
2479
+ the R27 label↔label and R19 node↔label guards intact.
2480
+ Each tier is colour-coded against the legend swatches
2481
+ and only renders when count > 0, so a healthy all-
2482
+ working group reads simply " · 2w". */}
2483
+ {box.statuses.working > 0 && (
2484
+ <tspan dx="8" fill={isLight ? '#059669' : '#22c55e'} fontSize="11" fontWeight="600">{box.statuses.working}w</tspan>
2485
+ )}
2486
+ {box.statuses.idle > 0 && (
2487
+ <tspan dx="4" fill={isLight ? '#0d9488' : '#2dd4bf'} fontSize="11" fontWeight="600">{box.statuses.idle}i</tspan>
2488
+ )}
2489
+ {box.statuses.offline > 0 && (
2490
+ <tspan dx="4" fill={isLight ? '#94a3b8' : '#6b7280'} fontSize="11" fontWeight="600">{box.statuses.offline}o</tspan>
2491
+ )}
2492
+ </text>
2493
+ </g>
2494
+ </g>
2495
+ );
2496
+ })}
1022
2497
 
1023
2498
  {/* directed message flows */}
1024
2499
  {flowLinks.map((link, index) => {
@@ -1036,17 +2511,111 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1036
2511
  const path = curvePath(from, to, lift);
1037
2512
  const width = Math.min(2 + link.count, 7);
1038
2513
  const duration = Math.max(0.9, 2.6 / Math.sqrt(link.count));
2514
+ // Round 10 / Loop: freshness fade. An edge that fired ≤30s ago
2515
+ // stays at full intensity; over 5 minutes it decays to ~35%.
2516
+ // Surfaces "what's happening now" vs background chatter without
2517
+ // hiding old flow entirely (some context still useful). `now`
2518
+ // captured at useMemo-recompute time (every 5s message refresh)
2519
+ // — accuracy is within the poll interval, plenty.
2520
+ const ageMs = link.last_at ? Math.max(0, Date.now() - Date.parse(link.last_at)) : 0;
2521
+ const fresh = Math.max(0.35, 1 - ageMs / (5 * 60 * 1000));
2522
+ // Round 16 arrow-tier binning — keep `topo-arrow` as the
2523
+ // medium tier id so the legend swatch picks it up unchanged.
2524
+ const arrowId = link.count <= 2 ? 'topo-arrow-s'
2525
+ : link.count <= 4 ? 'topo-arrow'
2526
+ : 'topo-arrow-l';
1039
2527
 
2528
+ // Round 39 / Loop: edge hover tooltip — surface the same
2529
+ // last_at + count info the freshness fade and arrow tier
2530
+ // already encode visually, in plain text. The stroke is the
2531
+ // hover target; SVG `<title>` honours newlines on every
2532
+ // browser the dashboard targets.
2533
+ const lastAt = relativeAgo(link.last_at);
2534
+ const tooltip = `${link.from} → ${link.to}\n${link.count} message${link.count === 1 ? '' : 's'}${lastAt ? ` · last ${lastAt}` : ''}`;
2535
+ // Round 40 / Loop: edges follow node hover — when an alias is
2536
+ // hovered, every edge touching it brightens, the rest fade.
2537
+ // Pairs with the Round 8 group-focus fade on nodes: hover a
2538
+ // node to find "who is this agent talking to" at a glance.
2539
+ // No hover → multiplier is 1.0 (current behaviour preserved).
2540
+ // Round 50 / Loop: edge-on-self priority. When the user hovers
2541
+ // a flow edge directly (R48 widened the hitbox so this is now
2542
+ // a precise gesture), THAT edge gets the strongest boost (2.0)
2543
+ // and every other edge dims to 0.35. Node-hover (R40) keeps
2544
+ // its own ladder. Edge-hover and node-hover are mutually
2545
+ // exclusive in practice — the cursor is over one or the
2546
+ // other — but the order below makes edge-hover win if both
2547
+ // ever read truthy at the same React tick.
2548
+ // Round 53 / Loop: in-group edges follow team focus. R40
2549
+ // brightened only edges touching the exact hovered alias —
2550
+ // but with R8/R18 prefix-clustering, a user hovering one
2551
+ // member is asking about the team. So when BOTH endpoints of
2552
+ // an edge share the hoveredGroup (and neither is the exact
2553
+ // hovered alias — that gets the stronger 1.7×), the edge
2554
+ // boosts to 1.3×. Edges leaving the team (one endpoint in,
2555
+ // one out) still dim to 0.35× per R40 since they read as
2556
+ // background to the focus. Singletons fall through unchanged
2557
+ // (their group key is the alias itself, so bothInHoveredGroup
2558
+ // is impossible for a non-self-edge).
2559
+ // R116: composes hover ?? pin — a pinned edge stays "hot" after the cursor leaves.
2560
+ const isHoveredEdge = activeEdgeKey === link.key;
2561
+ const fromGroup = groupKeys[link.from] ?? link.from;
2562
+ const toGroup = groupKeys[link.to] ?? link.to;
2563
+ const bothInHoveredGroup = !!activeGroup && fromGroup === activeGroup && toGroup === activeGroup;
2564
+ // R63: also gate "no filter" on activeGroup so pinnedGroup
2565
+ // alone activates the in-group 1.3× boost + non-group dim.
2566
+ // When neither a node nor a group is in focus, mul is 1.
2567
+ // R77: when the user hovers the "N active links" chip, the
2568
+ // baseline 1× becomes 1.5× — every flow brightens at once.
2569
+ // Sits inside the no-other-hover branch so it doesn't fight
2570
+ // the edge-hover (2.0×) or node-hover (1.7×) priorities.
2571
+ const edgeOpacityMul = isHoveredEdge
2572
+ ? 2.0
2573
+ : activeEdgeKey
2574
+ ? 0.35
2575
+ : !hoveredAlias && !activeGroup
2576
+ ? (hoveredActiveLinks ? 1.5 : 1)
2577
+ : (link.from === hoveredAlias || link.to === hoveredAlias)
2578
+ ? 1.7
2579
+ : bothInHoveredGroup
2580
+ ? 1.3
2581
+ : 0.35;
2582
+ // Round 50: the hovered edge also visibly thickens so the eye
2583
+ // tracks it even at low message counts (width was 3 → 4.5 on
2584
+ // hover). 1.4× is enough to read as "lifted" without
2585
+ // breaching the 16-px hitbox bound.
2586
+ const renderWidth = isHoveredEdge ? Math.min(width * 1.4, 10) : width;
1040
2587
  return (
1041
2588
  <g key={link.key}>
2589
+ {/* Round 48 / Loop: invisible hover hitbox — visible flow
2590
+ path is 3-7 px wide and damn hard to hover precisely.
2591
+ Stack a transparent 16-px-wide stroke behind it so the
2592
+ cursor only needs to be ~8 px from the line for the
2593
+ tooltip to fire. Native <title> moves here; the
2594
+ visible path no longer needs it. pointer-events on
2595
+ the visible path drop to "none" since the hitbox
2596
+ owns the hover surface. */}
2597
+ <path
2598
+ d={path}
2599
+ fill="none"
2600
+ stroke="transparent"
2601
+ strokeWidth={Math.max(width + 10, 16)}
2602
+ style={{ pointerEvents: 'stroke' }}
2603
+ data-edge-hitbox
2604
+ onMouseEnter={() => setHoveredEdgeKey(link.key)}
2605
+ onMouseLeave={() => setHoveredEdgeKey(prev => prev === link.key ? null : prev)}
2606
+ >
2607
+ <title>{tooltip}</title>
2608
+ </path>
1042
2609
  <path
1043
2610
  d={path}
1044
2611
  fill="none"
1045
2612
  stroke={pal.flowEdge}
1046
- strokeWidth={width}
1047
- opacity={isLight ? 0.22 : 0.28}
2613
+ strokeWidth={renderWidth}
2614
+ opacity={Math.min(1, (isLight ? 0.22 : 0.28) * fresh * edgeOpacityMul)}
1048
2615
  filter={isLight ? undefined : 'url(#topo-glow)'}
1049
- markerEnd="url(#topo-arrow)"
2616
+ markerEnd={`url(#${arrowId})`}
2617
+ className="transition-opacity duration-300"
2618
+ style={{ pointerEvents: 'none' }}
1050
2619
  />
1051
2620
  <path
1052
2621
  id={`flow-path-${index}`}
@@ -1055,45 +2624,344 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1055
2624
  stroke={pal.flowPath}
1056
2625
  strokeWidth="1"
1057
2626
  strokeDasharray="2 12"
1058
- opacity={isLight ? 0.4 : 0.75}
2627
+ opacity={Math.min(1, (isLight ? 0.4 : 0.75) * fresh * edgeOpacityMul)}
2628
+ className="transition-opacity duration-300"
1059
2629
  />
1060
- <circle r="4" fill={pal.flowParticle} filter={isLight ? undefined : 'url(#topo-glow)'}>
1061
- <animateMotion dur={`${duration}s`} repeatCount="indefinite" path={path} />
1062
- </circle>
2630
+ {!reducedMotion && (
2631
+ /* Round 103 / Loop: phase-stagger the particles so
2632
+ concurrent edges don't pulse in lockstep. SMIL
2633
+ `begin` accepts negative offsets to shift the cycle
2634
+ backwards in time, which means the particle starts
2635
+ mid-flight on first paint — no visible "all
2636
+ particles spawn from source simultaneously" tell.
2637
+ `(index * 0.37) % duration` gives a deterministic,
2638
+ well-distributed offset (the golden-ratio-ish 0.37
2639
+ fraction prevents lining up when N is a small
2640
+ multiple). Edge order is stable (sorted by recent
2641
+ activity), so the offsets feel calm rather than
2642
+ reshuffling each refresh. */
2643
+ <circle r="4" fill={pal.flowParticle} filter={isLight ? undefined : 'url(#topo-glow)'} opacity={Math.min(1, fresh * edgeOpacityMul)}>
2644
+ <animateMotion
2645
+ dur={`${duration}s`}
2646
+ begin={`-${((index * 0.37) % duration).toFixed(3)}s`}
2647
+ repeatCount="indefinite"
2648
+ path={path}
2649
+ />
2650
+ </circle>
2651
+ )}
2652
+ {/* Round 75 / Loop: arrival ping at the destination. The
2653
+ particle currently fades into the arrow marker
2654
+ silently — adding a small radiating ring synchronised
2655
+ to the particle's period turns message delivery into
2656
+ a visible event. begin = -dur*0.92 offsets the
2657
+ animation so the ring expands NEAR the end of each
2658
+ cycle (≈when the particle arrives). Gated by
2659
+ reducedMotion and on fresh > 0.5 — stale edges that
2660
+ haven't fired in minutes don't need the eye-grab.
2661
+ data-arrival-ping for testability. */}
2662
+ {!reducedMotion && fresh > 0.5 && (
2663
+ <circle
2664
+ cx={to.x}
2665
+ cy={to.y}
2666
+ r="0"
2667
+ fill="none"
2668
+ stroke={pal.flowEdge}
2669
+ strokeWidth="1.5"
2670
+ opacity="0"
2671
+ style={{ pointerEvents: 'none' }}
2672
+ data-arrival-ping={link.key}
2673
+ >
2674
+ <animate attributeName="r" values="0;14;22" dur={`${duration}s`} begin={`-${(duration * 0.92).toFixed(2)}s`} repeatCount="indefinite" />
2675
+ <animate attributeName="opacity" values="0;0.55;0" dur={`${duration}s`} begin={`-${(duration * 0.92).toFixed(2)}s`} repeatCount="indefinite" />
2676
+ </circle>
2677
+ )}
2678
+ {/* Round 76 / Loop: source dispatch pulse — mirror to the
2679
+ R75 arrival ping. begin = 0s (start of cycle) so the
2680
+ ring expands as the particle LEAVES the source. Only
2681
+ fires for high-traffic edges (link.count >= 3) — on
2682
+ quiet conversations the canvas should stay calm; on
2683
+ busy senders the pulse plus arrival ping bookend
2684
+ every message in flight, making the topology feel
2685
+ alive. Same fresh/reducedMotion gates as R75. Slightly
2686
+ smaller radius (0→12→18 vs R75's 0→14→22) so the
2687
+ source reads as "smaller event than arrival" — the
2688
+ destination is the meaningful endpoint. */}
2689
+ {!reducedMotion && fresh > 0.5 && link.count >= 3 && (
2690
+ <circle
2691
+ cx={from.x}
2692
+ cy={from.y}
2693
+ r="0"
2694
+ fill="none"
2695
+ stroke={pal.flowEdge}
2696
+ strokeWidth="1.5"
2697
+ opacity="0"
2698
+ style={{ pointerEvents: 'none' }}
2699
+ data-dispatch-pulse={link.key}
2700
+ >
2701
+ <animate attributeName="r" values="0;12;18" dur={`${duration}s`} begin="0s" repeatCount="indefinite" />
2702
+ <animate attributeName="opacity" values="0;0.45;0" dur={`${duration}s`} begin="0s" repeatCount="indefinite" />
2703
+ </circle>
2704
+ )}
2705
+ {/* Round 100 / Loop: midpoint count badge for high-
2706
+ traffic edges. Width already gauges intensity but
2707
+ "5 vs 12" is hard to read off stroke alone. Render
2708
+ a compact pill at the bezier midpoint (t=0.5 →
2709
+ midpoint + perpendicular × lift/2) showing the
2710
+ integer count. Threshold link.count >= 3 keeps
2711
+ the canvas quiet for sparse traffic. Bezier
2712
+ midpoint math: for a quadratic curve M A Q C B,
2713
+ the t=0.5 point is (A + 2C + B) / 4, which
2714
+ simplifies to (midAB) + 0.5 × (control - midAB)
2715
+ = midAB + perpendicular × lift/2. */}
2716
+ {link.count >= 3 && (() => {
2717
+ const midX = (from.x + to.x) / 2;
2718
+ const midY = (from.y + to.y) / 2;
2719
+ const dx = to.x - from.x;
2720
+ const dy = to.y - from.y;
2721
+ const len = Math.hypot(dx, dy) || 1;
2722
+ const badgeX = midX + (-dy / len) * lift * 0.5;
2723
+ const badgeY = midY + ( dx / len) * lift * 0.5;
2724
+ const badgeOpacity = Math.min(1, fresh * edgeOpacityMul);
2725
+ /* R121: the badge becomes a canvas-side click-to-pin
2726
+ affordance. R100 introduced it as a passive count
2727
+ display; R116 added pinnedEdgeKey. Joining them
2728
+ lets users pin a flow directly from the canvas
2729
+ without crossing to the recent-signal panel.
2730
+ pointerEvents move from 'none' to 'all' on the
2731
+ wrapper <g>; the underlying R48 edge hitbox is
2732
+ wider (16 px) than the 18-px badge diameter so
2733
+ clicks landing on either still route correctly
2734
+ — the badge consumes its small footprint, the
2735
+ hitbox owns the rest. stopPropagation on
2736
+ pointerdown so the SVG pan capture doesn't
2737
+ redirect the click. */
2738
+ const isPinned = pinnedEdgeKey === link.key;
2739
+ // R126: hot-edge accent. The edge stroke width (line
2740
+ // 2344) already scales with count but clamps at 7 —
2741
+ // so count=5 and count=50 look identical at the line,
2742
+ // and the only signal differentiating them is the
2743
+ // integer in the badge. Bucket count into a "hot"
2744
+ // band (≥ 10) and flip the badge stroke to a warmer
2745
+ // tone + thicker ring so busy lanes telegraph at a
2746
+ // glance without reading the digit. Reuses the amber
2747
+ // family from R125 (chip empty-state) — semantic is
2748
+ // "draw the eye here"; R125 amber is in the chip row
2749
+ // above the SVG, R126 amber is on the canvas, so the
2750
+ // surfaces never compete in the same eye-sweep. Pin
2751
+ // still wins (uses legendHeadline) so a pinned hot
2752
+ // edge reads as "locked + busy" via the badge text
2753
+ // and edge brightness, not via a third stroke colour.
2754
+ const isHot = link.count >= 10;
2755
+ const hotStroke = isLight ? '#d97706' : '#fbbf24';
2756
+ return (
2757
+ <g
2758
+ data-edge-count-badge={link.key}
2759
+ data-edge-count-badge-pinned={isPinned ? 'true' : 'false'}
2760
+ data-edge-count-badge-hot={isHot ? 'true' : 'false'}
2761
+ role="button"
2762
+ tabIndex={0}
2763
+ aria-pressed={isPinned}
2764
+ style={{ pointerEvents: 'all', cursor: 'pointer' }}
2765
+ opacity={badgeOpacity}
2766
+ onPointerDown={(e) => e.stopPropagation()}
2767
+ // R122: badge hover propagates to hoveredEdgeKey so
2768
+ // moving the cursor onto the badge lights the
2769
+ // same endpoint rings + edge brighten as hovering
2770
+ // the line. R121 only wired click; the badge sat
2771
+ // visually separate from the line on hover,
2772
+ // which felt like two surfaces rather than one.
2773
+ onMouseEnter={() => setHoveredEdgeKey(link.key)}
2774
+ onMouseLeave={() => setHoveredEdgeKey(prev => prev === link.key ? null : prev)}
2775
+ onClick={(e) => {
2776
+ e.stopPropagation();
2777
+ setPinnedEdgeKey(prev => prev === link.key ? null : link.key);
2778
+ }}
2779
+ onKeyDown={(e) => {
2780
+ if (e.key === 'Enter' || e.key === ' ') {
2781
+ e.preventDefault();
2782
+ setPinnedEdgeKey(prev => prev === link.key ? null : link.key);
2783
+ }
2784
+ }}
2785
+ >
2786
+ <title>{isPinned
2787
+ ? `${link.from} → ${link.to} (${link.count}) — click to release pin`
2788
+ : `${link.from} → ${link.to} (${link.count}) — click to pin`}</title>
2789
+ <circle
2790
+ cx={badgeX} cy={badgeY} r="9"
2791
+ fill={pal.legendBox.fill}
2792
+ stroke={isPinned ? pal.legendHeadline : isHot ? hotStroke : pal.flowEdge}
2793
+ strokeWidth={isPinned ? 2 : isHot ? 2 : 1}
2794
+ opacity={isLight ? 0.95 : 0.82}
2795
+ />
2796
+ <text
2797
+ x={badgeX} y={badgeY + 3}
2798
+ textAnchor="middle"
2799
+ fill={pal.legendHeadline}
2800
+ fontSize="10"
2801
+ fontFamily="monospace"
2802
+ fontWeight="700"
2803
+ style={{ pointerEvents: 'none' }}
2804
+ >{link.count}</text>
2805
+ </g>
2806
+ );
2807
+ })()}
1063
2808
  </g>
1064
2809
  );
1065
2810
  })}
1066
2811
 
1067
- {/* center hub — round 39: enlarged from r=6 (12px) to r=10 (20px)
1068
- core so the "control plane" reads as the network's anchor,
1069
- not a stray particle. Static halo ring at r=18 grounds it
1070
- visually; two outward pulses keep the "signal source" idea
1071
- from r17. Light theme gets a paler core to avoid hot-spotting
1072
- the bg. */}
1073
- {layout === 'ring' && (<g>
1074
- {/* static grounding halo sits underneath, low opacity */}
1075
- <circle
1076
- cx={cx} cy={cy} r="18"
1077
- fill={isLight ? '#d1fae5' : '#10b981'}
1078
- opacity={isLight ? 0.35 : 0.10}
1079
- />
1080
- {/* outer pulse 1 */}
1081
- <circle cx={cx} cy={cy} r="10" fill="none" stroke="#10b981" strokeWidth="1.5">
1082
- <animate attributeName="r" values="10;38;10" dur="2.4s" repeatCount="indefinite" />
1083
- <animate attributeName="opacity" values="0.55;0;0.55" dur="2.4s" repeatCount="indefinite" />
1084
- </circle>
1085
- {/* outer pulse 2 (delayed 1.2s) */}
1086
- <circle cx={cx} cy={cy} r="10" fill="none" stroke="#10b981" strokeWidth="1.5" opacity="0">
1087
- <animate attributeName="r" values="10;38;10" dur="2.4s" begin="1.2s" repeatCount="indefinite" />
1088
- <animate attributeName="opacity" values="0.45;0;0.45" dur="2.4s" begin="1.2s" repeatCount="indefinite" />
1089
- </circle>
2812
+ {/* center hub — round 39 sized + round 13 restraint.
2813
+ The hub is the control-plane anchor. r39 gave it two outward
2814
+ pulses (r 10→38, 2.4s, double-phase) which read as "loudest
2815
+ node in the room" wrong semantics: anchors don't emit,
2816
+ they hold. r13 swaps the kinetic pulse for a slow opacity
2817
+ breath on the static halo (4s, ±15% from base), so the hub
2818
+ stays alive without throwing kinetic energy outward. The
2819
+ dual-circle "lit lamp" core is unchanged. */}
2820
+ {layout === 'ring' && (<g
2821
+ data-topo-hub
2822
+ data-topo-hub-hovered={hoveredHub ? 'true' : 'false'}
2823
+ style={{ cursor: 'pointer' }}
2824
+ // Stop pointerdown from reaching the SVG pan handler — same
2825
+ // reason as the node <g>: a captured pointer makes Chromium
2826
+ // fire the follow-up click on the SVG, not this group.
2827
+ onPointerDown={(e) => e.stopPropagation()}
2828
+ onMouseEnter={() => setHoveredHub(true)}
2829
+ onMouseLeave={() => setHoveredHub(false)}
2830
+ // Round 52 / Loop: hub is the visual anchor but had no click
2831
+ // action users discovered fit-to-content only via the `f`
2832
+ // key or the chrome button. Wire the hub to fitView() so the
2833
+ // most prominent element in the canvas is also the "re-
2834
+ // center" affordance. A click-ripple keyed by ts confirms
2835
+ // the gesture; the hub <title> now ends with a hint.
2836
+ onClick={() => {
2837
+ fitView();
2838
+ setClickRipple({ ts: Date.now(), x: cx, y: cy, r0: 18, color: isLight ? '#059669' : '#10b981' });
2839
+ setTimeout(() => setClickRipple(prev => prev && prev.x === cx && prev.y === cy ? null : prev), 600);
2840
+ }}
2841
+ >
2842
+ {/* Round 43 / Loop: hub `<title>` summary — hovering the
2843
+ central glow now answers "what is this?" with a one-line
2844
+ fleet snapshot. Duplicates the header chips by design;
2845
+ hovering the most visually prominent element is the
2846
+ most natural impulse, so satisfy it where the cursor
2847
+ already is. Falls clean: omits sub-clauses when their
2848
+ counts are zero. R52 appends a "click to fit view" hint.
2849
+ */}
2850
+ <title>{(() => {
2851
+ const total = sessions.length;
2852
+ const parts = [`Network hub`, `${total} session${total === 1 ? '' : 's'}`];
2853
+ if (onlineNodes.length > 0) parts.push(`${onlineNodes.length} online`);
2854
+ if (workingCount > 0) parts.push(`${workingCount} working`);
2855
+ if (flowLinks.length > 0) parts.push(`${flowLinks.length} active link${flowLinks.length === 1 ? '' : 's'}`);
2856
+ return parts.join(' · ') + '\nclick to fit view';
2857
+ })()}</title>
2858
+ {/* grounding halo — breathes in opacity, no expansion.
2859
+ R84: breath amplitude + tempo reflect workingCount. An
2860
+ idle fleet keeps the original gentle 0.32→0.52 (light) /
2861
+ 0.08→0.16 (dark) cycle over 4s — "heart at rest". As
2862
+ working sessions accumulate, the peak climbs and the
2863
+ period shortens, capped at 2.4s so it never feels
2864
+ manic. Quiet fleets see zero change; busy fleets feel
2865
+ the canvas working. */}
2866
+ {(() => {
2867
+ // Bucket workingCount to keep the visual feedback discrete
2868
+ // rather than continuous: 0 / 1-2 / 3-5 / 6+. Three buckets
2869
+ // are enough — finer gradations are imperceptible.
2870
+ const busy = workingCount === 0 ? 0
2871
+ : workingCount <= 2 ? 1
2872
+ : workingCount <= 5 ? 2
2873
+ : 3;
2874
+ const peakLight = [0.52, 0.58, 0.65, 0.72][busy];
2875
+ const peakDark = [0.16, 0.20, 0.26, 0.32][busy];
2876
+ const troughLight = 0.32;
2877
+ const troughDark = 0.08;
2878
+ const dur = [4.0, 3.2, 2.7, 2.4][busy];
2879
+ const valuesLight = `${troughLight};${peakLight};${troughLight}`;
2880
+ const valuesDark = `${troughDark};${peakDark};${troughDark}`;
2881
+ return (
2882
+ <circle
2883
+ cx={cx} cy={cy} r="18"
2884
+ fill={isLight ? '#d1fae5' : '#10b981'}
2885
+ opacity={isLight ? 0.42 : 0.12}
2886
+ data-hub-busyness={busy}
2887
+ >
2888
+ {!reducedMotion && (
2889
+ <animate
2890
+ attributeName="opacity"
2891
+ values={isLight ? valuesLight : valuesDark}
2892
+ dur={`${dur}s`}
2893
+ repeatCount="indefinite"
2894
+ />
2895
+ )}
2896
+ </circle>
2897
+ );
2898
+ })()}
1090
2899
  {/* core — 20px diameter, larger inner highlight reads as a "lit lamp" */}
1091
2900
  <circle cx={cx} cy={cy} r="10" fill={isLight ? '#059669' : '#10b981'} />
1092
- <circle cx={cx} cy={cy} r="5" fill="#d1fae5" opacity="0.9" />
2901
+ {/* R130 / Loop: when workingCount > 0, the decorative inner
2902
+ highlight gets replaced with the workingCount digit. The
2903
+ R84 busyness breath already encodes the same metric
2904
+ through motion — adding the digit gives it a second
2905
+ visual channel right at the canvas's focal point. A
2906
+ user glancing at the hub now sees both "the network is
2907
+ pulsing" (motion) AND "3 agents are working" (digit)
2908
+ without having to scan the chip row or panels.
2909
+
2910
+ Geometry: text at (cx, cy) with fontSize 11 monospace
2911
+ + fontWeight 700 sits inside the r=10 core (a 2-digit
2912
+ 12 reads ~12 px wide × 11 px tall, well inside the
2913
+ 20-px diameter core). Centered vertically via dy=
2914
+ "0.36em" — the standard SVG trick for text-vertical-
2915
+ center without measuring fontMetrics.
2916
+
2917
+ pointerEvents:none so the digit can't intercept the
2918
+ hub click (R52 fit-to-view still fires).
2919
+
2920
+ workingCount=0 falls through to the existing
2921
+ decorative highlight so the hub never looks empty. */}
2922
+ {workingCount > 0 ? (
2923
+ <text
2924
+ x={cx} y={cy}
2925
+ textAnchor="middle"
2926
+ dy="0.36em"
2927
+ fill={isLight ? '#d1fae5' : '#ecfdf5'}
2928
+ fontSize="11"
2929
+ fontFamily="monospace"
2930
+ fontWeight="700"
2931
+ style={{ pointerEvents: 'none' }}
2932
+ data-topo-hub-working-count={workingCount}
2933
+ >
2934
+ {workingCount}
2935
+ </text>
2936
+ ) : (
2937
+ <circle
2938
+ cx={cx} cy={cy} r="5"
2939
+ fill="#d1fae5"
2940
+ opacity="0.9"
2941
+ data-topo-hub-highlight
2942
+ />
2943
+ )}
2944
+ {/* R115 / Loop: hover hint ring. Stroke-only circle at r=14
2945
+ that fades in when the hub is hovered — the same idea
2946
+ R44 used for node avatars (group-hover stroke). r=14
2947
+ sits comfortably outside the r=10 core and INSIDE the
2948
+ r=18 grounding halo, so the hover indicator is fully
2949
+ contained within the existing hub footprint (no bbox
2950
+ growth, overlap test unchanged). pointerEvents:none so
2951
+ the hint can't intercept the click that produced it. */}
2952
+ <circle
2953
+ cx={cx} cy={cy} r="14"
2954
+ fill="none"
2955
+ stroke={isLight ? '#059669' : '#10b981'}
2956
+ strokeWidth="1.5"
2957
+ opacity={hoveredHub ? (isLight ? 0.85 : 0.7) : 0}
2958
+ data-topo-hub-hover-ring
2959
+ style={{ pointerEvents: 'none', transition: 'opacity 180ms ease-out' }}
2960
+ />
1093
2961
  </g>)}
1094
2962
 
1095
2963
  {/* agent nodes */}
1096
- {[...onlineNodes, ...offlineNodes].map(session => {
2964
+ {[...onlineNodes, ...offlineNodes].map((session, nodeIdx) => {
1097
2965
  const pos = nodePositions[session.alias];
1098
2966
  if (!pos) return null;
1099
2967
 
@@ -1113,11 +2981,30 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1113
2981
  // occlude an avatar), and the full card appears only for the
1114
2982
  // hovered node or once zoomed in past 1.4×.
1115
2983
  const showFullLabel = !denseLayout || hoveredAlias === session.alias || view.zoom >= 1.4;
2984
+ // Round 8: when a node in another group is hovered, fade this
2985
+ // one. Same-group nodes (incl. singletons matching the hovered
2986
+ // alias) stay full. Pure visual focus, geometry unchanged.
2987
+ const inFocus = !activeGroup || (groupKeys[session.alias] ?? session.alias) === activeGroup;
2988
+ // R72: in ring layout, classify the node into a tier by its
2989
+ // distance from hub centre so the first-paint stagger can
2990
+ // emanate inner → outer instead of running clockwise. Grid
2991
+ // layout doesn't have a radial structure; it keeps R9's pure
2992
+ // nodeIdx stagger. Thresholds bracket the actual tier radii
2993
+ // (single 220, dual 175/260, triple 145/215/285, offline 325+).
2994
+ let tierIdx = 0;
2995
+ if (layout === 'ring') {
2996
+ const p = nodePositions[session.alias];
2997
+ if (p) {
2998
+ const d = Math.hypot(p.x - cx, p.y - cy);
2999
+ tierIdx = d < 195 ? 0 : d < 270 ? 1 : d < 310 ? 2 : 3;
3000
+ }
3001
+ }
1116
3002
 
1117
3003
  return (
1118
3004
  <g
1119
3005
  key={session.alias}
1120
3006
  data-node={session.alias}
3007
+ data-tier-idx={layout === 'ring' ? tierIdx : -1}
1121
3008
  // Round 3 / Loop: `anet-fade-in` runs once when the <g>
1122
3009
  // mounts — a new session entering the fleet (or the topology
1123
3010
  // first rendering) eases in instead of popping. Re-renders of
@@ -1125,7 +3012,87 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1125
3012
  // via the alias key), so status changes don't flicker. The
1126
3013
  // global prefers-reduced-motion sweep already neutralises it.
1127
3014
  className="group transition-opacity anet-fade-in"
1128
- style={{ cursor: 'pointer' }}
3015
+ style={{
3016
+ cursor: 'pointer',
3017
+ // Round 17 / Loop: offline nodes drop to 0.6 at rest so
3018
+ // online nodes pop without losing the offline-as-ghost
3019
+ // information. The dashed stroke + smaller radius already
3020
+ // say "offline"; dimming the whole group strengthens the
3021
+ // online-vs-offline hierarchy at first glance. Exempt the
3022
+ // chat-focused node — if the user explicitly opened a
3023
+ // popover targeting an offline alias, that node stays
3024
+ // full-brightness so the focus ring + popover read as one
3025
+ // selected thing rather than a dimmed selection. Group-
3026
+ // hover fade (Round 8) still wins when inFocus is false.
3027
+ // Round 49 / Loop: edge-hover endpoint highlight composes
3028
+ // OVER the inFocus/online formula — a non-endpoint node
3029
+ // dims to 0.28 (just below the inFocus 0.32 to read as a
3030
+ // stronger "not relevant" signal), endpoints keep their
3031
+ // base opacity. chatAlias still wins to keep the focus
3032
+ // ring legible if the user clicked through.
3033
+ // Round 55 / Loop: legend-status hover composes on the
3034
+ // SAME level as edge-hover-endpoint. Non-matching nodes
3035
+ // dim to 0.28; matching nodes stay at their base.
3036
+ // activeStatus matches: working = status==='working',
3037
+ // idle = online but not working, offline = !isOnline.
3038
+ // Round 60 / Loop: activeStatus = hoveredStatus ?? pinnedStatus
3039
+ // so the pressure-bar segment pins (R60) and the legend
3040
+ // row hover (R55) feed the same branch.
3041
+ // Round 80 / Loop: vendor-letter hover composes ABOVE the
3042
+ // activeStatus branch so hovering the vendor chip's `C`
3043
+ // dims everything except C-vendor nodes. Same dim value
3044
+ // (0.28) as edge-endpoint and status filters — visually
3045
+ // consistent. Vendor lookup uses the same vendorForModel
3046
+ // helper the avatar render uses, keyed by initial so the
3047
+ // chip and the avatar always agree on grouping.
3048
+ opacity: hoveredEdgeEndpoints && !hoveredEdgeEndpoints.has(session.alias) && chatAlias !== session.alias
3049
+ ? 0.28
3050
+ : activeVendor && chatAlias !== session.alias && (() => {
3051
+ const v = vendorForModel(session.model);
3052
+ const initial = v.id === 'unknown' ? '?' : v.initial;
3053
+ return initial !== activeVendor;
3054
+ })()
3055
+ ? 0.28
3056
+ : activeStatus && chatAlias !== session.alias && !(
3057
+ activeStatus === 'working' ? session.status === 'working'
3058
+ : activeStatus === 'idle' ? (isOnline && session.status !== 'working')
3059
+ : /* offline */ !isOnline
3060
+ )
3061
+ ? 0.28
3062
+ : !inFocus
3063
+ ? 0.32
3064
+ : chatAlias === session.alias
3065
+ ? 1
3066
+ : isOnline ? 1 : 0.6,
3067
+ // Round 9 / Loop: stagger the anet-fade-in so the topology
3068
+ // reveals as a wave on first paint instead of one big pop.
3069
+ // Cap at 24 indices (≈600ms tail) so 50-node fleets still
3070
+ // finish revealing within a beat. CSS animation-delay only
3071
+ // applies during the keyframe — re-renders without a new
3072
+ // mount (same alias key) don't replay, so status changes
3073
+ // never trigger the stagger again.
3074
+ // Round 72 / Loop: in ring layout, stagger by tier radius
3075
+ // so the topology emanates from the hub outward — inner
3076
+ // tier at 0ms, middle at ~180ms, outer at ~360ms, offline
3077
+ // at ~540ms. A small within-tier offset (nodeIdx % 6 * 25)
3078
+ // adds variety so each ring rotates in instead of all-at-
3079
+ // once popping. Grid keeps R9's pure nodeIdx stagger.
3080
+ animationDelay: layout === 'ring'
3081
+ ? `${tierIdx * 180 + (nodeIdx % 6) * 25}ms`
3082
+ : `${Math.min(nodeIdx, 24) * 25}ms`,
3083
+ // Round 51 / Loop: hover micro-lift. The label already
3084
+ // lifts on group-hover (R26). The node body — circle,
3085
+ // avatar, status ring — stays planted, so the gesture
3086
+ // reads "label moves, body doesn't". Now the whole <g>
3087
+ // translates -2px when hovered: avatar + ring + label
3088
+ // move as one unit. 2 px is well inside the inter-row
3089
+ // gap (cellH headroom ≥22), and CSS transform on SVG
3090
+ // <g> never affects the overlap-test geometry (the
3091
+ // test never simulates hover). useReducedMotion drops
3092
+ // the lift to 0 for prefers-reduced-motion users.
3093
+ transform: !reducedMotion && hoveredAlias === session.alias ? 'translateY(-2px)' : undefined,
3094
+ transition: 'transform 180ms cubic-bezier(0.4,0,0.2,1)',
3095
+ }}
1129
3096
  // Stop the pointerdown from reaching the SVG pan handler: the
1130
3097
  // SVG calls setPointerCapture, and a captured pointer makes
1131
3098
  // Chromium fire the follow-up `click` on the SVG instead of
@@ -1133,14 +3100,71 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1133
3100
  // Side effect (intended): you pan from empty canvas, not by
1134
3101
  // grabbing a node.
1135
3102
  onPointerDown={(e) => e.stopPropagation()}
1136
- onPointerEnter={() => denseLayout && setHoveredAlias(session.alias)}
1137
- onPointerLeave={() => denseLayout && setHoveredAlias(prev => (prev === session.alias ? null : prev))}
1138
- onClick={() => setChatAlias(session.alias)}
3103
+ // Track hover globally (not just under denseLayout) so the
3104
+ // Round 8 group-focus fade works at any fleet size.
3105
+ onPointerEnter={() => setHoveredAlias(session.alias)}
3106
+ onPointerLeave={() => setHoveredAlias(prev => (prev === session.alias ? null : prev))}
3107
+ onClick={() => {
3108
+ setChatAlias(session.alias);
3109
+ // Round 14 ripple — capture position, radius and status
3110
+ // colour at click time so the one-shot circle is self-
3111
+ // contained (no re-render-time recomputation needed).
3112
+ setClickRipple({
3113
+ ts: Date.now(),
3114
+ x: pos.x, y: pos.y, r0: radius,
3115
+ color: status.primary,
3116
+ });
3117
+ setTimeout(() => setClickRipple(prev =>
3118
+ prev && Date.now() - prev.ts >= 590 ? null : prev), 600);
3119
+ }}
1139
3120
  >
1140
3121
  {/* Issue #96: native hover tooltip — "Vendor · model · Runtime".
1141
3122
  Falls back to just the alias when the node reports no
1142
- model/runtime. */}
1143
- <title>{identityLine(session.model, session.runtime) || session.alias}</title>
3123
+ model/runtime.
3124
+ Round 33 / Loop: cwd line answers "what is this agent on?".
3125
+ Round 34 / Loop: for offline nodes, append "last seen: 6m ago"
3126
+ so the operator knows whether to wait or chase. Online nodes
3127
+ skip the line (Round 27's 1 h ghost age-out means anything
3128
+ still online has heartbeated recently — the line would just
3129
+ be noise). Accepts both ISO ("…T06:00:28Z") and SQL-style
3130
+ ("… 06:00:28" assumed UTC) formats. */}
3131
+ {(() => {
3132
+ // Round 35 / Loop: TZ-safe parsing via the shared lib helper
3133
+ // — same parseHubTime is used by isGhost above (Round 38
3134
+ // factored it to app/lib/time.ts so both paths interpret SQL
3135
+ // bare timestamps as UTC on every browser).
3136
+ const lastSeen = !isOnline && session.last_seen_at ? relativeAgo(session.last_seen_at) : null;
3137
+ // Round 98 / Loop: enrich the node tooltip with status,
3138
+ // group membership, and inbound/outbound flow counts —
3139
+ // same info-density spirit as R97 active-filter pill
3140
+ // tooltips. Hovering any node now answers "what is this
3141
+ // and how does it sit in the topology" without forcing
3142
+ // a click into the chat popover. Group line only shows
3143
+ // when the alias is part of a multi-member band (R106
3144
+ // prefix grouping); singletons skip it. Flow line only
3145
+ // when at least one direction has count > 0.
3146
+ const groupKey = groupKeys[session.alias];
3147
+ const groupMembers = groupKey
3148
+ ? Object.values(groupKeys).filter(k => k === groupKey).length
3149
+ : 1;
3150
+ const groupLine = groupMembers > 1 ? `group: ${groupKey} · ${groupMembers}` : null;
3151
+ let flowIn = 0, flowOut = 0;
3152
+ for (const fl of flowLinks) {
3153
+ if (fl.from === session.alias) flowOut += fl.count;
3154
+ if (fl.to === session.alias) flowIn += fl.count;
3155
+ }
3156
+ const flowLine = (flowIn + flowOut) > 0 ? `flows: ${flowIn} in / ${flowOut} out` : null;
3157
+ return (
3158
+ <title>{[
3159
+ `${session.alias} · ${session.status}`,
3160
+ identityLine(session.model, session.runtime),
3161
+ groupLine,
3162
+ session.project_dir ? `cwd: ${session.project_dir}` : null,
3163
+ lastSeen ? `last seen: ${lastSeen}` : null,
3164
+ flowLine,
3165
+ ].filter(Boolean).join('\n')}</title>
3166
+ );
3167
+ })()}
1144
3168
  {/* Round 2 / Loop: hover ring — a thin outer stroke that fades
1145
3169
  in when the cursor enters the node, signalling clickability
1146
3170
  (real-user feedback for the chat-popover open). Pure CSS via
@@ -1160,7 +3184,47 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1160
3184
  className="opacity-0 group-hover:opacity-70 transition-opacity duration-150"
1161
3185
  style={{ pointerEvents: 'none' }}
1162
3186
  />
1163
- {isActive && (
3187
+ {/* Round 11 / Loop: chat-focus ring — when the ChatPopover is
3188
+ open targeting this node, anchor a persistent ring around
3189
+ it so the floating popover visibly links back to its source
3190
+ node. Static (not pulsing) so it reads as "selected state"
3191
+ rather than "this node is active". strokeWidth=2.5 stays
3192
+ clear of the overlap-test selectors (1.5 / 3). Sits just
3193
+ outside the halo radius+8 so it never overlaps a neighbour
3194
+ (halos already pack flush in dense grids). */}
3195
+ {chatAlias === session.alias && (
3196
+ /* R51 chat-target ring. R120 / Loop: gentle SMIL
3197
+ breath on the ring's opacity (±0.1 over 3s) when
3198
+ chat is open + !reducedMotion. Says "active session
3199
+ here" continuously without animation noise — the
3200
+ ring only appears for one node at a time (the
3201
+ chatAlias), so it never competes with R84 hub
3202
+ busyness or R112 working halo for attention. */
3203
+ <circle
3204
+ cx={pos.x}
3205
+ cy={pos.y}
3206
+ r={radius + 14}
3207
+ fill="none"
3208
+ stroke={status.primary}
3209
+ strokeWidth="2.5"
3210
+ opacity={isLight ? 0.85 : 0.95}
3211
+ filter={!isLight ? 'url(#topo-glow)' : undefined}
3212
+ className="transition-opacity duration-200"
3213
+ style={{ pointerEvents: 'none' }}
3214
+ data-chat-target-ring
3215
+ data-chat-target-breath={!reducedMotion ? 'on' : 'off'}
3216
+ >
3217
+ {!reducedMotion && (
3218
+ <animate
3219
+ attributeName="opacity"
3220
+ values={isLight ? '0.72;0.95;0.72' : '0.82;1;0.82'}
3221
+ dur="3s"
3222
+ repeatCount="indefinite"
3223
+ />
3224
+ )}
3225
+ </circle>
3226
+ )}
3227
+ {isActive && !reducedMotion && (
1164
3228
  <circle cx={pos.x} cy={pos.y} r={radius + 14} fill={status.primary} opacity={isLight ? 0.08 : 0.12}>
1165
3229
  <animate attributeName="r" values={`${radius + 8};${radius + 22};${radius + 8}`} dur="2.4s" repeatCount="indefinite" />
1166
3230
  <animate attributeName="opacity" values={isLight ? '0.12;0.02;0.12' : '0.18;0.04;0.18'} dur="2.4s" repeatCount="indefinite" />
@@ -1168,7 +3232,14 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1168
3232
  )}
1169
3233
  {/* Round 4 / Loop: transition-[fill,stroke,opacity] smooths
1170
3234
  status colour changes so idle↔working↔offline doesn't snap
1171
- — task replies / node-rename / SSE updates ease in. */}
3235
+ — task replies / node-rename / SSE updates ease in.
3236
+ Round 112 / Loop: working nodes get a subtle halo breath
3237
+ (±0.12 opacity at 3s cycle) so the eye can find "what's
3238
+ busy" at a glance without scanning chips. Idle + offline
3239
+ halos stay flat — they don't need to demand attention.
3240
+ R84 hub-center breath stays the loudest "fleet busyness"
3241
+ signal; this one is quieter, per-node. SMIL `<animate>`
3242
+ inside the circle, gated by reducedMotion. */}
1172
3243
  <circle
1173
3244
  cx={pos.x}
1174
3245
  cy={pos.y}
@@ -1176,7 +3247,39 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1176
3247
  fill={status.halo}
1177
3248
  opacity={isOnline ? (isLight ? 0.85 : 0.65) : (isLight ? 0.4 : 0.25)}
1178
3249
  className="transition-[fill,opacity] duration-300 ease-out"
1179
- />
3250
+ data-node-halo-breath={!reducedMotion && session.status === 'working' ? 'on' : 'off'}
3251
+ >
3252
+ {!reducedMotion && session.status === 'working' && (
3253
+ <animate
3254
+ attributeName="opacity"
3255
+ values={isLight ? '0.73;0.92;0.73' : '0.53;0.78;0.53'}
3256
+ dur="3s"
3257
+ repeatCount="indefinite"
3258
+ />
3259
+ )}
3260
+ </circle>
3261
+ {/* Round 111 / Loop: edge-endpoint emphasis ring. R49
3262
+ already keeps endpoint nodes at opacity 1 while
3263
+ others dim when an edge is hovered, but the
3264
+ endpoints had no POSITIVE indicator — they just
3265
+ "stayed bright". An accent stroke at r=radius+7
3266
+ (just inside the halo's r=radius+8 bbox so we
3267
+ don't grow the overlap footprint) clearly says
3268
+ "these are the two participants in this flow".
3269
+ pointerEvents:none so the node hitbox stays alive. */}
3270
+ {hoveredEdgeEndpoints && hoveredEdgeEndpoints.has(session.alias) && (
3271
+ <circle
3272
+ cx={pos.x}
3273
+ cy={pos.y}
3274
+ r={radius + 7}
3275
+ fill="none"
3276
+ stroke={pal.flowEdge}
3277
+ strokeWidth={1.5}
3278
+ opacity={isLight ? 0.9 : 0.85}
3279
+ data-edge-endpoint-ring
3280
+ style={{ pointerEvents: 'none', transition: 'opacity 180ms ease-out' }}
3281
+ />
3282
+ )}
1180
3283
  <circle
1181
3284
  cx={pos.x}
1182
3285
  cy={pos.y}
@@ -1273,52 +3376,115 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1273
3376
  </g>
1274
3377
  );
1275
3378
  })()}
1276
- {session.status === 'working' && (
1277
- // working pulse small dot just inside the status ring,
1278
- // above the avatar text. Was a 18px horizontal bar at
1279
- // y+11 which now collides with the avatar; the dot reads
1280
- // as the same "active" cue without occluding the initial.
1281
- <circle cx={pos.x} cy={pos.y - (radius - 6)} r="2.5" fill={pal.flowParticle}>
1282
- <animate attributeName="opacity" values="1;0.25;1" dur="1.1s" repeatCount="indefinite" />
1283
- </circle>
1284
- )}
3379
+ {session.status === 'working' && (() => {
3380
+ // Round 24 / Loop: pulse rate traffic. The dot's dur
3381
+ // was a flat 1.1s every working node looked equally
3382
+ // busy. Mapping it to sse:N lets the eye land on what's
3383
+ // actually hot. 3 discrete tiers read cleaner than
3384
+ // continuous easing at a glance; thresholds picked so
3385
+ // typical 1-2-SSE Claude/Codex sessions stay in the
3386
+ // "active" tier and only multi-pane orchestrators pop
3387
+ // into the "busy" tier. Geometry unchanged (r=2.5).
3388
+ const sse = sseCountFor ?? 0;
3389
+ const dur = sse >= 4 ? '0.7s' : sse >= 2 ? '0.9s' : '1.2s';
3390
+ return (
3391
+ <circle cx={pos.x} cy={pos.y - (radius - 6)} r="2.5" fill={pal.flowParticle} data-pulse-dur={dur} opacity={reducedMotion ? 0.6 : undefined}>
3392
+ {!reducedMotion && (
3393
+ <animate attributeName="opacity" values="1;0.25;1" dur={dur} repeatCount="indefinite" />
3394
+ )}
3395
+ </circle>
3396
+ );
3397
+ })()}
1285
3398
 
1286
3399
  {/* Round 98 (issue #61): label rect 124px → 100px.
1287
3400
  Round 109/110 (Vincent P0): full opaque card below the
1288
3401
  density threshold / on hover / when zoomed; otherwise a
1289
3402
  lightweight plain-text alias that keeps every node
1290
- labelled without an opaque box covering its neighbours. */}
1291
- {showFullLabel ? (
1292
- <g transform={`translate(${pos.x}, ${pos.y + radius + 22})`} style={{ pointerEvents: 'none' }}>
1293
- <rect x="-50" y="-14" width="100" height="42" rx="6" fill={pal.labelBox.fill} stroke={pal.labelBox.stroke} opacity={isLight ? 1 : 0.94} />
1294
- <text x="0" y="1" textAnchor="middle" fill={status.text} fontSize="12" fontFamily="monospace" fontWeight="700">
1295
- {truncate(session.alias, 12)}
1296
- </text>
1297
- <text x="0" y="17" textAnchor="middle" fill={status.primary} fontSize="9" fontFamily="monospace">
1298
- {status.label}{isOnline && sseCountFor != null ? ` sse:${sseCountFor}` : ''}
3403
+ labelled without an opaque box covering its neighbours.
3404
+ Round 15 / Loop: when nodeScale=S the node shrinks 30%
3405
+ but the label card was staying full-size, so the label
3406
+ visually outweighed the small node. Tighten the card
3407
+ frame, alias / sub fontSize, drop-offset and truncate
3408
+ length specifically for S; M and L keep their existing
3409
+ sizes (M ≈ L for labels by design — the S user is the
3410
+ one who explicitly asked for a denser view). */}
3411
+ {(() => {
3412
+ const isSmall = nodeScale < 0.8;
3413
+ const cardW = isSmall ? 88 : 100;
3414
+ const cardH = isSmall ? 36 : 42;
3415
+ const cardTopY = isSmall ? -12 : -14;
3416
+ const aliasFs = isSmall ? 11 : 12;
3417
+ const subFs = isSmall ? 8 : 9;
3418
+ const subY = isSmall ? 15 : 17;
3419
+ const dropY = isSmall ? 18 : 22;
3420
+ const fullMax = isSmall ? 11 : 12;
3421
+ const denseFs = isSmall ? 9 : 10;
3422
+ const denseDrop = isSmall ? 12 : 14;
3423
+ // Round 26 / Loop: micro-lift the label group on hover —
3424
+ // 1.5 px upward, 200 ms ease. Pairs with the Round 18
3425
+ // group-box hover-accent treatment to give the same
3426
+ // "this is the focused element" feedback at the per-
3427
+ // node level. CSS transform stacks onto the SVG
3428
+ // positioning transform attribute (SVG 2 cascade);
3429
+ // bbox is unchanged at rest, so the overlap-test gate
3430
+ // continues to see the geometric layout it expects.
3431
+ return showFullLabel ? (
3432
+ <g transform={`translate(${pos.x}, ${pos.y + radius + dropY})`} style={{ pointerEvents: 'none' }}
3433
+ className="transition-transform duration-200 group-hover:-translate-y-[1.5px]">
3434
+ <rect x={-cardW / 2} y={cardTopY} width={cardW} height={cardH} rx="6" fill={pal.labelBox.fill} stroke={pal.labelBox.stroke} opacity={isLight ? 1 : 0.94} />
3435
+ <text x="0" y="1" textAnchor="middle" fill={status.text} fontSize={aliasFs} fontFamily="monospace" fontWeight="700">
3436
+ {truncate(session.alias, fullMax)}
3437
+ </text>
3438
+ <text x="0" y={subY} textAnchor="middle" fill={status.primary} fontSize={subFs} fontFamily="monospace">
3439
+ {status.label}{isOnline && sseCountFor != null ? ` sse:${sseCountFor}` : ''}
3440
+ </text>
3441
+ </g>
3442
+ ) : (
3443
+ <text
3444
+ x={pos.x}
3445
+ y={pos.y + radius + denseDrop}
3446
+ textAnchor="middle"
3447
+ fill={status.text}
3448
+ fontSize={denseFs}
3449
+ fontFamily="monospace"
3450
+ fontWeight="700"
3451
+ opacity={0.9}
3452
+ className="transition-transform duration-200 group-hover:-translate-y-[1.5px]"
3453
+ style={{ pointerEvents: 'none', paintOrder: 'stroke' }}
3454
+ stroke={pal.containerBg}
3455
+ strokeWidth="3"
3456
+ >
3457
+ {truncate(session.alias, isSmall ? 9 : 10)}
1299
3458
  </text>
1300
- </g>
1301
- ) : (
1302
- <text
1303
- x={pos.x}
1304
- y={pos.y + radius + 14}
1305
- textAnchor="middle"
1306
- fill={status.text}
1307
- fontSize="10"
1308
- fontFamily="monospace"
1309
- fontWeight="700"
1310
- opacity={0.9}
1311
- style={{ pointerEvents: 'none', paintOrder: 'stroke' }}
1312
- stroke={pal.containerBg}
1313
- strokeWidth="3"
1314
- >
1315
- {truncate(session.alias, 10)}
1316
- </text>
1317
- )}
3459
+ );
3460
+ })()}
1318
3461
  </g>
1319
3462
  );
1320
3463
  })}
1321
3464
 
3465
+ {/* Round 14 / Loop: click ripple — one-shot expanding ring from
3466
+ the clicked node, ~500ms, status-coloured. Sits inside the
3467
+ zoom/pan <g> so it scales / pans with the topology. Keyed by
3468
+ ts so a re-click on any node (same or different) remounts the
3469
+ <circle> and the SMIL <animate> elements replay from t=0.
3470
+ strokeWidth=2 doesn't match the overlap-test selectors. */}
3471
+ {clickRipple && !reducedMotion && (
3472
+ <circle
3473
+ key={clickRipple.ts}
3474
+ cx={clickRipple.x}
3475
+ cy={clickRipple.y}
3476
+ r={clickRipple.r0 + 4}
3477
+ fill="none"
3478
+ stroke={clickRipple.color}
3479
+ strokeWidth="2"
3480
+ opacity="0"
3481
+ style={{ pointerEvents: 'none' }}
3482
+ >
3483
+ <animate attributeName="r" values={`${clickRipple.r0 + 4};${clickRipple.r0 + 30}`} dur="0.5s" fill="freeze" />
3484
+ <animate attributeName="opacity" values="0.7;0" dur="0.5s" fill="freeze" />
3485
+ </circle>
3486
+ )}
3487
+
1322
3488
  </g>
1323
3489
 
1324
3490
  {/* #112: overlay panels (recent-signal + legend) render OUTSIDE the
@@ -1329,30 +3495,538 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1329
3495
  corner triangles, so the panels never overlap a node, in ring
1330
3496
  OR grid layout (Vincent 4727 zero-overlap criterion). */}
1331
3497
  {/* latest flow labels */}
1332
- <g transform="translate(16, 16)">
1333
- <rect x="0" y="0" width="230" height="84" rx="10" fill={pal.legendBox.fill} stroke={pal.legendBox.stroke} opacity={isLight ? 0.97 : 0.92} />
3498
+ {/* Round 57 / Loop: drop-shadow on the panel rects gives them
3499
+ card-like elevation, especially on light theme where the
3500
+ near-white fill on a near-white canvas read as pasted-on.
3501
+ data-topo-panel-elevation tag so the test can verify both
3502
+ panels carry the filter. The filter is on the rect, not
3503
+ the parent <g>, so it doesn't shadow the rows + text inside
3504
+ — only the panel chrome lifts. */}
3505
+ <g
3506
+ transform="translate(16, 16)"
3507
+ data-topo-panel="recent"
3508
+ data-topo-panel-hovered={hoveredPanel === 'recent' ? 'true' : 'false'}
3509
+ onMouseEnter={() => setHoveredPanel('recent')}
3510
+ onMouseLeave={() => setHoveredPanel(prev => prev === 'recent' ? null : prev)}
3511
+ >
3512
+ <rect
3513
+ x="0" y="0" width="230" height="84" rx="10"
3514
+ fill={pal.legendBox.fill}
3515
+ stroke={pal.legendBox.stroke}
3516
+ opacity={isLight ? 0.97 : 0.92}
3517
+ style={{
3518
+ /* R135: drop-shadow intensifies on panel hover. Base
3519
+ shadow (2px / 6px blur) signals card elevation
3520
+ (R57); hovered (4px / 12px blur) tells the user
3521
+ the whole chrome is interactive territory — rows
3522
+ pin (R116), footer navigates (R133), legend rows
3523
+ pin status (R61). Reuses R18's KPI-card hover-
3524
+ elevation idiom for visual consistency. Theme-
3525
+ aware shadow colour stays the same; just the
3526
+ spread + blur grow. */
3527
+ filter: hoveredPanel === 'recent'
3528
+ ? (isLight ? 'drop-shadow(0 4px 12px rgba(15,23,42,0.14))'
3529
+ : 'drop-shadow(0 4px 12px rgba(0,0,0,0.65))')
3530
+ : (isLight ? 'drop-shadow(0 2px 6px rgba(15,23,42,0.08))'
3531
+ : 'drop-shadow(0 2px 6px rgba(0,0,0,0.45))'),
3532
+ transition: 'filter 200ms ease-out',
3533
+ }}
3534
+ data-topo-panel-elevation="recent"
3535
+ />
1334
3536
  <text x="13" y="21" fill={pal.legendHeadline} fontSize="12" fontFamily="monospace" fontWeight="700">recent signal</text>
1335
- <text x="150" y="21" fill={pal.legendAccent} fontSize="10" fontFamily="monospace">{messages.length} msgs</text>
1336
- {flowLinks.slice(0, 3).map((link, index) => (
1337
- <text key={link.key} x="13" y={38 + index * 16} fill={pal.legendText} fontSize="9" fontFamily="monospace">
1338
- {truncate(link.from, 6)} {'->'} {truncate(link.to, 6)} / {link.count} / {truncate(link.content, 12)}
1339
- </text>
1340
- ))}
3537
+ {/* R96: header count now matches what the rows show. Pre-R96
3538
+ this read "X msgs" off the raw messages array, but the
3539
+ rows below render DEDUPED flowLinks so a fleet with 10
3540
+ messages aggregating to 3 pairs read "10 msgs" above
3541
+ only 3 rows. Misreads as "where are the other 7?".
3542
+ "X flows" mirrors flowLinks.length one-for-one. When
3543
+ flows < msgs the chip-row's "N active links · last 2s"
3544
+ already tells the operator about traffic volume — no
3545
+ duplicate metric needed here.
3546
+ R129 / Loop: header gains an amber " · N hot" tail
3547
+ when ≥ 1 flowLink has count ≥ 10. The third surface
3548
+ of the hot-lane convention (R126 canvas badge / R127
3549
+ row count) lives at the panel header so a user
3550
+ scanning vertically — header → rows — gets a top-
3551
+ level summary before reading each row's amber digit.
3552
+ Restructured into a single <text> with <tspan>
3553
+ fragments so the amber portion can carry its own
3554
+ fill + weight without a sibling <text>. Switched
3555
+ anchor x=150 left-justified → x=217 right-justified
3556
+ so the count column unifies visually with the legend
3557
+ panel's right-justified header (line 3511 — also
3558
+ fontSize 10 monospace, also x≈215 textAnchor end).
3559
+ data-recent-panel-count stays on the flow tspan so
3560
+ the R96 / R128 tests still resolve. data-recent-
3561
+ panel-hot-count exposes the hot bucket count. */}
3562
+ {(() => {
3563
+ const hotFlowCount = flowLinks.filter(l => l.count >= 10).length;
3564
+ const hotStroke = isLight ? '#d97706' : '#fbbf24';
3565
+ return (
3566
+ <text
3567
+ x="217" y="21"
3568
+ textAnchor="end"
3569
+ fontSize="10"
3570
+ fontFamily="monospace"
3571
+ >
3572
+ <tspan fill={pal.legendAccent} data-recent-panel-count>{flowLinks.length} flows</tspan>
3573
+ {hotFlowCount > 0 && (
3574
+ <tspan
3575
+ fill={hotStroke}
3576
+ fontWeight="700"
3577
+ data-recent-panel-hot-count={hotFlowCount}
3578
+ >
3579
+ {' · '}{hotFlowCount} hot
3580
+ </tspan>
3581
+ )}
3582
+ </text>
3583
+ );
3584
+ })()}
3585
+ {/* Round 45 / Loop: empty state. The panel used to render
3586
+ "recent signal" + "0 msgs" with three blank slots below
3587
+ when no flow yet — read as "broken" rather than "quiet".
3588
+ A muted centred placeholder makes the empty state
3589
+ deliberate. Messages count CAN diverge from flowLinks
3590
+ count (raw count vs. deduped pairs), so the placeholder
3591
+ fires on flowLinks.length=0 specifically. */}
3592
+ {flowLinks.length === 0 ? (
3593
+ /* R45 placeholder. R110: add a sub-text hint so the
3594
+ empty state explains what it's empty OF — operators
3595
+ looking at "no flow yet" sometimes mistook it for
3596
+ a connection error. The sub-line reads as a quiet
3597
+ invitation, not an error. Two-line layout uses
3598
+ standard SVG <text>+<text> rather than tspan so the
3599
+ y-coordinates are explicit and the data-attr selector
3600
+ still finds the primary line. */
3601
+ <>
3602
+ <text x="115" y="54" textAnchor="middle" fill={pal.legendText} fontSize="10" fontFamily="monospace" fontStyle="italic" opacity={0.65} data-recent-signal-empty>
3603
+ no flow yet
3604
+ </text>
3605
+ <text x="115" y="68" textAnchor="middle" fill={pal.legendText} fontSize="8" fontFamily="monospace" opacity={0.45} data-recent-signal-empty-hint>
3606
+ send a message between agents
3607
+ </text>
3608
+ </>
3609
+ ) : (
3610
+ // Round 56 / Loop: each row is a navigator into the canvas.
3611
+ // Hover a row → set hoveredEdgeKey, which the existing R50
3612
+ // edge-focus + R49 endpoint-highlight ladders consume. The
3613
+ // matching flow edge brightens to 2× + thickens, its two
3614
+ // endpoint nodes stay full opacity, and every other edge +
3615
+ // non-endpoint node dims. Released → all restore. Wrapping
3616
+ // <g> + a transparent 218×14 hitbox so the cursor doesn't
3617
+ // have to land precisely on the truncated text.
3618
+ flowLinks.slice(0, 3).map((link, index) => {
3619
+ // Round 94 / Loop: per-row relative timestamp. The chip
3620
+ // row shows "last 2s" for the most recent flow overall,
3621
+ // but a user scanning the recent-signal panel had no way
3622
+ // to tell whether row 2 was 5s old or 5m old without
3623
+ // hovering nodes. Compact `2s` / `1m` glyph at the
3624
+ // right edge — same relativeAgo helper R42 uses for
3625
+ // the chip — pulls double duty as a recency anchor and
3626
+ // a sortedness hint (top row is freshest by construction).
3627
+ // Strip the " ago" suffix — at fontSize=8 in a 32-px
3628
+ // right-edge slot, every char counts. "30s ago" → "30s".
3629
+ const rawAt = link.last_at ? relativeAgo(link.last_at) : null;
3630
+ const lastAt = rawAt ? rawAt.replace(/\s+ago$/, '') : null;
3631
+ const isRowHovered = hoveredEdgeKey === link.key;
3632
+ const isRowPinned = pinnedEdgeKey === link.key;
3633
+ const isRowActive = isRowHovered || isRowPinned;
3634
+ // R127: panel-side mirror of R126's canvas hot-badge.
3635
+ // The recent-signal row text packs `alias→alias / N /
3636
+ // preview` into one line, with N rendered identically
3637
+ // regardless of magnitude. Now that the canvas badge
3638
+ // tells the user "≥ 10 msgs = hot lane" via amber
3639
+ // stroke, the panel row needs the same affordance so
3640
+ // the user reading the list at a glance can spot hot
3641
+ // lanes without crossing to the canvas. Renders the
3642
+ // count digit in amber + 700-weight when isHot; the
3643
+ // surrounding alias text + separators stay in the
3644
+ // existing legendText/legendHeadline palette. Reuses
3645
+ // R126's hotStroke colour for visual consistency.
3646
+ const isHot = link.count >= 10;
3647
+ const hotStroke = isLight ? '#d97706' : '#fbbf24';
3648
+ return (
3649
+ <g
3650
+ key={link.key}
3651
+ data-recent-row={link.key}
3652
+ data-recent-row-hovered={isRowHovered ? 'true' : 'false'}
3653
+ data-recent-row-pinned={isRowPinned ? 'true' : 'false'}
3654
+ data-recent-row-hot={isHot ? 'true' : 'false'}
3655
+ data-recent-row-lifted={(isRowHovered || isRowPinned) ? 'true' : 'false'}
3656
+ role="button"
3657
+ tabIndex={0}
3658
+ aria-pressed={isRowPinned}
3659
+ // R143 / Loop: extend the R135/R142 "interactive surface
3660
+ // elevates" idiom down one layer to the recent-signal
3661
+ // panel rows. R104 already tints the row background on
3662
+ // hover; R143 adds a 1-px translate so the row text
3663
+ // visually lifts off the panel — same vocabulary R51
3664
+ // uses for nodes, R135 uses for panels, R142 uses for
3665
+ // group boxes. Pinned rows lift too (sticky state
3666
+ // should look like locked-in selection). Reduced-motion
3667
+ // safe via prefers-reduced-motion blanket override
3668
+ // applied to transition-duration in globals.css.
3669
+ style={{
3670
+ cursor: 'pointer',
3671
+ transform: (isRowHovered || isRowPinned) ? 'translateY(-1px)' : undefined,
3672
+ transition: 'transform 150ms cubic-bezier(0.4, 0, 0.2, 1)',
3673
+ }}
3674
+ onPointerDown={(e) => e.stopPropagation()}
3675
+ onMouseEnter={() => setHoveredEdgeKey(link.key)}
3676
+ onMouseLeave={() => setHoveredEdgeKey(prev => prev === link.key ? null : prev)}
3677
+ // R116: click toggles pin. activeEdgeKey =
3678
+ // hoveredEdgeKey ?? pinnedEdgeKey so the matching
3679
+ // edge stays "hot" after mouseleave; click again
3680
+ // (or Esc) releases.
3681
+ onClick={() => setPinnedEdgeKey(prev => prev === link.key ? null : link.key)}
3682
+ onKeyDown={(e) => {
3683
+ if (e.key === 'Enter' || e.key === ' ') {
3684
+ e.preventDefault();
3685
+ setPinnedEdgeKey(prev => prev === link.key ? null : link.key);
3686
+ }
3687
+ }}
3688
+ >
3689
+ {/* R104: subtle row-background tint on hover. R56
3690
+ already brightens the matching edge on the canvas,
3691
+ but the panel row itself stayed flat — felt more
3692
+ like text-with-handlers than a navigable list.
3693
+ Filling the rect at hover with `pal.legendAccent`
3694
+ at low alpha gives the row visual feedback at the
3695
+ source surface, mirroring the list-item idiom from
3696
+ the chip-row pills. R116: pinned rows tint
3697
+ stronger than hovered ones so locked vs preview
3698
+ is discriminable. */}
3699
+ <rect
3700
+ x="6" y={38 + index * 16 - 10}
3701
+ width="218" height="14" rx="3"
3702
+ fill={isRowActive ? pal.legendAccent : 'transparent'}
3703
+ opacity={isRowPinned ? (isLight ? 0.18 : 0.22)
3704
+ : isRowHovered ? (isLight ? 0.10 : 0.14)
3705
+ : 1}
3706
+ style={{ transition: 'fill 150ms ease-out, opacity 150ms ease-out' }}
3707
+ />
3708
+ <text
3709
+ x="13" y={38 + index * 16}
3710
+ fill={isRowActive ? pal.legendHeadline : pal.legendText}
3711
+ fontSize="9"
3712
+ fontFamily="monospace"
3713
+ style={{ transition: 'fill 150ms ease-out' }}
3714
+ >
3715
+ {/* R138 / Loop: typography unification with the rest
3716
+ of the topology UI. Filter pills (R119) render
3717
+ "{from}→{to}", node tooltips (R98) use →, the
3718
+ active-links chip tooltip (R114) and edge-badge
3719
+ titles all use unicode →. The recent-signal row
3720
+ was the lone holdout still rendering "from -> to"
3721
+ in ASCII. The data delimiter likewise: filter
3722
+ pills use " · " ("status · 3"); the row was using
3723
+ " / ". Both swaps make the row read like every
3724
+ other surface — one less micro-style to remember. */}
3725
+ {truncate(link.from, 6)} {'→'} {truncate(link.to, 6)} {' · '}
3726
+ {isHot ? (
3727
+ <tspan fill={hotStroke} fontWeight="700" data-recent-row-count-hot>
3728
+ {link.count}
3729
+ </tspan>
3730
+ ) : (
3731
+ <tspan data-recent-row-count>{link.count}</tspan>
3732
+ )}
3733
+ {' · '}{truncate(link.content, 8)}
3734
+ </text>
3735
+ {lastAt ? (
3736
+ <text
3737
+ x="217" y={38 + index * 16}
3738
+ textAnchor="end"
3739
+ fill={pal.legendText}
3740
+ fontSize="8"
3741
+ fontFamily="monospace"
3742
+ opacity={0.55}
3743
+ data-recent-row-ts={link.key}
3744
+ style={{ pointerEvents: 'none' }}
3745
+ >
3746
+ {lastAt}
3747
+ </text>
3748
+ ) : null}
3749
+ </g>
3750
+ );
3751
+ })
3752
+ )}
3753
+ {/* Round 128 / Loop: overflow hint. The recent-signal panel
3754
+ renders the top 3 flowLinks via .slice(0, 3) — but a
3755
+ fleet with 5 or 10 active flows silently truncates the
3756
+ rest. The R96 "X flows" header tells the total but
3757
+ doesn't say "you're seeing top-3". This hint fires
3758
+ only when flowLinks.length > 3 so quiet fleets stay
3759
+ clean. Footer y=82 sits in the 10-px gap between
3760
+ row 3 (baseline 70) and the panel bottom (84), so
3761
+ overlap-test geometry is unchanged. fontStyle=italic
3762
+ + opacity 0.55 reads as muted metadata, not an
3763
+ actionable row — matches the R110 empty-state hint
3764
+ idiom. */}
3765
+ {flowLinks.length > 3 && (() => {
3766
+ const moreCount = flowLinks.length - 3;
3767
+ const label = `+ ${moreCount} more flow${moreCount === 1 ? '' : 's'}`;
3768
+ // R133: the truncation hint becomes a clickable nav to
3769
+ // /messages. R128 introduced the footer as pure metadata
3770
+ // ("you're seeing top-3"); R133 closes the gap by giving
3771
+ // users a way to ACT on that info — see the full list.
3772
+ // Wrap in <g> with onClick so SVG hit-testing fires the
3773
+ // route push. cursor:pointer + the underline-on-hover
3774
+ // visual cue tells users this is interactive. The hover
3775
+ // state is React-controlled (no CSS :hover on SVG <g>
3776
+ // descendant text would feel reliable across Chrome's
3777
+ // SVG quirks). pointerEvents:all so the text receives
3778
+ // the click; onPointerDown stop-propagation so the
3779
+ // R103 zoom/pan capture doesn't intercept first.
3780
+ return (
3781
+ <g
3782
+ data-recent-panel-more-nav
3783
+ role="link"
3784
+ tabIndex={0}
3785
+ style={{ cursor: 'pointer', pointerEvents: 'all' }}
3786
+ onPointerDown={(e) => e.stopPropagation()}
3787
+ onMouseEnter={() => setHoveredRecentMore(true)}
3788
+ onMouseLeave={() => setHoveredRecentMore(false)}
3789
+ onClick={() => router.push('/messages')}
3790
+ onKeyDown={(e) => {
3791
+ if (e.key === 'Enter' || e.key === ' ') {
3792
+ e.preventDefault();
3793
+ router.push('/messages');
3794
+ }
3795
+ }}
3796
+ >
3797
+ <title>{`${label} — open /messages for the full list`}</title>
3798
+ <text
3799
+ x="115" y="82"
3800
+ textAnchor="middle"
3801
+ fill={pal.legendText}
3802
+ fontSize="8"
3803
+ fontFamily="monospace"
3804
+ fontStyle="italic"
3805
+ opacity={hoveredRecentMore ? 0.85 : 0.55}
3806
+ textDecoration={hoveredRecentMore ? 'underline' : 'none'}
3807
+ data-recent-panel-more={moreCount}
3808
+ style={{ transition: 'opacity 150ms ease-out' }}
3809
+ >
3810
+ {label}
3811
+ </text>
3812
+ </g>
3813
+ );
3814
+ })()}
1341
3815
  </g>
1342
3816
 
1343
- {/* legend */}
1344
- <g transform="translate(760, 16)">
1345
- <rect x="0" y="0" width="224" height="96" rx="10" fill={pal.legendBox.fill} stroke={pal.legendBox.stroke} opacity={isLight ? 0.97 : 0.92} />
1346
- <circle cx="16" cy="24" r="5.5" fill={isLight ? '#059669' : '#22c55e'} />
1347
- <text x="30" y="28" fill={pal.legendText} fontSize="11" fontFamily="monospace">working node</text>
1348
- <circle cx="16" cy="48" r="5.5" fill={isLight ? '#0d9488' : '#2dd4bf'} />
1349
- <text x="30" y="52" fill={pal.legendText} fontSize="11" fontFamily="monospace">online idle</text>
1350
- <circle cx="16" cy="72" r="5.5" fill={isLight ? '#94a3b8' : '#6b7280'} />
1351
- <text x="30" y="76" fill={pal.legendText} fontSize="11" fontFamily="monospace">offline / no SSE</text>
1352
- <path d="M140,72 Q164,48 196,72" fill="none" stroke={pal.flowEdge} strokeWidth="3" markerEnd="url(#topo-arrow)" />
3817
+ {/* legend — Round 55 / Loop: each status row is now a hover
3818
+ target. Pointer enter sets `hoveredStatus`; pointer leave
3819
+ clears it. Node opacity formula composes the match below.
3820
+ The row text brightens to legendHeadline while hovered as
3821
+ a small affordance hint. Geometry unchanged — the new
3822
+ <g> wrappers only carry pointer handlers. */}
3823
+ <g
3824
+ transform="translate(760, 16)"
3825
+ data-topo-panel="legend"
3826
+ data-topo-panel-hovered={hoveredPanel === 'legend' ? 'true' : 'false'}
3827
+ onMouseEnter={() => setHoveredPanel('legend')}
3828
+ onMouseLeave={() => setHoveredPanel(prev => prev === 'legend' ? null : prev)}
3829
+ >
3830
+ {/* R57: matching drop-shadow elevation to the legend panel.
3831
+ R106: panel height grew 96 → 104 to seat the new header
3832
+ line + 4 px row-shift below it (so the new header text
3833
+ doesn't overlap the row-1 hitbox region).
3834
+ R135: hover-elevation mirrors the recent-signal panel
3835
+ rect at line ~3299. Both panels grow their shadow on
3836
+ hover to telegraph "the chrome is interactive" since
3837
+ their rows pin / nav. */}
3838
+ <rect
3839
+ x="0" y="0" width="224" height="104" rx="10"
3840
+ fill={pal.legendBox.fill}
3841
+ stroke={pal.legendBox.stroke}
3842
+ opacity={isLight ? 0.97 : 0.92}
3843
+ style={{
3844
+ filter: hoveredPanel === 'legend'
3845
+ ? (isLight ? 'drop-shadow(0 4px 12px rgba(15,23,42,0.14))'
3846
+ : 'drop-shadow(0 4px 12px rgba(0,0,0,0.65))')
3847
+ : (isLight ? 'drop-shadow(0 2px 6px rgba(15,23,42,0.08))'
3848
+ : 'drop-shadow(0 2px 6px rgba(0,0,0,0.45))'),
3849
+ transition: 'filter 200ms ease-out',
3850
+ }}
3851
+ data-topo-panel-elevation="legend"
3852
+ />
3853
+ {/* R106 / Loop: panel header — symmetric with the recent-
3854
+ signal panel's "recent signal · N flows" (R96). Same
3855
+ font + position vocabulary so the two side panels feel
3856
+ paired. Title text at x=13 y=21; total fleet count
3857
+ right-aligned at x=215 y=21 in the accent colour. */}
3858
+ <text x="13" y="21" fill={pal.legendHeadline} fontSize="12" fontFamily="monospace" fontWeight="700">legend</text>
3859
+ <text x="215" y="21" textAnchor="end" fill={pal.legendAccent} fontSize="10" fontFamily="monospace" data-legend-panel-count>{sessions.length} node{sessions.length === 1 ? '' : 's'}</text>
3860
+ {(() => {
3861
+ const idleCount = onlineNodes.length - workingCount;
3862
+ // R106: rows shift +8 px (was y0=24, 48, 72 → 32, 56, 80)
3863
+ // to clear the new header row. R57 panel rect grew 96 →
3864
+ // 104 to seat them.
3865
+ const rows = [
3866
+ { key: 'working' as const, y0: 32, y1: 36, fill: isLight ? '#059669' : '#22c55e', label: 'working node', count: workingCount },
3867
+ { key: 'idle' as const, y0: 56, y1: 60, fill: isLight ? '#0d9488' : '#2dd4bf', label: 'online idle', count: idleCount },
3868
+ { key: 'offline' as const, y0: 80, y1: 84, fill: isLight ? '#94a3b8' : '#6b7280', label: 'offline / no SSE', count: offlineNodes.length },
3869
+ ];
3870
+ return rows;
3871
+ })().map(row => {
3872
+ // Round 61 / Loop: legend rows pin too — symmetric with the
3873
+ // R60 pressure-bar segments. R55 hover stays transient; the
3874
+ // new onClick toggles pinnedStatus so users can lock a
3875
+ // filter without holding the cursor still. Pinned row gets
3876
+ // an inset ring on the swatch (same vocab as R60).
3877
+ const isPinned = pinnedStatus === row.key;
3878
+ const isRowHovered = hoveredStatus === row.key;
3879
+ const isLifted = isRowHovered || isPinned;
3880
+ return (
3881
+ <g
3882
+ key={row.key}
3883
+ data-legend-status={row.key}
3884
+ data-legend-row-lifted={isLifted ? 'true' : 'false'}
3885
+ role="button"
3886
+ tabIndex={0}
3887
+ aria-pressed={isPinned}
3888
+ // R144: mirror of R143 — extend the row-lift idiom to the
3889
+ // legend panel rows for symmetry with the recent-signal
3890
+ // panel rows. Same translate-1px transform, same 150ms
3891
+ // cubic-bezier timing. R55 hovers the row (transient),
3892
+ // R61 pins it (sticky); both states earn the lift.
3893
+ // Composes with R105 row-bg-tint and R135 panel hover-
3894
+ // shadow → three layers of feedback at three nested
3895
+ // scopes (panel chrome → row text lift → bg tint).
3896
+ style={{
3897
+ cursor: 'pointer',
3898
+ transform: isLifted ? 'translateY(-1px)' : undefined,
3899
+ transition: 'transform 150ms cubic-bezier(0.4, 0, 0.2, 1)',
3900
+ }}
3901
+ // R61: stopPropagation on pointerdown so the SVG-level
3902
+ // pan handler (R103) doesn't setPointerCapture and
3903
+ // redirect the follow-up click away from this <g>.
3904
+ // Same trick the node <g> uses (and R52 hub).
3905
+ onPointerDown={(e) => e.stopPropagation()}
3906
+ onMouseEnter={() => setHoveredStatus(row.key)}
3907
+ onMouseLeave={() => setHoveredStatus(prev => prev === row.key ? null : prev)}
3908
+ onClick={() => setPinnedStatus(prev => prev === row.key ? null : row.key)}
3909
+ >
3910
+ {/* R55 hitbox covers the row so cursor doesn't need to
3911
+ be exactly on the 5-px swatch. R105 / Loop: the
3912
+ hitbox now also carries a subtle hover/pin tint —
3913
+ mirroring R104's recent-signal row treatment so
3914
+ both side panels share the list-item idiom. The
3915
+ tint borrows the ROW'S OWN swatch colour rather
3916
+ than legendAccent, so the user's eye associates
3917
+ the tinted row with its colour swatch instead of
3918
+ a generic accent. Pin is a stronger tint than
3919
+ hover; idle stays fully transparent. */}
3920
+ <rect
3921
+ x="6" y={row.y0 - 12}
3922
+ width="170" height="22" rx="3"
3923
+ fill={hoveredStatus === row.key || isPinned ? row.fill : 'transparent'}
3924
+ opacity={isPinned ? (isLight ? 0.14 : 0.18)
3925
+ : hoveredStatus === row.key ? (isLight ? 0.08 : 0.12)
3926
+ : 1}
3927
+ data-legend-row-tinted={isPinned ? 'pinned' : hoveredStatus === row.key ? 'hover' : 'none'}
3928
+ style={{ transition: 'fill 150ms ease-out, opacity 150ms ease-out' }}
3929
+ />
3930
+ <circle cx="16" cy={row.y0} r="5.5" fill={row.fill} />
3931
+ {/* R61 pinned-state ring — concentric stroke at r=8 in
3932
+ the row colour, draws OUTSIDE the swatch so it
3933
+ doesn't fight the fill colour the user is matching. */}
3934
+ {isPinned && (
3935
+ <circle cx="16" cy={row.y0} r="8" fill="none" stroke={row.fill} strokeWidth="1.5" />
3936
+ )}
3937
+ <text
3938
+ x="30" y={row.y1}
3939
+ fill={hoveredStatus === row.key || isPinned ? pal.legendHeadline : pal.legendText}
3940
+ fontSize="11"
3941
+ fontFamily="monospace"
3942
+ style={{ transition: 'fill 150ms ease-out' }}
3943
+ >{row.label}</text>
3944
+ {/* R95: live count anchored to the right edge of the
3945
+ panel (x=215, after the flow-arrow swatch). Same
3946
+ counts the chip-row shows ("3 working" etc.) but
3947
+ here next to the swatch the user is matching —
3948
+ saves crossing the canvas to the chip row for
3949
+ the number. text-anchor=end aligns the column
3950
+ visually like a table. pointerEvents:none so the
3951
+ count doesn't intercept the row hover hitbox. */}
3952
+ <text
3953
+ x="215" y={row.y1}
3954
+ textAnchor="end"
3955
+ fill={pal.legendText}
3956
+ fontSize="11"
3957
+ fontFamily="monospace"
3958
+ opacity={hoveredStatus === row.key || isPinned ? 0.95 : 0.65}
3959
+ data-legend-count={row.key}
3960
+ style={{ pointerEvents: 'none', transition: 'opacity 150ms ease-out' }}
3961
+ >{row.count}</text>
3962
+ </g>
3963
+ );
3964
+ })}
3965
+ {/* Flow-arrow swatch tracks the offline row — R106 shifted
3966
+ rows down by 8 px to make space for the panel header so
3967
+ this moves from y=72 to y=80. Drop its pointerEvents so
3968
+ the offline legend row stays hoverable (R55). It's
3969
+ decoration, no need to receive events. */}
3970
+ <path d="M140,80 Q164,56 196,80" fill="none" stroke={pal.flowEdge} strokeWidth="3" markerEnd="url(#topo-arrow)" style={{ pointerEvents: 'none' }} />
1353
3971
  </g>
1354
3972
  </svg>
1355
3973
 
3974
+ {/* Round 30 / Loop: minimap. Big fleets in fullscreen mode at high
3975
+ zoom let users lose their position — the minimap shows the
3976
+ whole topology miniaturised plus a viewport rectangle so the
3977
+ user always knows where they are. Click anywhere to recenter
3978
+ the canvas there. Only mounted when the view is non-default
3979
+ (zoomed or panned) since at 1× centered the minimap and the
3980
+ canvas show the same thing. HTML overlay so it stays fixed
3981
+ while the SVG transforms. */}
3982
+ {(() => {
3983
+ const isDefaultView = Math.abs(view.zoom - 1) < 0.01 && Math.abs(view.x) < 1 && Math.abs(view.y) < 1;
3984
+ if (isDefaultView || (onlineNodes.length + offlineNodes.length) === 0) return null;
3985
+ const MW = 120, MH = 82;
3986
+ const sx = MW / VIEWBOX_W, sy = MH / VIEWBOX_H;
3987
+ const rectX = (-view.x / view.zoom) * sx;
3988
+ const rectY = (-view.y / view.zoom) * sy;
3989
+ const rectW = (VIEWBOX_W / view.zoom) * sx;
3990
+ const rectH = (VIEWBOX_H / view.zoom) * sy;
3991
+ return (
3992
+ <div
3993
+ className="absolute right-3 rounded-md border shadow-lg shadow-black/30 overflow-hidden anet-fade-in"
3994
+ style={{ bottom: 56, background: pal.legendBox.fill, borderColor: pal.containerBorder, cursor: 'crosshair' }}
3995
+ role="img"
3996
+ aria-label="Topology minimap — click to recenter"
3997
+ title="Minimap · click to recenter"
3998
+ onClick={(e) => {
3999
+ const r = e.currentTarget.getBoundingClientRect();
4000
+ const fx = (e.clientX - r.left) / r.width;
4001
+ const fy = (e.clientY - r.top) / r.height;
4002
+ setView(prev => ({
4003
+ ...prev,
4004
+ x: VIEWBOX_W / 2 - fx * VIEWBOX_W * prev.zoom,
4005
+ y: VIEWBOX_H / 2 - fy * VIEWBOX_H * prev.zoom,
4006
+ }));
4007
+ }}
4008
+ data-topo-minimap
4009
+ >
4010
+ <svg width={MW} height={MH} viewBox={`0 0 ${MW} ${MH}`} style={{ display: 'block' }}>
4011
+ {[...onlineNodes, ...offlineNodes].map(s => {
4012
+ const p = nodePositions[s.alias];
4013
+ if (!p) return null;
4014
+ const sseN = (s.network_id ? sseSessions[`${s.network_id}:${s.alias}`] : undefined) ?? sseSessions[s.alias];
4015
+ const isOn = s.status !== 'offline' || !!sseN;
4016
+ const st = nodeStatus(s, isOn, isLight);
4017
+ return <circle key={s.alias} cx={p.x * sx} cy={p.y * sy} r={isOn ? 1.7 : 1.2} fill={st.primary} opacity={isOn ? 0.9 : 0.5} />;
4018
+ })}
4019
+ {/* viewport rectangle */}
4020
+ <rect
4021
+ x={Math.max(0, rectX)} y={Math.max(0, rectY)}
4022
+ width={Math.max(0, Math.min(MW - Math.max(0, rectX), rectW))}
4023
+ height={Math.max(0, Math.min(MH - Math.max(0, rectY), rectH))}
4024
+ fill="none" stroke={pal.legendAccent} strokeWidth="1" opacity="0.9"
4025
+ />
4026
+ </svg>
4027
+ </div>
4028
+ );
4029
+ })()}
1356
4030
  {/* Round 103 (issue #81): zoom / pan / fullscreen controls — HTML
1357
4031
  overlay so they stay fixed while the SVG content transforms.
1358
4032
  Round 104: Vincent 实测 — the reset action used to be hidden
@@ -1389,6 +4063,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1389
4063
  className="px-2 py-1 hover:bg-white/5 transition-colors"
1390
4064
  style={{ color: pal.legendText }}
1391
4065
  aria-label="Zoom out"
4066
+ title="Zoom out (−)"
1392
4067
  >
1393
4068
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" aria-hidden><path d="M5 12h14" /></svg>
1394
4069
  </button>
@@ -1404,6 +4079,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1404
4079
  className="px-2 py-1 hover:bg-white/5 transition-colors"
1405
4080
  style={{ color: pal.legendText }}
1406
4081
  aria-label="Zoom in"
4082
+ title="Zoom in (+)"
1407
4083
  >
1408
4084
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" aria-hidden><path d="M12 5v14M5 12h14" /></svg>
1409
4085
  </button>
@@ -1413,7 +4089,7 @@ export function TopoGraph({ sessions, sseSessions, renameSignal }: TopoGraphProp
1413
4089
  className="p-1.5 rounded-md border hover:bg-white/5 transition-colors"
1414
4090
  style={{ background: pal.legendBox.fill, borderColor: pal.containerBorder, color: pal.legendText }}
1415
4091
  aria-label="Reset view"
1416
- title="Reset zoom + pan (or double-click the canvas)"
4092
+ title="Reset zoom + pan (0, or double-click the canvas)"
1417
4093
  >
1418
4094
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
1419
4095
  <path d="M3 12a9 9 0 1 0 9-9 9 9 0 0 0-6.4 2.6L3 8" />