@vibefield/puppeteer-views 0.3.4 → 0.4.1

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 (104) hide show
  1. package/dist/deck/PaneFrame.d.ts.map +1 -1
  2. package/dist/deck/PaneFrame.js +4 -2
  3. package/dist/deck/PaneFrame.js.map +1 -1
  4. package/dist/find/FindSheet.d.ts.map +1 -1
  5. package/dist/find/FindSheet.js +12 -9
  6. package/dist/find/FindSheet.js.map +1 -1
  7. package/dist/find/find-model.d.ts.map +1 -1
  8. package/dist/find/find-model.js +3 -1
  9. package/dist/find/find-model.js.map +1 -1
  10. package/dist/find/history-port.d.ts +3 -1
  11. package/dist/find/history-port.d.ts.map +1 -1
  12. package/dist/monitor/types.d.ts +4 -2
  13. package/dist/monitor/types.d.ts.map +1 -1
  14. package/dist/styles/usage.css +14 -0
  15. package/dist/usage/UsageColumn.d.ts.map +1 -1
  16. package/dist/usage/UsageColumn.js +2 -2
  17. package/dist/usage/UsageColumn.js.map +1 -1
  18. package/dist/usage/account-usage.d.ts +2 -0
  19. package/dist/usage/account-usage.d.ts.map +1 -1
  20. package/dist/usage/account-usage.js +80 -43
  21. package/dist/usage/account-usage.js.map +1 -1
  22. package/dist/views/rain/RainView.d.ts.map +1 -1
  23. package/dist/views/rain/RainView.js +84 -57
  24. package/dist/views/rain/RainView.js.map +1 -1
  25. package/dist/views/spend/SpendView.d.ts +4 -1
  26. package/dist/views/spend/SpendView.d.ts.map +1 -1
  27. package/dist/views/spend/SpendView.js +78 -33
  28. package/dist/views/spend/SpendView.js.map +1 -1
  29. package/dist/views/spend/spend-words.d.ts +51 -0
  30. package/dist/views/spend/spend-words.d.ts.map +1 -1
  31. package/dist/views/spend/spend-words.js +52 -2
  32. package/dist/views/spend/spend-words.js.map +1 -1
  33. package/dist/views/spend/spend.css +18 -4
  34. package/dist/views/swarm/AgentSwarm.d.ts.map +1 -1
  35. package/dist/views/swarm/AgentSwarm.js +115 -80
  36. package/dist/views/swarm/AgentSwarm.js.map +1 -1
  37. package/dist/views/swarm/bloom/SpawnBloom.d.ts.map +1 -1
  38. package/dist/views/swarm/bloom/SpawnBloom.js +26 -2
  39. package/dist/views/swarm/bloom/SpawnBloom.js.map +1 -1
  40. package/dist/views/swarm/bloom/birth.d.ts +4 -3
  41. package/dist/views/swarm/bloom/birth.d.ts.map +1 -1
  42. package/dist/views/swarm/bloom/birth.js +3 -2
  43. package/dist/views/swarm/bloom/birth.js.map +1 -1
  44. package/dist/views/swarm/bloom/fuel.d.ts +78 -0
  45. package/dist/views/swarm/bloom/fuel.d.ts.map +1 -0
  46. package/dist/views/swarm/bloom/fuel.js +233 -0
  47. package/dist/views/swarm/bloom/fuel.js.map +1 -0
  48. package/dist/views/swarm/bloom/model.d.ts +3 -0
  49. package/dist/views/swarm/bloom/model.d.ts.map +1 -1
  50. package/dist/views/swarm/bloom/model.js +7 -3
  51. package/dist/views/swarm/bloom/model.js.map +1 -1
  52. package/dist/views/swarm/bloom/spawn-bloom.css +64 -2
  53. package/dist/views/swarm/bloom/words.d.ts.map +1 -1
  54. package/dist/views/swarm/bloom/words.js +6 -4
  55. package/dist/views/swarm/bloom/words.js.map +1 -1
  56. package/dist/views/swarm/bubble-model.d.ts +7 -5
  57. package/dist/views/swarm/bubble-model.d.ts.map +1 -1
  58. package/dist/views/swarm/bubble-model.js +13 -6
  59. package/dist/views/swarm/bubble-model.js.map +1 -1
  60. package/dist/views/swarm/departure.d.ts +5 -1
  61. package/dist/views/swarm/departure.d.ts.map +1 -1
  62. package/dist/views/swarm/departure.js +6 -3
  63. package/dist/views/swarm/departure.js.map +1 -1
  64. package/dist/views/swarm/gpu/frame-layout.d.ts +13 -3
  65. package/dist/views/swarm/gpu/frame-layout.d.ts.map +1 -1
  66. package/dist/views/swarm/gpu/frame-layout.js +17 -4
  67. package/dist/views/swarm/gpu/frame-layout.js.map +1 -1
  68. package/dist/views/swarm/gpu/glyph-atlas.d.ts +5 -1
  69. package/dist/views/swarm/gpu/glyph-atlas.d.ts.map +1 -1
  70. package/dist/views/swarm/gpu/glyph-atlas.js +6 -1
  71. package/dist/views/swarm/gpu/glyph-atlas.js.map +1 -1
  72. package/dist/views/swarm/gpu/shaders/body.wgsl.d.ts +1 -1
  73. package/dist/views/swarm/gpu/shaders/body.wgsl.js +1 -1
  74. package/dist/views/swarm/gpu/shaders/common.wgsl.d.ts +1 -1
  75. package/dist/views/swarm/gpu/shaders/common.wgsl.js +2 -2
  76. package/dist/views/swarm/gpu/swarm-renderer.d.ts +17 -1
  77. package/dist/views/swarm/gpu/swarm-renderer.d.ts.map +1 -1
  78. package/dist/views/swarm/gpu/swarm-renderer.js +58 -20
  79. package/dist/views/swarm/gpu/swarm-renderer.js.map +1 -1
  80. package/dist/views/swarm/lab/fixtures.d.ts +5 -2
  81. package/dist/views/swarm/lab/fixtures.d.ts.map +1 -1
  82. package/dist/views/swarm/lab/fixtures.js +39 -1
  83. package/dist/views/swarm/lab/fixtures.js.map +1 -1
  84. package/dist/views/swarm/lab/main.js +1 -1
  85. package/dist/views/swarm/lab/main.js.map +1 -1
  86. package/dist/views/swarm/physics/driver.d.ts +1 -1
  87. package/dist/views/swarm/physics/driver.d.ts.map +1 -1
  88. package/dist/views/swarm/physics/host.d.ts +6 -0
  89. package/dist/views/swarm/physics/host.d.ts.map +1 -1
  90. package/dist/views/swarm/physics/host.js +3 -0
  91. package/dist/views/swarm/physics/host.js.map +1 -1
  92. package/dist/views/swarm/physics/protocol.d.ts +4 -3
  93. package/dist/views/swarm/physics/protocol.d.ts.map +1 -1
  94. package/dist/views/swarm/physics/protocol.js.map +1 -1
  95. package/dist/views/swarm/physics/swarm-physics.worker.js +14 -4
  96. package/dist/views/swarm/physics/swarm-physics.worker.js.map +1 -1
  97. package/dist/views/timeline/TimelineView.d.ts.map +1 -1
  98. package/dist/views/timeline/TimelineView.js +21 -24
  99. package/dist/views/timeline/TimelineView.js.map +1 -1
  100. package/dist/views/timeline/timeline-lanes.d.ts +9 -4
  101. package/dist/views/timeline/timeline-lanes.d.ts.map +1 -1
  102. package/dist/views/timeline/timeline-lanes.js +6 -4
  103. package/dist/views/timeline/timeline-lanes.js.map +1 -1
  104. package/package.json +4 -4
@@ -96,6 +96,9 @@
96
96
  color: var(--mv-spend-t3);
97
97
  }
98
98
 
99
+ /* The compact hero is one line. At narrow it runs from the plot's left edge to the list's column, and SpendView.tsx's
100
+ `heroRoom` measures it by these sizes and gaps (and the list's 10 px padding), as spend-words.ts's NARROW_HERO
101
+ names them, to cut its caption to fit; test/spend-sheet.test.ts fails if the two part. */
99
102
  .mv-spend .vf-monitor-spend-hero.is-compact {
100
103
  top: 10px;
101
104
  gap: 10px;
@@ -115,10 +118,6 @@
115
118
  font-size: 20px;
116
119
  }
117
120
 
118
- .mv-spend .vf-monitor-spend-hero.is-narrow .vf-monitor-spend-cap i {
119
- display: none;
120
- }
121
-
122
121
  /* The chart's caption at the plot's top-left, where every line starts at $0 (the prototype's `.sv-colcap`): the
123
122
  lines are what each agent spent in the window, never the totals the list prints. */
124
123
  .mv-spend .vf-monitor-spend-colcap {
@@ -257,6 +256,7 @@
257
256
  display: flex;
258
257
  align-items: center;
259
258
  justify-content: space-between;
259
+ gap: 8px;
260
260
  font: 600 10.5px/1 var(--vf-font-sans, sans-serif);
261
261
  letter-spacing: 0.06em;
262
262
  text-transform: uppercase;
@@ -264,6 +264,20 @@
264
264
  cursor: default;
265
265
  }
266
266
 
267
+ /* The head's two labels stand 8 px apart at least. Where both do not fit, the first ("N of M started") is cut,
268
+ and the second, which names the money column, stays whole (item 291 · 2, James's A). */
269
+ .mv-spend .vf-monitor-spend-head span:first-child {
270
+ min-width: 0;
271
+ overflow: hidden;
272
+ text-overflow: ellipsis;
273
+ white-space: nowrap;
274
+ }
275
+
276
+ .mv-spend .vf-monitor-spend-head span:last-child {
277
+ flex: none;
278
+ white-space: nowrap;
279
+ }
280
+
267
281
  /* The compact form keeps a slim header, so "Total" still names the money column beside the chart's window
268
282
  spend: one 14 px line, the same caps a size down. */
269
283
  .mv-spend .vf-monitor-spend-head.is-slim {
@@ -1 +1 @@
1
- {"version":3,"file":"AgentSwarm.d.ts","sourceRoot":"","sources":["../../../src/views/swarm/AgentSwarm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAwNjF,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,YAAY,CAimCnF"}
1
+ {"version":3,"file":"AgentSwarm.d.ts","sourceRoot":"","sources":["../../../src/views/swarm/AgentSwarm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAoPjF,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,YAAY,CA+nCnF"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState, } from 'react';
3
- import { animationFrameScheduler, approachRecede, createMotionLoop, everyReceded, recedeTarget, resolveCssColor, } from '@vibefield/puppeteer-view-sdk/toolkit';
4
- import { birthAgent, birthOf, birthOverdue, birthRow, profileLineFor } from './bloom/birth.js';
3
+ import { approachRecede, createMotionLoop, everyReceded, motionAllowed, recedeTarget, resolveCssColor, themeMotion, } from '@vibefield/puppeteer-view-sdk/toolkit';
4
+ import { birthAgent, birthOf, birthOverdue, birthRow, profileLineFor, } from './bloom/birth.js';
5
5
  import { BLOOM } from './bloom/constants.js';
6
6
  import { arrivalFrom, bloomFieldMemory, departure, stepBloomField, stepLit, veiledOpacity, } from './bloom/field-frame.js';
7
7
  import { SpawnBloom } from './bloom/SpawnBloom.js';
@@ -10,7 +10,7 @@ import { bodyIdOf } from './body-id.js';
10
10
  import { baseRadius, bubbleModel, workingShares } from './bubble-model.js';
11
11
  import { departureMotion, departuresAfter, fadingBack, leaving } from './departure.js';
12
12
  import { fitScale } from './fit.js';
13
- import { createSwarmRenderer, MAX_CLEARINGS, } from './gpu/swarm-renderer.js';
13
+ import { createSwarmRenderer, MAX_CLEARINGS, RENDERER_UNBUILT, } from './gpu/swarm-renderer.js';
14
14
  import { createSwarmPhysicsDriver } from './physics/driver.js';
15
15
  import { readSwarmFrame } from './physics/frame.js';
16
16
  import { PHYSICS_HZ_FLOOR } from './physics/world.js';
@@ -104,14 +104,44 @@ function drawnRows(rows) {
104
104
  function measured(stage) {
105
105
  return stage.width > 0 && stage.height > 0;
106
106
  }
107
+ /**
108
+ * The profile a body of the desktop you sit at runs under, when that desktop has more than one: a terminal names it
109
+ * (SB §2.10), an agent wears its glyph (UM-D6). A peer's body never draws a guess (UM-L3): this menu is not its
110
+ * desktop's. `native` is whatever the row's `profileSet` says: where the tabs place it (`AgentView.profileSet`).
111
+ */
112
+ function bodyProfile(menu, agent) {
113
+ return !agent.device.self ? undefined : profileLineFor(menu, agent.profileSet);
114
+ }
107
115
  export function AgentSwarm({ input, commands }) {
108
116
  const { model, theme, stage, parameters, capabilities } = input;
109
117
  const palette = theme.tokens;
110
118
  const spawnMenu = capabilities.spawn;
111
- /** Motion is the host's switch and the person's preference together (MV-W4): off, the field holds still. */
112
- const motionOn = theme.animations && !theme.reducedMotion;
119
+ /** Motion: the host's switch, the person's preference and the stage in sight (MV-W4). Else the field holds still. */
120
+ const motionOn = motionAllowed(theme);
113
121
  const swarm = useMemo(() => normalizeSwarmParameters(parameters), [parameters]);
114
122
  const agents = useMemo(() => drawnRows(model.agents), [model.agents]);
123
+ /**
124
+ * What the hidden list and the tooltip say, from the input this render was handed: the frame loop's models
125
+ * (`modelsRef`) are rebuilt only after the commit, so a render that read them would say the input before it. No
126
+ * fit and no foreground job's clock: neither moves a body's state, its accessible name or its title.
127
+ */
128
+ const listModels = useMemo(() => {
129
+ const nowMs = Date.now();
130
+ const shares = workingShares(agents);
131
+ const byId = new Map();
132
+ for (const agent of agents) {
133
+ const profile = bodyProfile(spawnMenu, agent);
134
+ byId.set(bodyIdOf(agent), bubbleModel({
135
+ agent,
136
+ parameters: swarm,
137
+ nowMs,
138
+ unread: agent.unread,
139
+ workingShare: shares.get(agent.id) ?? 0,
140
+ ...(profile ? { profile } : {}),
141
+ }));
142
+ }
143
+ return byId;
144
+ }, [agents, swarm, spawnMenu]);
115
145
  const containerRef = useRef(null);
116
146
  const canvasRef = useRef(null);
117
147
  const driverRef = useRef(undefined);
@@ -141,6 +171,7 @@ export function AgentSwarm({ input, commands }) {
141
171
  const holdTimerRef = useRef(undefined);
142
172
  const focusedIdRef = useRef(undefined);
143
173
  const hoveredIdRef = useRef(undefined);
174
+ /** The body under a resting pointer, by id: its words are read from the input each render (`listModels`). */
144
175
  const [hovered, setHovered] = useState(undefined);
145
176
  const [cursor, setCursor] = useState('default');
146
177
  const [failure, setFailure] = useState(undefined);
@@ -162,8 +193,9 @@ export function AgentSwarm({ input, commands }) {
162
193
  stageRef.current = stage;
163
194
  const motionRef = useRef(motionOn);
164
195
  motionRef.current = motionOn;
165
- const switchesRef = useRef({ animations: theme.animations, reducedMotion: theme.reducedMotion });
166
- switchesRef.current = { animations: theme.animations, reducedMotion: theme.reducedMotion };
196
+ /** The theme's switches as the loop takes them, the stage out of sight among them. */
197
+ const switchesRef = useRef(themeMotion(theme));
198
+ switchesRef.current = themeMotion(theme);
167
199
  /** The ramp a bare terminal wears, for a birth's body. */
168
200
  const neutralRef = useRef(palette.neutral);
169
201
  neutralRef.current = palette.neutral;
@@ -171,9 +203,8 @@ export function AgentSwarm({ input, commands }) {
171
203
  commandsRef.current = commands;
172
204
  /** Where the keyboard's focus stands, from the view's own focus events (MV-W2); the bloom asks. */
173
205
  const focusRef = useRef('none');
206
+ /** The frame loop, which also draws a held field's still frames (`requestStill`). Set by the render effect. */
174
207
  const loopRef = useRef(null);
175
- /** Draws the field once where it stands: what a stopped loop shows. Set by the render effect. */
176
- const stillDrawRef = useRef(null);
177
208
  /** Re-reads the motion switches into the loop and the physics. Set by the render effect. */
178
209
  const motionSyncRef = useRef(null);
179
210
  /** Posts the physics' first world once the stage is measured. Set by the render effect. */
@@ -222,10 +253,15 @@ export function AgentSwarm({ input, commands }) {
222
253
  seed: Math.random() * Math.PI * 2,
223
254
  };
224
255
  birthsRef.current = [...birthsRef.current, record];
225
- // The host's answer starts the wait for its row; a refusal gives the birth up at once.
256
+ // Held still, the birth is drawn where it was let go.
257
+ loopRef.current?.requestStill();
258
+ // The host's answer starts the wait for its row; a refusal gives the birth up at once, and held still its
259
+ // gone-form (nothing) is drawn then, never at the next change.
226
260
  const settle = (patch) => {
227
- if (birthsRef.current.includes(record))
228
- record.birth = { ...record.birth, ...patch };
261
+ if (!birthsRef.current.includes(record))
262
+ return;
263
+ record.birth = { ...record.birth, ...patch };
264
+ loopRef.current?.requestStill();
229
265
  };
230
266
  answer.then(({ opened }) => settle(opened ? { answeredAt: performance.now() } : { failedAt: performance.now() }), () => settle({ failedAt: performance.now() }));
231
267
  },
@@ -304,41 +340,58 @@ export function AgentSwarm({ input, commands }) {
304
340
  return;
305
341
  let alive = true;
306
342
  let current;
343
+ /** The stage's failure face, and the same said to the host. */
344
+ const unavailable = (reason) => {
345
+ setFailure(reason);
346
+ commandsRef.current.report({ renderer: 'unavailable' });
347
+ };
307
348
  const start = async () => {
308
- const result = await createSwarmRenderer(canvas);
349
+ const result = await createSwarmRenderer(canvas, {
350
+ // The first draw of a picture only starts its decode; held still, nothing else draws it once it lands.
351
+ onSpriteReady: () => {
352
+ if (alive)
353
+ loopRef.current?.requestStill();
354
+ },
355
+ });
309
356
  if (!alive) {
310
357
  if (result.ok)
311
358
  result.renderer.destroy();
312
359
  return;
313
360
  }
314
361
  if (!result.ok) {
315
- setFailure(result.reason);
316
- commandsRef.current.report({ renderer: 'unavailable' });
362
+ unavailable(result.reason);
317
363
  return;
318
364
  }
319
365
  current = result.renderer;
320
366
  rendererRef.current = current;
321
367
  setFailure(undefined);
322
368
  commandsRef.current.report({ renderer: 'webgpu' });
323
- stillDrawRef.current?.();
369
+ loopRef.current?.requestStill();
324
370
  void current.lost.then((info) => {
325
371
  if (!alive || rendererRef.current !== current)
326
372
  return;
327
373
  console.warn('[swarm] WebGPU device lost, rebuilding', info.message);
328
374
  rendererRef.current = undefined;
329
- void start();
375
+ build();
376
+ });
377
+ };
378
+ // The renderer answers every failure it can meet with a reason. One that escapes it all the same (a programmer
379
+ // error) is still the renderer not built, said in its words: never a blank stage.
380
+ const build = () => {
381
+ start().catch((error) => {
382
+ console.error('[swarm] the renderer could not be built:', error);
383
+ if (alive)
384
+ unavailable(RENDERER_UNBUILT);
330
385
  });
331
386
  };
332
- void start();
387
+ build();
333
388
  return () => {
334
389
  alive = false;
335
390
  rendererRef.current = undefined;
336
391
  current?.destroy();
337
392
  };
338
393
  }, []);
339
- /** A terminal born under a profile of the desktop you sit at names it, when there is more than one (SB §2.10). */
340
- const terminalProfile = (agent) => agent.kind === 'agent' || !agent.device.self ? undefined : profileLineFor(spawnMenuRef.current, agent.profileSet);
341
- // A new tree can change which terminals name their profile.
394
+ // A new tree can change which bodies name or wear their profile.
342
395
  useEffect(() => {
343
396
  modelsRef.current.at = 0;
344
397
  }, [spawnMenu]);
@@ -376,7 +429,7 @@ export function AgentSwarm({ input, commands }) {
376
429
  const shares = workingShares(agentsRef.current);
377
430
  for (const agent of agentsRef.current) {
378
431
  const runningSince = runningSinceRef.current.get(bodyIdOf(agent));
379
- const profile = terminalProfile(agent);
432
+ const profile = bodyProfile(spawnMenuRef.current, agent);
380
433
  byId.set(bodyIdOf(agent), bubbleModel({
381
434
  agent,
382
435
  parameters: parametersRef.current,
@@ -394,12 +447,12 @@ export function AgentSwarm({ input, commands }) {
394
447
  if (refitted && initialisedRef.current)
395
448
  driverRef.current?.post({ type: 'updateAgents', agents: agentSpecs() });
396
449
  };
397
- /** The field or its chrome moved: refit, and where the scale moved, remodel (and redraw a field held still). */
450
+ /** The field or its chrome moved: refit, and where the scale moved, remodel (held still, ask for a frame). */
398
451
  const refitIfMoved = () => {
399
452
  if (fitNow() === fitRef.current)
400
453
  return;
401
454
  refreshModels(performance.now(), true);
402
- stillDrawRef.current?.();
455
+ loopRef.current?.requestStill();
403
456
  };
404
457
  /**
405
458
  * The agents as the physics needs them: a body, the size to grow toward, where a creation gesture happened. And
@@ -445,6 +498,9 @@ export function AgentSwarm({ input, commands }) {
445
498
  const container = containerRef.current;
446
499
  if (!container)
447
500
  return;
501
+ // What the physics publish arrives after the change that asked for it (always, from a worker): held still, each
502
+ // table and each frame read asks for a still frame of its own. The inline physics answer inside the post, before
503
+ // the loop exists at the first world: the effects' own requests draw that.
448
504
  const applyTable = (event) => {
449
505
  tableRef.current = { generation: event.generation, ids: event.ids };
450
506
  const living = new Set(event.ids);
@@ -456,6 +512,7 @@ export function AgentSwarm({ input, commands }) {
456
512
  if (dragRef.current?.id === id)
457
513
  dragRef.current = undefined;
458
514
  }
515
+ loopRef.current?.requestStill();
459
516
  };
460
517
  let width = container.clientWidth;
461
518
  let height = container.clientHeight;
@@ -470,8 +527,10 @@ export function AgentSwarm({ input, commands }) {
470
527
  // READ, THEN RELEASE, and never the other way round: handing the buffer
471
528
  // back transfers it, which detaches this thread's view of it, and a
472
529
  // detached array reads as empty rather than throwing.
473
- if (readSwarmFrame(frame, tableRef.current, statesRef.current))
530
+ if (readSwarmFrame(frame, tableRef.current, statesRef.current)) {
474
531
  frameAtRef.current = performance.now();
532
+ loopRef.current?.requestStill();
533
+ }
475
534
  driver.post({ type: 'releaseFrame', buffer: frame }, [frame.buffer]);
476
535
  },
477
536
  onDemote: (reason) => console.warn('[swarm] the physics run in this thread:', reason),
@@ -581,10 +640,10 @@ export function AgentSwarm({ input, commands }) {
581
640
  }
582
641
  if (departed)
583
642
  driver.post({ type: 'updateAgents', agents: agentSpecs() });
584
- // Held still for reduced motion the loop draws nothing, so a fade (M6) asks for its own frames, only while a
585
- // body is leaving: the field is still again the moment the last has gone (MV-W4).
643
+ // Held still for reduced motion the loop draws nothing, so a fade (M6) asks for one still frame after another,
644
+ // only while a body is leaving: the field is still again the moment the last has gone (MV-W4).
586
645
  if (departing.size > 0)
587
- fadeFrames();
646
+ loop.requestStill();
588
647
  // A birth whose row has arrived: the row takes over where the birth stood.
589
648
  const takeovers = new Map();
590
649
  for (const record of birthsRef.current) {
@@ -678,7 +737,7 @@ export function AgentSwarm({ input, commands }) {
678
737
  (departure ? leavingBodies : bodies).push(body);
679
738
  }
680
739
  if (fadingUp)
681
- fadeFrames();
740
+ loop.requestStill();
682
741
  bodies.sort((left, right) => {
683
742
  const rank = STATUS_RANK[left.model.appearance] - STATUS_RANK[right.model.appearance];
684
743
  if (rank !== 0)
@@ -767,8 +826,9 @@ export function AgentSwarm({ input, commands }) {
767
826
  : {}),
768
827
  });
769
828
  };
770
- // The toolkit's loop: the display's frames while motion is on, no frame at all while it is off (MV-W4). The
771
- // physics pause with it and start again fresh, so the time held still is never stepped through.
829
+ // The toolkit's loop: the display's frames while motion is on, no frame at all while it is off or the stage is out
830
+ // of sight (MV-W4). The physics pause with it and start again fresh, so the time held still is never stepped
831
+ // through. Held still, a still frame is the loop's default, `render(time, 0)`: no time passes.
772
832
  const loop = createMotionLoop(render, switchesRef.current);
773
833
  loopRef.current = loop;
774
834
  let running = loop.running;
@@ -781,37 +841,23 @@ export function AgentSwarm({ input, commands }) {
781
841
  running = loop.running;
782
842
  driver.post({ type: running ? 'resume' : 'pause' });
783
843
  };
784
- const still = () => {
785
- if (!loop.running)
786
- render(performance.now(), 0);
787
- };
788
844
  motionSyncRef.current = () => {
789
845
  syncMotion();
790
- still();
846
+ loop.requestStill();
791
847
  };
792
- stillDrawRef.current = still;
793
- // A departure's fade under reduced motion (M6) is drawn on frames of its own while the loop is stopped: one at a
794
- // time, asked for by the render only while a body is leaving, so never a loop (MV-W4).
795
- const fadeScheduler = animationFrameScheduler();
796
- let fading;
797
- const fadeFrames = () => {
798
- if (fading !== undefined || loop.running)
799
- return;
800
- fading = fadeScheduler.request((time) => {
801
- fading = undefined;
802
- if (!loop.running)
803
- render(time, 0);
804
- });
848
+ // Observer delivery follows rAF: draw now, so a resized backing store is never presented without its frame. Out of
849
+ // sight nothing is presented: the frame is owed, and drawn when the stage is shown.
850
+ const resized = () => {
851
+ if (switchesRef.current.hidden)
852
+ loop.requestStill();
853
+ else
854
+ render(performance.now(), 0);
805
855
  };
806
- // Observer delivery follows rAF: draw now, so a resized backing store is never presented without its frame.
807
- const resizeObserver = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(() => render(performance.now(), 0));
856
+ const resizeObserver = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(resized);
808
857
  resizeObserver?.observe(container);
809
858
  return () => {
810
- if (fading !== undefined)
811
- fadeScheduler.cancel(fading);
812
859
  loop.dispose();
813
860
  loopRef.current = null;
814
- stillDrawRef.current = null;
815
861
  motionSyncRef.current = null;
816
862
  initRef.current = null;
817
863
  resizeObserver?.disconnect();
@@ -897,15 +943,16 @@ export function AgentSwarm({ input, commands }) {
897
943
  });
898
944
  refitIfMoved();
899
945
  }, [stage]);
900
- // The host's animations switch and the reduced-motion preference start or stop the loop (and the physics with
901
- // it); stopped, every change the field shows is drawn once where it stands.
946
+ // The host's animations switch, the reduced-motion preference and the stage out of sight start or stop the loop
947
+ // (and the physics with it); stopped, the field is drawn once where it stands, and out of sight once it is shown.
902
948
  useEffect(() => {
903
949
  motionSyncRef.current?.();
904
- }, [theme.animations, theme.reducedMotion]);
950
+ }, [theme.animations, theme.reducedMotion, theme.hidden]);
951
+ // Held still, every input the field draws asks for one still frame, merged with any asked for before it: the rows,
952
+ // the palette, the parameters, the stage, the spawn menu, and the bloom (its veil, its clearings, its hub).
905
953
  useEffect(() => {
906
- if (loopRef.current && !loopRef.current.running)
907
- stillDrawRef.current?.();
908
- }, [agents, palette, swarm, stage, spawnMenu]);
954
+ loopRef.current?.requestStill();
955
+ }, [agents, palette, swarm, stage, spawnMenu, bloom.state]);
909
956
  const localPoint = (event) => {
910
957
  const bounds = containerRef.current?.getBoundingClientRect();
911
958
  if (!bounds)
@@ -937,9 +984,8 @@ export function AgentSwarm({ input, commands }) {
937
984
  return;
938
985
  }
939
986
  hoveredIdRef.current = id;
940
- const agent = id ? agentById(id) : undefined;
941
- setHovered(agent ? { agent, x, y } : undefined);
942
- setCursor(agent ? 'grab' : 'default');
987
+ setHovered(id ? { id, x, y } : undefined);
988
+ setCursor(id ? 'grab' : 'default');
943
989
  };
944
990
  const onPointerDown = (event) => {
945
991
  watchStill(undefined);
@@ -1088,21 +1134,8 @@ export function AgentSwarm({ input, commands }) {
1088
1134
  const onKeyDown = (event) => {
1089
1135
  bloom.fieldKeyDown(event);
1090
1136
  };
1091
- const modelFor = (agent) => {
1092
- const known = modelsRef.current.byId.get(bodyIdOf(agent));
1093
- if (known)
1094
- return known;
1095
- const profile = terminalProfile(agent);
1096
- return bubbleModel({
1097
- agent,
1098
- parameters: swarm,
1099
- nowMs: Date.now(),
1100
- unread: agent.unread,
1101
- workingShare: workingShares(agentsRef.current).get(agent.id) ?? 0,
1102
- scale: fitRef.current,
1103
- ...(profile ? { profile } : {}),
1104
- });
1105
- };
1137
+ /** The hovered body's words, while its row is in this input: a row that leaves takes its tooltip with it. */
1138
+ const hoveredModel = hovered ? listModels.get(hovered.id) : undefined;
1106
1139
  // The view's own properties (L18): the two palette colours its stylesheets draw with — the monitor's ground
1107
1140
  // behind the bloom's words and the signifier's halo, and the orange of the bloom's waiting dot.
1108
1141
  const style = {
@@ -1120,16 +1153,18 @@ export function AgentSwarm({ input, commands }) {
1120
1153
  .join(' ');
1121
1154
  return (_jsxs("section", { ref: containerRef, className: className, style: style, tabIndex: -1, "aria-label": "Running agent status field", onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerCancel, onLostPointerCapture: (event) => bloom.pointerCancel(event), onPointerLeave: onPointerLeave, onContextMenu: spawnMenu ? onContextMenu : undefined, children: [_jsx("canvas", { ref: canvasRef, className: "vf-monitor-swarm-canvas", "aria-hidden": "true" }), failure ? (_jsxs("div", { className: "vf-monitor-swarm-empty", role: "status", children: [_jsx("span", { children: "WEBGPU UNAVAILABLE" }), _jsx("small", { children: failure })] })) : agents.length === 0 ? (_jsxs("div", { className: "vf-monitor-swarm-empty", children: [_jsx("span", { children: "NO ACTIVE AGENTS" }), _jsx("small", { children: "Launch an agent from a terminal pane." }), spawnMenu ? _jsx("small", { children: "Hold empty ground for a terminal." }) : null] })) : null, spawnMenu ? (_jsx(SpawnBloom, { state: bloom.state, reduced: bloom.reduced, menuRef: bloom.menuRef, onKeyDown: bloom.onKeyDown, onBlur: bloom.onBlur })) : null, signifier && !blooming ? (_jsx("span", { className: "vf-monitor-swarm-signifier", style: { left: signifier.x, top: signifier.y }, "aria-hidden": "true", children: "Hold for a terminal" })) : null, newTerminalFocus && !blooming ? (
1122
1155
  // The keys door has the keyboard: say so where its bloom will open.
1123
- _jsx("span", { className: "vf-monitor-swarm-new-echo", "aria-hidden": "true", children: "\uFF0B New terminal\u2026" })) : null, hovered ? (_jsx("span", { className: "vf-monitor-swarm-tooltip", style: { left: hovered.x, top: hovered.y }, role: "tooltip", "aria-hidden": "true", children: modelFor(hovered.agent).title })) : null, _jsxs("ul", { className: "vf-monitor-swarm-list", "aria-label": "Agents", children: [spawnMenu ? (
1156
+ _jsx("span", { className: "vf-monitor-swarm-new-echo", "aria-hidden": "true", children: "\uFF0B New terminal\u2026" })) : null, hovered && hoveredModel ? (_jsx("span", { className: "vf-monitor-swarm-tooltip", style: { left: hovered.x, top: hovered.y }, role: "tooltip", "aria-hidden": "true", children: hoveredModel.title })) : null, _jsxs("ul", { className: "vf-monitor-swarm-list", "aria-label": "Agents", children: [spawnMenu ? (
1124
1157
  // The keys door (SB §2.11): a bloom at the field's middle with the keyboard in it.
1125
1158
  _jsx("li", { children: _jsx("button", { ref: newTerminalRef, type: "button", "aria-haspopup": "menu", "aria-expanded": blooming && bloom.state?.mode === 'keys', "data-swarm-new-terminal": "", onFocus: (event) => setNewTerminalFocus(focusVisible(event.currentTarget)), onBlur: () => setNewTerminalFocus(false), onClick: () => bloom.openKeys(newTerminalRef.current), children: "\uFF0B New terminal\u2026" }) })) : null, agents.map((agent) => {
1126
- const model = modelFor(agent);
1127
1159
  const bodyId = bodyIdOf(agent);
1160
+ const model = listModels.get(bodyId);
1128
1161
  return (_jsx("li", { children: _jsx("button", { type: "button", "aria-label": model.ariaLabel, "aria-current": agent.active ? 'true' : undefined, "data-agent-bubble-id": bodyId, "data-agent-bubble-status": agent.status, "data-agent-bubble-visual": model.state, "data-agent-bubble-source": !agent.device.self ? 'remote' : agent.kind === 'agent' ? 'agent' : 'terminal', "data-agent-bubble-receded": agent.receded ? 'true' : undefined, onFocus: () => {
1129
1162
  focusedIdRef.current = bodyId;
1163
+ loopRef.current?.requestStill();
1130
1164
  }, onBlur: () => {
1131
1165
  if (focusedIdRef.current === bodyId)
1132
1166
  focusedIdRef.current = undefined;
1167
+ loopRef.current?.requestStill();
1133
1168
  }, onClick: () => commands.select(agent.id), children: model.title }) }, bodyId));
1134
1169
  })] })] }));
1135
1170
  }