dsh-agent-floor 0.2.0 → 0.4.0
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.
- package/README.md +7 -5
- package/client.js +136 -84
- package/package.json +1 -1
- package/scripts/harness.js +33 -22
package/README.md
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# Agent Floor · 常驻监控条
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在 DeepSeek Harness **左侧边栏底部(Settings 旁边)**挂一行常驻状态:不用开标签页、也不覆盖正文,随时能瞄一眼哪个会话在跑、跑到第几步、烧了多少 token、改了哪些文件。
|
|
4
4
|
|
|
5
5
|
DSH 自带的「任务管理」页已经能看到 agent 树和后台任务,但它是**按会话打开的标签页**,而且没有步/轮/token/改动文件这些指标。这个插件只补这块,不重复画树。
|
|
6
6
|
|
|
7
7
|
## 长什么样
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- **侧边栏底部**:`● 2 在跑 / 5 在岗` 一行常驻(有会话在跑时圆点呼吸),不挡正文
|
|
10
|
+
- **点一下**:在它上方弹出面板 —— 每个会话一行
|
|
11
|
+
- 面板每行:状态点、名字(组长带 `带队 N`)、`第N步·第T轮 · 12.3k tok`、正在跑的 `bash · pnpm run build` 或 `改 client.js · index.js`
|
|
11
12
|
- 点任意一行 → 跳到那个会话
|
|
12
13
|
|
|
13
14
|
## 装
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
|
-
dsh plugin install dsh-agent-floor # npm,0.
|
|
17
|
+
dsh plugin install dsh-agent-floor # npm,0.4.0+
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
或加市场索引源:`https://raw.githubusercontent.com/ITxuezhe/dsh-agent-floor/main/market/index.json`
|
|
@@ -22,12 +23,13 @@ dsh plugin install dsh-agent-floor # npm,0.2.0+
|
|
|
22
23
|
|
|
23
24
|
## 数据从哪来
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
插件挂两个官方插槽:`sidebar.footer.action`(侧边栏底部那一行)与 `shell.overlay`(弹出面板,避免被侧边栏裁剪)。客户端每 2 秒(收起时 6 秒)拉一次只读路由 `GET /dsh-agent-floor/state`。
|
|
26
27
|
Host 半监听会话事件折叠成快照,并按会话 cwd 跑 `git status --porcelain`(10 秒缓存、失败降级为空)拿真实改动文件。
|
|
27
28
|
|
|
28
29
|
- 状态:`running` 或 45 秒内有动静 → RUNNING;5 分钟内 → STANDBY;否则 IDLE
|
|
29
30
|
- 子代理靠 `parentSession` 归到组长名下,空闲超过 10 分钟自动淡出
|
|
30
31
|
- 展开/收起状态存在 localStorage `dsh.agent-floor.open`
|
|
32
|
+
- 面板点空白处或 Esc 关闭
|
|
31
33
|
|
|
32
34
|
## 自检
|
|
33
35
|
|
package/client.js
CHANGED
|
@@ -12,28 +12,32 @@ window.__ModuleLoader__.load({
|
|
|
12
12
|
const MAX_ROWS = 8;
|
|
13
13
|
|
|
14
14
|
const CSS = `
|
|
15
|
-
.fg-root{
|
|
16
|
-
font:12px/1.5 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
15
|
+
.fg-root{font:11.5px/1.45 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
17
16
|
color:var(--dsw-alias-label-primary,#1c1c1e);}
|
|
18
|
-
.fg-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.fg-head{display:flex;align-items:center;gap:7px;padding:7px 10px;cursor:pointer;
|
|
23
|
-
user-select:none;-webkit-user-select:none;}
|
|
24
|
-
.fg-head:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.03));}
|
|
17
|
+
.fg-chip{display:flex;align-items:center;gap:6px;width:100%;padding:5px 8px;
|
|
18
|
+
border:0;border-radius:8px;background:transparent;cursor:pointer;
|
|
19
|
+
font:inherit;color:inherit;text-align:left;}
|
|
20
|
+
.fg-chip:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.04));}
|
|
25
21
|
.fg-pulse{width:7px;height:7px;border-radius:50%;flex:0 0 auto;
|
|
26
22
|
background:var(--dsw-alias-state-idle-primary,#9aa0a6);}
|
|
27
23
|
.fg-pulse.on{background:var(--dsw-alias-state-success-primary,#1a9b4e);
|
|
28
24
|
animation:fg-breathe 1.6s ease-in-out infinite;}
|
|
29
25
|
@keyframes fg-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}
|
|
30
|
-
.fg-sum{font-weight:600;
|
|
26
|
+
.fg-sum{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
31
27
|
.fg-sum i{font-style:normal;font-weight:500;opacity:.55;}
|
|
32
|
-
.fg-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
.fg-panel{position:fixed;left:12px;bottom:64px;z-index:61;width:290px;max-height:min(420px,60vh);
|
|
29
|
+
overflow:auto;border-radius:12px;padding:4px;
|
|
30
|
+
background:var(--dsw-alias-bg-overlay,#fff);
|
|
31
|
+
border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.09));
|
|
32
|
+
box-shadow:0 10px 30px rgba(0,0,0,.14);
|
|
33
|
+
font:12px/1.5 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
34
|
+
color:var(--dsw-alias-label-primary,#1c1c1e);}
|
|
35
|
+
.fg-panel-head{display:flex;align-items:center;gap:7px;padding:6px 8px 7px;font-weight:600;
|
|
36
|
+
border-bottom:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.07));margin-bottom:4px;}
|
|
37
|
+
.fg-panel-head span.close{margin-left:auto;cursor:pointer;opacity:.45;font-weight:500;padding:0 3px;}
|
|
38
|
+
.fg-panel-head span.close:hover{opacity:.9;}
|
|
35
39
|
.fg-row{display:grid;grid-template-columns:9px 1fr auto;gap:2px 7px;
|
|
36
|
-
padding:6px
|
|
40
|
+
padding:6px 8px;cursor:pointer;align-items:center;border-radius:8px;}
|
|
37
41
|
.fg-row:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.035));}
|
|
38
42
|
.fg-dot{width:7px;height:7px;border-radius:50%;
|
|
39
43
|
background:var(--dsw-alias-state-idle-primary,#c2c6cc);}
|
|
@@ -44,7 +48,7 @@ window.__ModuleLoader__.load({
|
|
|
44
48
|
.fg-num{font-variant-numeric:tabular-nums;opacity:.6;white-space:nowrap;font-size:11px;}
|
|
45
49
|
.fg-file{grid-column:2 / 4;font-size:11px;opacity:.5;overflow:hidden;
|
|
46
50
|
text-overflow:ellipsis;white-space:nowrap;}
|
|
47
|
-
.fg-more{grid-column:1 / 4;padding:5px
|
|
51
|
+
.fg-more{grid-column:1 / 4;padding:5px 8px;font-size:11px;opacity:.5;}
|
|
48
52
|
`;
|
|
49
53
|
|
|
50
54
|
function ensureStyle() {
|
|
@@ -63,31 +67,47 @@ window.__ModuleLoader__.load({
|
|
|
63
67
|
return (n / 1e6).toFixed(1) + 'M';
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return
|
|
70
|
+
// One shared poller for every mount point, so the chip and the panel never
|
|
71
|
+
// fetch twice and always show the same snapshot.
|
|
72
|
+
const store = { open: false, data: null, subs: new Set(), timer: null, started: false };
|
|
73
|
+
|
|
74
|
+
function readOpen() {
|
|
75
|
+
try { return localStorage.getItem(OPEN_KEY) === '1'; } catch { return false; }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function setOpen(next) {
|
|
79
|
+
store.open = next;
|
|
80
|
+
try { localStorage.setItem(OPEN_KEY, next ? '1' : '0'); } catch {}
|
|
81
|
+
notify();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function notify() {
|
|
85
|
+
store.subs.forEach((fn) => { try { fn(); } catch {} });
|
|
72
86
|
}
|
|
73
87
|
|
|
74
|
-
function
|
|
75
|
-
|
|
88
|
+
function startPolling() {
|
|
89
|
+
if (store.started) return;
|
|
90
|
+
store.started = true;
|
|
91
|
+
const tick = () => {
|
|
92
|
+
Promise.resolve()
|
|
93
|
+
.then(() => fetch(ROUTE, { headers: { accept: 'application/json' } }))
|
|
94
|
+
.then((r) => (r && r.ok ? r.json() : null))
|
|
95
|
+
.then((d) => { if (d) { store.data = d; notify(); } })
|
|
96
|
+
.catch(() => {})
|
|
97
|
+
.then(() => { store.timer = setTimeout(tick, store.open ? 2000 : 6000); });
|
|
98
|
+
};
|
|
99
|
+
tick();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function useStore() {
|
|
103
|
+
const [, bump] = useState(0);
|
|
76
104
|
useEffect(() => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.then((d) => { if (alive && d) setData(d); })
|
|
84
|
-
.catch(() => {})
|
|
85
|
-
.then(() => { if (alive) timer = setTimeout(tick, open ? 2000 : 6000); });
|
|
86
|
-
};
|
|
87
|
-
tick();
|
|
88
|
-
return () => { alive = false; if (timer) clearTimeout(timer); };
|
|
89
|
-
}, [open]);
|
|
90
|
-
return data;
|
|
105
|
+
const fn = () => bump((v) => v + 1);
|
|
106
|
+
store.subs.add(fn);
|
|
107
|
+
startPolling();
|
|
108
|
+
return () => { store.subs.delete(fn); };
|
|
109
|
+
}, []);
|
|
110
|
+
return store;
|
|
91
111
|
}
|
|
92
112
|
|
|
93
113
|
function deriveAgents(data) {
|
|
@@ -150,6 +170,17 @@ window.__ModuleLoader__.load({
|
|
|
150
170
|
return '';
|
|
151
171
|
}
|
|
152
172
|
|
|
173
|
+
function openSession(ctx, a) {
|
|
174
|
+
const id = a && a.id;
|
|
175
|
+
if (!id) return;
|
|
176
|
+
try {
|
|
177
|
+
const ui = ctx && typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : null;
|
|
178
|
+
if (ui && typeof ui.openSession === 'function') { ui.openSession(id); return; }
|
|
179
|
+
const ses = ctx && typeof ctx.get === 'function' ? ctx.get('sessions') : null;
|
|
180
|
+
if (ses && typeof ses.scope === 'function') ses.scope(id);
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
|
|
153
184
|
function MonitorRow(props) {
|
|
154
185
|
const a = props.agent;
|
|
155
186
|
const cls = 'fg-dot ' + (a.status === 'RUNNING' ? 'run' : a.status === 'STANDBY' ? 'wait' : '');
|
|
@@ -167,51 +198,69 @@ window.__ModuleLoader__.load({
|
|
|
167
198
|
]);
|
|
168
199
|
}
|
|
169
200
|
|
|
170
|
-
|
|
201
|
+
/** Sidebar-foot chip: always visible, one line, no overlay over the page. */
|
|
202
|
+
function FloorChip(props) {
|
|
171
203
|
const ctx = (props && props.ctx) || null;
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
204
|
+
const s = useStore();
|
|
205
|
+
const agents = deriveAgents(s.data);
|
|
206
|
+
const running = agents.filter((a) => a.status === 'RUNNING').length;
|
|
207
|
+
useEffect(() => { ensureStyle(); }, []);
|
|
208
|
+
const label = agents.length === 0
|
|
209
|
+
? '暂无会话'
|
|
210
|
+
: (running ? running + ' 在跑' : '全部空闲') + ' / ' + agents.length + ' 在岗';
|
|
211
|
+
return h('div', { className: 'fg-root' },
|
|
212
|
+
h('button', {
|
|
213
|
+
className: 'fg-chip',
|
|
214
|
+
type: 'button',
|
|
215
|
+
title: running ? running + ' 个会话正在跑,点开看详情' : '点开看会话详情',
|
|
216
|
+
onClick: () => setOpen(!s.open),
|
|
217
|
+
}, [
|
|
218
|
+
h('span', { className: 'fg-pulse' + (running ? ' on' : ''), key: 'p' }),
|
|
219
|
+
h('span', { className: 'fg-sum', key: 's' }, label),
|
|
220
|
+
]));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Frame-wide panel, only mounted while open; anchored above the chip. */
|
|
224
|
+
function FloorPanel(props) {
|
|
225
|
+
const ctx = (props && props.ctx) || null;
|
|
226
|
+
const s = useStore();
|
|
227
|
+
const agents = deriveAgents(s.data);
|
|
177
228
|
const running = agents.filter((a) => a.status === 'RUNNING').length;
|
|
178
229
|
const shown = agents.slice(0, MAX_ROWS);
|
|
179
230
|
const hidden = agents.length - shown.length;
|
|
180
|
-
|
|
181
|
-
const toggle = () => {
|
|
182
|
-
const next = !open;
|
|
183
|
-
setOpen(next);
|
|
184
|
-
try { localStorage.setItem(OPEN_KEY, next ? '1' : '0'); } catch {}
|
|
185
|
-
};
|
|
231
|
+
const ref = useRef(null);
|
|
186
232
|
|
|
187
233
|
useEffect(() => { ensureStyle(); }, []);
|
|
188
234
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (!s.open) return undefined;
|
|
237
|
+
const onDown = (e) => {
|
|
238
|
+
const el = ref.current;
|
|
239
|
+
if (el && e && e.target && el.contains && el.contains(e.target)) return;
|
|
240
|
+
setOpen(false);
|
|
241
|
+
};
|
|
242
|
+
const onKey = (e) => { if (e && e.key === 'Escape') setOpen(false); };
|
|
243
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
244
|
+
document.addEventListener('keydown', onKey);
|
|
245
|
+
return () => {
|
|
246
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
247
|
+
document.removeEventListener('keydown', onKey);
|
|
248
|
+
};
|
|
249
|
+
}, [s.open]);
|
|
199
250
|
|
|
200
|
-
|
|
201
|
-
|
|
251
|
+
if (!s.open) return null;
|
|
252
|
+
|
|
253
|
+
return h('div', { className: 'fg-panel', ref }, [
|
|
254
|
+
h('div', { className: 'fg-panel-head', key: 'head' }, [
|
|
202
255
|
h('span', { className: 'fg-pulse' + (running ? ' on' : ''), key: 'p' }),
|
|
203
|
-
h('span', {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
]),
|
|
207
|
-
h('span', { className: 'fg-caret', key: 'c' }, open ? '⌄' : '⌃'),
|
|
256
|
+
h('span', { key: 't' }, running ? running + ' 个在跑' : '全部空闲'),
|
|
257
|
+
h('span', { key: 'n', style: { opacity: .5, fontWeight: 500 } }, '共 ' + agents.length + ' 个会话'),
|
|
258
|
+
h('span', { className: 'close', key: 'x', onClick: () => setOpen(false), title: '关闭' }, '✕'),
|
|
208
259
|
]),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
]) : null,
|
|
214
|
-
]));
|
|
260
|
+
...shown.map((a) => h(MonitorRow, { key: a.id || a.name, agent: a, onOpen: (x) => openSession(ctx, x) })),
|
|
261
|
+
hidden > 0 ? h('div', { className: 'fg-more', key: 'more' }, '还有 ' + hidden + ' 个会话') : null,
|
|
262
|
+
agents.length === 0 ? h('div', { className: 'fg-more', key: 'empty' }, '暂无会话') : null,
|
|
263
|
+
]);
|
|
215
264
|
}
|
|
216
265
|
|
|
217
266
|
function apply(ctx) {
|
|
@@ -219,24 +268,27 @@ window.__ModuleLoader__.load({
|
|
|
219
268
|
const target = ready && ready.slots ? ready : ctx;
|
|
220
269
|
const slots = target && target.slots;
|
|
221
270
|
if (!slots) return;
|
|
271
|
+
const register = (name, id, order, label, Comp) => {
|
|
272
|
+
slots.inject(name, () => slots.register({ name, id, order, label }, (props) => h(Comp, { ...props, ctx })));
|
|
273
|
+
};
|
|
222
274
|
const render = () => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}, () => h(MonitorBar, { ctx })));
|
|
275
|
+
store.open = readOpen();
|
|
276
|
+
// Chip lives in the sidebar foot next to Settings — out of the content area.
|
|
277
|
+
register('sidebar.footer.action', 'dsh-agent-floor', 10, 'Agent Floor', FloorChip);
|
|
278
|
+
// Panel is frame-wide so the sidebar can never clip it.
|
|
279
|
+
register('shell.overlay', 'dsh-agent-floor.panel', 940, 'Agent Floor', FloorPanel);
|
|
229
280
|
};
|
|
230
281
|
if (typeof target.effect === 'function') target.effect(render, 'dsh-agent-floor: mounts');
|
|
231
282
|
else render();
|
|
232
283
|
};
|
|
233
|
-
if (typeof ctx.inject === 'function')
|
|
234
|
-
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (ctx.slots) bridge(ctx);
|
|
284
|
+
if (ctx && typeof ctx.inject === 'function') ctx.inject(['slots'], bridge);
|
|
285
|
+
else bridge(ctx);
|
|
238
286
|
}
|
|
239
287
|
|
|
240
|
-
return {
|
|
288
|
+
return {
|
|
289
|
+
inject,
|
|
290
|
+
apply,
|
|
291
|
+
__dshTest: { deriveAgents, FloorChip, FloorPanel, MonitorRow, store },
|
|
292
|
+
};
|
|
241
293
|
},
|
|
242
294
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-floor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Agent Floor — a compact always-on dock for DeepSeek Harness: which session is running, how far along, how many tokens, which files changed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/scripts/harness.js
CHANGED
|
@@ -153,7 +153,7 @@ function main() {
|
|
|
153
153
|
throw new Error('client.js: 既没有 __dshTest,也找不到 `return { inject, apply };` —— 导出结构变了?');
|
|
154
154
|
}
|
|
155
155
|
src = src.replace(EXPORT_RE,
|
|
156
|
-
'return { inject, apply, __dshTest: { deriveAgents: deriveAgents,
|
|
156
|
+
'return { inject, apply, __dshTest: { deriveAgents: deriveAgents, FloorChip: FloorChip, FloorPanel: FloorPanel, MonitorRow: MonitorRow, store: store } };');
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const factoryFn = new Function(
|
|
@@ -187,23 +187,31 @@ function main() {
|
|
|
187
187
|
if (typeof mod.apply !== 'function') throw new Error('模块没有导出 apply()');
|
|
188
188
|
mod.apply(ctx);
|
|
189
189
|
if (!registered.length) throw new Error('apply() 没有注册任何组件到 shell.overlay');
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
const bySlot = (name) => registered.find((r) => r.spec && r.spec.name === name);
|
|
191
|
+
const chip = bySlot('sidebar.footer.action');
|
|
192
|
+
const panel = bySlot('shell.overlay');
|
|
193
|
+
if (!chip) throw new Error('apply() 没有把 chip 注册到 sidebar.footer.action');
|
|
194
|
+
if (!panel) throw new Error('apply() 没有把 panel 注册到 shell.overlay');
|
|
195
|
+
if (typeof chip.render !== 'function' || typeof panel.render !== 'function') {
|
|
196
|
+
throw new Error('slots.register 的 render 不是函数');
|
|
197
|
+
}
|
|
192
198
|
|
|
193
|
-
// 2)
|
|
194
|
-
const tree = renderNode(React.createElement(
|
|
195
|
-
if (!tree.length) throw new Error('
|
|
199
|
+
// 2) 真的把注册出来的 chip 渲染一次。
|
|
200
|
+
const tree = renderNode(React.createElement(chip.render, {}));
|
|
201
|
+
if (!tree.length) throw new Error('FloorChip 渲染结果为空');
|
|
196
202
|
const rootTag = tree[0].tag;
|
|
197
|
-
if (typeof rootTag !== 'string') throw new Error('
|
|
203
|
+
if (typeof rootTag !== 'string') throw new Error('FloorChip 顶层不是 DOM 标签: ' + String(rootTag));
|
|
198
204
|
if (!tree[0].props.className || String(tree[0].props.className).indexOf('fg-') !== 0) {
|
|
199
|
-
throw new Error('
|
|
205
|
+
throw new Error('FloorChip 顶层缺少 fg-* className: ' + JSON.stringify(tree[0].props.className));
|
|
200
206
|
}
|
|
201
|
-
const
|
|
207
|
+
const chipNodes = countNodes(tree);
|
|
208
|
+
const chipButton = findTag(tree, 'button');
|
|
209
|
+
if (!chipButton) throw new Error('FloorChip 没有渲染出 button(点不了)');
|
|
202
210
|
|
|
203
|
-
// 3) 用 5 个假 agent
|
|
211
|
+
// 3) 用 5 个假 agent 验证分组,再渲染面板。
|
|
204
212
|
const test = mod.__dshTest;
|
|
205
|
-
if (!test || typeof test.
|
|
206
|
-
throw new Error('client.js 没有暴露 __dshTest.
|
|
213
|
+
if (!test || typeof test.FloorPanel !== 'function' || typeof test.deriveAgents !== 'function') {
|
|
214
|
+
throw new Error('client.js 没有暴露 __dshTest.FloorPanel / deriveAgents');
|
|
207
215
|
}
|
|
208
216
|
const now = Date.now();
|
|
209
217
|
const sessions = [
|
|
@@ -217,34 +225,37 @@ function main() {
|
|
|
217
225
|
if (ordered.length !== 5) throw new Error('deriveAgents 期望 5 个 agent,实际 ' + ordered.length);
|
|
218
226
|
if (ordered.filter((o) => o.depth === 1).length !== 1) throw new Error('deriveAgents 没把子代理排成 depth 1');
|
|
219
227
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
const
|
|
228
|
+
test.store.open = true;
|
|
229
|
+
test.store.data = { sessions };
|
|
230
|
+
const chipOn = renderNode(React.createElement(chip.render, {}));
|
|
231
|
+
const panelTree = renderNode(React.createElement(panel.render, {}));
|
|
232
|
+
if (!panelTree.length) throw new Error('FloorPanel 打开状态下渲染结果为空');
|
|
224
233
|
let rowCount = 0;
|
|
225
|
-
(function
|
|
234
|
+
(function walk(n) {
|
|
226
235
|
if (!n || typeof n !== 'object') return;
|
|
227
236
|
const cls = n.props && n.props.className;
|
|
228
237
|
if (typeof cls === 'string' && cls.indexOf('fg-row') === 0) rowCount++;
|
|
229
|
-
for (const c of n.children || [])
|
|
230
|
-
})(
|
|
238
|
+
for (const c of n.children || []) walk(c);
|
|
239
|
+
})(panelTree[0]);
|
|
231
240
|
if (rowCount !== 5) throw new Error('展开状态应渲染 5 行,实际 ' + rowCount);
|
|
232
241
|
|
|
233
242
|
const row = renderNode(React.createElement(test.MonitorRow, { agent: ordered[0], onOpen: () => {} }));
|
|
234
243
|
if (!row.length || row[0].tag !== 'div') throw new Error('MonitorRow 顶层不是 div');
|
|
235
244
|
if (String(row[0].props.className).indexOf('fg-row') !== 0) throw new Error('MonitorRow 缺少 fg-row className');
|
|
236
245
|
|
|
237
|
-
// 4) 跑一次 effect
|
|
246
|
+
// 4) 跑一次 effect(轮询会发起一次假 fetch),确认不炸。
|
|
238
247
|
for (const fn of effects) {
|
|
239
248
|
const cleanup = fn();
|
|
240
249
|
if (typeof cleanup === 'function') cleanup();
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
console.log(' client : ' + target);
|
|
244
|
-
console.log('
|
|
245
|
-
console.log('
|
|
253
|
+
console.log(' chip : <' + rootTag + ' class="' + tree[0].props.className + '"> (' + chipNodes + ' nodes)');
|
|
254
|
+
console.log(' panel : <div fg-panel> (' + countNodes(panelTree) + ' nodes, ' + ordered.length + ' agents, chip ' + countNodes(chipOn) + ' nodes)');
|
|
246
255
|
console.log(' effects: ' + effects.length + ' 个已执行');
|
|
247
256
|
console.log('render ok');
|
|
257
|
+
// 共享轮询器会挂一个真实 setTimeout,自检到这里就该退出。
|
|
258
|
+
process.exit(0);
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
try {
|