@smart-cloud/ai-kit-ui 1.1.34 → 1.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-cloud/ai-kit-ui",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -344,6 +344,7 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
344
344
  const [instructions, setInstructions] = useState<string | undefined>(
345
345
  defaults?.instructions,
346
346
  );
347
+ const [detectedLanguage, setDetectedLanguage] = useState<AiKitLanguageCode>();
347
348
  const [inputLanguage, setInputLanguage] = useState<
348
349
  AiKitLanguageCode | "auto" | undefined
349
350
  >(defaults?.inputLanguage);
@@ -462,7 +463,7 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
462
463
  return (
463
464
  Boolean(text && text.trim().length > 0) &&
464
465
  outputLanguage &&
465
- inputLanguage !== outputLanguage
466
+ detectedLanguage !== outputLanguage
466
467
  );
467
468
  case "summarize":
468
469
  case "proofread":
@@ -473,7 +474,7 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
473
474
  default:
474
475
  return false;
475
476
  }
476
- }, [inputText, mode, image, inputLanguage, outputLanguage, featureOpen]);
477
+ }, [inputText, mode, image, detectedLanguage, outputLanguage, featureOpen]);
477
478
 
478
479
  const ai = useAiRun();
479
480
  const statusText =
@@ -568,7 +569,9 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
568
569
  onDeviceTimeoutOverride: onDeviceTimeout,
569
570
  silent: true,
570
571
  });
571
- setInputLanguage(inputLang);
572
+ setDetectedLanguage(inputLang);
573
+ } else {
574
+ setDetectedLanguage(inputLang);
572
575
  }
573
576
  const outLang =
574
577
  (outputLanguage && outputLanguage !== "auto"
@@ -962,7 +965,7 @@ Follow these additional instructions: ${instructions}`
962
965
  if (ai.busy) {
963
966
  ai.cancel();
964
967
  }
965
- }, [ai]);
968
+ }, [ai.busy]);
966
969
 
967
970
  useEffect(() => {
968
971
  if (
@@ -979,7 +982,16 @@ Follow these additional instructions: ${instructions}`
979
982
  queueMicrotask(() => {
980
983
  void runGenerate(modeOverride);
981
984
  });
982
- }, [ai.busy, canGenerate, autoRun, generated, runGenerate, modeOverride]);
985
+ }, [
986
+ ai.busy,
987
+ autoRunOnceRef,
988
+ featureOpen,
989
+ canGenerate,
990
+ autoRun,
991
+ generated,
992
+ runGenerate,
993
+ modeOverride,
994
+ ]);
983
995
 
984
996
  useEffect(() => {
985
997
  if (!allowOverrideParameters) return;