@colixsystems/widget-sdk 0.149.0 → 0.149.1
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/hooks.js +21 -2
- package/package.json +2 -2
package/dist/hooks.js
CHANGED
|
@@ -2854,6 +2854,12 @@ export function useAgent(agentRef) {
|
|
|
2854
2854
|
throw err;
|
|
2855
2855
|
}
|
|
2856
2856
|
const turn = await thread.messages(conversationId).send({ content });
|
|
2857
|
+
// A rebind during the round trip makes this the PREVIOUS agent's reply;
|
|
2858
|
+
// writing it now would render it under the new one.
|
|
2859
|
+
if (agentIdRef.current !== agentId) {
|
|
2860
|
+
setSending(false);
|
|
2861
|
+
return turn && turn.reply ? turn.reply : null;
|
|
2862
|
+
}
|
|
2857
2863
|
const userMessage = turn && turn.user_message ? turn.user_message : null;
|
|
2858
2864
|
const reply = turn && turn.reply ? turn.reply : null;
|
|
2859
2865
|
setMessages((prior) =>
|
|
@@ -2866,7 +2872,8 @@ export function useAgent(agentRef) {
|
|
|
2866
2872
|
// A stale thread is recoverable on the next send rather than permanently
|
|
2867
2873
|
// broken: drop it so the widget opens a fresh one.
|
|
2868
2874
|
if (e.code === "CONVERSATION_NOT_FOUND") conversationRef.current = null;
|
|
2869
|
-
|
|
2875
|
+
// Same rebind guard: a new agent must not inherit the old one's error.
|
|
2876
|
+
if (agentIdRef.current === agentId) setError(e);
|
|
2870
2877
|
setSending(false);
|
|
2871
2878
|
throw e;
|
|
2872
2879
|
}
|
|
@@ -2875,13 +2882,25 @@ export function useAgent(agentRef) {
|
|
|
2875
2882
|
// The binding changed this render: hand back the empty transcript now rather
|
|
2876
2883
|
// than one frame of the previous agent's conversation.
|
|
2877
2884
|
let visibleMessages = messages;
|
|
2885
|
+
let visibleError = error;
|
|
2878
2886
|
if (pendingResetRef.current) {
|
|
2879
2887
|
pendingResetRef.current = false;
|
|
2880
2888
|
visibleMessages = [];
|
|
2881
2889
|
if (messages.length > 0) setMessages([]);
|
|
2890
|
+
// The previous agent's failure is not the new one's: leaving it would
|
|
2891
|
+
// report a healthy agent as broken, and widgets gate on error.code.
|
|
2892
|
+
visibleError = null;
|
|
2893
|
+
if (error) setError(null);
|
|
2882
2894
|
}
|
|
2883
2895
|
|
|
2884
|
-
return {
|
|
2896
|
+
return {
|
|
2897
|
+
send,
|
|
2898
|
+
reset,
|
|
2899
|
+
messages: visibleMessages,
|
|
2900
|
+
sending,
|
|
2901
|
+
error: visibleError,
|
|
2902
|
+
available,
|
|
2903
|
+
};
|
|
2885
2904
|
}
|
|
2886
2905
|
|
|
2887
2906
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.149.
|
|
3
|
+
"version": "0.149.1",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"homepage": "https://github.com/Colix-AB/AppStudio",
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "node scripts/build.js",
|
|
52
|
-
"test": "node --test src/__tests__
|
|
52
|
+
"test": "node --test \"src/__tests__/*.test.js\""
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=18"
|