@mindexec/cli 0.2.478 → 0.2.479

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 (146) hide show
  1. package/README.md +323 -323
  2. package/codex-model-catalog.js +202 -202
  3. package/codex-runtime.js +1608 -1608
  4. package/desktop-workspace-state.cjs +120 -120
  5. package/electron/main.cjs +517 -517
  6. package/electron/preload.cjs +17 -17
  7. package/electron/recurring-update-owner-smoke.mjs +55 -55
  8. package/electron/recurring-update-owner.cjs +97 -97
  9. package/electron/source-smoke.mjs +108 -108
  10. package/electron/update-feed-resolver.cjs +79 -79
  11. package/electron/update-feed.json +10 -10
  12. package/electron/update-manager-smoke.mjs +146 -146
  13. package/electron/update-manager.cjs +297 -297
  14. package/electron/windows-package-smoke.mjs +156 -156
  15. package/launch-bridge.cjs +236 -236
  16. package/lzo1x.js +110 -110
  17. package/mode4-atlas-worker.js +440 -440
  18. package/mode4-atlas.js +130 -130
  19. package/package.json +1 -1
  20. package/port-guard.cjs +285 -285
  21. package/remote-fast/osx-arm64/MacScreenCaptureKitH264.swift +339 -339
  22. package/remote-fast/osx-arm64/MacSystemAudioCapture.swift +214 -214
  23. package/remote-fast/osx-arm64/UnixRawCaptureHelper.mjs +80 -80
  24. package/remote-fast/osx-arm64/livedesk-raw-capture-resampler.mjs +73 -73
  25. package/remote-fast/osx-arm64/mindexec-remote-fast.dll +0 -0
  26. package/remote-fast/osx-x64/MacScreenCaptureKitH264.swift +339 -339
  27. package/remote-fast/osx-x64/MacSystemAudioCapture.swift +214 -214
  28. package/remote-fast/osx-x64/UnixRawCaptureHelper.mjs +80 -80
  29. package/remote-fast/osx-x64/livedesk-raw-capture-resampler.mjs +73 -73
  30. package/remote-fast/osx-x64/mindexec-remote-fast.dll +0 -0
  31. package/remote-fast/win-x64/mindexec-remote-fast.dll +0 -0
  32. package/remote-hub.js +3698 -3698
  33. package/scripts/auth-session-smoke.mjs +262 -262
  34. package/scripts/board-render-ownership-smoke.mjs +85 -85
  35. package/scripts/codex-model-catalog-smoke.mjs +150 -150
  36. package/scripts/codex-runtime-home-smoke.mjs +58 -58
  37. package/scripts/codex-sdk-image-live-smoke.mjs +43 -43
  38. package/scripts/codex-sdk-image-runtime-smoke.mjs +122 -122
  39. package/scripts/codex-sdk-runtime-smoke.mjs +89 -89
  40. package/scripts/desktop-update-publisher-smoke.mjs +89 -89
  41. package/scripts/desktop-update-worker-smoke.mjs +72 -72
  42. package/scripts/desktop-workspace-state-smoke.mjs +81 -81
  43. package/scripts/drive-installed-update-smoke.mjs +67 -67
  44. package/scripts/npm-fresh-install-smoke.mjs +216 -216
  45. package/scripts/publish-mindexec-desktop-updates.mjs +224 -224
  46. package/scripts/remote-agent-managed-smoke.mjs +318 -318
  47. package/scripts/remote-agent-package-smoke.mjs +64 -64
  48. package/scripts/remote-agent-ws-smoke.mjs +269 -269
  49. package/scripts/remote-fast-live-rate-smoke.mjs +343 -343
  50. package/scripts/remote-fast-mdm-browser-smoke.mjs +453 -453
  51. package/scripts/remote-fleet-render-smoke.mjs +1350 -1350
  52. package/scripts/remote-frame-ws-smoke.mjs +234 -234
  53. package/scripts/remote-http-smoke.mjs +592 -592
  54. package/scripts/remote-hub-identity-smoke.mjs +146 -146
  55. package/scripts/remote-hub-scale-smoke.mjs +124 -124
  56. package/scripts/remote-hub-smoke.mjs +699 -699
  57. package/scripts/remote-input-ws-smoke.mjs +263 -263
  58. package/scripts/remote-registry-follower-smoke.mjs +815 -815
  59. package/scripts/setup-tree-sitter-grammars.mjs +59 -59
  60. package/server.js +7510 -7510
  61. package/start-bridge.bat +32 -32
  62. package/start-bridge.sh +81 -81
  63. package/tree-sitter-grammars/README.md +18 -0
  64. package/tree-sitter-grammars/tree-sitter-c_sharp.wasm +0 -0
  65. package/tree-sitter-grammars/tree-sitter-go.wasm +0 -0
  66. package/tree-sitter-grammars/tree-sitter-java.wasm +0 -0
  67. package/tree-sitter-grammars/tree-sitter-javascript.wasm +0 -0
  68. package/tree-sitter-grammars/tree-sitter-python.wasm +0 -0
  69. package/tree-sitter-grammars/tree-sitter-rust.wasm +0 -0
  70. package/tree-sitter-grammars/tree-sitter-tsx.wasm +0 -0
  71. package/tree-sitter-grammars/tree-sitter-typescript.wasm +0 -0
  72. package/wwwroot/_content/MindExecution.Plugins.Admin/css/admin-dashboard.css +546 -546
  73. package/wwwroot/_content/MindExecution.Plugins.Directory/background.png +0 -0
  74. package/wwwroot/_content/MindExecution.Plugins.YouTube/css/youtube-search.css +251 -251
  75. package/wwwroot/_content/MindExecution.Shared/css/mind-map-overrides.css +3789 -3789
  76. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Bold.ttf +0 -0
  77. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Regular.ttf +0 -0
  78. package/wwwroot/_content/MindExecution.Shared/js/agent-visualization.js +27 -27
  79. package/wwwroot/_content/MindExecution.Shared/js/background-themes.js +1449 -1449
  80. package/wwwroot/_content/MindExecution.Shared/js/code-master.js +8316 -8316
  81. package/wwwroot/_content/MindExecution.Shared/js/file-system-helper.js +338 -338
  82. package/wwwroot/_content/MindExecution.Shared/js/marked.min.js +69 -69
  83. package/wwwroot/_content/MindExecution.Shared/js/mind-map-animated-image-preview.js +270 -270
  84. package/wwwroot/_content/MindExecution.Shared/js/mind-map-automation-edge-motion.js +170 -170
  85. package/wwwroot/_content/MindExecution.Shared/js/mind-map-board-render-ownership.js +81 -81
  86. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js +10506 -10506
  87. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js.backup +1059 -0
  88. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-hotpath.js +902 -902
  89. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-manager.js +24637 -24637
  90. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dev-guards.js +325 -325
  91. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js +1491 -1491
  92. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js.bak +434 -0
  93. package/wwwroot/_content/MindExecution.Shared/js/mind-map-glow-shader.js +70 -70
  94. package/wwwroot/_content/MindExecution.Shared/js/mind-map-image-policy.js +218 -218
  95. package/wwwroot/_content/MindExecution.Shared/js/mind-map-interactions.js +7078 -7078
  96. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js +160 -160
  97. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-renderer.js +9958 -9958
  98. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-video-placeholder.js +107 -107
  99. package/wwwroot/_content/MindExecution.Shared/js/mind-map-logic-workers.js +1004 -1004
  100. package/wwwroot/_content/MindExecution.Shared/js/mind-map-menu-manager.js +1351 -1351
  101. package/wwwroot/_content/MindExecution.Shared/js/mind-map-multi-select.js +865 -865
  102. package/wwwroot/_content/MindExecution.Shared/js/mind-map-node-search-worker.js +554 -554
  103. package/wwwroot/_content/MindExecution.Shared/js/mind-map-nodes.js +4744 -4744
  104. package/wwwroot/_content/MindExecution.Shared/js/mind-map-normal-boundary-optimizer.js +624 -624
  105. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js +241 -241
  106. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js.backup +372 -0
  107. package/wwwroot/_content/MindExecution.Shared/js/mind-map-pipeline.js +2290 -2290
  108. package/wwwroot/_content/MindExecution.Shared/js/mind-map-remote-codecs.js +202 -202
  109. package/wwwroot/_content/MindExecution.Shared/js/mind-map-render-plan.js +1971 -1971
  110. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-lod-system.js +93 -93
  111. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js +2391 -2391
  112. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js.backup +1258 -0
  113. package/wwwroot/_content/MindExecution.Shared/js/mind-map-video-playback-controls.js +95 -95
  114. package/wwwroot/_content/MindExecution.Shared/js/mind-map-visibility-worker.js +895 -895
  115. package/wwwroot/_content/MindExecution.Shared/js/mindmap-toolbar.js +636 -636
  116. package/wwwroot/_content/MindExecution.Shared/js/native-drop-handler.js +45 -45
  117. package/wwwroot/_content/MindExecution.Shared/js/plan-master.js +117 -117
  118. package/wwwroot/_content/MindExecution.Shared/js/renderers/CSS3DRenderer.js +114 -114
  119. package/wwwroot/_content/MindExecution.Shared/js/texture-worker-manager.js +10 -10
  120. package/wwwroot/_content/MindExecution.Shared/js/three.min.js +6 -6
  121. package/wwwroot/_content/MindExecution.Shared/js/token-manager.js +7 -7
  122. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js +6 -6
  123. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js.map +2 -2
  124. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/css/all.min.css +8 -8
  125. package/wwwroot/_content/MindExecution.Shared/models/vocab.txt +30522 -30522
  126. package/wwwroot/_framework/{Google.Protobuf.33g2gb5is0.dll → Google.Protobuf.9h59ukbel7.dll} +0 -0
  127. package/wwwroot/_framework/{MindExecution.Core.z100xo4mg0.dll → MindExecution.Core.xxsj2s456b.dll} +0 -0
  128. package/wwwroot/_framework/{MindExecution.Kernel.i9cldrx8yc.dll → MindExecution.Kernel.5jofnc0wrd.dll} +0 -0
  129. package/wwwroot/_framework/{MindExecution.Plugins.Admin.48lzqddb0a.dll → MindExecution.Plugins.Admin.t7m4jnqjg3.dll} +0 -0
  130. package/wwwroot/_framework/{MindExecution.Plugins.Business.7m8u1q142p.dll → MindExecution.Plugins.Business.6yjlhhavap.dll} +0 -0
  131. package/wwwroot/_framework/{MindExecution.Plugins.Concept.cl5wmr53od.dll → MindExecution.Plugins.Concept.iikqq5zxu0.dll} +0 -0
  132. package/wwwroot/_framework/{MindExecution.Plugins.Directory.slipi39041.dll → MindExecution.Plugins.Directory.c5ribyne4m.dll} +0 -0
  133. package/wwwroot/_framework/{MindExecution.Plugins.PlanMaster.qfge05l671.dll → MindExecution.Plugins.PlanMaster.365bbuifr9.dll} +0 -0
  134. package/wwwroot/_framework/{MindExecution.Plugins.YouTube.tn7v29ut77.dll → MindExecution.Plugins.YouTube.ax415cilpk.dll} +0 -0
  135. package/wwwroot/_framework/MindExecution.Shared.21e2nvf86u.dll +0 -0
  136. package/wwwroot/_framework/{MindExecution.Web.rwawrxxk38.dll → MindExecution.Web.ppgm8rey59.dll} +0 -0
  137. package/wwwroot/_framework/{System.Collections.23yxgetbju.dll → System.Collections.zyvbaq6mpd.dll} +0 -0
  138. package/wwwroot/_framework/blazor.boot.json +25 -25
  139. package/wwwroot/_headers +40 -40
  140. package/wwwroot/_redirects +1 -1
  141. package/wwwroot/index.html +772 -772
  142. package/wwwroot/js/marketing-tool.js +180 -180
  143. package/wwwroot/manifest.webmanifest +23 -23
  144. package/wwwroot/service-worker-assets.js +109 -81
  145. package/wwwroot/service-worker.js +33 -33
  146. package/wwwroot/_framework/MindExecution.Shared.rjqlf0umjn.dll +0 -0
@@ -1,1350 +1,1350 @@
1
- #!/usr/bin/env node
2
-
3
- import assert from 'node:assert/strict';
4
- import fs from 'node:fs/promises';
5
- import path from 'node:path';
6
- import vm from 'node:vm';
7
- import { fileURLToPath } from 'node:url';
8
- import { createRemoteHub } from '../remote-hub.js';
9
-
10
- const SYNTHETIC_COUNT = Number(process.env.REMOTE_FLEET_RENDER_SMOKE_COUNT || 500);
11
-
12
- function dataAttributeToDatasetKey(name) {
13
- return String(name || '').replace(/^data-/, '').replace(/-([a-z])/g, (_, char) => char.toUpperCase());
14
- }
15
-
16
- class MiniStyle {
17
- constructor() {
18
- this._cssText = '';
19
- }
20
-
21
- get cssText() {
22
- return this._cssText;
23
- }
24
-
25
- set cssText(value) {
26
- this._cssText = String(value || '');
27
- const displayMatch = /(?:^|;)\s*display\s*:\s*([^;]+)/i.exec(this._cssText);
28
- if (displayMatch) {
29
- this.display = displayMatch[1].trim();
30
- }
31
- }
32
-
33
- setProperty(name, value) {
34
- this[String(name)] = String(value);
35
- }
36
- }
37
-
38
- class MiniClassList {
39
- constructor(owner) {
40
- this.owner = owner;
41
- this.tokens = new Set();
42
- }
43
-
44
- add(...tokens) {
45
- tokens.forEach(token => {
46
- const value = String(token || '').trim();
47
- if (value) {
48
- this.tokens.add(value);
49
- }
50
- });
51
- this.sync();
52
- }
53
-
54
- remove(...tokens) {
55
- tokens.forEach(token => this.tokens.delete(String(token || '').trim()));
56
- this.sync();
57
- }
58
-
59
- contains(token) {
60
- return this.tokens.has(String(token || '').trim());
61
- }
62
-
63
- toggle(token, force) {
64
- const value = String(token || '').trim();
65
- if (!value) return false;
66
- const shouldAdd = force === undefined ? !this.tokens.has(value) : !!force;
67
- if (shouldAdd) {
68
- this.tokens.add(value);
69
- } else {
70
- this.tokens.delete(value);
71
- }
72
- this.sync();
73
- return shouldAdd;
74
- }
75
-
76
- sync() {
77
- this.owner.className = [...this.tokens].join(' ');
78
- }
79
- }
80
-
81
- class MiniElement {
82
- constructor(tagName, ownerDocument) {
83
- this.tagName = String(tagName || '').toUpperCase();
84
- this.nodeName = this.tagName;
85
- this.ownerDocument = ownerDocument;
86
- this.parentElement = null;
87
- this.children = [];
88
- this.attributes = {};
89
- this.dataset = {};
90
- this.style = new MiniStyle();
91
- this.classList = new MiniClassList(this);
92
- this.className = '';
93
- this._textContent = '';
94
- this._listeners = new Map();
95
- this.value = '';
96
- this.checked = false;
97
- this.disabled = false;
98
- this.clientWidth = 320;
99
- this.clientHeight = 180;
100
- this.width = 0;
101
- this.height = 0;
102
- }
103
-
104
- get textContent() {
105
- return `${this._textContent}${this.children.map(child => child.textContent).join('')}`;
106
- }
107
-
108
- set textContent(value) {
109
- this.children.forEach(child => {
110
- child.parentElement = null;
111
- });
112
- this.children = [];
113
- this._textContent = String(value ?? '');
114
- }
115
-
116
- get innerHTML() {
117
- return '';
118
- }
119
-
120
- set innerHTML(_value) {
121
- this.children.forEach(child => {
122
- child.parentElement = null;
123
- });
124
- this.children = [];
125
- this._textContent = '';
126
- }
127
-
128
- appendChild(child) {
129
- if (!child) return child;
130
- if (child.parentElement) {
131
- child.parentElement.children = child.parentElement.children.filter(item => item !== child);
132
- }
133
- child.parentElement = this;
134
- this.children.push(child);
135
- return child;
136
- }
137
-
138
- remove() {
139
- if (!this.parentElement) return;
140
- this.parentElement.children = this.parentElement.children.filter(child => child !== this);
141
- this.parentElement = null;
142
- }
143
-
144
- setAttribute(name, value) {
145
- const key = String(name || '');
146
- const text = String(value ?? '');
147
- this.attributes[key] = text;
148
- if (key === 'id') {
149
- this.id = text;
150
- } else if (key === 'class') {
151
- this.className = text;
152
- this.classList.tokens = new Set(text.split(/\s+/).filter(Boolean));
153
- } else if (key.startsWith('data-')) {
154
- this.dataset[dataAttributeToDatasetKey(key)] = text;
155
- } else if (key === 'aria-label') {
156
- this.ariaLabel = text;
157
- }
158
- }
159
-
160
- getAttribute(name) {
161
- const key = String(name || '');
162
- if (key.startsWith('data-')) {
163
- return this.dataset[dataAttributeToDatasetKey(key)];
164
- }
165
- return this.attributes[key];
166
- }
167
-
168
- addEventListener(type, listener) {
169
- const key = String(type || '');
170
- if (!this._listeners.has(key)) {
171
- this._listeners.set(key, []);
172
- }
173
- this._listeners.get(key).push(listener);
174
- }
175
-
176
- dispatchEvent(event) {
177
- const payload = typeof event === 'string' ? { type: event } : { ...(event || {}) };
178
- let immediateStopped = false;
179
- const originalStopImmediatePropagation = typeof payload.stopImmediatePropagation === 'function'
180
- ? payload.stopImmediatePropagation
181
- : null;
182
- payload.type = payload.type || 'event';
183
- payload.target = payload.target || this;
184
- payload.currentTarget = this;
185
- payload.preventDefault = payload.preventDefault || (() => {});
186
- payload.stopPropagation = payload.stopPropagation || (() => {});
187
- payload.stopImmediatePropagation = () => {
188
- immediateStopped = true;
189
- originalStopImmediatePropagation?.();
190
- };
191
- for (const listener of this._listeners.get(payload.type) || []) {
192
- listener(payload);
193
- if (immediateStopped) {
194
- break;
195
- }
196
- }
197
- return true;
198
- }
199
-
200
- focus() {
201
- this.ownerDocument.activeElement = this;
202
- }
203
-
204
- blur() {
205
- if (this.ownerDocument.activeElement === this) {
206
- this.ownerDocument.activeElement = null;
207
- }
208
- }
209
-
210
- getBoundingClientRect() {
211
- return {
212
- left: 0,
213
- top: 0,
214
- right: this.clientWidth,
215
- bottom: this.clientHeight,
216
- width: this.clientWidth,
217
- height: this.clientHeight
218
- };
219
- }
220
-
221
- getContext(type) {
222
- if (this.tagName !== 'CANVAS' || String(type || '').toLowerCase() !== '2d') {
223
- return null;
224
- }
225
-
226
- if (this._canvasContext) {
227
- return this._canvasContext;
228
- }
229
-
230
- const owner = this.ownerDocument;
231
- this._canvasContext = {
232
- imageSmoothingEnabled: false,
233
- imageSmoothingQuality: 'low',
234
- fillStyle: '#000',
235
- clearRect: (...args) => {
236
- owner.canvasDrawCalls.push({ canvas: this, op: 'clearRect', args });
237
- },
238
- fillRect: (...args) => {
239
- owner.canvasDrawCalls.push({ canvas: this, op: 'fillRect', args });
240
- },
241
- drawImage: (...args) => {
242
- owner.canvasDrawCalls.push({ canvas: this, op: 'drawImage', args });
243
- }
244
- };
245
- return this._canvasContext;
246
- }
247
-
248
- querySelector(selector) {
249
- return this.querySelectorAll(selector)[0] || null;
250
- }
251
-
252
- querySelectorAll(selector) {
253
- const matches = [];
254
- const visit = element => {
255
- for (const child of element.children) {
256
- if (matchesSelector(child, selector)) {
257
- matches.push(child);
258
- }
259
- visit(child);
260
- }
261
- };
262
- visit(this);
263
- return matches;
264
- }
265
-
266
- closest(selector) {
267
- let current = this;
268
- while (current) {
269
- if (matchesSelector(current, selector)) {
270
- return current;
271
- }
272
- current = current.parentElement;
273
- }
274
- return null;
275
- }
276
-
277
- contains(node) {
278
- let current = node;
279
- while (current) {
280
- if (current === this) return true;
281
- current = current.parentElement;
282
- }
283
- return false;
284
- }
285
- }
286
-
287
- class MiniDocument {
288
- constructor() {
289
- this.body = new MiniElement('body', this);
290
- this.head = new MiniElement('head', this);
291
- this.canvasDrawCalls = [];
292
- this.activeElement = null;
293
- }
294
-
295
- createElement(tagName) {
296
- return new MiniElement(tagName, this);
297
- }
298
-
299
- getElementById(id) {
300
- const target = String(id || '');
301
- return [this.head, this.body]
302
- .flatMap(root => root.querySelectorAll('*'))
303
- .find(element => element.id === target) || null;
304
- }
305
-
306
- querySelector(selector) {
307
- return this.body.querySelector(selector) || this.head.querySelector(selector);
308
- }
309
-
310
- querySelectorAll(selector) {
311
- return [
312
- ...this.head.querySelectorAll(selector),
313
- ...this.body.querySelectorAll(selector)
314
- ];
315
- }
316
- }
317
-
318
- function matchesSelector(element, selector) {
319
- const text = String(selector || '').trim();
320
- if (!text || !element) return false;
321
- if (text === '*') return true;
322
-
323
- const tagMatch = /^[a-zA-Z][\w-]*/.exec(text);
324
- if (tagMatch && element.tagName.toLowerCase() !== tagMatch[0].toLowerCase()) {
325
- return false;
326
- }
327
-
328
- for (const classMatch of text.matchAll(/\.([\w-]+)/g)) {
329
- if (!element.classList.contains(classMatch[1])) {
330
- return false;
331
- }
332
- }
333
-
334
- for (const attrMatch of text.matchAll(/\[([^\]=]+)(?:="([^"]*)")?\]/g)) {
335
- const attrName = attrMatch[1];
336
- const expected = attrMatch[2];
337
- const actual = attrName.startsWith('data-')
338
- ? element.dataset[dataAttributeToDatasetKey(attrName)]
339
- : element.getAttribute(attrName);
340
- if (actual === undefined || actual === null) {
341
- return false;
342
- }
343
- if (expected !== undefined && String(actual) !== expected) {
344
- return false;
345
- }
346
- }
347
-
348
- return true;
349
- }
350
-
351
- function readStatusNumber(status, key) {
352
- const value = status?.[key];
353
- return Number.isFinite(Number(value)) ? Number(value) : null;
354
- }
355
-
356
- function readLoad1(status) {
357
- const value = status?.loadavg;
358
- return Array.isArray(value) && Number.isFinite(Number(value[0])) ? Number(value[0]) : null;
359
- }
360
-
361
- function projectDevice(device) {
362
- const status = device.status || {};
363
- const capabilities = device.capabilities || {};
364
- const thumbnail = device.latestThumbnail || {};
365
- const liveFrame = device.latestLiveFrame || {};
366
- const liveStream = device.activeLiveStream || {};
367
- const latestTask = device.latestTask || {};
368
- const platform = String(status.platform || device.platform || 'unknown');
369
-
370
- return {
371
- DeviceId: String(device.deviceId || ''),
372
- SessionId: String(device.sessionId || ''),
373
- Name: String(device.deviceName || device.hostname || device.deviceId || 'device'),
374
- Hostname: String(device.hostname || ''),
375
- Platform: platform,
376
- Release: String(status.release || ''),
377
- Arch: String(device.arch || ''),
378
- AgentVersion: String(device.agentVersion || ''),
379
- Connected: device.connected === true,
380
- ConnectedAt: String(device.connectedAt || ''),
381
- DisconnectedAt: String(device.disconnectedAt || ''),
382
- LastSeenAt: String(device.lastSeenAt || ''),
383
- LastStatusAt: String(device.lastStatusAt || ''),
384
- LastDisconnectReason: String(device.lastDisconnectReason || ''),
385
- RemoteAddress: String(device.remoteAddress || ''),
386
- RemotePort: Number(device.remotePort || 0),
387
- UptimeSec: readStatusNumber(status, 'uptimeSec'),
388
- UsedMemRatio: readStatusNumber(status, 'usedMemRatio'),
389
- Load1: readLoad1(status),
390
- StatusEnabled: capabilities.status === true,
391
- ThumbnailEnabled: capabilities.thumbnail === true,
392
- LiveStreamEnabled: capabilities.liveStream === true,
393
- ControlEnabled: capabilities.control === true,
394
- ComputerAgentEnabled: capabilities.computerAgent === true || capabilities.taskDispatch === true,
395
- AiAssistEnabled: capabilities.aiAssist === true,
396
- AiModel: String(capabilities.aiModel || ''),
397
- AiProvider: String(capabilities.aiProvider || ''),
398
- ThumbnailStreamId: String(thumbnail.streamId || ''),
399
- ThumbnailFrameSeq: Number(thumbnail.frameSeq || 0),
400
- ThumbnailWidth: Number(thumbnail.width || 0),
401
- ThumbnailHeight: Number(thumbnail.height || 0),
402
- ThumbnailMimeType: String(thumbnail.mimeType || thumbnail.format || ''),
403
- ThumbnailCapturedAt: String(thumbnail.capturedAt || ''),
404
- ThumbnailReceivedAt: String(thumbnail.receivedAt || ''),
405
- ThumbnailDataUrl: String(thumbnail.dataUrl || ''),
406
- LiveStreamActive: liveStream.active === true,
407
- LiveStreamId: String(liveStream.streamId || ''),
408
- LiveStreamMode: String(liveStream.mode || ''),
409
- LiveStreamFps: Number(liveStream.fps || 0),
410
- LiveStreamStartedAt: String(liveStream.startedAt || ''),
411
- LiveStreamStoppedAt: String(liveStream.stoppedAt || ''),
412
- LiveStreamLastFrameAt: String(liveStream.lastFrameAt || ''),
413
- LiveStreamFrameSeq: Number(liveStream.lastFrameSeq || 0),
414
- LiveFrameStreamId: String(liveFrame.streamId || ''),
415
- LiveFrameSeq: Number(liveFrame.frameSeq || 0),
416
- LiveFrameWidth: Number(liveFrame.width || 0),
417
- LiveFrameHeight: Number(liveFrame.height || 0),
418
- LiveFrameMimeType: String(liveFrame.mimeType || liveFrame.format || ''),
419
- LiveFrameCapturedAt: String(liveFrame.capturedAt || ''),
420
- LiveFrameReceivedAt: String(liveFrame.receivedAt || ''),
421
- LiveFrameDataUrl: String(liveFrame.dataUrl || ''),
422
- LatestTaskId: String(latestTask.taskId || ''),
423
- LatestTaskCommandId: String(latestTask.commandId || ''),
424
- LatestTaskTitle: String(latestTask.title || ''),
425
- LatestTaskInstructionPreview: String(latestTask.instructionPreview || ''),
426
- LatestTaskStatus: String(latestTask.status || ''),
427
- LatestTaskApprovalLevel: String(latestTask.approvalLevel || ''),
428
- LatestTaskUpdatedAt: String(latestTask.updatedAt || latestTask.completedAt || latestTask.sentAt || ''),
429
- LatestTaskError: String(latestTask.error || ''),
430
- LatestTaskResultModel: String(latestTask.resultModel || ''),
431
- LatestTaskResultResponseId: String(latestTask.resultResponseId || ''),
432
- LatestTaskResultSummary: String(latestTask.resultSummary || '')
433
- };
434
- }
435
-
436
- async function loadCss3DManager() {
437
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
438
- const hotPathModulePath = path.resolve(__dirname, '../../MindExecution.Shared/wwwroot/js/mind-map-css3d-hotpath.js');
439
- const managerPath = path.resolve(__dirname, '../../MindExecution.Shared/wwwroot/js/mind-map-css3d-manager.js');
440
- const hotPathSource = await fs.readFile(hotPathModulePath, 'utf8');
441
- const source = await fs.readFile(managerPath, 'utf8');
442
- const document = new MiniDocument();
443
- const objectUrlCalls = [];
444
- const revokedObjectUrls = [];
445
- const imageBitmapCalls = [];
446
- const fetchCalls = [];
447
- const runtimeTrace = [];
448
- const webSocketConnections = [];
449
- const webSocketSends = [];
450
- const textOverlayInvalidations = [];
451
- class SmokeURL extends URL {}
452
- SmokeURL.createObjectURL = blob => {
453
- objectUrlCalls.push(blob);
454
- return `blob:remote-fleet-smoke-${objectUrlCalls.length}`;
455
- };
456
- SmokeURL.revokeObjectURL = value => {
457
- revokedObjectUrls.push(String(value || ''));
458
- };
459
- class MiniWebSocket {
460
- static CONNECTING = 0;
461
- static OPEN = 1;
462
- static CLOSING = 2;
463
- static CLOSED = 3;
464
-
465
- constructor(url) {
466
- this.url = String(url || '');
467
- this.readyState = MiniWebSocket.CONNECTING;
468
- this.binaryType = '';
469
- this.sent = [];
470
- this.closeCount = 0;
471
- webSocketConnections.push(this);
472
- setTimeout(() => {
473
- if (this.readyState !== MiniWebSocket.CONNECTING) return;
474
- this.readyState = MiniWebSocket.OPEN;
475
- this.onopen?.({ type: 'open' });
476
- }, 0);
477
- }
478
-
479
- send(payload) {
480
- const text = typeof payload === 'string' ? payload : String(payload || '');
481
- this.sent.push(text);
482
- webSocketSends.push({ url: this.url, payload: text });
483
- }
484
-
485
- close() {
486
- if (this.readyState === MiniWebSocket.CLOSED) return;
487
- this.closeCount += 1;
488
- this.readyState = MiniWebSocket.CLOSED;
489
- this.onclose?.({ type: 'close' });
490
- }
491
- }
492
- const context = {
493
- console,
494
- document,
495
- location: {
496
- origin: 'http://localhost:5147'
497
- },
498
- navigator: {
499
- clipboard: {
500
- writeText: async () => {}
501
- }
502
- },
503
- setInterval: () => 0,
504
- clearInterval: () => {},
505
- setTimeout,
506
- clearTimeout,
507
- Date,
508
- Math,
509
- Number,
510
- String,
511
- Boolean,
512
- Array,
513
- Object,
514
- JSON,
515
- RegExp,
516
- Map,
517
- Set,
518
- WeakMap,
519
- Blob,
520
- TextDecoder,
521
- TextEncoder,
522
- requestAnimationFrame: callback => setTimeout(() => callback(Date.now()), 0),
523
- cancelAnimationFrame: id => clearTimeout(id),
524
- createImageBitmap: async blob => {
525
- imageBitmapCalls.push(blob);
526
- return {
527
- width: 64,
528
- height: 36,
529
- close() {
530
- this.closed = true;
531
- }
532
- };
533
- },
534
- THREE: createThreeStub(),
535
- URL: SmokeURL,
536
- WebSocket: MiniWebSocket,
537
- fetch: async (url, options = {}) => {
538
- fetchCalls.push({ url: String(url || ''), options });
539
- return {
540
- ok: true,
541
- status: 200,
542
- json: async () => ({
543
- bridgeToken: 'render-smoke-bridge-token',
544
- remoteFrameWsPath: '/api/remote/frames/ws',
545
- remoteInputWsPath: '/api/remote/input/ws'
546
- })
547
- };
548
- },
549
- RuntimeTrace: {
550
- emit(type, data = {}) {
551
- runtimeTrace.push({ type, ...data });
552
- }
553
- },
554
- MindMapTextOverlayV2: {
555
- invalidateReadonlySource(module, nodeId, reason) {
556
- textOverlayInvalidations.push({ module, nodeId, reason });
557
- return true;
558
- },
559
- invalidateNode(module, nodeId, reason) {
560
- textOverlayInvalidations.push({ module, nodeId, reason, fallback: true });
561
- }
562
- },
563
- MindExecRemoteCodecs: {
564
- async decodeH264Frame(canvas, frame, onFrame) {
565
- onFrame?.(canvas, frame);
566
- return true;
567
- }
568
- },
569
- Promise
570
- };
571
- context.window = context;
572
- context.self = context;
573
-
574
- vm.runInNewContext(hotPathSource, context, { filename: hotPathModulePath });
575
- vm.runInNewContext(source, context, { filename: managerPath });
576
- return {
577
- manager: context.window.MindMapCss3DManager,
578
- document,
579
- diagnostics: {
580
- objectUrlCalls,
581
- revokedObjectUrls,
582
- imageBitmapCalls,
583
- fetchCalls,
584
- runtimeTrace,
585
- webSocketConnections,
586
- webSocketSends,
587
- textOverlayInvalidations
588
- }
589
- };
590
- }
591
-
592
- function wait(ms = 0) {
593
- return new Promise(resolve => setTimeout(resolve, ms));
594
- }
595
-
596
- async function waitFor(predicate, timeoutMs = 500, intervalMs = 10) {
597
- const deadline = Date.now() + Math.max(1, Number(timeoutMs || 500));
598
- while (Date.now() < deadline) {
599
- if (predicate()) return true;
600
- await wait(intervalMs);
601
- }
602
- return predicate();
603
- }
604
-
605
- function encodeRemoteBinaryFrame(metadata, payload = new Uint8Array([0xff, 0xd8, 0xff, 0xd9])) {
606
- const metaBytes = new TextEncoder().encode(JSON.stringify(metadata));
607
- const payloadBytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
608
- const buffer = new ArrayBuffer(4 + metaBytes.byteLength + payloadBytes.byteLength);
609
- const view = new DataView(buffer);
610
- view.setUint32(0, metaBytes.byteLength);
611
- const bytes = new Uint8Array(buffer);
612
- bytes.set(metaBytes, 4);
613
- bytes.set(payloadBytes, 4 + metaBytes.byteLength);
614
- return buffer;
615
- }
616
-
617
- function buildMonitorNode(devices, hubStatus, latestTaskBatch = null, recentTaskBatches = [], lastError = '', nodeId = 'remote-fleet-render-smoke') {
618
- const connected = devices.filter(device => device.Connected).length;
619
- const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5198';
620
- const pairToken = hubStatus.pairToken || 'render-smoke-token';
621
- const hostTargetState = hubStatus.hostTargetActive
622
- ? (hubStatus.hostTargetNodeId === nodeId ? 'hosting' : 'other-monitor')
623
- : 'inactive';
624
- return {
625
- id: nodeId,
626
- contentType: 'templateLauncher',
627
- metadata: {
628
- SemanticType: 'RemoteFleetMonitor',
629
- RemoteFleetSchemaVersion: 'remote-fleet@1',
630
- RemoteFleetViewMode: 'all-devices',
631
- RemoteFleetLastRefreshAtUtc: new Date().toISOString(),
632
- RemoteFleetHubStatus: 'online',
633
- RemoteFleetHubEndpoint: endpoint,
634
- RemoteFleetManagerPackage: hubStatus.managerPackage || '@mindexec/cli',
635
- RemoteFleetManagerVersion: hubStatus.managerVersion || 'render-smoke-manager',
636
- RemoteFleetAgentPackage: '@mindexec/remote',
637
- RemoteFleetPairTokenPreview: '<pair-token>',
638
- RemoteFleetConnectCommand: `npx @mindexec/remote connect --manager ${endpoint} --pair ${pairToken}`,
639
- RemoteFleetDeviceCount: String(devices.length),
640
- RemoteFleetConnectedDeviceCount: String(connected),
641
- RemoteFleetCanvasPagination: 'none',
642
- RemoteFleetHostTargetState: hostTargetState,
643
- RemoteFleetHostTargetNodeId: hubStatus.hostTargetNodeId || '',
644
- RemoteFleetHostTargetLeaseId: hubStatus.hostTargetLeaseId || '',
645
- RemoteFleetHostTargetEndpoint: hubStatus.hostTargetEndpoint || endpoint,
646
- RemoteFleetHostTargetActivatedAtUtc: hubStatus.hostTargetActivatedAt || '',
647
- RemoteFleetHostTargetUpdatedAtUtc: hubStatus.hostTargetUpdatedAt || '',
648
- RemoteFleetHostTargetExpiresAtUtc: hubStatus.hostTargetExpiresAt || '',
649
- RemoteFleetDevicesJson: JSON.stringify(devices),
650
- RemoteFleetLatestTaskBatchJson: latestTaskBatch ? JSON.stringify(latestTaskBatch) : '',
651
- RemoteFleetRecentTaskBatchesJson: JSON.stringify(recentTaskBatches),
652
- RemoteFleetLastError: String(lastError || '')
653
- }
654
- };
655
- }
656
-
657
- function createRemoteFleetTemplateShell(document, focusDeviceId = '', nodeId = 'remote-fleet-render-smoke') {
658
- const nodeShell = document.createElement('div');
659
- nodeShell.setAttribute('class', 'map-node-template-card map-node-remote-fleet');
660
- nodeShell.dataset.nodeId = nodeId;
661
- const shell = document.createElement('div');
662
- shell.setAttribute('class', 'template-card__shell template-card__shell--remote-fleet');
663
- const header = document.createElement('div');
664
- header.setAttribute('class', 'template-card__header template-card__header--remote-fleet');
665
- const icon = document.createElement('div');
666
- icon.setAttribute('class', 'template-card__icon template-card__icon--remote-fleet');
667
- const titleWrap = document.createElement('div');
668
- titleWrap.setAttribute('class', 'template-card__title-block');
669
- titleWrap.textContent = 'Multi Desktop Monitor';
670
- header.appendChild(icon);
671
- header.appendChild(titleWrap);
672
- const bodyView = document.createElement('div');
673
- bodyView.setAttribute('class', 'template-card__remote-fleet-body map-node-remote-fleet__body');
674
- bodyView.dataset.nodeId = nodeId;
675
- bodyView.dataset.remoteFleetAutoMonitor = 'false';
676
- if (focusDeviceId) {
677
- bodyView.dataset.remoteFleetFocusDeviceId = focusDeviceId;
678
- }
679
- shell.appendChild(header);
680
- shell.appendChild(bodyView);
681
- nodeShell.appendChild(shell);
682
- return { nodeShell, bodyView };
683
- }
684
-
685
- function buildDeviceNode(device, hubStatus) {
686
- const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5198';
687
- return {
688
- id: 'remote-device-render-smoke',
689
- contentType: 'memo',
690
- metadata: {
691
- SemanticType: 'RemoteFleetDevice',
692
- RemoteFleetSchemaVersion: 'remote-device@1',
693
- RemoteFleetViewMode: 'pinned-device',
694
- RemoteFleetLastRefreshAtUtc: new Date().toISOString(),
695
- RemoteFleetHubStatus: 'online',
696
- RemoteFleetHubEndpoint: endpoint,
697
- RemoteFleetManagerPackage: hubStatus.managerPackage || '@mindexec/cli',
698
- RemoteFleetManagerVersion: hubStatus.managerVersion || 'render-smoke-manager',
699
- RemoteFleetAgentPackage: '@mindexec/remote',
700
- RemoteFleetPinnedDeviceId: device.DeviceId,
701
- RemoteFleetPinnedDeviceJson: JSON.stringify(device),
702
- RemoteFleetLastError: ''
703
- }
704
- };
705
- }
706
-
707
- function createThreeStub() {
708
- class Vector3 {
709
- constructor(x = 0, y = 0, z = 0) {
710
- this.x = x;
711
- this.y = y;
712
- this.z = z;
713
- }
714
-
715
- set(x = 0, y = 0, z = 0) {
716
- this.x = x;
717
- this.y = y;
718
- this.z = z;
719
- return this;
720
- }
721
- }
722
-
723
- class Matrix4 {
724
- multiplyMatrices() { return this; }
725
- }
726
-
727
- class Frustum {
728
- setFromProjectionMatrix() { return this; }
729
- intersectsBox() { return true; }
730
- }
731
-
732
- class Quaternion {}
733
-
734
- class Box3 {
735
- setFromCenterAndSize() { return this; }
736
- }
737
-
738
- return { Box3, Frustum, Matrix4, Quaternion, Vector3 };
739
- }
740
-
741
- const hub = createRemoteHub({
742
- managerPackage: '@mindexec/cli',
743
- managerVersion: 'render-smoke-manager',
744
- env: {
745
- MINDEXEC_REMOTE_HUB: '1',
746
- REMOTE_HUB_HOST: '127.0.0.1',
747
- REMOTE_HUB_PORT: '0',
748
- REMOTE_HUB_PAIR_TOKEN: 'render-smoke-token'
749
- }
750
- });
751
-
752
- try {
753
- await hub.start();
754
- const seeded = hub.seedSyntheticFleet({
755
- count: SYNTHETIC_COUNT,
756
- connectedRatio: 0.84,
757
- thumbnailRatio: 0.72,
758
- aiAssistRatio: 0.42,
759
- liveCount: 0
760
- });
761
- assert.equal(seeded.ok, true);
762
- assert.equal(seeded.seeded, SYNTHETIC_COUNT);
763
-
764
- const seededAiTarget = hub.listDevices().find(device =>
765
- device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist);
766
- assert.ok(seededAiTarget);
767
- const renderAiTask = hub.requestAgentTask(seededAiTarget.deviceId, {
768
- instruction: 'Synthetic render smoke AI task: report model metadata to the canvas.',
769
- title: 'Render smoke AI task',
770
- approvalLevel: 'ai-assist',
771
- model: 'synthetic-render-ai'
772
- });
773
- assert.equal(renderAiTask.ok, true);
774
-
775
- const seededLiveTarget = hub.listDevices().find(device =>
776
- device.connected && device.capabilities?.liveStream);
777
- assert.ok(seededLiveTarget);
778
- const renderLive = hub.startLiveStream(seededLiveTarget.deviceId, {
779
- streamId: 'render-smoke-live',
780
- fps: 20,
781
- maxWidth: 960,
782
- maxHeight: 540,
783
- quality: 60
784
- });
785
- assert.equal(renderLive.ok, true);
786
-
787
- const rawDevices = hub.listDevices();
788
- const devices = rawDevices.map(projectDevice);
789
- const connectedCount = devices.filter(device => device.Connected).length;
790
- const aiCount = devices.filter(device => device.Connected && device.AiAssistEnabled).length;
791
- const focusedDevice = devices.find(device => device.Connected && device.LiveStreamActive)
792
- || devices.find(device => device.Connected);
793
- assert.ok(focusedDevice);
794
- focusedDevice.LatestTaskId = 'render-smoke-timeout-task';
795
- focusedDevice.LatestTaskCommandId = 'render-smoke-timeout-command';
796
- focusedDevice.LatestTaskTitle = 'Timed out smoke task';
797
- focusedDevice.LatestTaskInstructionPreview = 'This synthetic task timed out before the agent replied.';
798
- focusedDevice.LatestTaskStatus = 'failed';
799
- focusedDevice.LatestTaskApprovalLevel = 'task-only';
800
- focusedDevice.LatestTaskUpdatedAt = new Date().toISOString();
801
- focusedDevice.LatestTaskError = 'task-timeout';
802
- focusedDevice.LatestTaskResultSummary = '';
803
- const aiResultDevice = devices.find(device =>
804
- device.DeviceId !== focusedDevice.DeviceId
805
- && device.Connected);
806
- assert.ok(aiResultDevice);
807
- aiResultDevice.LatestTaskId = 'render-smoke-overview-ai-task';
808
- aiResultDevice.LatestTaskCommandId = 'render-smoke-overview-ai-command';
809
- aiResultDevice.LatestTaskTitle = 'Overview AI result';
810
- aiResultDevice.LatestTaskStatus = 'completed';
811
- aiResultDevice.LatestTaskApprovalLevel = 'ai-assist';
812
- aiResultDevice.LatestTaskUpdatedAt = new Date(Date.now() - 1000).toISOString();
813
- aiResultDevice.LatestTaskError = '';
814
- aiResultDevice.LatestTaskResultModel = 'synthetic-render-ai';
815
- aiResultDevice.LatestTaskResultResponseId = 'synthetic-response-overview';
816
- aiResultDevice.LatestTaskResultSummary = 'Overview AI result visible in the fleet monitor.';
817
- const latestTaskBatch = {
818
- batchId: 'render-smoke-batch',
819
- title: 'Render smoke batch',
820
- instructionPreview: 'Render smoke batch instruction preview.',
821
- approvalLevel: 'ai-assist',
822
- status: 'running',
823
- requestedAt: new Date(Date.now() - 2500).toISOString(),
824
- updatedAt: new Date().toISOString(),
825
- total: 210,
826
- queued: 210,
827
- pending: 1,
828
- completed: 208,
829
- failed: 1,
830
- timedOut: 1,
831
- results: []
832
- };
833
- const recentTaskBatches = [
834
- latestTaskBatch,
835
- {
836
- batchId: 'render-smoke-previous-ai-batch',
837
- title: 'Previous AI batch',
838
- instructionPreview: 'Previous AI batch instruction preview.',
839
- approvalLevel: 'ai-assist',
840
- status: 'completed',
841
- requestedAt: new Date(Date.now() - 180000).toISOString(),
842
- updatedAt: new Date(Date.now() - 150000).toISOString(),
843
- total: 42,
844
- queued: 42,
845
- pending: 0,
846
- completed: 42,
847
- failed: 0,
848
- timedOut: 0,
849
- results: []
850
- }
851
- ];
852
-
853
- const { manager, document, diagnostics } = await loadCss3DManager();
854
- assert.equal(typeof manager?.renderRemoteFleetMonitorForTest, 'function');
855
- assert.equal(typeof manager?.renderRemoteFleetDeviceForTest, 'function');
856
- assert.equal(typeof manager?.applyRemoteFleetFramePatchesForTest, 'function');
857
- assert.equal(typeof manager?.setModuleForTest, 'function');
858
-
859
- const dotNetCalls = [];
860
- const dotNetHelper = {
861
- invokeMethodAsync: async (methodName, ...args) => {
862
- dotNetCalls.push({ methodName, args });
863
- if (methodName === 'DispatchRemoteFleetTaskBatchFromJs') {
864
- const targetIds = Array.isArray(args[1]) ? args[1] : [];
865
- const failedDeviceId = targetIds[targetIds.length - 1] || 'synthetic-pc-failed';
866
- return {
867
- success: true,
868
- total: targetIds.length,
869
- queued: Math.max(0, targetIds.length - 1),
870
- failed: 1,
871
- failedDeviceIds: [failedDeviceId],
872
- failurePreview: `${failedDeviceId}: device-ai-assist-unavailable`
873
- };
874
- }
875
-
876
- if (methodName === 'DispatchRemoteFleetTaskFromJs') {
877
- const useAiAssist = args[3] === true;
878
- const total = useAiAssist ? aiCount : connectedCount;
879
- return {
880
- success: true,
881
- total,
882
- queued: total,
883
- failed: 0,
884
- approvalLevel: useAiAssist ? 'ai-assist' : 'task-only'
885
- };
886
- }
887
-
888
- if (methodName === 'SetRemoteFleetHostFromJs') {
889
- return {
890
- success: true,
891
- active: args[1] === true,
892
- registryStatus: args[1] === true ? 'local' : 'inactive',
893
- registryReason: args[1] === true ? 'registry-render-smoke' : 'inactive'
894
- };
895
- }
896
-
897
- if (methodName === 'AddRemoteFleetDeviceNodeFromJs') {
898
- const deviceId = String(args[1] || '');
899
- return {
900
- success: true,
901
- nodeId: 'remote-device-render-smoke',
902
- deviceId,
903
- nodeState: buildDeviceNode(
904
- devices.find(device => device.DeviceId === deviceId) || focusedDevice,
905
- hub.getStatus())
906
- };
907
- }
908
-
909
- return { success: true };
910
- }
911
- };
912
- const moduleRef = {
913
- dotNetHelper,
914
- nodeObjectsById: new Map(),
915
- _visibleIds: new Set(['remote-fleet-render-smoke']),
916
- _prevVisibleIds: new Set(['remote-fleet-render-smoke']),
917
- _forceUpdateFrames: 0,
918
- _textOverlayV2State: {
919
- cards: new Map(),
920
- passiveCandidateIds: new Set(['remote-fleet-render-smoke']),
921
- layer: document.createElement('div')
922
- },
923
- requestAnimationWake(reason) {
924
- this._lastAnimationWakeReason = reason;
925
- this._animationWakeCount = Number(this._animationWakeCount || 0) + 1;
926
- },
927
- isAnimationLoopActive() {
928
- return true;
929
- }
930
- };
931
- manager.setModuleForTest(moduleRef);
932
-
933
- const { nodeShell, bodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
934
- document.body.appendChild(nodeShell);
935
- const monitorNode = buildMonitorNode(devices, hub.getStatus({ includeSecrets: true }), latestTaskBatch, recentTaskBatches);
936
- moduleRef.nodeObjectsById.set('remote-fleet-render-smoke', {
937
- model: monitorNode,
938
- currentType: 'CSS',
939
- cssObject: {
940
- visible: true,
941
- element: nodeShell
942
- }
943
- });
944
- document.body.appendChild(moduleRef._textOverlayV2State.layer);
945
-
946
- manager.renderRemoteFleetMonitorForTest(bodyView, monitorNode);
947
- const { nodeShell: mirrorShell, bodyView: mirrorBodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
948
- document.body.appendChild(mirrorShell);
949
- mirrorBodyView.dataset.remoteFleetDensity = 'cards';
950
-
951
- let cards = bodyView.querySelectorAll('article[data-device-id]');
952
- assert.equal(cards.length, connectedCount);
953
- assert.ok(bodyView.querySelector('[data-remote-fleet-match-count="true"]'));
954
- assert.ok(bodyView.querySelector('[data-remote-fleet-search="true"]'));
955
- assert.equal(bodyView.querySelectorAll('select').length, 4);
956
- assert.ok(bodyView.querySelector('[data-remote-fleet-task-composer="visible"]'));
957
- assert.ok(bodyView.querySelector('[data-remote-fleet-task-input="true"]'));
958
- const deviceGrid = bodyView.querySelector('[data-remote-fleet-device-grid="true"]');
959
- assert.ok(deviceGrid);
960
- assert.match(deviceGrid.style.cssText, /padding:\s*0 4px;/);
961
- const statusFooter = bodyView.querySelector('[data-remote-fleet-status-rail="true"]');
962
- assert.ok(statusFooter);
963
- const bodyChildOrder = Array.from(bodyView.children).map(child =>
964
- Object.keys(child.dataset || {}).join(',') || child.tagName).join('|');
965
- assert.ok(bodyChildOrder.endsWith('remoteFleetStatusRail'), bodyChildOrder);
966
- assert.ok(statusFooter.style.cssText.includes('flex-direction: row'));
967
- assert.ok(statusFooter.style.cssText.includes('justify-content: flex-end'));
968
- const sizeControls = statusFooter.querySelector('[data-remote-fleet-size-controls="true"]');
969
- assert.ok(sizeControls);
970
- assert.equal(sizeControls.querySelector('[data-remote-fleet-action="monitor-size-down"]')?.textContent, '-');
971
- assert.equal(sizeControls.querySelector('[data-remote-fleet-action="monitor-size-up"]')?.textContent, '+');
972
- assert.match(statusFooter.style.cssText, /box-sizing:\s*border-box;/);
973
- assert.equal(statusFooter.querySelectorAll('[data-remote-fleet-status-item]').length, 5);
974
- assert.ok(statusFooter.querySelector('[data-remote-fleet-status-item="route"]'));
975
- const initialDetailPanel = bodyView.querySelector('[data-remote-fleet-detail-panel="true"]');
976
- assert.equal(initialDetailPanel, null);
977
- const initialSelectedCard = bodyView.querySelector(`article[data-device-id="${focusedDevice.DeviceId}"]`);
978
- assert.ok(initialSelectedCard);
979
- assert.equal(initialSelectedCard?.querySelector('[data-remote-fleet-selected-indicator="true"]'), null);
980
- assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="pin-device"]').length, 0);
981
- assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="task-device"]').length, 0);
982
- assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="thumbnail-device"]').length, 0);
983
- assert.equal(bodyView.querySelectorAll('[data-remote-fleet-frame-badge="true"]').length, 0);
984
- const firstPreview = cards[0]?.querySelector('[data-remote-fleet-device-preview="tile"]');
985
- assert.ok(firstPreview);
986
- assert.match(cards[0]?.style.cssText || '', /border-radius:\s*0/);
987
- assert.match(firstPreview.style.cssText, /border-radius:\s*0/);
988
- assert.match(cards[0]?.title || '', /Status:\s*(Connected|Offline)/);
989
- assert.match(cards[0]?.title || '', /Seen:/);
990
- assert.match(cards[0]?.title || '', /Uptime:/);
991
- assert.equal(/\b(Seen|Uptime|Mem|Load)\b/.test(cards[0]?.textContent || ''), false);
992
- assert.match(deviceGrid.style.cssText, /minmax\(198px,\s*1fr\)/);
993
- sizeControls.querySelector('[data-remote-fleet-action="monitor-size-up"]').dispatchEvent({ type: 'click' });
994
- assert.equal(bodyView.dataset.remoteFleetDensity, 'large');
995
- assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(297px,\s*1fr\)/);
996
- assert.equal(mirrorBodyView.dataset.remoteFleetDensity, 'large');
997
- assert.match(mirrorBodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(297px,\s*1fr\)/);
998
- assert.ok(diagnostics.runtimeTrace.some(entry =>
999
- entry.type === 'remote.monitor.sizeChanged'
1000
- && entry.nodeId === 'remote-fleet-render-smoke'
1001
- && entry.density === 'large'
1002
- && entry.css3dOnly === true));
1003
- bodyView.querySelector('[data-remote-fleet-action="monitor-size-down"]').dispatchEvent({ type: 'click' });
1004
- assert.equal(bodyView.dataset.remoteFleetDensity, 'cards');
1005
- assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1006
- assert.equal(mirrorBodyView.dataset.remoteFleetDensity, 'cards');
1007
- assert.match(mirrorBodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1008
- bodyView.querySelector('[data-remote-fleet-action="monitor-size-down"]').dispatchEvent({ type: 'click' });
1009
- assert.equal(bodyView.dataset.remoteFleetDensity, 'dense');
1010
- assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(132px,\s*1fr\)/);
1011
- bodyView.querySelector('[data-remote-fleet-action="monitor-size-up"]').dispatchEvent({ type: 'click' });
1012
- assert.equal(bodyView.dataset.remoteFleetDensity, 'cards');
1013
- assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1014
- mirrorShell.remove();
1015
- cards = bodyView.querySelectorAll('article[data-device-id]');
1016
- const patchTarget = devices.find(device =>
1017
- device.Connected === true
1018
- && device.ThumbnailEnabled === true);
1019
- assert.ok(patchTarget);
1020
- const patchCard = Array.from(cards).find(card => card.dataset.deviceId === patchTarget.DeviceId);
1021
- const patchPreview = patchCard?.querySelector('[data-remote-fleet-device-preview="tile"]');
1022
- assert.ok(patchPreview);
1023
- assert.notEqual(patchPreview.dataset.remoteFleetFrameKind, 'live');
1024
- const patchKind = 'thumbnail';
1025
- const patchUrl = `/api/remote/devices/${encodeURIComponent(patchTarget.DeviceId)}/${patchKind}?token=render-smoke-frame&seq=9999`;
1026
- const patchCount = manager.applyRemoteFleetFramePatchesForTest(bodyView, [{
1027
- deviceId: patchTarget.DeviceId,
1028
- kind: patchKind,
1029
- frameSeq: 9999,
1030
- frameUrl: patchUrl,
1031
- receivedAt: new Date().toISOString()
1032
- }]);
1033
- assert.equal(patchCount, 1, JSON.stringify({
1034
- targetDeviceId: patchTarget.DeviceId,
1035
- previewCount: bodyView.querySelectorAll('[data-remote-fleet-device-preview]').length,
1036
- previewIds: Array.from(bodyView.querySelectorAll('[data-remote-fleet-device-preview]')).slice(0, 12).map(preview => preview.dataset.deviceId || ''),
1037
- currentKind: patchPreview.dataset.remoteFleetFrameKind || '',
1038
- currentSeq: patchPreview.dataset.remoteFleetFrameSeq || '',
1039
- currentUrl: patchPreview.dataset.remoteFleetFrameUrl || ''
1040
- }));
1041
- await wait();
1042
- assert.equal(patchPreview.dataset.remoteFleetFrameSeq, '9999');
1043
- assert.equal(patchPreview.dataset.remoteFleetFrameUrl, patchUrl);
1044
- assert.equal(patchPreview.dataset.remoteFleetPendingFrameUrl || '', '');
1045
- assert.ok(patchPreview.querySelector('canvas[data-remote-fleet-frame-canvas="true"]'));
1046
- assert.equal(patchPreview.querySelector('img[data-remote-fleet-frame-image="true"]')?.dataset.remoteFleetFrameUrl, patchUrl);
1047
- assert.equal(patchPreview.querySelector('[data-remote-fleet-frame-badge="true"]'), null);
1048
-
1049
- const controlCard = bodyView.querySelector(`article[data-device-id="${patchTarget.DeviceId}"]`);
1050
- assert.ok(controlCard);
1051
- controlCard.dispatchEvent({ type: 'dblclick', button: 0 });
1052
- await wait(30);
1053
- assert.equal(document.body.querySelector('[data-remote-fleet-control-popup="true"]'), null);
1054
- const addControlNodeCall = dotNetCalls.find(call => call.methodName === 'AddRemoteFleetDeviceNodeFromJs');
1055
- assert.equal(addControlNodeCall, undefined, 'MDM thumbnails must not create an expanded device node');
1056
-
1057
- const alternateDevice = devices.find(device =>
1058
- device.Connected === true
1059
- && device.DeviceId !== focusedDevice.DeviceId);
1060
- assert.ok(alternateDevice);
1061
- const alternateCard = Array.from(cards).find(card => card.dataset.deviceId === alternateDevice.DeviceId);
1062
- assert.ok(alternateCard);
1063
- alternateCard.dispatchEvent({ type: 'click' });
1064
- assert.equal(bodyView.dataset.remoteFleetSelectedDeviceId, alternateDevice.DeviceId);
1065
- assert.equal(bodyView.querySelector('[data-remote-fleet-detail-panel="true"]'), null);
1066
- const selectedAfterClick = bodyView.querySelector(`article[data-device-id="${alternateDevice.DeviceId}"]`);
1067
- assert.ok(selectedAfterClick);
1068
- assert.equal(selectedAfterClick?.querySelector('[data-remote-fleet-selected-indicator="true"]'), null);
1069
- const livePanel = bodyView.querySelector('[data-remote-fleet-live-panel="true"]');
1070
- assert.equal(livePanel, null);
1071
- assert.ok(bodyView.querySelector('[data-remote-fleet-action="task-selected"]'));
1072
- assert.ok(bodyView.querySelector('[data-remote-fleet-action="task-connected"]'));
1073
- assert.ok(bodyView.querySelector('[data-remote-fleet-task-input="true"]'));
1074
- assert.ok(bodyView.querySelector('[data-remote-fleet-ai-toggle="true"]'));
1075
- const selectedTaskInput = bodyView.querySelector('[data-remote-fleet-task-input="true"]');
1076
- const selectedTaskButton = bodyView.querySelector('[data-remote-fleet-action="task-selected"]');
1077
- selectedTaskInput.value = 'Inspect Git status and report the result.';
1078
- selectedTaskButton.dispatchEvent({ type: 'click' });
1079
- await wait(20);
1080
- const selectedTaskCall = dotNetCalls.find(call =>
1081
- call.methodName === 'DispatchRemoteFleetTaskFromJs'
1082
- && call.args[0] === 'remote-fleet-render-smoke'
1083
- && call.args[1] === alternateDevice.DeviceId);
1084
- assert.ok(selectedTaskCall, 'selected thumbnail must target its agent command');
1085
- assert.equal(bodyView.textContent.includes('all devices, no paging'), false);
1086
- assert.equal(bodyView.textContent.includes('Host: Inactive'), false);
1087
- assert.equal(bodyView.textContent.includes('No screen'), false);
1088
- assert.equal(bodyView.textContent.includes('@mindexec/cli'), false);
1089
- assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'false');
1090
- const { nodeShell: hostMirrorShell, bodyView: hostMirrorBodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
1091
- document.body.appendChild(hostMirrorShell);
1092
- manager.renderRemoteFleetMonitorForTest(hostMirrorBodyView, monitorNode);
1093
- assert.equal(hostMirrorShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'false');
1094
- const initialHostButton = nodeShell.querySelector('[data-remote-fleet-action="set-host"]');
1095
- assert.equal(initialHostButton?.textContent, 'Set Host');
1096
- initialHostButton.dispatchEvent({ type: 'click' });
1097
- await wait();
1098
- const setHostCall = dotNetCalls.find(call => call.methodName === 'SetRemoteFleetHostFromJs');
1099
- assert.ok(setHostCall);
1100
- assert.equal(setHostCall.args[0], 'remote-fleet-render-smoke');
1101
- assert.equal(setHostCall.args[1], true);
1102
- const hostFeedback = bodyView.querySelector('[data-remote-fleet-task-feedback="true"]');
1103
- assert.equal(hostFeedback?.style.display, 'none');
1104
- assert.equal(hostFeedback?.textContent, '');
1105
- assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1106
- assert.equal(hostMirrorShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1107
- assert.ok(diagnostics.runtimeTrace.some(entry =>
1108
- entry.type === 'remote.monitor.projectionInvalidated'
1109
- && entry.nodeId === 'remote-fleet-render-smoke'
1110
- && entry.reason === 'host'
1111
- && entry.css3dOnly === true));
1112
- hostMirrorShell.remove();
1113
-
1114
- hub.setHostTarget({
1115
- nodeId: 'remote-fleet-render-smoke',
1116
- enabled: true,
1117
- leaseMs: 30000
1118
- });
1119
- manager.renderRemoteFleetMonitorForTest(bodyView, buildMonitorNode(devices, hub.getStatus({ includeSecrets: true }), latestTaskBatch, recentTaskBatches));
1120
- assert.equal(bodyView.textContent.includes('Host: Active'), false);
1121
- assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1122
- assert.equal(nodeShell.querySelector('[data-remote-fleet-action="set-host"]')?.textContent, 'Set Host');
1123
- assert.equal(nodeShell.querySelector('[data-remote-fleet-action="stop-host"]'), null);
1124
- hub.setHostTarget({
1125
- nodeId: 'remote-fleet-render-smoke',
1126
- enabled: false
1127
- });
1128
-
1129
- assert.equal(bodyView.querySelector('[data-remote-fleet-live-panel="true"]'), null);
1130
- assert.equal(bodyView.querySelector('code'), null);
1131
- assert.equal(bodyView.textContent.includes('npx @mindexec/remote connect'), false);
1132
- assert.equal(bodyView.querySelector('[data-remote-fleet-action="copy-command"]'), null);
1133
- assert.equal(bodyView.querySelector('[data-remote-fleet-action="refresh"]'), null);
1134
- assert.equal(bodyView.querySelector('[data-remote-fleet-auto-toggle="true"]'), null);
1135
- assert.equal(bodyView.textContent.includes('synthetic-render-ai'), true);
1136
- assert.equal(bodyView.textContent.includes('Task timed out waiting for the agent response.'), true);
1137
- const batchSummary = bodyView.querySelector('[data-remote-fleet-task-batch="true"]');
1138
- assert.ok(batchSummary);
1139
- const batchHistory = bodyView.querySelector('[data-remote-fleet-task-history="true"]');
1140
- assert.ok(batchHistory);
1141
- const resultPanel = bodyView.querySelector('[data-remote-fleet-task-results="true"]');
1142
- assert.ok(resultPanel);
1143
- assert.ok(devices.some(device => /^synthetic-response-/.test(device.LatestTaskResultResponseId)));
1144
- await wait(20);
1145
- const liveStartCalls = dotNetCalls
1146
- .filter(call => call.methodName === 'StartRemoteFleetLiveStreamFromJs');
1147
- assert.equal(liveStartCalls.length, 0, 'thumbnail-only MDM must not start live streams');
1148
- assert.equal(
1149
- diagnostics.webSocketConnections.some(connection =>
1150
- String(connection?.url || '').includes('/api/remote/atlas/ws')
1151
- || String(connection?.url || '').includes('/api/remote/frames/ws')),
1152
- false,
1153
- 'thumbnail-only MDM must not open live frame WebSockets');
1154
- assert.equal(
1155
- diagnostics.fetchCalls.some(call => call.url.includes('/api/status?remoteFrames=ws')),
1156
- false,
1157
- 'thumbnail-only MDM must not initialize live-frame transport');
1158
- await wait(320);
1159
- assert.ok(dotNetCalls.some(call => call.methodName === 'RefreshRemoteFleetMonitorNodeFromJs'));
1160
- assert.equal(bodyView.dataset.remoteFleetTaskFollowKey, 'render-smoke-batch');
1161
- assert.ok(Number(bodyView.dataset.remoteFleetTaskFollowTicks || '0') >= 1);
1162
-
1163
- const feedback = bodyView.querySelector('[data-remote-fleet-task-feedback="true"]');
1164
- assert.ok(feedback);
1165
-
1166
- assert.ok(bodyView.querySelector('[data-remote-fleet-ai-toggle="true"]'));
1167
- assert.ok(dotNetCalls.some(call =>
1168
- call.methodName === 'DispatchRemoteFleetTaskFromJs'
1169
- && call.args[1] === alternateDevice.DeviceId));
1170
-
1171
- const { nodeShell: emptyShell, bodyView: emptyBody } = createRemoteFleetTemplateShell(document);
1172
- document.body.appendChild(emptyShell);
1173
- manager.renderRemoteFleetMonitorForTest(emptyBody, buildMonitorNode([], hub.getStatus({ includeSecrets: true })));
1174
- const emptyScreenShell = emptyBody.querySelector('[data-remote-fleet-empty-screens="true"]');
1175
- assert.ok(emptyScreenShell);
1176
- assert.match(emptyScreenShell.style.cssText, /padding:\s*2px 4px 6px 4px;/);
1177
- const emptyScreens = emptyBody.querySelectorAll('[data-remote-fleet-empty-screen="true"]');
1178
- assert.ok(emptyScreens.length >= 12, `expected empty monitor to fill space, got ${emptyScreens.length}`);
1179
- assert.notEqual(emptyScreens.length, 6);
1180
- assert.match(emptyScreens[0].style.cssText, /border-radius:\s*0/);
1181
- assert.ok(Array.from(emptyBody.children).map(child =>
1182
- Object.keys(child.dataset || {}).join(',') || child.tagName).join('|').endsWith('remoteFleetStatusRail'));
1183
- assert.equal(emptyBody.textContent.includes('No devices connected yet.'), false);
1184
- assert.equal(emptyBody.textContent.includes('Select a screen'), false);
1185
- assert.equal(emptyBody.textContent.includes('No screen'), false);
1186
- assert.equal(emptyBody.textContent.includes('Endpoint 127.0.0.1'), false);
1187
-
1188
- const oneDevice = devices.find(device => device.Connected === true);
1189
- assert.ok(oneDevice);
1190
- const { nodeShell: oneShell, bodyView: oneBody } = createRemoteFleetTemplateShell(document);
1191
- document.body.appendChild(oneShell);
1192
- manager.renderRemoteFleetMonitorForTest(oneBody, buildMonitorNode([oneDevice], hub.getStatus({ includeSecrets: true })));
1193
- const oneCards = oneBody.querySelectorAll('article[data-device-id]');
1194
- assert.equal(oneCards.length, 1);
1195
- const onePreview = oneCards[0]?.querySelector('[data-remote-fleet-device-preview="tile"]');
1196
- assert.ok(onePreview);
1197
- assert.match(oneCards[0]?.style.cssText || '', /border-radius:\s*0/);
1198
- assert.match(onePreview.style.cssText, /border-radius:\s*0/);
1199
- assert.match(oneCards[0]?.title || '', /Status:\s*Connected/);
1200
- assert.match(oneCards[0]?.title || '', /Seen:/);
1201
- assert.match(oneCards[0]?.title || '', /Uptime:/);
1202
- const oneFillers = oneBody.querySelectorAll('[data-remote-fleet-empty-screen="true"]');
1203
- assert.ok(oneFillers.length > 0, 'single connected monitor wall should keep blank screen placeholders');
1204
- assert.match(oneFillers[0].style.cssText, /border-radius:\s*0/);
1205
-
1206
- const { nodeShell: errorShell, bodyView: errorBody } = createRemoteFleetTemplateShell(document);
1207
- document.body.appendChild(errorShell);
1208
- manager.renderRemoteFleetMonitorForTest(errorBody, buildMonitorNode([], hub.getStatus({ includeSecrets: true }), null, [], 'RemoteHub is unavailable. Start LocalBridge and retry.'));
1209
- const errorFooter = errorBody.querySelector('[data-remote-fleet-status-rail="true"]');
1210
- const footerError = errorFooter?.querySelector('[data-remote-fleet-status-error="true"]');
1211
- assert.ok(errorFooter);
1212
- assert.ok(footerError);
1213
- assert.ok(Array.from(errorBody.children).map(child =>
1214
- Object.keys(child.dataset || {}).join(',') || child.tagName).join('|').endsWith('remoteFleetStatusRail'));
1215
- assert.equal(footerError.textContent.includes('RemoteHub is unavailable'), true);
1216
- assert.equal(Array.from(errorBody.children).some(child =>
1217
- child !== errorFooter && (child.textContent || '').includes('RemoteHub is unavailable')), false);
1218
-
1219
- const deviceBody = document.createElement('div');
1220
- deviceBody.dataset.nodeId = 'remote-device-render-smoke';
1221
- document.body.appendChild(deviceBody);
1222
- const sendCountBeforeControlNode = diagnostics.webSocketSends.length;
1223
- const drawCountBeforeControlNode = document.canvasDrawCalls.length;
1224
- manager.renderRemoteFleetDeviceForTest(deviceBody, buildDeviceNode(focusedDevice, hub.getStatus()));
1225
- assert.ok(deviceBody.textContent.includes(focusedDevice.Name));
1226
- assert.ok(deviceBody.querySelector('[data-remote-fleet-device-toolbar="true"]'));
1227
- assert.ok(deviceBody.querySelector('[data-remote-fleet-device-actions="true"]'));
1228
- assert.ok(deviceBody.querySelector('[data-remote-fleet-device-task-panel="true"]'));
1229
- const deviceStatusBar = deviceBody.querySelector('[data-remote-fleet-device-status-bar="true"]')
1230
- || deviceBody.querySelector('[data-remote-fleet-device-statusbar="true"]');
1231
- assert.ok(deviceStatusBar);
1232
- const deviceControlStage = deviceBody.querySelector('[data-remote-fleet-control-node-stage="true"]');
1233
- const deviceControlCanvas = deviceBody.querySelector('[data-remote-fleet-control-node-canvas="true"]');
1234
- assert.ok(deviceControlStage);
1235
- assert.ok(deviceControlCanvas);
1236
- assert.equal(
1237
- deviceControlStage.parentElement,
1238
- deviceBody,
1239
- 'RemoteFleetDevice should spend its main body area on the control screen');
1240
- assert.equal(deviceBody.querySelectorAll('[data-remote-fleet-status-card], [data-remote-fleet-stat]').length, 0);
1241
- assert.equal(document.activeElement, deviceControlStage);
1242
- await wait(30);
1243
- const deviceControlSubscribe = diagnostics.webSocketSends
1244
- .slice(sendCountBeforeControlNode)
1245
- .map(send => {
1246
- try {
1247
- return JSON.parse(send.payload);
1248
- } catch {
1249
- return null;
1250
- }
1251
- })
1252
- .find(message =>
1253
- message
1254
- && message.type === 'subscribe'
1255
- && message.nodeId === 'remote-device-render-smoke'
1256
- && message.autoStartLive === true
1257
- && message.fps === 2
1258
- && message.mode === 'mode2-lzo'
1259
- && message.streamPurpose === 'wall'
1260
- && Array.isArray(message.deviceIds)
1261
- && message.deviceIds.includes(focusedDevice.DeviceId));
1262
- assert.ok(deviceControlSubscribe, 'Remote workstation should subscribe to a 2fps view-only observation stream');
1263
- const deviceControlWs = diagnostics.webSocketConnections
1264
- .filter(ws => ws.url.includes('/api/remote/frames/ws'))
1265
- .at(-1);
1266
- assert.ok(deviceControlWs, 'RemoteFleetDevice node should open a binary frame WebSocket');
1267
- const controlNodeFrameSeq = 30001;
1268
- deviceControlWs.onmessage?.({
1269
- data: new Blob([encodeRemoteBinaryFrame({
1270
- type: 'remote.frame.binary',
1271
- deviceId: focusedDevice.DeviceId,
1272
- kind: 'live',
1273
- frameSeq: controlNodeFrameSeq,
1274
- streamId: 'render-smoke-control-node-live',
1275
- contentHash: `render-smoke-control-node-live-${controlNodeFrameSeq}`,
1276
- mimeType: 'image/jpeg',
1277
- width: 64,
1278
- height: 36,
1279
- capturedAt: new Date().toISOString(),
1280
- receivedAt: new Date().toISOString()
1281
- })])
1282
- });
1283
- await wait(40);
1284
- assert.ok(
1285
- document.canvasDrawCalls
1286
- .slice(drawCountBeforeControlNode)
1287
- .some(call => call.canvas === deviceControlCanvas && call.op === 'drawImage'),
1288
- 'RemoteFleetDevice node should paint binary WebSocket frames directly to its canvas');
1289
- deviceControlStage.dispatchEvent({
1290
- type: 'pointerdown',
1291
- button: 0,
1292
- pointerId: 11,
1293
- clientX: 160,
1294
- clientY: 90
1295
- });
1296
- deviceControlStage.dispatchEvent({
1297
- type: 'pointerup',
1298
- button: 0,
1299
- pointerId: 11,
1300
- clientX: 160,
1301
- clientY: 90
1302
- });
1303
- deviceControlStage.dispatchEvent({
1304
- type: 'keydown',
1305
- key: 'A',
1306
- code: 'KeyA',
1307
- repeat: false
1308
- });
1309
- deviceControlStage.dispatchEvent({
1310
- type: 'keyup',
1311
- key: 'A',
1312
- code: 'KeyA',
1313
- repeat: false
1314
- });
1315
- await wait(50);
1316
- const inputWsSends = diagnostics.webSocketSends
1317
- .filter(send => send.url.includes('/api/remote/input/ws'));
1318
- assert.equal(inputWsSends.length, 0, 'Remote workstation must remain view-only and send no pointer or keyboard input');
1319
- assert.equal(
1320
- dotNetCalls.filter(call => call.methodName === 'SendRemoteFleetInputFromJs').length,
1321
- 0,
1322
- 'View-only workstation must not use the DotNet input fallback');
1323
- assert.ok(deviceBody.querySelector('[data-remote-fleet-action="refresh-device"]'));
1324
- assert.ok(deviceBody.querySelector('[data-remote-fleet-action="task-device"]'));
1325
- assert.ok(deviceBody.textContent.includes('Task timed out waiting for the agent response.'));
1326
- assert.ok(deviceStatusBar.title.includes(focusedDevice.DeviceId));
1327
- const controlCanvasBeforeRerender = deviceControlCanvas;
1328
- manager.renderRemoteFleetDeviceForTest(deviceBody, buildDeviceNode(focusedDevice, hub.getStatus()));
1329
- await wait(30);
1330
- const controlCanvasAfterRerender = deviceBody.querySelector('[data-remote-fleet-control-node-canvas="true"]');
1331
- assert.equal(
1332
- controlCanvasAfterRerender,
1333
- controlCanvasBeforeRerender,
1334
- 'RemoteFleetDevice rerender should reuse the already-painted control canvas instead of flashing black');
1335
- assert.equal(
1336
- deviceBody.querySelector('[data-remote-fleet-control-node-placeholder="true"]'),
1337
- null,
1338
- 'RemoteFleetDevice rerender should not cover a restored control canvas with a waiting placeholder');
1339
-
1340
- nodeShell.remove();
1341
- emptyShell.remove();
1342
- oneShell.remove();
1343
- errorShell.remove();
1344
- deviceBody.remove();
1345
- await wait(2200);
1346
-
1347
- console.log(`RemoteFleet render smoke OK (${SYNTHETIC_COUNT} synthetic devices, ${connectedCount} connected, ${aiCount} AI-ready)`);
1348
- } finally {
1349
- await hub.close();
1350
- }
1
+ #!/usr/bin/env node
2
+
3
+ import assert from 'node:assert/strict';
4
+ import fs from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import vm from 'node:vm';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { createRemoteHub } from '../remote-hub.js';
9
+
10
+ const SYNTHETIC_COUNT = Number(process.env.REMOTE_FLEET_RENDER_SMOKE_COUNT || 500);
11
+
12
+ function dataAttributeToDatasetKey(name) {
13
+ return String(name || '').replace(/^data-/, '').replace(/-([a-z])/g, (_, char) => char.toUpperCase());
14
+ }
15
+
16
+ class MiniStyle {
17
+ constructor() {
18
+ this._cssText = '';
19
+ }
20
+
21
+ get cssText() {
22
+ return this._cssText;
23
+ }
24
+
25
+ set cssText(value) {
26
+ this._cssText = String(value || '');
27
+ const displayMatch = /(?:^|;)\s*display\s*:\s*([^;]+)/i.exec(this._cssText);
28
+ if (displayMatch) {
29
+ this.display = displayMatch[1].trim();
30
+ }
31
+ }
32
+
33
+ setProperty(name, value) {
34
+ this[String(name)] = String(value);
35
+ }
36
+ }
37
+
38
+ class MiniClassList {
39
+ constructor(owner) {
40
+ this.owner = owner;
41
+ this.tokens = new Set();
42
+ }
43
+
44
+ add(...tokens) {
45
+ tokens.forEach(token => {
46
+ const value = String(token || '').trim();
47
+ if (value) {
48
+ this.tokens.add(value);
49
+ }
50
+ });
51
+ this.sync();
52
+ }
53
+
54
+ remove(...tokens) {
55
+ tokens.forEach(token => this.tokens.delete(String(token || '').trim()));
56
+ this.sync();
57
+ }
58
+
59
+ contains(token) {
60
+ return this.tokens.has(String(token || '').trim());
61
+ }
62
+
63
+ toggle(token, force) {
64
+ const value = String(token || '').trim();
65
+ if (!value) return false;
66
+ const shouldAdd = force === undefined ? !this.tokens.has(value) : !!force;
67
+ if (shouldAdd) {
68
+ this.tokens.add(value);
69
+ } else {
70
+ this.tokens.delete(value);
71
+ }
72
+ this.sync();
73
+ return shouldAdd;
74
+ }
75
+
76
+ sync() {
77
+ this.owner.className = [...this.tokens].join(' ');
78
+ }
79
+ }
80
+
81
+ class MiniElement {
82
+ constructor(tagName, ownerDocument) {
83
+ this.tagName = String(tagName || '').toUpperCase();
84
+ this.nodeName = this.tagName;
85
+ this.ownerDocument = ownerDocument;
86
+ this.parentElement = null;
87
+ this.children = [];
88
+ this.attributes = {};
89
+ this.dataset = {};
90
+ this.style = new MiniStyle();
91
+ this.classList = new MiniClassList(this);
92
+ this.className = '';
93
+ this._textContent = '';
94
+ this._listeners = new Map();
95
+ this.value = '';
96
+ this.checked = false;
97
+ this.disabled = false;
98
+ this.clientWidth = 320;
99
+ this.clientHeight = 180;
100
+ this.width = 0;
101
+ this.height = 0;
102
+ }
103
+
104
+ get textContent() {
105
+ return `${this._textContent}${this.children.map(child => child.textContent).join('')}`;
106
+ }
107
+
108
+ set textContent(value) {
109
+ this.children.forEach(child => {
110
+ child.parentElement = null;
111
+ });
112
+ this.children = [];
113
+ this._textContent = String(value ?? '');
114
+ }
115
+
116
+ get innerHTML() {
117
+ return '';
118
+ }
119
+
120
+ set innerHTML(_value) {
121
+ this.children.forEach(child => {
122
+ child.parentElement = null;
123
+ });
124
+ this.children = [];
125
+ this._textContent = '';
126
+ }
127
+
128
+ appendChild(child) {
129
+ if (!child) return child;
130
+ if (child.parentElement) {
131
+ child.parentElement.children = child.parentElement.children.filter(item => item !== child);
132
+ }
133
+ child.parentElement = this;
134
+ this.children.push(child);
135
+ return child;
136
+ }
137
+
138
+ remove() {
139
+ if (!this.parentElement) return;
140
+ this.parentElement.children = this.parentElement.children.filter(child => child !== this);
141
+ this.parentElement = null;
142
+ }
143
+
144
+ setAttribute(name, value) {
145
+ const key = String(name || '');
146
+ const text = String(value ?? '');
147
+ this.attributes[key] = text;
148
+ if (key === 'id') {
149
+ this.id = text;
150
+ } else if (key === 'class') {
151
+ this.className = text;
152
+ this.classList.tokens = new Set(text.split(/\s+/).filter(Boolean));
153
+ } else if (key.startsWith('data-')) {
154
+ this.dataset[dataAttributeToDatasetKey(key)] = text;
155
+ } else if (key === 'aria-label') {
156
+ this.ariaLabel = text;
157
+ }
158
+ }
159
+
160
+ getAttribute(name) {
161
+ const key = String(name || '');
162
+ if (key.startsWith('data-')) {
163
+ return this.dataset[dataAttributeToDatasetKey(key)];
164
+ }
165
+ return this.attributes[key];
166
+ }
167
+
168
+ addEventListener(type, listener) {
169
+ const key = String(type || '');
170
+ if (!this._listeners.has(key)) {
171
+ this._listeners.set(key, []);
172
+ }
173
+ this._listeners.get(key).push(listener);
174
+ }
175
+
176
+ dispatchEvent(event) {
177
+ const payload = typeof event === 'string' ? { type: event } : { ...(event || {}) };
178
+ let immediateStopped = false;
179
+ const originalStopImmediatePropagation = typeof payload.stopImmediatePropagation === 'function'
180
+ ? payload.stopImmediatePropagation
181
+ : null;
182
+ payload.type = payload.type || 'event';
183
+ payload.target = payload.target || this;
184
+ payload.currentTarget = this;
185
+ payload.preventDefault = payload.preventDefault || (() => {});
186
+ payload.stopPropagation = payload.stopPropagation || (() => {});
187
+ payload.stopImmediatePropagation = () => {
188
+ immediateStopped = true;
189
+ originalStopImmediatePropagation?.();
190
+ };
191
+ for (const listener of this._listeners.get(payload.type) || []) {
192
+ listener(payload);
193
+ if (immediateStopped) {
194
+ break;
195
+ }
196
+ }
197
+ return true;
198
+ }
199
+
200
+ focus() {
201
+ this.ownerDocument.activeElement = this;
202
+ }
203
+
204
+ blur() {
205
+ if (this.ownerDocument.activeElement === this) {
206
+ this.ownerDocument.activeElement = null;
207
+ }
208
+ }
209
+
210
+ getBoundingClientRect() {
211
+ return {
212
+ left: 0,
213
+ top: 0,
214
+ right: this.clientWidth,
215
+ bottom: this.clientHeight,
216
+ width: this.clientWidth,
217
+ height: this.clientHeight
218
+ };
219
+ }
220
+
221
+ getContext(type) {
222
+ if (this.tagName !== 'CANVAS' || String(type || '').toLowerCase() !== '2d') {
223
+ return null;
224
+ }
225
+
226
+ if (this._canvasContext) {
227
+ return this._canvasContext;
228
+ }
229
+
230
+ const owner = this.ownerDocument;
231
+ this._canvasContext = {
232
+ imageSmoothingEnabled: false,
233
+ imageSmoothingQuality: 'low',
234
+ fillStyle: '#000',
235
+ clearRect: (...args) => {
236
+ owner.canvasDrawCalls.push({ canvas: this, op: 'clearRect', args });
237
+ },
238
+ fillRect: (...args) => {
239
+ owner.canvasDrawCalls.push({ canvas: this, op: 'fillRect', args });
240
+ },
241
+ drawImage: (...args) => {
242
+ owner.canvasDrawCalls.push({ canvas: this, op: 'drawImage', args });
243
+ }
244
+ };
245
+ return this._canvasContext;
246
+ }
247
+
248
+ querySelector(selector) {
249
+ return this.querySelectorAll(selector)[0] || null;
250
+ }
251
+
252
+ querySelectorAll(selector) {
253
+ const matches = [];
254
+ const visit = element => {
255
+ for (const child of element.children) {
256
+ if (matchesSelector(child, selector)) {
257
+ matches.push(child);
258
+ }
259
+ visit(child);
260
+ }
261
+ };
262
+ visit(this);
263
+ return matches;
264
+ }
265
+
266
+ closest(selector) {
267
+ let current = this;
268
+ while (current) {
269
+ if (matchesSelector(current, selector)) {
270
+ return current;
271
+ }
272
+ current = current.parentElement;
273
+ }
274
+ return null;
275
+ }
276
+
277
+ contains(node) {
278
+ let current = node;
279
+ while (current) {
280
+ if (current === this) return true;
281
+ current = current.parentElement;
282
+ }
283
+ return false;
284
+ }
285
+ }
286
+
287
+ class MiniDocument {
288
+ constructor() {
289
+ this.body = new MiniElement('body', this);
290
+ this.head = new MiniElement('head', this);
291
+ this.canvasDrawCalls = [];
292
+ this.activeElement = null;
293
+ }
294
+
295
+ createElement(tagName) {
296
+ return new MiniElement(tagName, this);
297
+ }
298
+
299
+ getElementById(id) {
300
+ const target = String(id || '');
301
+ return [this.head, this.body]
302
+ .flatMap(root => root.querySelectorAll('*'))
303
+ .find(element => element.id === target) || null;
304
+ }
305
+
306
+ querySelector(selector) {
307
+ return this.body.querySelector(selector) || this.head.querySelector(selector);
308
+ }
309
+
310
+ querySelectorAll(selector) {
311
+ return [
312
+ ...this.head.querySelectorAll(selector),
313
+ ...this.body.querySelectorAll(selector)
314
+ ];
315
+ }
316
+ }
317
+
318
+ function matchesSelector(element, selector) {
319
+ const text = String(selector || '').trim();
320
+ if (!text || !element) return false;
321
+ if (text === '*') return true;
322
+
323
+ const tagMatch = /^[a-zA-Z][\w-]*/.exec(text);
324
+ if (tagMatch && element.tagName.toLowerCase() !== tagMatch[0].toLowerCase()) {
325
+ return false;
326
+ }
327
+
328
+ for (const classMatch of text.matchAll(/\.([\w-]+)/g)) {
329
+ if (!element.classList.contains(classMatch[1])) {
330
+ return false;
331
+ }
332
+ }
333
+
334
+ for (const attrMatch of text.matchAll(/\[([^\]=]+)(?:="([^"]*)")?\]/g)) {
335
+ const attrName = attrMatch[1];
336
+ const expected = attrMatch[2];
337
+ const actual = attrName.startsWith('data-')
338
+ ? element.dataset[dataAttributeToDatasetKey(attrName)]
339
+ : element.getAttribute(attrName);
340
+ if (actual === undefined || actual === null) {
341
+ return false;
342
+ }
343
+ if (expected !== undefined && String(actual) !== expected) {
344
+ return false;
345
+ }
346
+ }
347
+
348
+ return true;
349
+ }
350
+
351
+ function readStatusNumber(status, key) {
352
+ const value = status?.[key];
353
+ return Number.isFinite(Number(value)) ? Number(value) : null;
354
+ }
355
+
356
+ function readLoad1(status) {
357
+ const value = status?.loadavg;
358
+ return Array.isArray(value) && Number.isFinite(Number(value[0])) ? Number(value[0]) : null;
359
+ }
360
+
361
+ function projectDevice(device) {
362
+ const status = device.status || {};
363
+ const capabilities = device.capabilities || {};
364
+ const thumbnail = device.latestThumbnail || {};
365
+ const liveFrame = device.latestLiveFrame || {};
366
+ const liveStream = device.activeLiveStream || {};
367
+ const latestTask = device.latestTask || {};
368
+ const platform = String(status.platform || device.platform || 'unknown');
369
+
370
+ return {
371
+ DeviceId: String(device.deviceId || ''),
372
+ SessionId: String(device.sessionId || ''),
373
+ Name: String(device.deviceName || device.hostname || device.deviceId || 'device'),
374
+ Hostname: String(device.hostname || ''),
375
+ Platform: platform,
376
+ Release: String(status.release || ''),
377
+ Arch: String(device.arch || ''),
378
+ AgentVersion: String(device.agentVersion || ''),
379
+ Connected: device.connected === true,
380
+ ConnectedAt: String(device.connectedAt || ''),
381
+ DisconnectedAt: String(device.disconnectedAt || ''),
382
+ LastSeenAt: String(device.lastSeenAt || ''),
383
+ LastStatusAt: String(device.lastStatusAt || ''),
384
+ LastDisconnectReason: String(device.lastDisconnectReason || ''),
385
+ RemoteAddress: String(device.remoteAddress || ''),
386
+ RemotePort: Number(device.remotePort || 0),
387
+ UptimeSec: readStatusNumber(status, 'uptimeSec'),
388
+ UsedMemRatio: readStatusNumber(status, 'usedMemRatio'),
389
+ Load1: readLoad1(status),
390
+ StatusEnabled: capabilities.status === true,
391
+ ThumbnailEnabled: capabilities.thumbnail === true,
392
+ LiveStreamEnabled: capabilities.liveStream === true,
393
+ ControlEnabled: capabilities.control === true,
394
+ ComputerAgentEnabled: capabilities.computerAgent === true || capabilities.taskDispatch === true,
395
+ AiAssistEnabled: capabilities.aiAssist === true,
396
+ AiModel: String(capabilities.aiModel || ''),
397
+ AiProvider: String(capabilities.aiProvider || ''),
398
+ ThumbnailStreamId: String(thumbnail.streamId || ''),
399
+ ThumbnailFrameSeq: Number(thumbnail.frameSeq || 0),
400
+ ThumbnailWidth: Number(thumbnail.width || 0),
401
+ ThumbnailHeight: Number(thumbnail.height || 0),
402
+ ThumbnailMimeType: String(thumbnail.mimeType || thumbnail.format || ''),
403
+ ThumbnailCapturedAt: String(thumbnail.capturedAt || ''),
404
+ ThumbnailReceivedAt: String(thumbnail.receivedAt || ''),
405
+ ThumbnailDataUrl: String(thumbnail.dataUrl || ''),
406
+ LiveStreamActive: liveStream.active === true,
407
+ LiveStreamId: String(liveStream.streamId || ''),
408
+ LiveStreamMode: String(liveStream.mode || ''),
409
+ LiveStreamFps: Number(liveStream.fps || 0),
410
+ LiveStreamStartedAt: String(liveStream.startedAt || ''),
411
+ LiveStreamStoppedAt: String(liveStream.stoppedAt || ''),
412
+ LiveStreamLastFrameAt: String(liveStream.lastFrameAt || ''),
413
+ LiveStreamFrameSeq: Number(liveStream.lastFrameSeq || 0),
414
+ LiveFrameStreamId: String(liveFrame.streamId || ''),
415
+ LiveFrameSeq: Number(liveFrame.frameSeq || 0),
416
+ LiveFrameWidth: Number(liveFrame.width || 0),
417
+ LiveFrameHeight: Number(liveFrame.height || 0),
418
+ LiveFrameMimeType: String(liveFrame.mimeType || liveFrame.format || ''),
419
+ LiveFrameCapturedAt: String(liveFrame.capturedAt || ''),
420
+ LiveFrameReceivedAt: String(liveFrame.receivedAt || ''),
421
+ LiveFrameDataUrl: String(liveFrame.dataUrl || ''),
422
+ LatestTaskId: String(latestTask.taskId || ''),
423
+ LatestTaskCommandId: String(latestTask.commandId || ''),
424
+ LatestTaskTitle: String(latestTask.title || ''),
425
+ LatestTaskInstructionPreview: String(latestTask.instructionPreview || ''),
426
+ LatestTaskStatus: String(latestTask.status || ''),
427
+ LatestTaskApprovalLevel: String(latestTask.approvalLevel || ''),
428
+ LatestTaskUpdatedAt: String(latestTask.updatedAt || latestTask.completedAt || latestTask.sentAt || ''),
429
+ LatestTaskError: String(latestTask.error || ''),
430
+ LatestTaskResultModel: String(latestTask.resultModel || ''),
431
+ LatestTaskResultResponseId: String(latestTask.resultResponseId || ''),
432
+ LatestTaskResultSummary: String(latestTask.resultSummary || '')
433
+ };
434
+ }
435
+
436
+ async function loadCss3DManager() {
437
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
438
+ const hotPathModulePath = path.resolve(__dirname, '../../MindExecution.Shared/wwwroot/js/mind-map-css3d-hotpath.js');
439
+ const managerPath = path.resolve(__dirname, '../../MindExecution.Shared/wwwroot/js/mind-map-css3d-manager.js');
440
+ const hotPathSource = await fs.readFile(hotPathModulePath, 'utf8');
441
+ const source = await fs.readFile(managerPath, 'utf8');
442
+ const document = new MiniDocument();
443
+ const objectUrlCalls = [];
444
+ const revokedObjectUrls = [];
445
+ const imageBitmapCalls = [];
446
+ const fetchCalls = [];
447
+ const runtimeTrace = [];
448
+ const webSocketConnections = [];
449
+ const webSocketSends = [];
450
+ const textOverlayInvalidations = [];
451
+ class SmokeURL extends URL {}
452
+ SmokeURL.createObjectURL = blob => {
453
+ objectUrlCalls.push(blob);
454
+ return `blob:remote-fleet-smoke-${objectUrlCalls.length}`;
455
+ };
456
+ SmokeURL.revokeObjectURL = value => {
457
+ revokedObjectUrls.push(String(value || ''));
458
+ };
459
+ class MiniWebSocket {
460
+ static CONNECTING = 0;
461
+ static OPEN = 1;
462
+ static CLOSING = 2;
463
+ static CLOSED = 3;
464
+
465
+ constructor(url) {
466
+ this.url = String(url || '');
467
+ this.readyState = MiniWebSocket.CONNECTING;
468
+ this.binaryType = '';
469
+ this.sent = [];
470
+ this.closeCount = 0;
471
+ webSocketConnections.push(this);
472
+ setTimeout(() => {
473
+ if (this.readyState !== MiniWebSocket.CONNECTING) return;
474
+ this.readyState = MiniWebSocket.OPEN;
475
+ this.onopen?.({ type: 'open' });
476
+ }, 0);
477
+ }
478
+
479
+ send(payload) {
480
+ const text = typeof payload === 'string' ? payload : String(payload || '');
481
+ this.sent.push(text);
482
+ webSocketSends.push({ url: this.url, payload: text });
483
+ }
484
+
485
+ close() {
486
+ if (this.readyState === MiniWebSocket.CLOSED) return;
487
+ this.closeCount += 1;
488
+ this.readyState = MiniWebSocket.CLOSED;
489
+ this.onclose?.({ type: 'close' });
490
+ }
491
+ }
492
+ const context = {
493
+ console,
494
+ document,
495
+ location: {
496
+ origin: 'http://localhost:5147'
497
+ },
498
+ navigator: {
499
+ clipboard: {
500
+ writeText: async () => {}
501
+ }
502
+ },
503
+ setInterval: () => 0,
504
+ clearInterval: () => {},
505
+ setTimeout,
506
+ clearTimeout,
507
+ Date,
508
+ Math,
509
+ Number,
510
+ String,
511
+ Boolean,
512
+ Array,
513
+ Object,
514
+ JSON,
515
+ RegExp,
516
+ Map,
517
+ Set,
518
+ WeakMap,
519
+ Blob,
520
+ TextDecoder,
521
+ TextEncoder,
522
+ requestAnimationFrame: callback => setTimeout(() => callback(Date.now()), 0),
523
+ cancelAnimationFrame: id => clearTimeout(id),
524
+ createImageBitmap: async blob => {
525
+ imageBitmapCalls.push(blob);
526
+ return {
527
+ width: 64,
528
+ height: 36,
529
+ close() {
530
+ this.closed = true;
531
+ }
532
+ };
533
+ },
534
+ THREE: createThreeStub(),
535
+ URL: SmokeURL,
536
+ WebSocket: MiniWebSocket,
537
+ fetch: async (url, options = {}) => {
538
+ fetchCalls.push({ url: String(url || ''), options });
539
+ return {
540
+ ok: true,
541
+ status: 200,
542
+ json: async () => ({
543
+ bridgeToken: 'render-smoke-bridge-token',
544
+ remoteFrameWsPath: '/api/remote/frames/ws',
545
+ remoteInputWsPath: '/api/remote/input/ws'
546
+ })
547
+ };
548
+ },
549
+ RuntimeTrace: {
550
+ emit(type, data = {}) {
551
+ runtimeTrace.push({ type, ...data });
552
+ }
553
+ },
554
+ MindMapTextOverlayV2: {
555
+ invalidateReadonlySource(module, nodeId, reason) {
556
+ textOverlayInvalidations.push({ module, nodeId, reason });
557
+ return true;
558
+ },
559
+ invalidateNode(module, nodeId, reason) {
560
+ textOverlayInvalidations.push({ module, nodeId, reason, fallback: true });
561
+ }
562
+ },
563
+ MindExecRemoteCodecs: {
564
+ async decodeH264Frame(canvas, frame, onFrame) {
565
+ onFrame?.(canvas, frame);
566
+ return true;
567
+ }
568
+ },
569
+ Promise
570
+ };
571
+ context.window = context;
572
+ context.self = context;
573
+
574
+ vm.runInNewContext(hotPathSource, context, { filename: hotPathModulePath });
575
+ vm.runInNewContext(source, context, { filename: managerPath });
576
+ return {
577
+ manager: context.window.MindMapCss3DManager,
578
+ document,
579
+ diagnostics: {
580
+ objectUrlCalls,
581
+ revokedObjectUrls,
582
+ imageBitmapCalls,
583
+ fetchCalls,
584
+ runtimeTrace,
585
+ webSocketConnections,
586
+ webSocketSends,
587
+ textOverlayInvalidations
588
+ }
589
+ };
590
+ }
591
+
592
+ function wait(ms = 0) {
593
+ return new Promise(resolve => setTimeout(resolve, ms));
594
+ }
595
+
596
+ async function waitFor(predicate, timeoutMs = 500, intervalMs = 10) {
597
+ const deadline = Date.now() + Math.max(1, Number(timeoutMs || 500));
598
+ while (Date.now() < deadline) {
599
+ if (predicate()) return true;
600
+ await wait(intervalMs);
601
+ }
602
+ return predicate();
603
+ }
604
+
605
+ function encodeRemoteBinaryFrame(metadata, payload = new Uint8Array([0xff, 0xd8, 0xff, 0xd9])) {
606
+ const metaBytes = new TextEncoder().encode(JSON.stringify(metadata));
607
+ const payloadBytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
608
+ const buffer = new ArrayBuffer(4 + metaBytes.byteLength + payloadBytes.byteLength);
609
+ const view = new DataView(buffer);
610
+ view.setUint32(0, metaBytes.byteLength);
611
+ const bytes = new Uint8Array(buffer);
612
+ bytes.set(metaBytes, 4);
613
+ bytes.set(payloadBytes, 4 + metaBytes.byteLength);
614
+ return buffer;
615
+ }
616
+
617
+ function buildMonitorNode(devices, hubStatus, latestTaskBatch = null, recentTaskBatches = [], lastError = '', nodeId = 'remote-fleet-render-smoke') {
618
+ const connected = devices.filter(device => device.Connected).length;
619
+ const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5198';
620
+ const pairToken = hubStatus.pairToken || 'render-smoke-token';
621
+ const hostTargetState = hubStatus.hostTargetActive
622
+ ? (hubStatus.hostTargetNodeId === nodeId ? 'hosting' : 'other-monitor')
623
+ : 'inactive';
624
+ return {
625
+ id: nodeId,
626
+ contentType: 'templateLauncher',
627
+ metadata: {
628
+ SemanticType: 'RemoteFleetMonitor',
629
+ RemoteFleetSchemaVersion: 'remote-fleet@1',
630
+ RemoteFleetViewMode: 'all-devices',
631
+ RemoteFleetLastRefreshAtUtc: new Date().toISOString(),
632
+ RemoteFleetHubStatus: 'online',
633
+ RemoteFleetHubEndpoint: endpoint,
634
+ RemoteFleetManagerPackage: hubStatus.managerPackage || '@mindexec/cli',
635
+ RemoteFleetManagerVersion: hubStatus.managerVersion || 'render-smoke-manager',
636
+ RemoteFleetAgentPackage: '@mindexec/remote',
637
+ RemoteFleetPairTokenPreview: '<pair-token>',
638
+ RemoteFleetConnectCommand: `npx @mindexec/remote connect --manager ${endpoint} --pair ${pairToken}`,
639
+ RemoteFleetDeviceCount: String(devices.length),
640
+ RemoteFleetConnectedDeviceCount: String(connected),
641
+ RemoteFleetCanvasPagination: 'none',
642
+ RemoteFleetHostTargetState: hostTargetState,
643
+ RemoteFleetHostTargetNodeId: hubStatus.hostTargetNodeId || '',
644
+ RemoteFleetHostTargetLeaseId: hubStatus.hostTargetLeaseId || '',
645
+ RemoteFleetHostTargetEndpoint: hubStatus.hostTargetEndpoint || endpoint,
646
+ RemoteFleetHostTargetActivatedAtUtc: hubStatus.hostTargetActivatedAt || '',
647
+ RemoteFleetHostTargetUpdatedAtUtc: hubStatus.hostTargetUpdatedAt || '',
648
+ RemoteFleetHostTargetExpiresAtUtc: hubStatus.hostTargetExpiresAt || '',
649
+ RemoteFleetDevicesJson: JSON.stringify(devices),
650
+ RemoteFleetLatestTaskBatchJson: latestTaskBatch ? JSON.stringify(latestTaskBatch) : '',
651
+ RemoteFleetRecentTaskBatchesJson: JSON.stringify(recentTaskBatches),
652
+ RemoteFleetLastError: String(lastError || '')
653
+ }
654
+ };
655
+ }
656
+
657
+ function createRemoteFleetTemplateShell(document, focusDeviceId = '', nodeId = 'remote-fleet-render-smoke') {
658
+ const nodeShell = document.createElement('div');
659
+ nodeShell.setAttribute('class', 'map-node-template-card map-node-remote-fleet');
660
+ nodeShell.dataset.nodeId = nodeId;
661
+ const shell = document.createElement('div');
662
+ shell.setAttribute('class', 'template-card__shell template-card__shell--remote-fleet');
663
+ const header = document.createElement('div');
664
+ header.setAttribute('class', 'template-card__header template-card__header--remote-fleet');
665
+ const icon = document.createElement('div');
666
+ icon.setAttribute('class', 'template-card__icon template-card__icon--remote-fleet');
667
+ const titleWrap = document.createElement('div');
668
+ titleWrap.setAttribute('class', 'template-card__title-block');
669
+ titleWrap.textContent = 'Multi Desktop Monitor';
670
+ header.appendChild(icon);
671
+ header.appendChild(titleWrap);
672
+ const bodyView = document.createElement('div');
673
+ bodyView.setAttribute('class', 'template-card__remote-fleet-body map-node-remote-fleet__body');
674
+ bodyView.dataset.nodeId = nodeId;
675
+ bodyView.dataset.remoteFleetAutoMonitor = 'false';
676
+ if (focusDeviceId) {
677
+ bodyView.dataset.remoteFleetFocusDeviceId = focusDeviceId;
678
+ }
679
+ shell.appendChild(header);
680
+ shell.appendChild(bodyView);
681
+ nodeShell.appendChild(shell);
682
+ return { nodeShell, bodyView };
683
+ }
684
+
685
+ function buildDeviceNode(device, hubStatus) {
686
+ const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5198';
687
+ return {
688
+ id: 'remote-device-render-smoke',
689
+ contentType: 'memo',
690
+ metadata: {
691
+ SemanticType: 'RemoteFleetDevice',
692
+ RemoteFleetSchemaVersion: 'remote-device@1',
693
+ RemoteFleetViewMode: 'pinned-device',
694
+ RemoteFleetLastRefreshAtUtc: new Date().toISOString(),
695
+ RemoteFleetHubStatus: 'online',
696
+ RemoteFleetHubEndpoint: endpoint,
697
+ RemoteFleetManagerPackage: hubStatus.managerPackage || '@mindexec/cli',
698
+ RemoteFleetManagerVersion: hubStatus.managerVersion || 'render-smoke-manager',
699
+ RemoteFleetAgentPackage: '@mindexec/remote',
700
+ RemoteFleetPinnedDeviceId: device.DeviceId,
701
+ RemoteFleetPinnedDeviceJson: JSON.stringify(device),
702
+ RemoteFleetLastError: ''
703
+ }
704
+ };
705
+ }
706
+
707
+ function createThreeStub() {
708
+ class Vector3 {
709
+ constructor(x = 0, y = 0, z = 0) {
710
+ this.x = x;
711
+ this.y = y;
712
+ this.z = z;
713
+ }
714
+
715
+ set(x = 0, y = 0, z = 0) {
716
+ this.x = x;
717
+ this.y = y;
718
+ this.z = z;
719
+ return this;
720
+ }
721
+ }
722
+
723
+ class Matrix4 {
724
+ multiplyMatrices() { return this; }
725
+ }
726
+
727
+ class Frustum {
728
+ setFromProjectionMatrix() { return this; }
729
+ intersectsBox() { return true; }
730
+ }
731
+
732
+ class Quaternion {}
733
+
734
+ class Box3 {
735
+ setFromCenterAndSize() { return this; }
736
+ }
737
+
738
+ return { Box3, Frustum, Matrix4, Quaternion, Vector3 };
739
+ }
740
+
741
+ const hub = createRemoteHub({
742
+ managerPackage: '@mindexec/cli',
743
+ managerVersion: 'render-smoke-manager',
744
+ env: {
745
+ MINDEXEC_REMOTE_HUB: '1',
746
+ REMOTE_HUB_HOST: '127.0.0.1',
747
+ REMOTE_HUB_PORT: '0',
748
+ REMOTE_HUB_PAIR_TOKEN: 'render-smoke-token'
749
+ }
750
+ });
751
+
752
+ try {
753
+ await hub.start();
754
+ const seeded = hub.seedSyntheticFleet({
755
+ count: SYNTHETIC_COUNT,
756
+ connectedRatio: 0.84,
757
+ thumbnailRatio: 0.72,
758
+ aiAssistRatio: 0.42,
759
+ liveCount: 0
760
+ });
761
+ assert.equal(seeded.ok, true);
762
+ assert.equal(seeded.seeded, SYNTHETIC_COUNT);
763
+
764
+ const seededAiTarget = hub.listDevices().find(device =>
765
+ device.connected && device.capabilities?.taskDispatch && device.capabilities?.aiAssist);
766
+ assert.ok(seededAiTarget);
767
+ const renderAiTask = hub.requestAgentTask(seededAiTarget.deviceId, {
768
+ instruction: 'Synthetic render smoke AI task: report model metadata to the canvas.',
769
+ title: 'Render smoke AI task',
770
+ approvalLevel: 'ai-assist',
771
+ model: 'synthetic-render-ai'
772
+ });
773
+ assert.equal(renderAiTask.ok, true);
774
+
775
+ const seededLiveTarget = hub.listDevices().find(device =>
776
+ device.connected && device.capabilities?.liveStream);
777
+ assert.ok(seededLiveTarget);
778
+ const renderLive = hub.startLiveStream(seededLiveTarget.deviceId, {
779
+ streamId: 'render-smoke-live',
780
+ fps: 20,
781
+ maxWidth: 960,
782
+ maxHeight: 540,
783
+ quality: 60
784
+ });
785
+ assert.equal(renderLive.ok, true);
786
+
787
+ const rawDevices = hub.listDevices();
788
+ const devices = rawDevices.map(projectDevice);
789
+ const connectedCount = devices.filter(device => device.Connected).length;
790
+ const aiCount = devices.filter(device => device.Connected && device.AiAssistEnabled).length;
791
+ const focusedDevice = devices.find(device => device.Connected && device.LiveStreamActive)
792
+ || devices.find(device => device.Connected);
793
+ assert.ok(focusedDevice);
794
+ focusedDevice.LatestTaskId = 'render-smoke-timeout-task';
795
+ focusedDevice.LatestTaskCommandId = 'render-smoke-timeout-command';
796
+ focusedDevice.LatestTaskTitle = 'Timed out smoke task';
797
+ focusedDevice.LatestTaskInstructionPreview = 'This synthetic task timed out before the agent replied.';
798
+ focusedDevice.LatestTaskStatus = 'failed';
799
+ focusedDevice.LatestTaskApprovalLevel = 'task-only';
800
+ focusedDevice.LatestTaskUpdatedAt = new Date().toISOString();
801
+ focusedDevice.LatestTaskError = 'task-timeout';
802
+ focusedDevice.LatestTaskResultSummary = '';
803
+ const aiResultDevice = devices.find(device =>
804
+ device.DeviceId !== focusedDevice.DeviceId
805
+ && device.Connected);
806
+ assert.ok(aiResultDevice);
807
+ aiResultDevice.LatestTaskId = 'render-smoke-overview-ai-task';
808
+ aiResultDevice.LatestTaskCommandId = 'render-smoke-overview-ai-command';
809
+ aiResultDevice.LatestTaskTitle = 'Overview AI result';
810
+ aiResultDevice.LatestTaskStatus = 'completed';
811
+ aiResultDevice.LatestTaskApprovalLevel = 'ai-assist';
812
+ aiResultDevice.LatestTaskUpdatedAt = new Date(Date.now() - 1000).toISOString();
813
+ aiResultDevice.LatestTaskError = '';
814
+ aiResultDevice.LatestTaskResultModel = 'synthetic-render-ai';
815
+ aiResultDevice.LatestTaskResultResponseId = 'synthetic-response-overview';
816
+ aiResultDevice.LatestTaskResultSummary = 'Overview AI result visible in the fleet monitor.';
817
+ const latestTaskBatch = {
818
+ batchId: 'render-smoke-batch',
819
+ title: 'Render smoke batch',
820
+ instructionPreview: 'Render smoke batch instruction preview.',
821
+ approvalLevel: 'ai-assist',
822
+ status: 'running',
823
+ requestedAt: new Date(Date.now() - 2500).toISOString(),
824
+ updatedAt: new Date().toISOString(),
825
+ total: 210,
826
+ queued: 210,
827
+ pending: 1,
828
+ completed: 208,
829
+ failed: 1,
830
+ timedOut: 1,
831
+ results: []
832
+ };
833
+ const recentTaskBatches = [
834
+ latestTaskBatch,
835
+ {
836
+ batchId: 'render-smoke-previous-ai-batch',
837
+ title: 'Previous AI batch',
838
+ instructionPreview: 'Previous AI batch instruction preview.',
839
+ approvalLevel: 'ai-assist',
840
+ status: 'completed',
841
+ requestedAt: new Date(Date.now() - 180000).toISOString(),
842
+ updatedAt: new Date(Date.now() - 150000).toISOString(),
843
+ total: 42,
844
+ queued: 42,
845
+ pending: 0,
846
+ completed: 42,
847
+ failed: 0,
848
+ timedOut: 0,
849
+ results: []
850
+ }
851
+ ];
852
+
853
+ const { manager, document, diagnostics } = await loadCss3DManager();
854
+ assert.equal(typeof manager?.renderRemoteFleetMonitorForTest, 'function');
855
+ assert.equal(typeof manager?.renderRemoteFleetDeviceForTest, 'function');
856
+ assert.equal(typeof manager?.applyRemoteFleetFramePatchesForTest, 'function');
857
+ assert.equal(typeof manager?.setModuleForTest, 'function');
858
+
859
+ const dotNetCalls = [];
860
+ const dotNetHelper = {
861
+ invokeMethodAsync: async (methodName, ...args) => {
862
+ dotNetCalls.push({ methodName, args });
863
+ if (methodName === 'DispatchRemoteFleetTaskBatchFromJs') {
864
+ const targetIds = Array.isArray(args[1]) ? args[1] : [];
865
+ const failedDeviceId = targetIds[targetIds.length - 1] || 'synthetic-pc-failed';
866
+ return {
867
+ success: true,
868
+ total: targetIds.length,
869
+ queued: Math.max(0, targetIds.length - 1),
870
+ failed: 1,
871
+ failedDeviceIds: [failedDeviceId],
872
+ failurePreview: `${failedDeviceId}: device-ai-assist-unavailable`
873
+ };
874
+ }
875
+
876
+ if (methodName === 'DispatchRemoteFleetTaskFromJs') {
877
+ const useAiAssist = args[3] === true;
878
+ const total = useAiAssist ? aiCount : connectedCount;
879
+ return {
880
+ success: true,
881
+ total,
882
+ queued: total,
883
+ failed: 0,
884
+ approvalLevel: useAiAssist ? 'ai-assist' : 'task-only'
885
+ };
886
+ }
887
+
888
+ if (methodName === 'SetRemoteFleetHostFromJs') {
889
+ return {
890
+ success: true,
891
+ active: args[1] === true,
892
+ registryStatus: args[1] === true ? 'local' : 'inactive',
893
+ registryReason: args[1] === true ? 'registry-render-smoke' : 'inactive'
894
+ };
895
+ }
896
+
897
+ if (methodName === 'AddRemoteFleetDeviceNodeFromJs') {
898
+ const deviceId = String(args[1] || '');
899
+ return {
900
+ success: true,
901
+ nodeId: 'remote-device-render-smoke',
902
+ deviceId,
903
+ nodeState: buildDeviceNode(
904
+ devices.find(device => device.DeviceId === deviceId) || focusedDevice,
905
+ hub.getStatus())
906
+ };
907
+ }
908
+
909
+ return { success: true };
910
+ }
911
+ };
912
+ const moduleRef = {
913
+ dotNetHelper,
914
+ nodeObjectsById: new Map(),
915
+ _visibleIds: new Set(['remote-fleet-render-smoke']),
916
+ _prevVisibleIds: new Set(['remote-fleet-render-smoke']),
917
+ _forceUpdateFrames: 0,
918
+ _textOverlayV2State: {
919
+ cards: new Map(),
920
+ passiveCandidateIds: new Set(['remote-fleet-render-smoke']),
921
+ layer: document.createElement('div')
922
+ },
923
+ requestAnimationWake(reason) {
924
+ this._lastAnimationWakeReason = reason;
925
+ this._animationWakeCount = Number(this._animationWakeCount || 0) + 1;
926
+ },
927
+ isAnimationLoopActive() {
928
+ return true;
929
+ }
930
+ };
931
+ manager.setModuleForTest(moduleRef);
932
+
933
+ const { nodeShell, bodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
934
+ document.body.appendChild(nodeShell);
935
+ const monitorNode = buildMonitorNode(devices, hub.getStatus({ includeSecrets: true }), latestTaskBatch, recentTaskBatches);
936
+ moduleRef.nodeObjectsById.set('remote-fleet-render-smoke', {
937
+ model: monitorNode,
938
+ currentType: 'CSS',
939
+ cssObject: {
940
+ visible: true,
941
+ element: nodeShell
942
+ }
943
+ });
944
+ document.body.appendChild(moduleRef._textOverlayV2State.layer);
945
+
946
+ manager.renderRemoteFleetMonitorForTest(bodyView, monitorNode);
947
+ const { nodeShell: mirrorShell, bodyView: mirrorBodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
948
+ document.body.appendChild(mirrorShell);
949
+ mirrorBodyView.dataset.remoteFleetDensity = 'cards';
950
+
951
+ let cards = bodyView.querySelectorAll('article[data-device-id]');
952
+ assert.equal(cards.length, connectedCount);
953
+ assert.ok(bodyView.querySelector('[data-remote-fleet-match-count="true"]'));
954
+ assert.ok(bodyView.querySelector('[data-remote-fleet-search="true"]'));
955
+ assert.equal(bodyView.querySelectorAll('select').length, 4);
956
+ assert.ok(bodyView.querySelector('[data-remote-fleet-task-composer="visible"]'));
957
+ assert.ok(bodyView.querySelector('[data-remote-fleet-task-input="true"]'));
958
+ const deviceGrid = bodyView.querySelector('[data-remote-fleet-device-grid="true"]');
959
+ assert.ok(deviceGrid);
960
+ assert.match(deviceGrid.style.cssText, /padding:\s*0 4px;/);
961
+ const statusFooter = bodyView.querySelector('[data-remote-fleet-status-rail="true"]');
962
+ assert.ok(statusFooter);
963
+ const bodyChildOrder = Array.from(bodyView.children).map(child =>
964
+ Object.keys(child.dataset || {}).join(',') || child.tagName).join('|');
965
+ assert.ok(bodyChildOrder.endsWith('remoteFleetStatusRail'), bodyChildOrder);
966
+ assert.ok(statusFooter.style.cssText.includes('flex-direction: row'));
967
+ assert.ok(statusFooter.style.cssText.includes('justify-content: flex-end'));
968
+ const sizeControls = statusFooter.querySelector('[data-remote-fleet-size-controls="true"]');
969
+ assert.ok(sizeControls);
970
+ assert.equal(sizeControls.querySelector('[data-remote-fleet-action="monitor-size-down"]')?.textContent, '-');
971
+ assert.equal(sizeControls.querySelector('[data-remote-fleet-action="monitor-size-up"]')?.textContent, '+');
972
+ assert.match(statusFooter.style.cssText, /box-sizing:\s*border-box;/);
973
+ assert.equal(statusFooter.querySelectorAll('[data-remote-fleet-status-item]').length, 5);
974
+ assert.ok(statusFooter.querySelector('[data-remote-fleet-status-item="route"]'));
975
+ const initialDetailPanel = bodyView.querySelector('[data-remote-fleet-detail-panel="true"]');
976
+ assert.equal(initialDetailPanel, null);
977
+ const initialSelectedCard = bodyView.querySelector(`article[data-device-id="${focusedDevice.DeviceId}"]`);
978
+ assert.ok(initialSelectedCard);
979
+ assert.equal(initialSelectedCard?.querySelector('[data-remote-fleet-selected-indicator="true"]'), null);
980
+ assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="pin-device"]').length, 0);
981
+ assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="task-device"]').length, 0);
982
+ assert.equal(bodyView.querySelectorAll('[data-remote-fleet-action="thumbnail-device"]').length, 0);
983
+ assert.equal(bodyView.querySelectorAll('[data-remote-fleet-frame-badge="true"]').length, 0);
984
+ const firstPreview = cards[0]?.querySelector('[data-remote-fleet-device-preview="tile"]');
985
+ assert.ok(firstPreview);
986
+ assert.match(cards[0]?.style.cssText || '', /border-radius:\s*0/);
987
+ assert.match(firstPreview.style.cssText, /border-radius:\s*0/);
988
+ assert.match(cards[0]?.title || '', /Status:\s*(Connected|Offline)/);
989
+ assert.match(cards[0]?.title || '', /Seen:/);
990
+ assert.match(cards[0]?.title || '', /Uptime:/);
991
+ assert.equal(/\b(Seen|Uptime|Mem|Load)\b/.test(cards[0]?.textContent || ''), false);
992
+ assert.match(deviceGrid.style.cssText, /minmax\(198px,\s*1fr\)/);
993
+ sizeControls.querySelector('[data-remote-fleet-action="monitor-size-up"]').dispatchEvent({ type: 'click' });
994
+ assert.equal(bodyView.dataset.remoteFleetDensity, 'large');
995
+ assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(297px,\s*1fr\)/);
996
+ assert.equal(mirrorBodyView.dataset.remoteFleetDensity, 'large');
997
+ assert.match(mirrorBodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(297px,\s*1fr\)/);
998
+ assert.ok(diagnostics.runtimeTrace.some(entry =>
999
+ entry.type === 'remote.monitor.sizeChanged'
1000
+ && entry.nodeId === 'remote-fleet-render-smoke'
1001
+ && entry.density === 'large'
1002
+ && entry.css3dOnly === true));
1003
+ bodyView.querySelector('[data-remote-fleet-action="monitor-size-down"]').dispatchEvent({ type: 'click' });
1004
+ assert.equal(bodyView.dataset.remoteFleetDensity, 'cards');
1005
+ assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1006
+ assert.equal(mirrorBodyView.dataset.remoteFleetDensity, 'cards');
1007
+ assert.match(mirrorBodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1008
+ bodyView.querySelector('[data-remote-fleet-action="monitor-size-down"]').dispatchEvent({ type: 'click' });
1009
+ assert.equal(bodyView.dataset.remoteFleetDensity, 'dense');
1010
+ assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(132px,\s*1fr\)/);
1011
+ bodyView.querySelector('[data-remote-fleet-action="monitor-size-up"]').dispatchEvent({ type: 'click' });
1012
+ assert.equal(bodyView.dataset.remoteFleetDensity, 'cards');
1013
+ assert.match(bodyView.querySelector('[data-remote-fleet-device-grid="true"]')?.style.cssText || '', /minmax\(198px,\s*1fr\)/);
1014
+ mirrorShell.remove();
1015
+ cards = bodyView.querySelectorAll('article[data-device-id]');
1016
+ const patchTarget = devices.find(device =>
1017
+ device.Connected === true
1018
+ && device.ThumbnailEnabled === true);
1019
+ assert.ok(patchTarget);
1020
+ const patchCard = Array.from(cards).find(card => card.dataset.deviceId === patchTarget.DeviceId);
1021
+ const patchPreview = patchCard?.querySelector('[data-remote-fleet-device-preview="tile"]');
1022
+ assert.ok(patchPreview);
1023
+ assert.notEqual(patchPreview.dataset.remoteFleetFrameKind, 'live');
1024
+ const patchKind = 'thumbnail';
1025
+ const patchUrl = `/api/remote/devices/${encodeURIComponent(patchTarget.DeviceId)}/${patchKind}?token=render-smoke-frame&seq=9999`;
1026
+ const patchCount = manager.applyRemoteFleetFramePatchesForTest(bodyView, [{
1027
+ deviceId: patchTarget.DeviceId,
1028
+ kind: patchKind,
1029
+ frameSeq: 9999,
1030
+ frameUrl: patchUrl,
1031
+ receivedAt: new Date().toISOString()
1032
+ }]);
1033
+ assert.equal(patchCount, 1, JSON.stringify({
1034
+ targetDeviceId: patchTarget.DeviceId,
1035
+ previewCount: bodyView.querySelectorAll('[data-remote-fleet-device-preview]').length,
1036
+ previewIds: Array.from(bodyView.querySelectorAll('[data-remote-fleet-device-preview]')).slice(0, 12).map(preview => preview.dataset.deviceId || ''),
1037
+ currentKind: patchPreview.dataset.remoteFleetFrameKind || '',
1038
+ currentSeq: patchPreview.dataset.remoteFleetFrameSeq || '',
1039
+ currentUrl: patchPreview.dataset.remoteFleetFrameUrl || ''
1040
+ }));
1041
+ await wait();
1042
+ assert.equal(patchPreview.dataset.remoteFleetFrameSeq, '9999');
1043
+ assert.equal(patchPreview.dataset.remoteFleetFrameUrl, patchUrl);
1044
+ assert.equal(patchPreview.dataset.remoteFleetPendingFrameUrl || '', '');
1045
+ assert.ok(patchPreview.querySelector('canvas[data-remote-fleet-frame-canvas="true"]'));
1046
+ assert.equal(patchPreview.querySelector('img[data-remote-fleet-frame-image="true"]')?.dataset.remoteFleetFrameUrl, patchUrl);
1047
+ assert.equal(patchPreview.querySelector('[data-remote-fleet-frame-badge="true"]'), null);
1048
+
1049
+ const controlCard = bodyView.querySelector(`article[data-device-id="${patchTarget.DeviceId}"]`);
1050
+ assert.ok(controlCard);
1051
+ controlCard.dispatchEvent({ type: 'dblclick', button: 0 });
1052
+ await wait(30);
1053
+ assert.equal(document.body.querySelector('[data-remote-fleet-control-popup="true"]'), null);
1054
+ const addControlNodeCall = dotNetCalls.find(call => call.methodName === 'AddRemoteFleetDeviceNodeFromJs');
1055
+ assert.equal(addControlNodeCall, undefined, 'MDM thumbnails must not create an expanded device node');
1056
+
1057
+ const alternateDevice = devices.find(device =>
1058
+ device.Connected === true
1059
+ && device.DeviceId !== focusedDevice.DeviceId);
1060
+ assert.ok(alternateDevice);
1061
+ const alternateCard = Array.from(cards).find(card => card.dataset.deviceId === alternateDevice.DeviceId);
1062
+ assert.ok(alternateCard);
1063
+ alternateCard.dispatchEvent({ type: 'click' });
1064
+ assert.equal(bodyView.dataset.remoteFleetSelectedDeviceId, alternateDevice.DeviceId);
1065
+ assert.equal(bodyView.querySelector('[data-remote-fleet-detail-panel="true"]'), null);
1066
+ const selectedAfterClick = bodyView.querySelector(`article[data-device-id="${alternateDevice.DeviceId}"]`);
1067
+ assert.ok(selectedAfterClick);
1068
+ assert.equal(selectedAfterClick?.querySelector('[data-remote-fleet-selected-indicator="true"]'), null);
1069
+ const livePanel = bodyView.querySelector('[data-remote-fleet-live-panel="true"]');
1070
+ assert.equal(livePanel, null);
1071
+ assert.ok(bodyView.querySelector('[data-remote-fleet-action="task-selected"]'));
1072
+ assert.ok(bodyView.querySelector('[data-remote-fleet-action="task-connected"]'));
1073
+ assert.ok(bodyView.querySelector('[data-remote-fleet-task-input="true"]'));
1074
+ assert.ok(bodyView.querySelector('[data-remote-fleet-ai-toggle="true"]'));
1075
+ const selectedTaskInput = bodyView.querySelector('[data-remote-fleet-task-input="true"]');
1076
+ const selectedTaskButton = bodyView.querySelector('[data-remote-fleet-action="task-selected"]');
1077
+ selectedTaskInput.value = 'Inspect Git status and report the result.';
1078
+ selectedTaskButton.dispatchEvent({ type: 'click' });
1079
+ await wait(20);
1080
+ const selectedTaskCall = dotNetCalls.find(call =>
1081
+ call.methodName === 'DispatchRemoteFleetTaskFromJs'
1082
+ && call.args[0] === 'remote-fleet-render-smoke'
1083
+ && call.args[1] === alternateDevice.DeviceId);
1084
+ assert.ok(selectedTaskCall, 'selected thumbnail must target its agent command');
1085
+ assert.equal(bodyView.textContent.includes('all devices, no paging'), false);
1086
+ assert.equal(bodyView.textContent.includes('Host: Inactive'), false);
1087
+ assert.equal(bodyView.textContent.includes('No screen'), false);
1088
+ assert.equal(bodyView.textContent.includes('@mindexec/cli'), false);
1089
+ assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'false');
1090
+ const { nodeShell: hostMirrorShell, bodyView: hostMirrorBodyView } = createRemoteFleetTemplateShell(document, focusedDevice.DeviceId);
1091
+ document.body.appendChild(hostMirrorShell);
1092
+ manager.renderRemoteFleetMonitorForTest(hostMirrorBodyView, monitorNode);
1093
+ assert.equal(hostMirrorShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'false');
1094
+ const initialHostButton = nodeShell.querySelector('[data-remote-fleet-action="set-host"]');
1095
+ assert.equal(initialHostButton?.textContent, 'Set Host');
1096
+ initialHostButton.dispatchEvent({ type: 'click' });
1097
+ await wait();
1098
+ const setHostCall = dotNetCalls.find(call => call.methodName === 'SetRemoteFleetHostFromJs');
1099
+ assert.ok(setHostCall);
1100
+ assert.equal(setHostCall.args[0], 'remote-fleet-render-smoke');
1101
+ assert.equal(setHostCall.args[1], true);
1102
+ const hostFeedback = bodyView.querySelector('[data-remote-fleet-task-feedback="true"]');
1103
+ assert.equal(hostFeedback?.style.display, 'none');
1104
+ assert.equal(hostFeedback?.textContent, '');
1105
+ assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1106
+ assert.equal(hostMirrorShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1107
+ assert.ok(diagnostics.runtimeTrace.some(entry =>
1108
+ entry.type === 'remote.monitor.projectionInvalidated'
1109
+ && entry.nodeId === 'remote-fleet-render-smoke'
1110
+ && entry.reason === 'host'
1111
+ && entry.css3dOnly === true));
1112
+ hostMirrorShell.remove();
1113
+
1114
+ hub.setHostTarget({
1115
+ nodeId: 'remote-fleet-render-smoke',
1116
+ enabled: true,
1117
+ leaseMs: 30000
1118
+ });
1119
+ manager.renderRemoteFleetMonitorForTest(bodyView, buildMonitorNode(devices, hub.getStatus({ includeSecrets: true }), latestTaskBatch, recentTaskBatches));
1120
+ assert.equal(bodyView.textContent.includes('Host: Active'), false);
1121
+ assert.equal(nodeShell.querySelector('[data-remote-fleet-host-indicator="true"]')?.dataset.remoteFleetHostActive, 'true');
1122
+ assert.equal(nodeShell.querySelector('[data-remote-fleet-action="set-host"]')?.textContent, 'Set Host');
1123
+ assert.equal(nodeShell.querySelector('[data-remote-fleet-action="stop-host"]'), null);
1124
+ hub.setHostTarget({
1125
+ nodeId: 'remote-fleet-render-smoke',
1126
+ enabled: false
1127
+ });
1128
+
1129
+ assert.equal(bodyView.querySelector('[data-remote-fleet-live-panel="true"]'), null);
1130
+ assert.equal(bodyView.querySelector('code'), null);
1131
+ assert.equal(bodyView.textContent.includes('npx @mindexec/remote connect'), false);
1132
+ assert.equal(bodyView.querySelector('[data-remote-fleet-action="copy-command"]'), null);
1133
+ assert.equal(bodyView.querySelector('[data-remote-fleet-action="refresh"]'), null);
1134
+ assert.equal(bodyView.querySelector('[data-remote-fleet-auto-toggle="true"]'), null);
1135
+ assert.equal(bodyView.textContent.includes('synthetic-render-ai'), true);
1136
+ assert.equal(bodyView.textContent.includes('Task timed out waiting for the agent response.'), true);
1137
+ const batchSummary = bodyView.querySelector('[data-remote-fleet-task-batch="true"]');
1138
+ assert.ok(batchSummary);
1139
+ const batchHistory = bodyView.querySelector('[data-remote-fleet-task-history="true"]');
1140
+ assert.ok(batchHistory);
1141
+ const resultPanel = bodyView.querySelector('[data-remote-fleet-task-results="true"]');
1142
+ assert.ok(resultPanel);
1143
+ assert.ok(devices.some(device => /^synthetic-response-/.test(device.LatestTaskResultResponseId)));
1144
+ await wait(20);
1145
+ const liveStartCalls = dotNetCalls
1146
+ .filter(call => call.methodName === 'StartRemoteFleetLiveStreamFromJs');
1147
+ assert.equal(liveStartCalls.length, 0, 'thumbnail-only MDM must not start live streams');
1148
+ assert.equal(
1149
+ diagnostics.webSocketConnections.some(connection =>
1150
+ String(connection?.url || '').includes('/api/remote/atlas/ws')
1151
+ || String(connection?.url || '').includes('/api/remote/frames/ws')),
1152
+ false,
1153
+ 'thumbnail-only MDM must not open live frame WebSockets');
1154
+ assert.equal(
1155
+ diagnostics.fetchCalls.some(call => call.url.includes('/api/status?remoteFrames=ws')),
1156
+ false,
1157
+ 'thumbnail-only MDM must not initialize live-frame transport');
1158
+ await wait(320);
1159
+ assert.ok(dotNetCalls.some(call => call.methodName === 'RefreshRemoteFleetMonitorNodeFromJs'));
1160
+ assert.equal(bodyView.dataset.remoteFleetTaskFollowKey, 'render-smoke-batch');
1161
+ assert.ok(Number(bodyView.dataset.remoteFleetTaskFollowTicks || '0') >= 1);
1162
+
1163
+ const feedback = bodyView.querySelector('[data-remote-fleet-task-feedback="true"]');
1164
+ assert.ok(feedback);
1165
+
1166
+ assert.ok(bodyView.querySelector('[data-remote-fleet-ai-toggle="true"]'));
1167
+ assert.ok(dotNetCalls.some(call =>
1168
+ call.methodName === 'DispatchRemoteFleetTaskFromJs'
1169
+ && call.args[1] === alternateDevice.DeviceId));
1170
+
1171
+ const { nodeShell: emptyShell, bodyView: emptyBody } = createRemoteFleetTemplateShell(document);
1172
+ document.body.appendChild(emptyShell);
1173
+ manager.renderRemoteFleetMonitorForTest(emptyBody, buildMonitorNode([], hub.getStatus({ includeSecrets: true })));
1174
+ const emptyScreenShell = emptyBody.querySelector('[data-remote-fleet-empty-screens="true"]');
1175
+ assert.ok(emptyScreenShell);
1176
+ assert.match(emptyScreenShell.style.cssText, /padding:\s*2px 4px 6px 4px;/);
1177
+ const emptyScreens = emptyBody.querySelectorAll('[data-remote-fleet-empty-screen="true"]');
1178
+ assert.ok(emptyScreens.length >= 12, `expected empty monitor to fill space, got ${emptyScreens.length}`);
1179
+ assert.notEqual(emptyScreens.length, 6);
1180
+ assert.match(emptyScreens[0].style.cssText, /border-radius:\s*0/);
1181
+ assert.ok(Array.from(emptyBody.children).map(child =>
1182
+ Object.keys(child.dataset || {}).join(',') || child.tagName).join('|').endsWith('remoteFleetStatusRail'));
1183
+ assert.equal(emptyBody.textContent.includes('No devices connected yet.'), false);
1184
+ assert.equal(emptyBody.textContent.includes('Select a screen'), false);
1185
+ assert.equal(emptyBody.textContent.includes('No screen'), false);
1186
+ assert.equal(emptyBody.textContent.includes('Endpoint 127.0.0.1'), false);
1187
+
1188
+ const oneDevice = devices.find(device => device.Connected === true);
1189
+ assert.ok(oneDevice);
1190
+ const { nodeShell: oneShell, bodyView: oneBody } = createRemoteFleetTemplateShell(document);
1191
+ document.body.appendChild(oneShell);
1192
+ manager.renderRemoteFleetMonitorForTest(oneBody, buildMonitorNode([oneDevice], hub.getStatus({ includeSecrets: true })));
1193
+ const oneCards = oneBody.querySelectorAll('article[data-device-id]');
1194
+ assert.equal(oneCards.length, 1);
1195
+ const onePreview = oneCards[0]?.querySelector('[data-remote-fleet-device-preview="tile"]');
1196
+ assert.ok(onePreview);
1197
+ assert.match(oneCards[0]?.style.cssText || '', /border-radius:\s*0/);
1198
+ assert.match(onePreview.style.cssText, /border-radius:\s*0/);
1199
+ assert.match(oneCards[0]?.title || '', /Status:\s*Connected/);
1200
+ assert.match(oneCards[0]?.title || '', /Seen:/);
1201
+ assert.match(oneCards[0]?.title || '', /Uptime:/);
1202
+ const oneFillers = oneBody.querySelectorAll('[data-remote-fleet-empty-screen="true"]');
1203
+ assert.ok(oneFillers.length > 0, 'single connected monitor wall should keep blank screen placeholders');
1204
+ assert.match(oneFillers[0].style.cssText, /border-radius:\s*0/);
1205
+
1206
+ const { nodeShell: errorShell, bodyView: errorBody } = createRemoteFleetTemplateShell(document);
1207
+ document.body.appendChild(errorShell);
1208
+ manager.renderRemoteFleetMonitorForTest(errorBody, buildMonitorNode([], hub.getStatus({ includeSecrets: true }), null, [], 'RemoteHub is unavailable. Start LocalBridge and retry.'));
1209
+ const errorFooter = errorBody.querySelector('[data-remote-fleet-status-rail="true"]');
1210
+ const footerError = errorFooter?.querySelector('[data-remote-fleet-status-error="true"]');
1211
+ assert.ok(errorFooter);
1212
+ assert.ok(footerError);
1213
+ assert.ok(Array.from(errorBody.children).map(child =>
1214
+ Object.keys(child.dataset || {}).join(',') || child.tagName).join('|').endsWith('remoteFleetStatusRail'));
1215
+ assert.equal(footerError.textContent.includes('RemoteHub is unavailable'), true);
1216
+ assert.equal(Array.from(errorBody.children).some(child =>
1217
+ child !== errorFooter && (child.textContent || '').includes('RemoteHub is unavailable')), false);
1218
+
1219
+ const deviceBody = document.createElement('div');
1220
+ deviceBody.dataset.nodeId = 'remote-device-render-smoke';
1221
+ document.body.appendChild(deviceBody);
1222
+ const sendCountBeforeControlNode = diagnostics.webSocketSends.length;
1223
+ const drawCountBeforeControlNode = document.canvasDrawCalls.length;
1224
+ manager.renderRemoteFleetDeviceForTest(deviceBody, buildDeviceNode(focusedDevice, hub.getStatus()));
1225
+ assert.ok(deviceBody.textContent.includes(focusedDevice.Name));
1226
+ assert.ok(deviceBody.querySelector('[data-remote-fleet-device-toolbar="true"]'));
1227
+ assert.ok(deviceBody.querySelector('[data-remote-fleet-device-actions="true"]'));
1228
+ assert.ok(deviceBody.querySelector('[data-remote-fleet-device-task-panel="true"]'));
1229
+ const deviceStatusBar = deviceBody.querySelector('[data-remote-fleet-device-status-bar="true"]')
1230
+ || deviceBody.querySelector('[data-remote-fleet-device-statusbar="true"]');
1231
+ assert.ok(deviceStatusBar);
1232
+ const deviceControlStage = deviceBody.querySelector('[data-remote-fleet-control-node-stage="true"]');
1233
+ const deviceControlCanvas = deviceBody.querySelector('[data-remote-fleet-control-node-canvas="true"]');
1234
+ assert.ok(deviceControlStage);
1235
+ assert.ok(deviceControlCanvas);
1236
+ assert.equal(
1237
+ deviceControlStage.parentElement,
1238
+ deviceBody,
1239
+ 'RemoteFleetDevice should spend its main body area on the control screen');
1240
+ assert.equal(deviceBody.querySelectorAll('[data-remote-fleet-status-card], [data-remote-fleet-stat]').length, 0);
1241
+ assert.equal(document.activeElement, deviceControlStage);
1242
+ await wait(30);
1243
+ const deviceControlSubscribe = diagnostics.webSocketSends
1244
+ .slice(sendCountBeforeControlNode)
1245
+ .map(send => {
1246
+ try {
1247
+ return JSON.parse(send.payload);
1248
+ } catch {
1249
+ return null;
1250
+ }
1251
+ })
1252
+ .find(message =>
1253
+ message
1254
+ && message.type === 'subscribe'
1255
+ && message.nodeId === 'remote-device-render-smoke'
1256
+ && message.autoStartLive === true
1257
+ && message.fps === 2
1258
+ && message.mode === 'mode2-lzo'
1259
+ && message.streamPurpose === 'wall'
1260
+ && Array.isArray(message.deviceIds)
1261
+ && message.deviceIds.includes(focusedDevice.DeviceId));
1262
+ assert.ok(deviceControlSubscribe, 'Remote workstation should subscribe to a 2fps view-only observation stream');
1263
+ const deviceControlWs = diagnostics.webSocketConnections
1264
+ .filter(ws => ws.url.includes('/api/remote/frames/ws'))
1265
+ .at(-1);
1266
+ assert.ok(deviceControlWs, 'RemoteFleetDevice node should open a binary frame WebSocket');
1267
+ const controlNodeFrameSeq = 30001;
1268
+ deviceControlWs.onmessage?.({
1269
+ data: new Blob([encodeRemoteBinaryFrame({
1270
+ type: 'remote.frame.binary',
1271
+ deviceId: focusedDevice.DeviceId,
1272
+ kind: 'live',
1273
+ frameSeq: controlNodeFrameSeq,
1274
+ streamId: 'render-smoke-control-node-live',
1275
+ contentHash: `render-smoke-control-node-live-${controlNodeFrameSeq}`,
1276
+ mimeType: 'image/jpeg',
1277
+ width: 64,
1278
+ height: 36,
1279
+ capturedAt: new Date().toISOString(),
1280
+ receivedAt: new Date().toISOString()
1281
+ })])
1282
+ });
1283
+ await wait(40);
1284
+ assert.ok(
1285
+ document.canvasDrawCalls
1286
+ .slice(drawCountBeforeControlNode)
1287
+ .some(call => call.canvas === deviceControlCanvas && call.op === 'drawImage'),
1288
+ 'RemoteFleetDevice node should paint binary WebSocket frames directly to its canvas');
1289
+ deviceControlStage.dispatchEvent({
1290
+ type: 'pointerdown',
1291
+ button: 0,
1292
+ pointerId: 11,
1293
+ clientX: 160,
1294
+ clientY: 90
1295
+ });
1296
+ deviceControlStage.dispatchEvent({
1297
+ type: 'pointerup',
1298
+ button: 0,
1299
+ pointerId: 11,
1300
+ clientX: 160,
1301
+ clientY: 90
1302
+ });
1303
+ deviceControlStage.dispatchEvent({
1304
+ type: 'keydown',
1305
+ key: 'A',
1306
+ code: 'KeyA',
1307
+ repeat: false
1308
+ });
1309
+ deviceControlStage.dispatchEvent({
1310
+ type: 'keyup',
1311
+ key: 'A',
1312
+ code: 'KeyA',
1313
+ repeat: false
1314
+ });
1315
+ await wait(50);
1316
+ const inputWsSends = diagnostics.webSocketSends
1317
+ .filter(send => send.url.includes('/api/remote/input/ws'));
1318
+ assert.equal(inputWsSends.length, 0, 'Remote workstation must remain view-only and send no pointer or keyboard input');
1319
+ assert.equal(
1320
+ dotNetCalls.filter(call => call.methodName === 'SendRemoteFleetInputFromJs').length,
1321
+ 0,
1322
+ 'View-only workstation must not use the DotNet input fallback');
1323
+ assert.ok(deviceBody.querySelector('[data-remote-fleet-action="refresh-device"]'));
1324
+ assert.ok(deviceBody.querySelector('[data-remote-fleet-action="task-device"]'));
1325
+ assert.ok(deviceBody.textContent.includes('Task timed out waiting for the agent response.'));
1326
+ assert.ok(deviceStatusBar.title.includes(focusedDevice.DeviceId));
1327
+ const controlCanvasBeforeRerender = deviceControlCanvas;
1328
+ manager.renderRemoteFleetDeviceForTest(deviceBody, buildDeviceNode(focusedDevice, hub.getStatus()));
1329
+ await wait(30);
1330
+ const controlCanvasAfterRerender = deviceBody.querySelector('[data-remote-fleet-control-node-canvas="true"]');
1331
+ assert.equal(
1332
+ controlCanvasAfterRerender,
1333
+ controlCanvasBeforeRerender,
1334
+ 'RemoteFleetDevice rerender should reuse the already-painted control canvas instead of flashing black');
1335
+ assert.equal(
1336
+ deviceBody.querySelector('[data-remote-fleet-control-node-placeholder="true"]'),
1337
+ null,
1338
+ 'RemoteFleetDevice rerender should not cover a restored control canvas with a waiting placeholder');
1339
+
1340
+ nodeShell.remove();
1341
+ emptyShell.remove();
1342
+ oneShell.remove();
1343
+ errorShell.remove();
1344
+ deviceBody.remove();
1345
+ await wait(2200);
1346
+
1347
+ console.log(`RemoteFleet render smoke OK (${SYNTHETIC_COUNT} synthetic devices, ${connectedCount} connected, ${aiCount} AI-ready)`);
1348
+ } finally {
1349
+ await hub.close();
1350
+ }