@anuma/sdk 6.27.7 → 6.27.8

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.
@@ -9449,6 +9449,7 @@ function useChat(options) {
9449
9449
  const abortControllerRef = (0, import_react3.useRef)(null);
9450
9450
  const detachControllerRef = (0, import_react3.useRef)(null);
9451
9451
  const pendingResumeRef = (0, import_react3.useRef)(null);
9452
+ const requestIdRef = (0, import_react3.useRef)(0);
9452
9453
  const fireCancel = (0, import_react3.useCallback)(
9453
9454
  (handle) => {
9454
9455
  const { inferenceId } = handle;
@@ -9577,6 +9578,8 @@ function useChat(options) {
9577
9578
  abortControllerRef.current = abortController;
9578
9579
  const detachController = new AbortController();
9579
9580
  detachControllerRef.current = detachController;
9581
+ const requestId = ++requestIdRef.current;
9582
+ const superseded = () => requestIdRef.current !== requestId;
9580
9583
  pendingResumeRef.current = null;
9581
9584
  setIsLoading(true);
9582
9585
  try {
@@ -9696,7 +9699,8 @@ function useChat(options) {
9696
9699
  piiRedaction: requestPiiRedaction ?? resolvedPiiRedaction,
9697
9700
  onPiiRedacted
9698
9701
  });
9699
- if ("detached" in result && result.detached && result.resume) {
9702
+ if (superseded()) {
9703
+ } else if ("detached" in result && result.detached && result.resume) {
9700
9704
  pendingResumeRef.current = result.resume;
9701
9705
  } else {
9702
9706
  pendingResumeRef.current = null;
@@ -9708,7 +9712,7 @@ function useChat(options) {
9708
9712
  onError
9709
9713
  );
9710
9714
  } finally {
9711
- setIsLoading(false);
9715
+ if (!superseded()) setIsLoading(false);
9712
9716
  if (abortControllerRef.current === abortController) {
9713
9717
  abortControllerRef.current = null;
9714
9718
  }
@@ -7841,6 +7841,7 @@ function useChat(options) {
7841
7841
  const abortControllerRef = useRef3(null);
7842
7842
  const detachControllerRef = useRef3(null);
7843
7843
  const pendingResumeRef = useRef3(null);
7844
+ const requestIdRef = useRef3(0);
7844
7845
  const fireCancel = useCallback3(
7845
7846
  (handle) => {
7846
7847
  const { inferenceId } = handle;
@@ -7969,6 +7970,8 @@ function useChat(options) {
7969
7970
  abortControllerRef.current = abortController;
7970
7971
  const detachController = new AbortController();
7971
7972
  detachControllerRef.current = detachController;
7973
+ const requestId = ++requestIdRef.current;
7974
+ const superseded = () => requestIdRef.current !== requestId;
7972
7975
  pendingResumeRef.current = null;
7973
7976
  setIsLoading(true);
7974
7977
  try {
@@ -8088,7 +8091,8 @@ function useChat(options) {
8088
8091
  piiRedaction: requestPiiRedaction ?? resolvedPiiRedaction,
8089
8092
  onPiiRedacted
8090
8093
  });
8091
- if ("detached" in result && result.detached && result.resume) {
8094
+ if (superseded()) {
8095
+ } else if ("detached" in result && result.detached && result.resume) {
8092
8096
  pendingResumeRef.current = result.resume;
8093
8097
  } else {
8094
8098
  pendingResumeRef.current = null;
@@ -8100,7 +8104,7 @@ function useChat(options) {
8100
8104
  onError
8101
8105
  );
8102
8106
  } finally {
8103
- setIsLoading(false);
8107
+ if (!superseded()) setIsLoading(false);
8104
8108
  if (abortControllerRef.current === abortController) {
8105
8109
  abortControllerRef.current = null;
8106
8110
  }
@@ -9406,6 +9406,7 @@ function useChat(options) {
9406
9406
  } = options || {};
9407
9407
  const [isLoading, setIsLoading] = (0, import_react.useState)(false);
9408
9408
  const abortControllerRef = (0, import_react.useRef)(null);
9409
+ const requestIdRef = (0, import_react.useRef)(0);
9409
9410
  const piiRedactorRef = (0, import_react.useRef)(null);
9410
9411
  if (piiRedaction === true && !piiRedactorRef.current) {
9411
9412
  piiRedactorRef.current = new PiiRedactor();
@@ -9455,6 +9456,7 @@ function useChat(options) {
9455
9456
  }
9456
9457
  const abortController = new AbortController();
9457
9458
  abortControllerRef.current = abortController;
9459
+ const requestId = ++requestIdRef.current;
9458
9460
  setIsLoading(true);
9459
9461
  try {
9460
9462
  const tokenGetterValidation = validateTokenGetter(getToken);
@@ -9554,8 +9556,8 @@ function useChat(options) {
9554
9556
  onError
9555
9557
  );
9556
9558
  } finally {
9557
- setIsLoading(false);
9558
- if (abortControllerRef.current === abortController) {
9559
+ if (requestIdRef.current === requestId) {
9560
+ setIsLoading(false);
9559
9561
  abortControllerRef.current = null;
9560
9562
  }
9561
9563
  }
@@ -7540,6 +7540,7 @@ function useChat(options) {
7540
7540
  } = options || {};
7541
7541
  const [isLoading, setIsLoading] = useState(false);
7542
7542
  const abortControllerRef = useRef(null);
7543
+ const requestIdRef = useRef(0);
7543
7544
  const piiRedactorRef = useRef(null);
7544
7545
  if (piiRedaction === true && !piiRedactorRef.current) {
7545
7546
  piiRedactorRef.current = new PiiRedactor();
@@ -7589,6 +7590,7 @@ function useChat(options) {
7589
7590
  }
7590
7591
  const abortController = new AbortController();
7591
7592
  abortControllerRef.current = abortController;
7593
+ const requestId = ++requestIdRef.current;
7592
7594
  setIsLoading(true);
7593
7595
  try {
7594
7596
  const tokenGetterValidation = validateTokenGetter(getToken);
@@ -7688,8 +7690,8 @@ function useChat(options) {
7688
7690
  onError
7689
7691
  );
7690
7692
  } finally {
7691
- setIsLoading(false);
7692
- if (abortControllerRef.current === abortController) {
7693
+ if (requestIdRef.current === requestId) {
7694
+ setIsLoading(false);
7693
7695
  abortControllerRef.current = null;
7694
7696
  }
7695
7697
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.27.7",
3
+ "version": "6.27.8",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",