@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.
package/dist/index.mjs CHANGED
@@ -16906,6 +16906,29 @@ var EVENT_CAPABILITIES = {
16906
16906
  artifact: "artifacts",
16907
16907
  usage: "usage"
16908
16908
  };
16909
+ function projectRun(events) {
16910
+ const statuses = events.filter(
16911
+ (event) => event.eventType === "status"
16912
+ );
16913
+ const run = statuses.at(-1);
16914
+ if (!run) return void 0;
16915
+ if (run.payload.status !== "stopped" || run.payload.durationMs !== void 0) return run;
16916
+ const runStatuses = run.runId ? statuses.filter((event) => event.runId === run.runId && event.sequence <= run.sequence) : statuses.filter((event) => event.sequence <= run.sequence);
16917
+ let previousStoppedIndex = -1;
16918
+ for (let index = runStatuses.length - 1; index >= 0; index -= 1) {
16919
+ const event = runStatuses[index];
16920
+ if (event.sequence < run.sequence && event.payload.status === "stopped") {
16921
+ previousStoppedIndex = index;
16922
+ break;
16923
+ }
16924
+ }
16925
+ const started = runStatuses.slice(previousStoppedIndex + 1).reverse().find((event) => event.payload.status === "running" || event.payload.status === "queued");
16926
+ const startedAt = started?.payload.startedAt ?? started?.occurredAt;
16927
+ const stoppedAt = run.payload.stoppedAt ?? run.occurredAt;
16928
+ if (!startedAt || !stoppedAt) return run;
16929
+ const durationMs = Date.parse(stoppedAt) - Date.parse(startedAt);
16930
+ return Number.isFinite(durationMs) && durationMs >= 0 ? { ...run, resolvedDurationMs: durationMs } : run;
16931
+ }
16909
16932
  function isVisible(event, capabilities) {
16910
16933
  const capability = EVENT_CAPABILITIES[event.eventType];
16911
16934
  return capability ? capabilities[capability] === true : true;
@@ -16961,9 +16984,7 @@ function createAgentWorkbenchActivityModel(viewModel) {
16961
16984
  usage: [...visibleEvents].reverse().find(
16962
16985
  (event) => event.eventType === "usage"
16963
16986
  ),
16964
- run: [...visibleEvents].reverse().find(
16965
- (event) => event.eventType === "status"
16966
- )
16987
+ run: projectRun(visibleEvents)
16967
16988
  };
16968
16989
  }
16969
16990
  function JsonValue({ value, className }) {
@@ -17142,7 +17163,9 @@ function formatDuration2(durationMs) {
17142
17163
  const seconds = totalSeconds % 60;
17143
17164
  return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
17144
17165
  }
17145
- function RunStatus({ event }) {
17166
+ function RunStatus({
17167
+ event
17168
+ }) {
17146
17169
  const messages = useMonkeysLocaleMessages().agentWorkbench;
17147
17170
  const status = event.payload.status;
17148
17171
  if (status !== "stopping" && status !== "stopped") return null;
@@ -17154,7 +17177,9 @@ function RunStatus({ event }) {
17154
17177
  children: [
17155
17178
  status === "stopping" ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CircleStop, { className: "size-4", "aria-hidden": "true" }),
17156
17179
  /* @__PURE__ */ jsx("span", { children: status === "stopping" ? messages.run.stopping : messages.run.stoppedAfter({
17157
- duration: formatDuration2(event.payload.durationMs ?? 0)
17180
+ duration: formatDuration2(
17181
+ event.payload.durationMs ?? event.resolvedDurationMs ?? 0
17182
+ )
17158
17183
  }) })
17159
17184
  ]
17160
17185
  }