@sleep2agi/agent-network-dashboard 0.4.6-preview.14 → 0.4.6-preview.140

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