@copilotkitnext/react 1.51.3-next.2 → 1.51.3-next.4
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 +11 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2514,16 +2514,18 @@ function useRenderCustomMessages() {
|
|
|
2514
2514
|
return null;
|
|
2515
2515
|
}
|
|
2516
2516
|
const { message, position } = params;
|
|
2517
|
-
const
|
|
2517
|
+
const resolvedRunId = copilotkit.getRunIdForMessage(agentId, threadId, message.id) ?? copilotkit.getRunIdsForThread(agentId, threadId).slice(-1)[0];
|
|
2518
|
+
const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
|
|
2518
2519
|
const agent = copilotkit.getAgent(agentId);
|
|
2519
2520
|
if (!agent) {
|
|
2520
2521
|
throw new Error("Agent not found");
|
|
2521
2522
|
}
|
|
2522
|
-
const messagesIdsInRun = agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) ===
|
|
2523
|
-
const
|
|
2524
|
-
const
|
|
2525
|
-
const
|
|
2526
|
-
const
|
|
2523
|
+
const messagesIdsInRun = resolvedRunId ? agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === resolvedRunId).map((msg) => msg.id) : [message.id];
|
|
2524
|
+
const rawMessageIndex = agent.messages.findIndex((msg) => msg.id === message.id);
|
|
2525
|
+
const messageIndex = rawMessageIndex >= 0 ? rawMessageIndex : 0;
|
|
2526
|
+
const messageIndexInRun = resolvedRunId ? Math.max(messagesIdsInRun.indexOf(message.id), 0) : 0;
|
|
2527
|
+
const numberOfMessagesInRun = resolvedRunId ? messagesIdsInRun.length : 1;
|
|
2528
|
+
const stateSnapshot = resolvedRunId ? copilotkit.getStateByRun(agentId, threadId, resolvedRunId) : void 0;
|
|
2527
2529
|
let result = null;
|
|
2528
2530
|
for (const renderer of customMessageRenderers) {
|
|
2529
2531
|
if (!renderer.render) {
|
|
@@ -3755,9 +3757,9 @@ function CopilotChatMessageView({
|
|
|
3755
3757
|
}, [config?.agentId, copilotkit, forceUpdate]);
|
|
3756
3758
|
const getStateSnapshotForMessage = (messageId) => {
|
|
3757
3759
|
if (!config) return void 0;
|
|
3758
|
-
const
|
|
3759
|
-
if (!
|
|
3760
|
-
return copilotkit.getStateByRun(config.agentId, config.threadId,
|
|
3760
|
+
const resolvedRunId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId) ?? copilotkit.getRunIdsForThread(config.agentId, config.threadId).slice(-1)[0];
|
|
3761
|
+
if (!resolvedRunId) return void 0;
|
|
3762
|
+
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
3761
3763
|
};
|
|
3762
3764
|
const messageElements = messages.flatMap((message) => {
|
|
3763
3765
|
const elements = [];
|