@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.
@@ -79,7 +79,9 @@ interface AgentWorkbenchActivityModel {
79
79
  approvals: AgentWorkbenchEventOf<'approval'>[];
80
80
  artifacts: AgentWorkbenchEventOf<'artifact'>[];
81
81
  usage?: AgentWorkbenchEventOf<'usage'>;
82
- run?: AgentWorkbenchEventOf<'status'>;
82
+ run?: AgentWorkbenchEventOf<'status'> & {
83
+ resolvedDurationMs?: number;
84
+ };
83
85
  }
84
86
  declare function createAgentWorkbenchActivityModel(viewModel: AgentSessionViewModel): AgentWorkbenchActivityModel;
85
87
  interface AgentWorkbenchToolClassNames {
@@ -79,7 +79,9 @@ interface AgentWorkbenchActivityModel {
79
79
  approvals: AgentWorkbenchEventOf<'approval'>[];
80
80
  artifacts: AgentWorkbenchEventOf<'artifact'>[];
81
81
  usage?: AgentWorkbenchEventOf<'usage'>;
82
- run?: AgentWorkbenchEventOf<'status'>;
82
+ run?: AgentWorkbenchEventOf<'status'> & {
83
+ resolvedDurationMs?: number;
84
+ };
83
85
  }
84
86
  declare function createAgentWorkbenchActivityModel(viewModel: AgentSessionViewModel): AgentWorkbenchActivityModel;
85
87
  interface AgentWorkbenchToolClassNames {
@@ -260,6 +260,29 @@ var EVENT_CAPABILITIES = {
260
260
  artifact: "artifacts",
261
261
  usage: "usage"
262
262
  };
263
+ function projectRun(events) {
264
+ const statuses = events.filter(
265
+ (event) => event.eventType === "status"
266
+ );
267
+ const run = statuses.at(-1);
268
+ if (!run) return void 0;
269
+ if (run.payload.status !== "stopped" || run.payload.durationMs !== void 0) return run;
270
+ const runStatuses = run.runId ? statuses.filter((event) => event.runId === run.runId && event.sequence <= run.sequence) : statuses.filter((event) => event.sequence <= run.sequence);
271
+ let previousStoppedIndex = -1;
272
+ for (let index = runStatuses.length - 1; index >= 0; index -= 1) {
273
+ const event = runStatuses[index];
274
+ if (event.sequence < run.sequence && event.payload.status === "stopped") {
275
+ previousStoppedIndex = index;
276
+ break;
277
+ }
278
+ }
279
+ const started = runStatuses.slice(previousStoppedIndex + 1).reverse().find((event) => event.payload.status === "running" || event.payload.status === "queued");
280
+ const startedAt = started?.payload.startedAt ?? started?.occurredAt;
281
+ const stoppedAt = run.payload.stoppedAt ?? run.occurredAt;
282
+ if (!startedAt || !stoppedAt) return run;
283
+ const durationMs = Date.parse(stoppedAt) - Date.parse(startedAt);
284
+ return Number.isFinite(durationMs) && durationMs >= 0 ? { ...run, resolvedDurationMs: durationMs } : run;
285
+ }
263
286
  function isVisible(event, capabilities) {
264
287
  const capability = EVENT_CAPABILITIES[event.eventType];
265
288
  return capability ? capabilities[capability] === true : true;
@@ -315,9 +338,7 @@ function createAgentWorkbenchActivityModel(viewModel) {
315
338
  usage: [...visibleEvents].reverse().find(
316
339
  (event) => event.eventType === "usage"
317
340
  ),
318
- run: [...visibleEvents].reverse().find(
319
- (event) => event.eventType === "status"
320
- )
341
+ run: projectRun(visibleEvents)
321
342
  };
322
343
  }
323
344
  function JsonValue({ value, className }) {
@@ -496,7 +517,9 @@ function formatDuration(durationMs) {
496
517
  const seconds = totalSeconds % 60;
497
518
  return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
498
519
  }
499
- function RunStatus({ event }) {
520
+ function RunStatus({
521
+ event
522
+ }) {
500
523
  const messages = useMonkeysLocaleMessages().agentWorkbench;
501
524
  const status = event.payload.status;
502
525
  if (status !== "stopping" && status !== "stopped") return null;
@@ -508,7 +531,9 @@ function RunStatus({ event }) {
508
531
  children: [
509
532
  status === "stopping" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleStop, { className: "size-4", "aria-hidden": "true" }),
510
533
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: status === "stopping" ? messages.run.stopping : messages.run.stoppedAfter({
511
- duration: formatDuration(event.payload.durationMs ?? 0)
534
+ duration: formatDuration(
535
+ event.payload.durationMs ?? event.resolvedDurationMs ?? 0
536
+ )
512
537
  }) })
513
538
  ]
514
539
  }