@contentgrowth/llm-service 0.8.6 → 0.8.7

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.
@@ -400,20 +400,28 @@ var ChatInputArea = forwardRef(({
400
400
  const message = isControlled ? value : internalMessage;
401
401
  const messageRef = useRef3(message);
402
402
  messageRef.current = message;
403
+ const onChangeRef = useRef3(onChange);
404
+ useEffect3(() => {
405
+ onChangeRef.current = onChange;
406
+ }, [onChange]);
403
407
  const { voice: globalVoice } = useChatConfig();
404
408
  const isVoiceEnabled = (_a = globalVoice == null ? void 0 : globalVoice.enabled) != null ? _a : !!propVoiceConfig;
405
409
  const voiceConfig = isVoiceEnabled ? propVoiceConfig || (globalVoice == null ? void 0 : globalVoice.config) : void 0;
406
- const triggerChange = (newValue) => {
407
- if (isControlled && onChange && textareaRef.current) {
410
+ const voiceConfigRef = useRef3(voiceConfig);
411
+ useEffect3(() => {
412
+ voiceConfigRef.current = voiceConfig;
413
+ }, [voiceConfig]);
414
+ const triggerChange = useCallback3((newValue) => {
415
+ if (isControlled && onChangeRef.current && textareaRef.current) {
408
416
  const syntheticEvent = {
409
417
  target: { value: newValue },
410
418
  currentTarget: { value: newValue }
411
419
  };
412
- onChange(syntheticEvent);
420
+ onChangeRef.current(syntheticEvent);
413
421
  } else {
414
422
  setInternalMessage(newValue);
415
423
  }
416
- };
424
+ }, [isControlled]);
417
425
  const isInputDisabled = (currentTask == null ? void 0 : currentTask.complete) || (lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactive) && (((_b = lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactiveData) == null ? void 0 : _b.function) === "form" && !(lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.isResponseSubmitted) || ((_c = lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactiveData) == null ? void 0 : _c.function) === "confirm" && !(lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.isResponseSubmitted));
418
426
  useProactiveResize(textareaRef, measurementRef, message, isInputDisabled || !!voiceTrigger || inputMode === "voice");
419
427
  const handleVoiceKeyDown = (e) => {
@@ -443,20 +451,20 @@ var ChatInputArea = forwardRef(({
443
451
  triggerChange(messageRef.current + (messageRef.current ? " " : "") + text);
444
452
  }, []);
445
453
  const handleVoiceEnd = useCallback3(() => {
446
- var _a2;
454
+ var _a2, _b2;
447
455
  console.log("[ChatInputArea] nativeSpeech onEnd triggered");
448
456
  setVoiceTrigger(null);
449
- (_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceEnd) == null ? void 0 : _a2.call(voiceConfig);
450
- }, [voiceConfig]);
457
+ (_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
458
+ }, []);
451
459
  const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
452
460
  const customRecorder = useAudioRecorder(async (blob) => {
453
- var _a2;
461
+ var _a2, _b2, _c2;
454
462
  console.log("[ChatInputArea] customRecorder onStop triggered");
455
463
  setVoiceTrigger(null);
456
- (_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceEnd) == null ? void 0 : _a2.call(voiceConfig);
457
- if (voiceConfig == null ? void 0 : voiceConfig.onAudioCapture) {
464
+ (_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
465
+ if ((_c2 = voiceConfigRef.current) == null ? void 0 : _c2.onAudioCapture) {
458
466
  try {
459
- const text = await voiceConfig.onAudioCapture(blob);
467
+ const text = await voiceConfigRef.current.onAudioCapture(blob);
460
468
  if (text) triggerChange(messageRef.current + (messageRef.current ? " " : "") + text);
461
469
  } catch (e) {
462
470
  console.error("[ChatInputArea] Audio capture failed", e);