@inf-monkeys-tech/monkeys-design 1.0.10 → 1.0.11

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.
@@ -258,6 +258,29 @@ var EVENT_CAPABILITIES = {
258
258
  artifact: "artifacts",
259
259
  usage: "usage"
260
260
  };
261
+ function projectRun(events) {
262
+ const statuses = events.filter(
263
+ (event) => event.eventType === "status"
264
+ );
265
+ const run = statuses.at(-1);
266
+ if (!run) return void 0;
267
+ if (run.payload.status !== "stopped" || run.payload.durationMs !== void 0) return run;
268
+ const runStatuses = run.runId ? statuses.filter((event) => event.runId === run.runId && event.sequence <= run.sequence) : statuses.filter((event) => event.sequence <= run.sequence);
269
+ let previousStoppedIndex = -1;
270
+ for (let index = runStatuses.length - 1; index >= 0; index -= 1) {
271
+ const event = runStatuses[index];
272
+ if (event.sequence < run.sequence && event.payload.status === "stopped") {
273
+ previousStoppedIndex = index;
274
+ break;
275
+ }
276
+ }
277
+ const started = runStatuses.slice(previousStoppedIndex + 1).reverse().find((event) => event.payload.status === "running" || event.payload.status === "queued");
278
+ const startedAt = started?.payload.startedAt ?? started?.occurredAt;
279
+ const stoppedAt = run.payload.stoppedAt ?? run.occurredAt;
280
+ if (!startedAt || !stoppedAt) return run;
281
+ const durationMs = Date.parse(stoppedAt) - Date.parse(startedAt);
282
+ return Number.isFinite(durationMs) && durationMs >= 0 ? { ...run, resolvedDurationMs: durationMs } : run;
283
+ }
261
284
  function isVisible(event, capabilities) {
262
285
  const capability = EVENT_CAPABILITIES[event.eventType];
263
286
  return capability ? capabilities[capability] === true : true;
@@ -313,9 +336,7 @@ function createAgentWorkbenchActivityModel(viewModel) {
313
336
  usage: [...visibleEvents].reverse().find(
314
337
  (event) => event.eventType === "usage"
315
338
  ),
316
- run: [...visibleEvents].reverse().find(
317
- (event) => event.eventType === "status"
318
- )
339
+ run: projectRun(visibleEvents)
319
340
  };
320
341
  }
321
342
  function JsonValue({ value, className }) {
@@ -494,7 +515,9 @@ function formatDuration(durationMs) {
494
515
  const seconds = totalSeconds % 60;
495
516
  return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
496
517
  }
497
- function RunStatus({ event }) {
518
+ function RunStatus({
519
+ event
520
+ }) {
498
521
  const messages = useMonkeysLocaleMessages().agentWorkbench;
499
522
  const status = event.payload.status;
500
523
  if (status !== "stopping" && status !== "stopped") return null;
@@ -506,7 +529,9 @@ function RunStatus({ event }) {
506
529
  children: [
507
530
  status === "stopping" ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CircleStop, { className: "size-4", "aria-hidden": "true" }),
508
531
  /* @__PURE__ */ jsx("span", { children: status === "stopping" ? messages.run.stopping : messages.run.stoppedAfter({
509
- duration: formatDuration(event.payload.durationMs ?? 0)
532
+ duration: formatDuration(
533
+ event.payload.durationMs ?? event.resolvedDurationMs ?? 0
534
+ )
510
535
  }) })
511
536
  ]
512
537
  }