@copilotkit/react-core 1.56.5-canary.1777983277 → 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.
@@ -5654,15 +5654,21 @@ const DEFAULT_TOOL_PATTERNS = [/^bash$/];
5654
5654
  * again here as a defence)
5655
5655
  * 2. The message is an assistant message with at least one tool call
5656
5656
  * whose name matches {@link DEFAULT_TOOL_PATTERNS}
5657
- * 3. The message's run is the latest run on the thread
5658
- * 4. The message is the *latest* such matching-assistant message in
5659
- * its run — i.e. no later assistant-with-matching-tool-call
5660
- * message exists in the same run. Tool result messages
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
5661
5660
  * (`role: "tool"`) and prose-only assistant messages do NOT
5662
5661
  * invalidate this slot, so the pill stays continuously through a
5663
- * multi-step bash chain instead of flickering off every time a
5664
- * tool result arrives.
5665
- * 5. The phase machine is not yet `hidden`
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.)
5666
5672
  *
5667
5673
  * Phase machine (per-instance, all timers local):
5668
5674
  * - `spinner` while `agent.isRunning`
@@ -5699,13 +5705,14 @@ function IntelligenceIndicator(props) {
5699
5705
  }, [agent]);
5700
5706
  const [phase, setPhase] = (0, react.useState)(agent.isRunning ? "spinner" : "check");
5701
5707
  (0, react.useEffect)(() => {
5708
+ if (phase === "hidden") return void 0;
5702
5709
  if (agent.isRunning) {
5703
5710
  setPhase("spinner");
5704
5711
  return;
5705
5712
  }
5706
5713
  const t = setTimeout(() => setPhase("check"), RUN_IDLE_DEBOUNCE_MS);
5707
5714
  return () => clearTimeout(t);
5708
- }, [agent.isRunning]);
5715
+ }, [agent.isRunning, phase]);
5709
5716
  (0, react.useEffect)(() => {
5710
5717
  if (phase !== "check") return void 0;
5711
5718
  const t = setTimeout(() => setPhase("fading"), CHECK_HOLD_MS);
@@ -5724,24 +5731,19 @@ function IntelligenceIndicator(props) {
5724
5731
  const name = tc?.function?.name;
5725
5732
  return typeof name === "string" && DEFAULT_TOOL_PATTERNS.some((p) => p.test(name));
5726
5733
  })) return null;
5727
- const messageRunId = copilotkit.getRunIdForMessage(agentId, config.threadId, message.id);
5728
- if (!messageRunId) return null;
5729
- let latestRunId;
5730
- let latestMatchingAssistantIdInRun;
5734
+ let latestMatchingAssistantId;
5731
5735
  for (let i = agent.messages.length - 1; i >= 0; i -= 1) {
5732
5736
  const m = agent.messages[i];
5733
- const r = copilotkit.getRunIdForMessage(agentId, config.threadId, m.id);
5734
- if (latestRunId === void 0 && r) latestRunId = r;
5735
- if (latestMatchingAssistantIdInRun === void 0 && r === messageRunId && m.role === "assistant") {
5736
- if ((Array.isArray(m.toolCalls) ? m.toolCalls : []).some((tc) => {
5737
- const name = tc?.function?.name;
5738
- return typeof name === "string" && DEFAULT_TOOL_PATTERNS.some((p) => p.test(name));
5739
- })) latestMatchingAssistantIdInRun = m.id;
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;
5740
5744
  }
5741
- if (latestRunId !== void 0 && latestMatchingAssistantIdInRun !== void 0) break;
5742
5745
  }
5743
- if (latestRunId !== messageRunId) return null;
5744
- if (latestMatchingAssistantIdInRun !== message.id) return null;
5746
+ if (latestMatchingAssistantId !== message.id) return null;
5745
5747
  const showSpinner = phase === "spinner";
5746
5748
  const isFading = phase === "fading";
5747
5749
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -10422,4 +10424,4 @@ Object.defineProperty(exports, 'useToast', {
10422
10424
  return useToast;
10423
10425
  }
10424
10426
  });
10425
- //# sourceMappingURL=copilotkit-BsmznxTd.cjs.map
10427
+ //# sourceMappingURL=copilotkit-BP4xj-n_.cjs.map