@sleep2agi/agent-network-dashboard 0.6.3-preview.45 → 0.6.3-preview.47

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 (178) hide show
  1. package/.next/BUILD_COMMIT +1 -1
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/diagnostics/route-bundle-stats.json +6 -5
  5. package/.next/fallback-build-manifest.json +3 -3
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +2 -2
  15. package/.next/server/app/_not-found.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  19. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  22. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/admin.html +2 -2
  24. package/.next/server/app/admin.rsc +2 -2
  25. package/.next/server/app/admin.segments/_full.segment.rsc +2 -2
  26. package/.next/server/app/admin.segments/_head.segment.rsc +1 -1
  27. package/.next/server/app/admin.segments/_index.segment.rsc +2 -2
  28. package/.next/server/app/admin.segments/_tree.segment.rsc +2 -2
  29. package/.next/server/app/admin.segments/admin/__PAGE__.segment.rsc +1 -1
  30. package/.next/server/app/admin.segments/admin.segment.rsc +1 -1
  31. package/.next/server/app/index.html +2 -2
  32. package/.next/server/app/index.rsc +3 -3
  33. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  34. package/.next/server/app/index.segments/_full.segment.rsc +3 -3
  35. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  36. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  37. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  38. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app/login.html +2 -2
  40. package/.next/server/app/login.rsc +3 -3
  41. package/.next/server/app/login.segments/_full.segment.rsc +3 -3
  42. package/.next/server/app/login.segments/_head.segment.rsc +1 -1
  43. package/.next/server/app/login.segments/_index.segment.rsc +2 -2
  44. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  45. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  46. package/.next/server/app/login.segments/login.segment.rsc +1 -1
  47. package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/logs.html +2 -2
  49. package/.next/server/app/logs.rsc +2 -2
  50. package/.next/server/app/logs.segments/_full.segment.rsc +2 -2
  51. package/.next/server/app/logs.segments/_head.segment.rsc +1 -1
  52. package/.next/server/app/logs.segments/_index.segment.rsc +2 -2
  53. package/.next/server/app/logs.segments/_tree.segment.rsc +2 -2
  54. package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +1 -1
  55. package/.next/server/app/logs.segments/logs.segment.rsc +1 -1
  56. package/.next/server/app/messages/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/messages.html +2 -2
  58. package/.next/server/app/messages.rsc +2 -2
  59. package/.next/server/app/messages.segments/_full.segment.rsc +2 -2
  60. package/.next/server/app/messages.segments/_head.segment.rsc +1 -1
  61. package/.next/server/app/messages.segments/_index.segment.rsc +2 -2
  62. package/.next/server/app/messages.segments/_tree.segment.rsc +2 -2
  63. package/.next/server/app/messages.segments/messages/__PAGE__.segment.rsc +1 -1
  64. package/.next/server/app/messages.segments/messages.segment.rsc +1 -1
  65. package/.next/server/app/node/page_client-reference-manifest.js +1 -1
  66. package/.next/server/app/node.html +2 -2
  67. package/.next/server/app/node.rsc +2 -2
  68. package/.next/server/app/node.segments/_full.segment.rsc +2 -2
  69. package/.next/server/app/node.segments/_head.segment.rsc +1 -1
  70. package/.next/server/app/node.segments/_index.segment.rsc +2 -2
  71. package/.next/server/app/node.segments/_tree.segment.rsc +2 -2
  72. package/.next/server/app/node.segments/node/__PAGE__.segment.rsc +1 -1
  73. package/.next/server/app/node.segments/node.segment.rsc +1 -1
  74. package/.next/server/app/nodes/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/nodes.html +2 -2
  76. package/.next/server/app/nodes.rsc +3 -3
  77. package/.next/server/app/nodes.segments/_full.segment.rsc +3 -3
  78. package/.next/server/app/nodes.segments/_head.segment.rsc +1 -1
  79. package/.next/server/app/nodes.segments/_index.segment.rsc +2 -2
  80. package/.next/server/app/nodes.segments/_tree.segment.rsc +2 -2
  81. package/.next/server/app/nodes.segments/nodes/__PAGE__.segment.rsc +2 -2
  82. package/.next/server/app/nodes.segments/nodes.segment.rsc +1 -1
  83. package/.next/server/app/page_client-reference-manifest.js +1 -1
  84. package/.next/server/app/providers/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/providers.html +2 -2
  86. package/.next/server/app/providers.rsc +2 -2
  87. package/.next/server/app/providers.segments/_full.segment.rsc +2 -2
  88. package/.next/server/app/providers.segments/_head.segment.rsc +1 -1
  89. package/.next/server/app/providers.segments/_index.segment.rsc +2 -2
  90. package/.next/server/app/providers.segments/_tree.segment.rsc +2 -2
  91. package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +1 -1
  92. package/.next/server/app/providers.segments/providers.segment.rsc +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 +2 -2
  96. package/.next/server/app/server-logs.segments/_full.segment.rsc +2 -2
  97. package/.next/server/app/server-logs.segments/_head.segment.rsc +1 -1
  98. package/.next/server/app/server-logs.segments/_index.segment.rsc +2 -2
  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 +1 -1
  101. package/.next/server/app/server-logs.segments/server-logs.segment.rsc +1 -1
  102. package/.next/server/app/servers/page_client-reference-manifest.js +1 -1
  103. package/.next/server/app/servers.html +2 -2
  104. package/.next/server/app/servers.rsc +2 -2
  105. package/.next/server/app/servers.segments/_full.segment.rsc +2 -2
  106. package/.next/server/app/servers.segments/_head.segment.rsc +1 -1
  107. package/.next/server/app/servers.segments/_index.segment.rsc +2 -2
  108. package/.next/server/app/servers.segments/_tree.segment.rsc +2 -2
  109. package/.next/server/app/servers.segments/servers/__PAGE__.segment.rsc +1 -1
  110. package/.next/server/app/servers.segments/servers.segment.rsc +1 -1
  111. package/.next/server/app/settings/networks/page_client-reference-manifest.js +1 -1
  112. package/.next/server/app/settings/networks.html +2 -2
  113. package/.next/server/app/settings/networks.rsc +2 -2
  114. package/.next/server/app/settings/networks.segments/_full.segment.rsc +2 -2
  115. package/.next/server/app/settings/networks.segments/_head.segment.rsc +1 -1
  116. package/.next/server/app/settings/networks.segments/_index.segment.rsc +2 -2
  117. package/.next/server/app/settings/networks.segments/_tree.segment.rsc +2 -2
  118. package/.next/server/app/settings/networks.segments/settings/networks/__PAGE__.segment.rsc +1 -1
  119. package/.next/server/app/settings/networks.segments/settings/networks.segment.rsc +1 -1
  120. package/.next/server/app/settings/networks.segments/settings.segment.rsc +1 -1
  121. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  122. package/.next/server/app/settings/tokens/page_client-reference-manifest.js +1 -1
  123. package/.next/server/app/settings/tokens.html +2 -2
  124. package/.next/server/app/settings/tokens.rsc +2 -2
  125. package/.next/server/app/settings/tokens.segments/_full.segment.rsc +2 -2
  126. package/.next/server/app/settings/tokens.segments/_head.segment.rsc +1 -1
  127. package/.next/server/app/settings/tokens.segments/_index.segment.rsc +2 -2
  128. package/.next/server/app/settings/tokens.segments/_tree.segment.rsc +2 -2
  129. package/.next/server/app/settings/tokens.segments/settings/tokens/__PAGE__.segment.rsc +1 -1
  130. package/.next/server/app/settings/tokens.segments/settings/tokens.segment.rsc +1 -1
  131. package/.next/server/app/settings/tokens.segments/settings.segment.rsc +1 -1
  132. package/.next/server/app/settings.html +2 -2
  133. package/.next/server/app/settings.rsc +3 -3
  134. package/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  135. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  136. package/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  137. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  138. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  139. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  140. package/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  141. package/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/tasks.html +2 -2
  143. package/.next/server/app/tasks.rsc +2 -2
  144. package/.next/server/app/tasks.segments/_full.segment.rsc +2 -2
  145. package/.next/server/app/tasks.segments/_head.segment.rsc +1 -1
  146. package/.next/server/app/tasks.segments/_index.segment.rsc +2 -2
  147. package/.next/server/app/tasks.segments/_tree.segment.rsc +2 -2
  148. package/.next/server/app/tasks.segments/tasks/__PAGE__.segment.rsc +1 -1
  149. package/.next/server/app/tasks.segments/tasks.segment.rsc +1 -1
  150. package/.next/server/chunks/ssr/[root-of-the-server]__0z0lvdf._.js +1 -1
  151. package/.next/server/chunks/ssr/[root-of-the-server]__0z0lvdf._.js.map +1 -1
  152. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_0fv9~x1._.js +1 -1
  153. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_0fv9~x1._.js.map +1 -1
  154. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_10nv4wt._.js +1 -1
  155. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_10nv4wt._.js.map +1 -1
  156. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_nodes_page_tsx_0txhbdg._.js +1 -1
  157. package/.next/server/chunks/ssr/dash-492_agent-network-dashboard_app_nodes_page_tsx_0txhbdg._.js.map +1 -1
  158. package/.next/server/middleware-build-manifest.js +3 -3
  159. package/.next/server/pages/404.html +2 -2
  160. package/.next/server/pages/500.html +1 -1
  161. package/.next/static/chunks/{0gv~xarphwy7~.js → 01._8ofei5fhr.js} +1 -1
  162. package/.next/static/chunks/0gk0h85cypg0x.js +2 -0
  163. package/.next/static/chunks/0ox1.tctxohjp.js +1 -0
  164. package/.next/static/chunks/{00.lep~gx75xc.js → 0sho~kyb36fsr.js} +1 -1
  165. package/.next/static/chunks/0zr5_trgn~gcn.css +1 -0
  166. package/.next/static/chunks/{0k_3kdj.1c2m5.js → 14d59jgser~dh.js} +1 -1
  167. package/.next/trace +2 -2
  168. package/.next/trace-build +1 -1
  169. package/app/components/NodeList.tsx +128 -0
  170. package/app/nodes/page.tsx +200 -1
  171. package/package.json +1 -1
  172. package/tests/e2e-9-nodes-team-tag-filter.spec.ts +222 -0
  173. package/tests/e2e-stage-a-node-list.spec.ts +138 -0
  174. package/.next/static/chunks/0e3gktr80d3im.js +0 -2
  175. package/.next/static/chunks/0e4..kvu5tnv-.css +0 -1
  176. /package/.next/static/{EEoQxe-lggOsAx0h8hIFx → 51LJguBtVvMSYOWJA7Qbc}/_buildManifest.js +0 -0
  177. /package/.next/static/{EEoQxe-lggOsAx0h8hIFx → 51LJguBtVvMSYOWJA7Qbc}/_clientMiddlewareManifest.js +0 -0
  178. /package/.next/static/{EEoQxe-lggOsAx0h8hIFx → 51LJguBtVvMSYOWJA7Qbc}/_ssgManifest.js +0 -0
@@ -14,6 +14,7 @@ import { isMuted, useMuteVersion } from '../lib/chat-mute';
14
14
  import { isPinned, usePinVersion } from '../lib/chat-pin';
15
15
  import { pinyinMatch, usePinyinReady } from '../lib/pinyin-match';
16
16
  import { useCollapsibleSearch } from '../components/CollapsibleSearch';
17
+ import { NodeList } from '../components/NodeList';
17
18
  import type { Session } from '../components/types';
18
19
  import { SESSION_STATUS_CHIP_CLASS as STATUS_COLORS } from '../lib/status';
19
20
  import { useChatUnread } from '../lib/chat-unread';
@@ -56,7 +57,29 @@ export default function NodesPage() {
56
57
  const sseFor = (s: { alias: string; network_id?: string }) =>
57
58
  (s.network_id ? sseMap[`${s.network_id}:${s.alias}`] : undefined) ?? sseMap[s.alias];
58
59
  const [filterStatus, setFilterStatus] = useState('');
60
+ // #492 goal-3 step 2: filter by team (single-select, '' = no filter,
61
+ // '__NO_TEAM__' = "nodes without any team assignment"). team match is
62
+ // strict equality against attrsByAlias[alias].team ?? null — nodes
63
+ // WITHOUT a team never leak into "team X" results (per PR review:
64
+ // fixture must have mixed team values and assert exact aliases, not
65
+ // just count).
66
+ const [filterTeam, setFilterTeam] = useState('');
67
+ // #492 goal-3 step 2: tag filter is multi-select with AND semantics —
68
+ // "show nodes that have ALL of these tags". This is a product
69
+ // decision (per PR review: OR would be the naive user default; AND
70
+ // is intentional so operators can narrow down instead of widen out).
71
+ // Rendered chip row shows explicit "AND" separators + empty-state
72
+ // echoes the filter conditions so a zero-result AND intersection
73
+ // never looks like a data-sync bug.
74
+ const [filterTags, setFilterTags] = useState<string[]>([]);
59
75
  const [search, setSearch] = useState('');
76
+ const toggleTag = (t: string) => setFilterTags(cur => cur.includes(t) ? cur.filter(x => x !== t) : [...cur, t]);
77
+ // Distinct teams/tags across visible sessions — drives the select
78
+ // options and chip row, and lets us distinguish "cold-start no attrs"
79
+ // from "no match" in the empty state.
80
+ const distinctTeams = Array.from(new Set(sessions.map(s => attrsByAlias[s.alias]?.team).filter((t): t is string => !!t && t.length > 0))).sort();
81
+ const distinctTags = Array.from(new Set(sessions.flatMap(s => attrsByAlias[s.alias]?.tags ?? []).filter(t => t && t.length > 0))).sort();
82
+ const anyAttrs = distinctTeams.length > 0 || distinctTags.length > 0;
60
83
  const pinyinReady = usePinyinReady();
61
84
  const muteVersion = useMuteVersion();
62
85
  void muteVersion; // re-render on mute toggles (isMuted used in map callbacks)
@@ -66,6 +89,24 @@ export default function NodesPage() {
66
89
  const [viewMode, setViewMode] = useState<ViewMode>('list');
67
90
  const [chatAlias, setChatAlias] = useState<string | null>(null);
68
91
  const [showCreate, setShowCreate] = useState(false);
92
+ // #Stage A (dashboard 3-col, 07-31): persistent narrow node list rail
93
+ // to the left of the existing table. Default on; user can hide to
94
+ // restore the pre-Stage-A dense-table-only layout (Vincent's "看全局"
95
+ // pattern MUST stay reachable — 通信龙 07-31 explicit constraint).
96
+ // Persisted in localStorage so a returning user gets the same layout
97
+ // they left.
98
+ const [showRail, setShowRail] = useState<boolean>(() => {
99
+ if (typeof window === 'undefined') return true;
100
+ const v = window.localStorage.getItem('anet-nodes-rail');
101
+ return v === null ? true : v !== '0';
102
+ });
103
+ const toggleRail = () => {
104
+ setShowRail(v => {
105
+ const next = !v;
106
+ try { window.localStorage.setItem('anet-nodes-rail', next ? '1' : '0'); } catch {}
107
+ return next;
108
+ });
109
+ };
69
110
  // #209 R32→R34: the WeChat-style magnifier-toggle search was hand-rolled
70
111
  // inline in R32. R34 extracted it to a shared hook so /nodes, /messages,
71
112
  // and any future search surface stay visually + behaviourally identical.
@@ -93,13 +134,57 @@ export default function NodesPage() {
93
134
  if (filterStatus && filterStatus !== s.status) return false;
94
135
  return true;
95
136
  })
137
+ .filter(s => {
138
+ // #492 team filter — strict match. '' = pass all; '__NO_TEAM__' =
139
+ // only nodes with no team assigned; any other value = exact match.
140
+ // Nodes without a team NEVER leak into a "team X" result.
141
+ if (!filterTeam) return true;
142
+ const team = attrsByAlias[s.alias]?.team ?? null;
143
+ if (filterTeam === '__NO_TEAM__') return team === null || team === '';
144
+ return team === filterTeam;
145
+ })
146
+ .filter(s => {
147
+ // #492 tag filter — AND across all chip selections. Zero selected =
148
+ // pass all. Product decision (AND not OR): operators narrow down.
149
+ if (filterTags.length === 0) return true;
150
+ const nodeTags = attrsByAlias[s.alias]?.tags ?? [];
151
+ return filterTags.every(t => nodeTags.includes(t));
152
+ })
96
153
  .filter(s => !search || pinyinMatch(s.alias, search) || pinyinMatch(s.agent || '', search))
97
154
  .sort((a, b) => ((isPinned(b.alias) ? 1 : 0) - (isPinned(a.alias) ? 1 : 0)) || (sortOnline(b.alias, b.online) - sortOnline(a.alias, a.online)) || lastActivityAt(b.alias) - lastActivityAt(a.alias)); // R41 pin > R29 online-hysteresis > recency
98
155
 
99
156
  const onlineCount = sessions.filter(s => sseFor(s)).length;
100
157
 
158
+ // #Stage A: filtered rail sessions — same criteria as the table, so
159
+ // the two views agree while chips are toggled. Passing the SAME
160
+ // filtered array (not re-computing) is the invariant that keeps
161
+ // "rail count == table count" true at all times.
162
+ const railSessions = filtered;
163
+
101
164
  return (
102
- <div className="min-h-screen max-w-full overflow-x-hidden bg-[#0b0b0d] text-gray-100 p-4 sm:p-6">
165
+ <div
166
+ data-testid="nodes-layout"
167
+ data-rail-visible={showRail ? 'true' : 'false'}
168
+ className="min-h-screen max-w-full overflow-x-hidden bg-[#0b0b0d] text-gray-100 flex"
169
+ >
170
+ {/* #Stage A rail — only mounted when showRail is true AND we're
171
+ past the mobile breakpoint (below sm, rail is hidden by CSS
172
+ to give the table full width on small screens; the toggle
173
+ button controls both). sessions.length===0 also hides the rail
174
+ because there's nothing to list. */}
175
+ {showRail && sessions.length > 0 && (
176
+ <aside
177
+ data-testid="node-list-rail"
178
+ className="hidden sm:flex sm:flex-col w-[280px] shrink-0 min-h-screen sticky top-0"
179
+ >
180
+ <NodeList
181
+ sessions={railSessions}
182
+ selectedAlias={chatAlias}
183
+ onSelect={setChatAlias}
184
+ />
185
+ </aside>
186
+ )}
187
+ <div className="flex-1 min-w-0 max-w-full overflow-x-hidden p-4 sm:p-6">
103
188
  {/* #209 R31 (mobile vertical rhythm — goal "大幅提升移动端体验",
104
189
  extending R28's Overview pattern + R30's /tasks pattern):
105
190
  this header row + the status-bar wrapper + the filter row
@@ -119,6 +204,21 @@ export default function NodesPage() {
119
204
  </span>
120
205
  </div>
121
206
  <div className="flex items-center gap-2 shrink-0">
207
+ {/* #Stage A rail toggle — visible on sm+ (where rail also
208
+ renders). Preserves Vincent's "看全局" dense-table view
209
+ as one click away (通信龙 07-31 constraint). Icon-only
210
+ on mobile / sm; icon + text on md+. */}
211
+ <button
212
+ type="button"
213
+ onClick={toggleRail}
214
+ aria-pressed={showRail}
215
+ data-testid="toggle-rail"
216
+ title={showRail ? t('隐藏节点列表', 'Hide node list') : t('显示节点列表', 'Show node list')}
217
+ className="hidden sm:inline-flex items-center gap-1 rounded-lg border border-[#26262b] bg-[#161618] px-2.5 py-1.5 text-xs text-gray-400 hover:text-gray-200 hover:border-[#3a3a40] transition-colors"
218
+ >
219
+ <span aria-hidden className="text-sm leading-none">{showRail ? '☷' : '☰'}</span>
220
+ <span className="hidden md:inline">{showRail ? t('密视图', 'Dense') : t('分栏', 'Split')}</span>
221
+ </button>
122
222
  {/* node-lifecycle M2: open the create-node wizard (RFC-026 §3.1 P1). */}
123
223
  <button
124
224
  type="button"
@@ -168,6 +268,24 @@ export default function NodesPage() {
168
268
  <option value="blocked">Blocked</option>
169
269
  <option value="error">Error</option>
170
270
  </select>
271
+ {/* #492 team select — only shown once at least one node has a
272
+ team attribute. "__NO_TEAM__" surfaces nodes without team,
273
+ so operators can find nodes that never got tagged. */}
274
+ {distinctTeams.length > 0 && (
275
+ <select
276
+ value={filterTeam}
277
+ onChange={e => setFilterTeam(e.target.value)}
278
+ aria-label={t('按 Team 过滤', 'Filter by team')}
279
+ data-testid="filter-team"
280
+ className="bg-[#161618] border border-[#26262b] rounded-lg px-3 py-2 text-base sm:text-sm text-white focus:border-blue-500/50 focus:outline-none"
281
+ >
282
+ <option value="">{t('全部 Team', 'All teams')}</option>
283
+ <option value="__NO_TEAM__">{t('未分组', '(no team)')}</option>
284
+ {distinctTeams.map(team => (
285
+ <option key={team} value={team}>{team}</option>
286
+ ))}
287
+ </select>
288
+ )}
171
289
  {/* Round 80: List/Grid toggle hidden on mobile — Grid uses
172
290
  grid-cols-1 below `md` and List degrades to the same single
173
291
  column, so the toggle has no visual effect under sm and only
@@ -190,6 +308,57 @@ export default function NodesPage() {
190
308
  </div>
191
309
  </div>
192
310
  )}
311
+ {/* #492 tag chip row — separate row so multi-select feels distinct
312
+ from single-select controls above. Each chip toggles inclusion;
313
+ selected chips get cyan bg. Explicit "AND" separators between
314
+ selected chips make the join semantics visible in the UI (per
315
+ PR review: silent AND under selected-multiple → 0 results
316
+ reads as bug; the label makes it a deliberate narrow-down). */}
317
+ {sessions.length > 0 && distinctTags.length > 0 && (
318
+ <div className="mb-4 sm:mb-6 flex flex-wrap items-center gap-1.5" data-testid="filter-tags-row">
319
+ <span className="text-[11px] text-gray-500 mr-1">{t('Tags:', 'Tags:')}</span>
320
+ {distinctTags.map((tag, idx) => {
321
+ const selected = filterTags.includes(tag);
322
+ const isNotFirstSelected = selected && filterTags.slice(0, filterTags.indexOf(tag)).length > 0;
323
+ void idx; void isNotFirstSelected;
324
+ return (
325
+ <button
326
+ key={tag}
327
+ type="button"
328
+ onClick={() => toggleTag(tag)}
329
+ aria-pressed={selected}
330
+ data-tag={tag}
331
+ data-selected={selected ? 'true' : 'false'}
332
+ className={`text-xs rounded-full px-2.5 py-1 border transition-colors ${
333
+ selected
334
+ ? 'bg-cyan-500/15 text-cyan-200 border-cyan-500/40'
335
+ : 'bg-[#161618] text-gray-400 border-[#26262b] hover:text-gray-200 hover:border-[#3a3a40]'
336
+ }`}
337
+ >
338
+ {tag}
339
+ </button>
340
+ );
341
+ })}
342
+ {filterTags.length >= 2 && (
343
+ <span
344
+ className="text-[10px] text-cyan-300/80 ml-1 tabular-nums"
345
+ data-testid="filter-tags-and-hint"
346
+ >
347
+ {t(`= 同时具有 ${filterTags.length} 个标签`, `= AND of ${filterTags.length} tags`)}
348
+ </span>
349
+ )}
350
+ {(filterTags.length > 0 || filterTeam) && (
351
+ <button
352
+ type="button"
353
+ onClick={() => { setFilterTags([]); setFilterTeam(''); }}
354
+ className="text-[11px] text-gray-500 hover:text-gray-200 underline-offset-2 hover:underline ml-2"
355
+ data-testid="clear-attr-filters"
356
+ >
357
+ {t('清除', 'Clear')}
358
+ </button>
359
+ )}
360
+ </div>
361
+ )}
193
362
 
194
363
  {loading ? (
195
364
  <div className="animate-pulse space-y-2">
@@ -203,6 +372,31 @@ export default function NodesPage() {
203
372
  was the "No nodes match your filters" copy, which was wrong
204
373
  for new users who have no filters applied. */
205
374
  <NodesEmptyState />
375
+ ) : (filterTeam || filterTags.length > 0) ? (
376
+ /* #492: attribute-filter no-match — echo the specific filter
377
+ conditions so the user can tell "no nodes exist with this
378
+ combo" from "I mis-typed / data isn't synced". Distinct
379
+ from the generic status/search "No match" below. Under
380
+ AND semantics for multi-tag, this is the copy 通信龙 asked
381
+ for: "没有节点同时具有 A 和 B" instead of "no match". */
382
+ <EmptyState
383
+ variant="nodes"
384
+ title={t('没有节点符合当前属性筛选', 'No nodes match the current attribute filters')}
385
+ sub={(() => {
386
+ const parts: string[] = [];
387
+ if (filterTeam === '__NO_TEAM__') parts.push(t('未分组', 'no-team'));
388
+ else if (filterTeam) parts.push(t(`Team = ${filterTeam}`, `Team = ${filterTeam}`));
389
+ if (filterTags.length === 1) parts.push(t(`标签 ${filterTags[0]}`, `tag ${filterTags[0]}`));
390
+ else if (filterTags.length >= 2) parts.push(t(`同时具有标签 ${filterTags.join(' 和 ')}`, `all of tags: ${filterTags.join(' AND ')}`));
391
+ return t(`没有节点满足:${parts.join(' + ')}。清除筛选或减少标签。`, `No node satisfies: ${parts.join(' + ')}. Clear filters or drop a tag.`);
392
+ })()}
393
+ />
394
+ ) : !anyAttrs && (filterStatus || search) ? (
395
+ <EmptyState
396
+ variant="nodes"
397
+ title={t('还没有节点被打过标签', 'No nodes have been tagged yet')}
398
+ sub={t('先在节点详情里给几个节点分配 team / tag,然后就可以按属性筛选。', 'Assign team / tag to a few nodes first, then attribute filters will show up.')}
399
+ />
206
400
  ) : (
207
401
  <EmptyState
208
402
  variant="nodes"
@@ -222,6 +416,8 @@ export default function NodesPage() {
222
416
  key={s.alias}
223
417
  role="button"
224
418
  tabIndex={0}
419
+ data-node-card
420
+ data-node-alias={s.alias}
225
421
  onClick={() => setChatAlias(s.alias)}
226
422
  onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setChatAlias(s.alias); } }}
227
423
  className={`relative min-w-0 max-w-full overflow-hidden rounded-xl border border-[#26262b] bg-[#161618] p-4 transition-colors hover:border-cyan-500/40 cursor-pointer ${!s.online ? 'opacity-60' : ''}`}
@@ -316,6 +512,8 @@ export default function NodesPage() {
316
512
  key={s.alias}
317
513
  role="button"
318
514
  tabIndex={0}
515
+ data-node-card
516
+ data-node-alias={s.alias}
319
517
  onClick={() => setChatAlias(s.alias)}
320
518
  onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setChatAlias(s.alias); } }}
321
519
  className={`rounded-lg border border-[#26262b] bg-[#161618] px-3 py-2 sm:px-4 sm:py-3 transition-colors hover:border-cyan-500/40 cursor-pointer ${!s.online ? 'opacity-50' : ''}`}
@@ -407,6 +605,7 @@ export default function NodesPage() {
407
605
  )}
408
606
 
409
607
  {chatAlias && <TaskChatPanel alias={chatAlias} onClose={() => setChatAlias(null)} />}
608
+ </div>
410
609
  </div>
411
610
  );
412
611
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network-dashboard",
3
- "version": "0.6.3-preview.45",
3
+ "version": "0.6.3-preview.47",
4
4
  "description": "Agent Network Dashboard — Web UI for managing AI Agent networks",
5
5
  "main": "apps/desktop/electron/main.cjs",
6
6
  "scripts": {
@@ -0,0 +1,222 @@
1
+ import { test, expect, Page } from '@playwright/test';
2
+
3
+ const BASE = process.env.TEST_URL || 'http://localhost:3100';
4
+
5
+ // #492 Goal-3 step 2 — /nodes filter by team/tag. Three fixtures with
6
+ // DELIBERATELY MIXED attr values so tests can't accidentally pass on
7
+ // the "everyone has team X, so filter=X shows everyone" trap.
8
+ //
9
+ // Per PR review (通信龙):
10
+ // - team fixture MUST contain (a) target-team nodes, (b) empty-team
11
+ // nodes, (c) other-team nodes. Assert filter result equals the
12
+ // EXACT alias set, not just count.
13
+ // - tag fixture MUST contain (a) nodes with target-tag, (b) nodes
14
+ // with a different tag, (c) nodes with empty tags[]. Assert AND
15
+ // semantics catch nodes with ALL selected tags, not any.
16
+ // - Empty state copy MUST echo the filter conditions under AND
17
+ // (e.g. "no nodes with A and B") so a 0-result intersection
18
+ // doesn't look like a data-sync bug.
19
+ // - Cold-start (no node has any attrs) MUST render its own copy
20
+ // ("还没有节点被打过标签"), not generic "no match".
21
+
22
+ // Fixture 1 — TEAMS: mixed values.
23
+ const HUB_STATUS_TEAMS = {
24
+ sessions: [
25
+ { alias: 'alpha-a', status: 'idle', network_id: 'net_x' },
26
+ { alias: 'alpha-b', status: 'idle', network_id: 'net_x' },
27
+ { alias: 'beta-a', status: 'idle', network_id: 'net_x' },
28
+ { alias: 'no-team', status: 'idle', network_id: 'net_x' },
29
+ ],
30
+ };
31
+ const HUB_NODES_TEAMS = {
32
+ nodes: [
33
+ { alias: 'alpha-a', team: 'alpha', tags: [] },
34
+ { alias: 'alpha-b', team: 'alpha', tags: [] },
35
+ { alias: 'beta-a', team: 'beta', tags: [] },
36
+ { alias: 'no-team', team: null, tags: [] },
37
+ ],
38
+ };
39
+
40
+ // Fixture 2 — TAGS: mixed values including empty and disjoint tag sets.
41
+ const HUB_STATUS_TAGS = {
42
+ sessions: [
43
+ { alias: 'both-tags', status: 'idle', network_id: 'net_x' }, // has BOTH a,b
44
+ { alias: 'a-only', status: 'idle', network_id: 'net_x' }, // has just a
45
+ { alias: 'b-only', status: 'idle', network_id: 'net_x' }, // has just b
46
+ { alias: 'no-tags', status: 'idle', network_id: 'net_x' }, // has none
47
+ ],
48
+ };
49
+ const HUB_NODES_TAGS = {
50
+ nodes: [
51
+ // Adding a third distinct tag 'canary' on 'b-only' so an AND like
52
+ // {prod,canary} produces 0 results — used by the empty-state-copy test.
53
+ { alias: 'both-tags', team: null, tags: ['prod', 'db'] },
54
+ { alias: 'a-only', team: null, tags: ['prod'] },
55
+ { alias: 'b-only', team: null, tags: ['db', 'canary'] },
56
+ { alias: 'no-tags', team: null, tags: [] },
57
+ ],
58
+ };
59
+
60
+ // Fixture 3 — COLD START: no attrs at all. Filter chrome must NOT
61
+ // appear (no distinct teams/tags); if user has filterStatus/search set
62
+ // AND gets no results, the copy must say "no nodes tagged yet".
63
+ const HUB_STATUS_COLD = {
64
+ sessions: [
65
+ { alias: 'untagged-1', status: 'idle', network_id: 'net_x' },
66
+ { alias: 'untagged-2', status: 'idle', network_id: 'net_x' },
67
+ ],
68
+ };
69
+ const HUB_NODES_COLD = {
70
+ nodes: [
71
+ { alias: 'untagged-1', team: null, tags: [] },
72
+ { alias: 'untagged-2', team: null, tags: [] },
73
+ ],
74
+ };
75
+
76
+ const HUB_HEALTH_EMPTY = {
77
+ ok: true,
78
+ version: '0.9.0-test',
79
+ sse_connections: 0,
80
+ sse_sessions: {},
81
+ };
82
+
83
+ async function login(context: Page['context'] extends () => infer C ? C : never) {
84
+ const res = await context.request.post(`${BASE}/api/auth/login`, {
85
+ data: { password: process.env.ANET_DASHBOARD_PASSWORD || 'admin123' },
86
+ });
87
+ const setCookie = res.headers()['set-cookie'] || '';
88
+ const m = setCookie.match(/anet_dashboard_session=([^;]+)/);
89
+ if (m) {
90
+ await context.addCookies([{
91
+ name: 'anet_dashboard_session',
92
+ value: decodeURIComponent(m[1]),
93
+ domain: new URL(BASE).hostname,
94
+ path: '/',
95
+ }]);
96
+ }
97
+ }
98
+
99
+ async function mockCommon(page: Page, statusBody: object, nodesBody: object) {
100
+ await page.route('**/api/hub/status**', r =>
101
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(statusBody) }));
102
+ await page.route('**/api/hub/nodes**', r =>
103
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(nodesBody) }));
104
+ await page.route('**/api/hub/health', r =>
105
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(HUB_HEALTH_EMPTY) }));
106
+ await page.route('**/api/hub/tasks**', r =>
107
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ tasks: [] }) }));
108
+ await page.route('**/api/hub/stats**', r =>
109
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({}) }));
110
+ await page.route('**/api/hub/messages**', r =>
111
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ messages: [] }) }));
112
+ }
113
+
114
+ test.describe('#492 /nodes filter by team/tag', () => {
115
+ test('TEAMS: filter=alpha returns EXACTLY {alpha-a, alpha-b} (no leak of empty-team or beta)', async ({ page, context }) => {
116
+ await login(context);
117
+ await mockCommon(page, HUB_STATUS_TEAMS, HUB_NODES_TEAMS);
118
+ await page.goto(`${BASE}/nodes`);
119
+ await expect(page.locator('h1', { hasText: 'Nodes' }).first()).toBeVisible({ timeout: 15000 });
120
+ await expect(page.locator('[data-testid="filter-team"]').first()).toBeVisible({ timeout: 10000 });
121
+ await page.locator('[data-testid="filter-team"]').selectOption('alpha');
122
+ await page.waitForTimeout(500);
123
+
124
+ // Assert EXACT alias set — count assertion alone would let a bug
125
+ // that also leaks "no-team" survive (2 alpha + 2 leaks would still
126
+ // == 2 if beta was also excluded).
127
+ const bodyText = await page.locator('body').innerText();
128
+ expect(bodyText).toContain('alpha-a');
129
+ expect(bodyText).toContain('alpha-b');
130
+ expect(bodyText).not.toContain('beta-a');
131
+ expect(bodyText).not.toContain('no-team');
132
+ });
133
+
134
+ test('TEAMS: filter=__NO_TEAM__ returns EXACTLY {no-team}', async ({ page, context }) => {
135
+ await login(context);
136
+ await mockCommon(page, HUB_STATUS_TEAMS, HUB_NODES_TEAMS);
137
+ await page.goto(`${BASE}/nodes`);
138
+ await expect(page.locator('[data-testid="filter-team"]').first()).toBeVisible({ timeout: 15000 });
139
+ await page.locator('[data-testid="filter-team"]').selectOption('__NO_TEAM__');
140
+ await page.waitForTimeout(500);
141
+
142
+ const bodyText = await page.locator('body').innerText();
143
+ expect(bodyText).toContain('no-team');
144
+ expect(bodyText).not.toContain('alpha-a');
145
+ expect(bodyText).not.toContain('alpha-b');
146
+ expect(bodyText).not.toContain('beta-a');
147
+ });
148
+
149
+ test('TAGS: AND semantics — selecting prod+db returns EXACTLY {ab}', async ({ page, context }) => {
150
+ await login(context);
151
+ await mockCommon(page, HUB_STATUS_TAGS, HUB_NODES_TAGS);
152
+ await page.goto(`${BASE}/nodes`);
153
+ await expect(page.locator('[data-testid="filter-tags-row"]').first()).toBeVisible({ timeout: 15000 });
154
+ // Click both tag chips
155
+ await page.locator('button[data-tag="prod"]').click();
156
+ await page.locator('button[data-tag="db"]').click();
157
+ await page.waitForTimeout(500);
158
+
159
+ // Explicit AND hint must appear when >= 2 tags selected
160
+ await expect(page.locator('[data-testid="filter-tags-and-hint"]').first()).toBeVisible();
161
+
162
+ const bodyText = await page.locator('body').innerText();
163
+ expect(bodyText).toContain('both-tags');
164
+ expect(bodyText).not.toContain('a-only');
165
+ expect(bodyText).not.toContain('b-only');
166
+ expect(bodyText).not.toContain('no-tags');
167
+ // Round-2 review (通信龙): substring assertions alone can't
168
+ // distinguish "correct 1 result" from "0 results" when the target
169
+ // alias happens to appear elsewhere on the page. Pin exact count
170
+ // via data-node-card (added on both list + grid render modes).
171
+ // Also assert the ONE surviving card is the target — kills any
172
+ // "1 card visible but wrong one" bug.
173
+ await expect(page.locator('[data-node-card]')).toHaveCount(1);
174
+ await expect(page.locator('[data-node-alias="both-tags"]')).toHaveCount(1);
175
+ });
176
+
177
+ test('TAGS: AND-empty result — copy echoes the specific filter conditions', async ({ page, context }) => {
178
+ await login(context);
179
+ await mockCommon(page, HUB_STATUS_TAGS, HUB_NODES_TAGS);
180
+ await page.goto(`${BASE}/nodes`);
181
+ await expect(page.locator('[data-testid="filter-tags-row"]').first()).toBeVisible({ timeout: 15000 });
182
+ // prod + canary — no node has BOTH ('both-tags' has prod+db, 'b-only'
183
+ // has db+canary). AND intersection is empty. This is the exact
184
+ // scenario 通信龙 flagged: silent 0-result looks like a data-sync
185
+ // bug; the copy must echo "no nodes with both prod AND canary".
186
+ await page.locator('button[data-tag="prod"]').click();
187
+ await page.locator('button[data-tag="canary"]').click();
188
+ await page.waitForTimeout(500);
189
+
190
+ const bodyText = await page.locator('body').innerText();
191
+ // Filter-echoing empty-state names the specific tags (English locale
192
+ // is the runtime default; also match Chinese as a safety net for
193
+ // locale flips in future).
194
+ expect(bodyText).toMatch(/prod/);
195
+ expect(bodyText).toMatch(/canary/);
196
+ expect(bodyText).toMatch(/No nodes match the current attribute filters|没有节点符合当前属性筛选/);
197
+ // The specific "all of tags: prod AND canary" copy must appear —
198
+ // this is what makes the AND-empty state distinguishable from a
199
+ // data-sync bug (通信龙 review requirement).
200
+ expect(bodyText).toMatch(/all of tags:\s*prod\s+AND\s+canary|同时具有标签\s*prod\s+和\s+canary/);
201
+ // Generic "No nodes match your filters" (older status/search copy)
202
+ // MUST NOT show up when attribute filters are active.
203
+ expect(bodyText).not.toContain('No nodes match your filters');
204
+ });
205
+
206
+ test('COLD START: no attrs — team select + tag chip row are hidden', async ({ page, context }) => {
207
+ await login(context);
208
+ await mockCommon(page, HUB_STATUS_COLD, HUB_NODES_COLD);
209
+ await page.goto(`${BASE}/nodes`);
210
+ await expect(page.locator('h1', { hasText: 'Nodes' }).first()).toBeVisible({ timeout: 15000 });
211
+ await page.waitForTimeout(500);
212
+
213
+ // Neither filter control should render — nothing to filter by.
214
+ expect(await page.locator('[data-testid="filter-team"]').count()).toBe(0);
215
+ expect(await page.locator('[data-testid="filter-tags-row"]').count()).toBe(0);
216
+
217
+ // Nodes ARE visible (untagged-1, untagged-2).
218
+ const bodyText = await page.locator('body').innerText();
219
+ expect(bodyText).toContain('untagged-1');
220
+ expect(bodyText).toContain('untagged-2');
221
+ });
222
+ });
@@ -0,0 +1,138 @@
1
+ import { test, expect, Page } from '@playwright/test';
2
+
3
+ const BASE = process.env.TEST_URL || 'http://localhost:3100';
4
+
5
+ // Stage A — persistent node list rail on /nodes. Two guarantees:
6
+ // 1. Rail entries mirror the existing table (same filtered set),
7
+ // just in a WeChat-style narrow row form.
8
+ // 2. Toggle button hides/shows the rail; state persists.
9
+ //
10
+ // Explicitly NOT tested here (covered by e2e-9-nodes-team-tag-filter):
11
+ // - filter behavior (team, tags, search) — rail feeds off same
12
+ // `filtered` array as the table, so filter tests transitively
13
+ // cover rail contents too. See the "count matches table" test
14
+ // below for the transitivity assertion.
15
+
16
+ const HUB_STATUS = {
17
+ sessions: [
18
+ { alias: 'stage-a-1', status: 'idle', network_id: 'net_x' },
19
+ { alias: 'stage-a-2', status: 'working', network_id: 'net_x' },
20
+ { alias: 'stage-a-3', status: 'idle', network_id: 'net_x' },
21
+ ],
22
+ };
23
+
24
+ const HUB_NODES = {
25
+ nodes: [
26
+ { alias: 'stage-a-1', team: null, tags: [] },
27
+ { alias: 'stage-a-2', team: null, tags: [] },
28
+ { alias: 'stage-a-3', team: null, tags: [] },
29
+ ],
30
+ };
31
+
32
+ const HUB_HEALTH = {
33
+ ok: true,
34
+ version: '0.9.0-test',
35
+ sse_connections: 3,
36
+ sse_sessions: {
37
+ 'net_x:stage-a-1': 1,
38
+ 'net_x:stage-a-2': 1,
39
+ 'net_x:stage-a-3': 1,
40
+ },
41
+ };
42
+
43
+ async function login(context: Page['context'] extends () => infer C ? C : never) {
44
+ const res = await context.request.post(`${BASE}/api/auth/login`, {
45
+ data: { password: process.env.ANET_DASHBOARD_PASSWORD || 'admin123' },
46
+ });
47
+ const setCookie = res.headers()['set-cookie'] || '';
48
+ const m = setCookie.match(/anet_dashboard_session=([^;]+)/);
49
+ if (m) {
50
+ await context.addCookies([{
51
+ name: 'anet_dashboard_session',
52
+ value: decodeURIComponent(m[1]),
53
+ domain: new URL(BASE).hostname,
54
+ path: '/',
55
+ }]);
56
+ }
57
+ }
58
+
59
+ async function mockCommon(page: Page) {
60
+ await page.route('**/api/hub/status**', r =>
61
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(HUB_STATUS) }));
62
+ await page.route('**/api/hub/nodes**', r =>
63
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(HUB_NODES) }));
64
+ await page.route('**/api/hub/health', r =>
65
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(HUB_HEALTH) }));
66
+ await page.route('**/api/hub/tasks**', r =>
67
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ tasks: [] }) }));
68
+ await page.route('**/api/hub/stats**', r =>
69
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({}) }));
70
+ await page.route('**/api/hub/messages**', r =>
71
+ r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ messages: [] }) }));
72
+ }
73
+
74
+ test.describe('Stage A — persistent NodeList rail', () => {
75
+ test('rail is visible by default AND contains the SAME nodes as the table', async ({ page, context }) => {
76
+ await login(context);
77
+ await mockCommon(page);
78
+ // Clear the localStorage anet-nodes-rail toggle first so we test the default.
79
+ await page.addInitScript(() => window.localStorage.removeItem('anet-nodes-rail'));
80
+ await page.goto(`${BASE}/nodes`);
81
+ await expect(page.locator('[data-testid="node-list-rail"]').first()).toBeVisible({ timeout: 15000 });
82
+
83
+ // Rail entries and table cards must have IDENTICAL alias sets —
84
+ // this is the transitivity guarantee that lets filter tests
85
+ // (which only assert on the table) cover the rail too.
86
+ const railAliases = await page.locator('[data-node-list-item][data-node-list-alias]').evaluateAll(els => els.map(e => e.getAttribute('data-node-list-alias')).sort());
87
+ const tableAliases = await page.locator('[data-node-card][data-node-alias]').evaluateAll(els => els.map(e => e.getAttribute('data-node-alias')).sort());
88
+ expect(railAliases).toEqual(tableAliases);
89
+ expect(railAliases).toEqual(['stage-a-1', 'stage-a-2', 'stage-a-3']);
90
+ });
91
+
92
+ test('toggle button hides the rail and restores it; state written to localStorage', async ({ page, context }) => {
93
+ await login(context);
94
+ await mockCommon(page);
95
+ await page.addInitScript(() => window.localStorage.removeItem('anet-nodes-rail'));
96
+ await page.goto(`${BASE}/nodes`);
97
+ await expect(page.locator('[data-testid="node-list-rail"]').first()).toBeVisible({ timeout: 15000 });
98
+
99
+ // Hide
100
+ await page.locator('[data-testid="toggle-rail"]').click();
101
+ await expect(page.locator('[data-testid="node-list-rail"]')).toHaveCount(0);
102
+ await expect(page.locator('[data-testid="nodes-layout"]')).toHaveAttribute('data-rail-visible', 'false');
103
+ // Persistence — localStorage got the '0'. Assert directly rather
104
+ // than via reload, because Playwright's addInitScript re-runs on
105
+ // reload and re-clears storage, which would spuriously overturn
106
+ // the persistence signal (test-harness artifact, not product bug).
107
+ expect(await page.evaluate(() => window.localStorage.getItem('anet-nodes-rail'))).toBe('0');
108
+
109
+ // Show again — click restores + storage flips to '1'
110
+ await page.locator('[data-testid="toggle-rail"]').click();
111
+ await expect(page.locator('[data-testid="node-list-rail"]').first()).toBeVisible();
112
+ expect(await page.evaluate(() => window.localStorage.getItem('anet-nodes-rail'))).toBe('1');
113
+ });
114
+
115
+ test('rail entry click selects the alias (data-selected="true"); another click swaps selection', async ({ page, context }) => {
116
+ await login(context);
117
+ await mockCommon(page);
118
+ await page.addInitScript(() => window.localStorage.removeItem('anet-nodes-rail'));
119
+ await page.goto(`${BASE}/nodes`);
120
+ await expect(page.locator('[data-testid="node-list-rail"]').first()).toBeVisible({ timeout: 15000 });
121
+
122
+ // Initially none selected
123
+ const initiallySelected = await page.locator('[data-node-list-item][data-selected="true"]').count();
124
+ expect(initiallySelected).toBe(0);
125
+
126
+ // Click stage-a-2 → chatAlias set → data-selected switches
127
+ await page.locator('[data-node-list-alias="stage-a-2"]').click();
128
+ await expect(page.locator('[data-node-list-alias="stage-a-2"]')).toHaveAttribute('data-selected', 'true');
129
+ // Only one selected at a time
130
+ await expect(page.locator('[data-node-list-item][data-selected="true"]')).toHaveCount(1);
131
+
132
+ // Click stage-a-1 → selection swaps
133
+ await page.locator('[data-node-list-alias="stage-a-1"]').click();
134
+ await expect(page.locator('[data-node-list-alias="stage-a-1"]')).toHaveAttribute('data-selected', 'true');
135
+ await expect(page.locator('[data-node-list-alias="stage-a-2"]')).toHaveAttribute('data-selected', 'false');
136
+ await expect(page.locator('[data-node-list-item][data-selected="true"]')).toHaveCount(1);
137
+ });
138
+ });