@athenaintel/react 0.12.0 → 0.12.2

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.js CHANGED
@@ -33,7 +33,8 @@ import { runsMaterialize, StatewireThread, useStatewireSendCommand, useStatewire
33
33
  import { useAuiState } from "@assistant-ui/store";
34
34
  import * as ReactDOM from "react-dom";
35
35
  import ReactDOM__default, { flushSync } from "react-dom";
36
- const version$1 = "0.12.0";
36
+ import { A as AthenaContext, u as useAthenaConfig } from "./AthenaContext-MOslgOmE.js";
37
+ const version$1 = "0.12.2";
37
38
  const packageJson = {
38
39
  version: version$1
39
40
  };
@@ -17018,14 +17019,6 @@ const DEFAULT_AUTO_OPEN_TOOLS = {
17018
17019
  CreateParagraph: openOnResult("document"),
17019
17020
  OpenDocument: openOnResult("document")
17020
17021
  };
17021
- const AthenaContext = createContext(null);
17022
- function useAthenaConfig() {
17023
- const ctx = useContext(AthenaContext);
17024
- if (!ctx) {
17025
- throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
17026
- }
17027
- return ctx;
17028
- }
17029
17022
  const MAX_FALLBACK_TITLE_LENGTH = 50;
17030
17023
  const CONTENT_PART_TYPES = /* @__PURE__ */ new Set(["text", "image_url", "image"]);
17031
17024
  function isRecord(value) {
@@ -61963,6 +61956,27 @@ const getToolkitDisplayInfo = (id) => {
61963
61956
  icon: (info == null ? void 0 : info.icon) ?? "Package"
61964
61957
  };
61965
61958
  };
61959
+ function runActivityKey(parts) {
61960
+ const last = parts[parts.length - 1];
61961
+ if (last === void 0 || last === null || typeof last !== "object") return null;
61962
+ const tail = last;
61963
+ const type = typeof tail["type"] === "string" ? tail["type"] : "unknown";
61964
+ if (type === "text" || type === "reasoning") return null;
61965
+ const argsText = typeof tail["argsText"] === "string" ? tail["argsText"].length : 0;
61966
+ const settled = tail["result"] === void 0 ? 0 : 1;
61967
+ return `${parts.length}:${type}:${argsText}:${settled}`;
61968
+ }
61969
+ const RUN_ACTIVITY_STALL_SECONDS = 30;
61970
+ const RUN_ACTIVITY_COUNTER_SECONDS = 5;
61971
+ function runActivityLabel(seconds) {
61972
+ if (seconds >= RUN_ACTIVITY_STALL_SECONDS) {
61973
+ return `Still working — nothing new for ${seconds}s`;
61974
+ }
61975
+ if (seconds >= RUN_ACTIVITY_COUNTER_SECONDS) {
61976
+ return `Working · ${seconds}s`;
61977
+ }
61978
+ return "Working";
61979
+ }
61966
61980
  function QuotePostMessageBridge() {
61967
61981
  useQuoteFromPostMessage();
61968
61982
  return null;
@@ -62338,6 +62352,34 @@ const AthenaMessageEmptyIndicator = ({
62338
62352
  if (hasParts || !isRunning) return null;
62339
62353
  return /* @__PURE__ */ jsx(EmptyComponent2, { status: { type: "running" } });
62340
62354
  };
62355
+ const AthenaMessageActivityIndicator = () => {
62356
+ const isRunning = useAuiState$1((s) => {
62357
+ var _a3;
62358
+ return ((_a3 = s.message.status) == null ? void 0 : _a3.type) === "running";
62359
+ });
62360
+ const activityKey = useAuiState$1((s) => runActivityKey(s.message.parts));
62361
+ const [seconds, setSeconds] = useState(0);
62362
+ useEffect(() => {
62363
+ setSeconds(0);
62364
+ if (!isRunning || activityKey === null) return;
62365
+ const startedAt = Date.now();
62366
+ const timer = setInterval(() => {
62367
+ setSeconds(Math.floor((Date.now() - startedAt) / 1e3));
62368
+ }, 1e3);
62369
+ return () => clearInterval(timer);
62370
+ }, [isRunning, activityKey]);
62371
+ if (!isRunning || activityKey === null) return null;
62372
+ const stalled = seconds >= RUN_ACTIVITY_STALL_SECONDS;
62373
+ return /* @__PURE__ */ jsxs("div", { className: "aui-run-activity mt-2 flex items-center gap-2 px-1 text-[12px] text-muted-foreground", children: [
62374
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", "aria-hidden": true, children: [
62375
+ /* @__PURE__ */ jsx("span", { className: "size-1.5 animate-bounce rounded-full bg-current [animation-delay:0ms]" }),
62376
+ /* @__PURE__ */ jsx("span", { className: "size-1.5 animate-bounce rounded-full bg-current [animation-delay:150ms]" }),
62377
+ /* @__PURE__ */ jsx("span", { className: "size-1.5 animate-bounce rounded-full bg-current [animation-delay:300ms]" })
62378
+ ] }),
62379
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: stalled ? "text-amber-600 dark:text-amber-400" : void 0, children: runActivityLabel(seconds) }),
62380
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", children: stalled ? "Assistant is still working; nothing new for over thirty seconds." : "Assistant is working." })
62381
+ ] });
62382
+ };
62341
62383
  const AthenaReasoningPart = ({
62342
62384
  text: text2,
62343
62385
  status,
@@ -62458,7 +62500,8 @@ const AthenaAssistantMessage = ({
62458
62500
  ReasoningComponent: effectiveReasoningComponent
62459
62501
  }
62460
62502
  ),
62461
- /* @__PURE__ */ jsx(SuperGroupingFinalText, { TextComponent })
62503
+ /* @__PURE__ */ jsx(SuperGroupingFinalText, { TextComponent }),
62504
+ /* @__PURE__ */ jsx(AthenaMessageActivityIndicator, {})
62462
62505
  ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
62463
62506
  /* @__PURE__ */ jsx(AthenaMessageEmptyIndicator, { EmptyComponent: EmptyComponent2 }),
62464
62507
  /* @__PURE__ */ jsx(MessagePrimitive.GroupedParts, { groupBy: noToolGrouping, children: ({ part }) => {
@@ -62483,7 +62526,8 @@ const AthenaAssistantMessage = ({
62483
62526
  default:
62484
62527
  return null;
62485
62528
  }
62486
- } })
62529
+ } }),
62530
+ /* @__PURE__ */ jsx(AthenaMessageActivityIndicator, {})
62487
62531
  ] }) }),
62488
62532
  /* @__PURE__ */ jsx(MessageError, {})
62489
62533
  ] }) }),