@copilotkit/react-core 1.56.5-canary.1777972218 → 1.56.5-canary.1777984472

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.
@@ -5652,11 +5652,23 @@ const DEFAULT_TOOL_PATTERNS = [/^bash$/];
5652
5652
  * 1. `copilotkit.intelligence !== undefined` (Intelligence runtime
5653
5653
  * is configured; checked by the parent before mounting, and
5654
5654
  * again here as a defence)
5655
- * 2. The message is the last message of its run
5656
- * 3. The message's run is the latest run on the thread
5657
- * 4. The message has at least one tool call whose name matches
5658
- * {@link DEFAULT_TOOL_PATTERNS}
5659
- * 5. The phase machine is not yet `hidden`
5655
+ * 2. The message is an assistant message with at least one tool call
5656
+ * whose name matches {@link DEFAULT_TOOL_PATTERNS}
5657
+ * 3. The message is the *latest* such matching-assistant message
5658
+ * anywhere in `agent.messages` — i.e. no later assistant-with-
5659
+ * matching-tool-call message exists. Tool result messages
5660
+ * (`role: "tool"`) and prose-only assistant messages do NOT
5661
+ * invalidate this slot, so the pill stays continuously through a
5662
+ * multi-step tool chain instead of flickering off every time a
5663
+ * tool reply arrives.
5664
+ * 4. The phase machine is not yet `hidden` — once a pill has faded
5665
+ * out it stays gone; a subsequent run on the same chat mounts a
5666
+ * fresh pill on its own assistant message rather than resurrecting
5667
+ * this one.
5668
+ * 5. (Run scoping comes for free from `phase === "hidden"` being
5669
+ * sticky after the previous run's fade-out — no `getRunIdForMessage`
5670
+ * lookup is needed, and the indicator stays robust against gaps
5671
+ * in the SDK's run-tracking map.)
5660
5672
  *
5661
5673
  * Phase machine (per-instance, all timers local):
5662
5674
  * - `spinner` while `agent.isRunning`
@@ -5693,13 +5705,14 @@ function IntelligenceIndicator(props) {
5693
5705
  }, [agent]);
5694
5706
  const [phase, setPhase] = (0, react.useState)(agent.isRunning ? "spinner" : "check");
5695
5707
  (0, react.useEffect)(() => {
5708
+ if (phase === "hidden") return void 0;
5696
5709
  if (agent.isRunning) {
5697
5710
  setPhase("spinner");
5698
5711
  return;
5699
5712
  }
5700
5713
  const t = setTimeout(() => setPhase("check"), RUN_IDLE_DEBOUNCE_MS);
5701
5714
  return () => clearTimeout(t);
5702
- }, [agent.isRunning]);
5715
+ }, [agent.isRunning, phase]);
5703
5716
  (0, react.useEffect)(() => {
5704
5717
  if (phase !== "check") return void 0;
5705
5718
  const t = setTimeout(() => setPhase("fading"), CHECK_HOLD_MS);
@@ -5718,19 +5731,19 @@ function IntelligenceIndicator(props) {
5718
5731
  const name = tc?.function?.name;
5719
5732
  return typeof name === "string" && DEFAULT_TOOL_PATTERNS.some((p) => p.test(name));
5720
5733
  })) return null;
5721
- const messageRunId = copilotkit.getRunIdForMessage(agentId, config.threadId, message.id);
5722
- if (!messageRunId) return null;
5723
- let latestRunId;
5724
- let lastMessageIdInThisRun;
5734
+ let latestMatchingAssistantId;
5725
5735
  for (let i = agent.messages.length - 1; i >= 0; i -= 1) {
5726
5736
  const m = agent.messages[i];
5727
- const r = copilotkit.getRunIdForMessage(agentId, config.threadId, m.id);
5728
- if (latestRunId === void 0 && r) latestRunId = r;
5729
- if (lastMessageIdInThisRun === void 0 && r === messageRunId) lastMessageIdInThisRun = m.id;
5730
- if (latestRunId !== void 0 && lastMessageIdInThisRun !== void 0) break;
5737
+ if (m.role !== "assistant") continue;
5738
+ if ((Array.isArray(m.toolCalls) ? m.toolCalls : []).some((tc) => {
5739
+ const name = tc?.function?.name;
5740
+ return typeof name === "string" && DEFAULT_TOOL_PATTERNS.some((p) => p.test(name));
5741
+ })) {
5742
+ latestMatchingAssistantId = m.id;
5743
+ break;
5744
+ }
5731
5745
  }
5732
- if (latestRunId !== messageRunId) return null;
5733
- if (lastMessageIdInThisRun !== message.id) return null;
5746
+ if (latestMatchingAssistantId !== message.id) return null;
5734
5747
  const showSpinner = phase === "spinner";
5735
5748
  const isFading = phase === "fading";
5736
5749
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -10411,4 +10424,4 @@ Object.defineProperty(exports, 'useToast', {
10411
10424
  return useToast;
10412
10425
  }
10413
10426
  });
10414
- //# sourceMappingURL=copilotkit-BGIsblrk.cjs.map
10427
+ //# sourceMappingURL=copilotkit-BP4xj-n_.cjs.map