@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.
Files changed (2) hide show
  1. package/dist/hooks.js +21 -2
  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
- setError(e);
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 { send, reset, messages: visibleMessages, sending, error, available };
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.0",
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__/contract.test.js src/__tests__/theme-token-refs.test.js src/__tests__/vetted-imports-audit.test.js src/__tests__/hooks-users.test.js src/__tests__/hooks-groups.test.js src/__tests__/hooks-invites.test.js src/__tests__/hooks-schema.test.js src/__tests__/hooks-assets-by-tag.test.js src/__tests__/hooks-filestore-upload.test.js src/__tests__/hooks-filestore-file.test.js src/__tests__/hooks-mutation.test.js src/__tests__/hooks-payments.test.js src/__tests__/hooks-record-permissions.test.js src/__tests__/hooks-geolocation.test.js src/__tests__/hooks-section-empty.test.js src/__tests__/hooks-screen-title.test.js src/__tests__/hooks-widget-event.test.js src/__tests__/hooks-widget-input.test.js src/__tests__/hooks-identification.test.js src/__tests__/hooks-subscription.test.js src/__tests__/hooks-volatile-query-key.test.js src/__tests__/linter-users-scope.test.js src/__tests__/linter-comments.test.js src/__tests__/linter-translation-api.test.js src/__tests__/linter-page-url.test.js src/__tests__/linter-image-height.test.js src/__tests__/linter-flex-basis-percent.test.js src/__tests__/linter-hardcoded-design.test.js src/__tests__/linter-editability.test.js src/__tests__/linter-measured-padding.test.js src/__tests__/linter-payment-error.test.js src/__tests__/linter-platform.test.js src/__tests__/linter-react-import.test.js src/__tests__/lucide-icon-names.test.js src/__tests__/lucideIconName.test.js src/__tests__/manifest-actions.test.js src/__tests__/widget-translations.test.js src/__tests__/hooks-translate.test.js src/__tests__/devserver.test.js src/__tests__/flatten-entry.test.js src/__tests__/host-externals.test.js src/__tests__/datetimepicker.test.js src/__tests__/property-schema-resolve.test.js src/__tests__/corner-radius.test.js src/__tests__/theme-components-parity.test.js src/__tests__/navigation-parity.test.js src/__tests__/theme-depth-tokens.test.js src/__tests__/interaction-lift.test.js src/__tests__/toast-host.test.js src/__tests__/overlay-tokens.test.js src/__tests__/hooks-domain-error-mapping.test.js src/__tests__/linter-datastore-error.test.js src/__tests__/linter-write-gating.test.js src/__tests__/hooks-speech-to-text.test.js src/__tests__/hooks-camera.test.js src/__tests__/hooks-barcode.test.js src/__tests__/hooks-image-editor.test.js src/__tests__/hooks-bound-columns.test.js src/__tests__/hooks-stable-query.test.js src/__tests__/hooks-can-write.test.js src/__tests__/widget-route.test.js src/__tests__/linter-html-in-content.test.js src/__tests__/markdown.test.js src/__tests__/markdown-edit.test.js src/__tests__/richtext-tokens.test.js src/__tests__/style-group.test.js"
52
+ "test": "node --test \"src/__tests__/*.test.js\""
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=18"