@pega/cosmos-react-work 9.29.0 → 9.31.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"GenAICoach.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":"AA2GA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AAyChF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAy2DyB,eAAe;;;AAQ1C,wBAA6D"}
1
+ {"version":3,"file":"GenAICoach.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":"AAgHA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AAiDhF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAk5DyB,eAAe;;;AAQ1C,wBAA6D"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
3
3
  import { getLuminance } from 'polished';
4
- import { Button, Flex, Icon, MenuButton, Progress, Text, createUID, menuHelpers, useI18n, useSpeechRecognition, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, useFocusTrap, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useFullscreenContext, useBreakpoint, Grid, useRefMap, VisuallyHiddenText, FileList, Lightbox, FormField, useUID, SpeechToTextButton, Toaster, useToaster, throttle } from '@pega/cosmos-react-core';
4
+ import { Button, Flex, Icon, MenuButton, Progress, Text, createUID, menuHelpers, useI18n, useSpeechRecognition, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, useFocusTrap, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useFullscreenContext, useBreakpoint, Grid, useRefMap, VisuallyHiddenText, FileList, Lightbox, FormField, useUID, SpeechToTextButton, Toaster, useToaster, throttle, HTML } from '@pega/cosmos-react-core';
5
5
  import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
6
6
  import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
7
7
  import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
@@ -17,24 +17,30 @@ import * as dockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/doc
17
17
  import * as undockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/undock.icon';
18
18
  import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
19
19
  import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
20
+ import * as clockSlaIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/clock-sla.icon';
20
21
  import { getGenAICoachTestIds } from './GenAICoach.test-ids';
21
22
  import { getSelectedKeys, isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
22
- import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledHeaderContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledSubHeading, StyledComposerWrapper, StyledBannerSalutationBlock } from './GenAICoach.styles';
23
+ import { StyledMessagesContainer, StyledDisclaimerText, StyledDisclaimerMessage, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledHeaderContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledSubHeading, StyledComposerWrapper, StyledBannerSalutationBlock, StyledSimplifiedInitialMessageGrid, StyledConversationHistoryButton } from './GenAICoach.styles';
23
24
  import ActiveCases from './ActiveCases';
24
25
  import CaseWorkflow from './CaseWorkflow';
25
26
  import ConversationHistory from './ConversationHistory';
26
27
  import Questionnaire from './Questionnaire';
27
28
  import { GenAIMessage, InitialSuggestedMessage } from '.';
28
- registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon, squareSolidIcon, sendSolidIcon, plusIcon, dockIcon, undockIcon, caretLeftIcon, caretRightIcon, moreAltIcon);
29
+ registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon, squareSolidIcon, sendSolidIcon, plusIcon, dockIcon, undockIcon, caretLeftIcon, caretRightIcon, clockSlaIcon, moreAltIcon);
29
30
  const onHeightTransitionEnd = (el, callback) => {
30
31
  const handler = (e) => {
31
32
  if (e.propertyName !== 'height' || e.target !== el)
32
33
  return;
33
34
  el.removeEventListener('transitionend', handler);
35
+ el.removeEventListener('transitioncancel', handler);
34
36
  callback();
35
37
  };
36
38
  el.addEventListener('transitionend', handler);
37
- return () => el.removeEventListener('transitionend', handler);
39
+ el.addEventListener('transitioncancel', handler);
40
+ return () => {
41
+ el.removeEventListener('transitionend', handler);
42
+ el.removeEventListener('transitioncancel', handler);
43
+ };
38
44
  };
39
45
  const buildInitialFormAnswers = (questions = []) => Object.fromEntries(questions.map(question => [
40
46
  question.field,
@@ -98,7 +104,7 @@ const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef,
98
104
  }
99
105
  return (_jsx(Actions, { ...(actions ?? {}), menuAt: 1, "data-testid": actionsTestId, contextualLabel: selectedCoach, items: mergedItems }));
100
106
  };
101
- const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, onNewChat, conversationHistory, onLayoutChange, onAddAttachment, attachments, attachmentsError, lightboxPreviewProps, allowFullScreen = true, isInLandingPageUtilities, stopProcess, voiceToTextProps, salutation, showSalutation = true, isPortalAgent = false, pagePanel, suggestionCardsView, draftMessage, caseWorkflow, activeCases, onStop, isCreatingConversation, conversationId, conversationError, questionnaireData, onQuestionnaireDismiss, simplifiedAgent = false, subHeading, operatorName, ...restProps }) => {
107
+ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, onNewChat, conversationHistory, onConversationHistoryOpen, onLayoutChange, onAddAttachment, attachments, attachmentsError, lightboxPreviewProps, allowFullScreen = true, isInLandingPageUtilities, stopProcess, voiceToTextProps, salutation, showSalutation = true, isPortalAgent = false, pagePanel, suggestionCardsView, draftMessage, caseWorkflow, activeCases, onStop, isCreatingConversation, conversationId, conversationError, questionnaireData, onQuestionnaireDismiss, simplifiedAgent = false, subHeading, operatorName, disclaimerMessage, ...restProps }) => {
102
108
  const scrollTolerancePx = 2;
103
109
  const scrollThresholdPx = 50;
104
110
  const streamBufferLh = simplifiedAgent ? 15 : 5;
@@ -116,14 +122,14 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
116
122
  const genAICoachRef = useRef(null);
117
123
  const [messageEls, getMessageCbRef] = useRefMap();
118
124
  const [showInitialScreen, setShowInitialScreen] = useState(true);
119
- const prevExpandedHeightRef = useRef(0);
120
125
  const agentInBanner = simplifiedAgent && variant.placement === 'fullpage';
126
+ const historyOpen = !!conversationHistory;
121
127
  const agentExpanded = simplifiedAgent && messages.length > 0;
122
128
  const focusInMessageListRef = useRef(false);
123
129
  const mouseTriggeredFocusRef = useRef(false);
124
130
  const isUserTriggered = useRef(false);
125
131
  const userInitiatedSendRef = useRef(false);
126
- const userInitiatedNewChatRef = useRef(false);
132
+ const prevHeightRef = useRef(0);
127
133
  const showNextCoachSender = useRef(true);
128
134
  const lastFocusedMessageRef = useRef(null);
129
135
  const initialFocusedElementRef = useRef(null);
@@ -466,6 +472,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
466
472
  return;
467
473
  if (simplifiedAgent) {
468
474
  userInitiatedSendRef.current = true;
475
+ if (agentInBanner && messages.length === 0) {
476
+ prevHeightRef.current = genAICoachRef.current?.getBoundingClientRect().height ?? 0;
477
+ }
469
478
  }
470
479
  onSend({
471
480
  id: createUID(),
@@ -510,11 +519,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
510
519
  variant.onStateChange('maximized');
511
520
  isUserTriggered.current = true;
512
521
  }, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, _jsxs(Flex, { container: { gap: 0.5 }, as: StyledActionsContainer, children: [activeCases && _jsx(ActiveCases, { activeCases: activeCases }), simplifiedAgent && (_jsx(HeaderActions, { actions: actions, allowFullScreen: allowFullScreen, variant: variant, isUserTriggeredRef: isUserTriggered, onFullscreenToggle: toggleFullscreen, isFullscreen: fullScreen, selectedCoach: selectedCoach, actionsTestId: testIds.actions, simplifiedAgent: true })), onNewChat && (_jsx(Button, { icon: true, variant: 'simple', label: simplifiedAgent ? t('close') : t('new_chat'), "aria-label": simplifiedAgent ? t('close_chat_with_ai') : t('new_chat'), onClick: () => {
513
- if (simplifiedAgent && genAICoachRef.current) {
514
- prevExpandedHeightRef.current =
515
- genAICoachRef.current.getBoundingClientRect().height;
522
+ if (agentInBanner && genAICoachRef.current) {
523
+ prevHeightRef.current = genAICoachRef.current.getBoundingClientRect().height;
516
524
  }
517
- userInitiatedNewChatRef.current = true;
518
525
  if (simplifiedAgent && conversationHistory) {
519
526
  conversationHistory.onDismiss();
520
527
  }
@@ -575,38 +582,16 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
575
582
  textAreaRef.current?.focus();
576
583
  }
577
584
  }, [draftMessage, suggestionCardsView]);
578
- useLayoutEffect(() => {
579
- if (!agentInBanner ||
580
- !genAICoachRef.current ||
581
- messages.length !== 0 ||
582
- (loading && conversationHistory))
583
- return;
585
+ const animateHeightFrom = useCallback((fromHeight) => {
584
586
  const el = genAICoachRef.current;
585
- const currentHeight = el.getBoundingClientRect().height;
586
- const storedHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
587
- if (storedHeight > 0 && Math.abs(currentHeight - storedHeight) > scrollTolerancePx)
588
- return;
589
- el.style.removeProperty('--compact-height');
590
- const naturalHeight = el.getBoundingClientRect().height;
591
- el.style.setProperty('--compact-height', `${naturalHeight}px`);
592
- });
593
- useLayoutEffect(() => {
594
- if (!agentInBanner || messages.length !== 0)
595
- return;
596
- if (!userInitiatedNewChatRef.current || !genAICoachRef.current)
587
+ if (!el)
597
588
  return;
598
- userInitiatedNewChatRef.current = false;
599
- const el = genAICoachRef.current;
600
- const fromHeight = prevExpandedHeightRef.current;
601
- const toHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
602
- if (!fromHeight || !toHeight)
589
+ const toHeight = el.getBoundingClientRect().height;
590
+ if (Math.abs(fromHeight - toHeight) <= scrollTolerancePx)
603
591
  return;
604
- el.style.height = `${fromHeight}px`;
605
592
  el.style.transition = 'none';
606
- const removeListener = onHeightTransitionEnd(el, () => {
607
- el.style.removeProperty('height');
608
- prevExpandedHeightRef.current = 0;
609
- });
593
+ el.style.height = `${fromHeight}px`;
594
+ const removeListener = onHeightTransitionEnd(el, () => el.style.removeProperty('height'));
610
595
  const rafId = requestAnimationFrame(() => {
611
596
  el.getBoundingClientRect();
612
597
  el.style.removeProperty('transition');
@@ -615,8 +600,19 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
615
600
  return () => {
616
601
  cancelAnimationFrame(rafId);
617
602
  removeListener();
603
+ el.style.removeProperty('height');
604
+ el.style.removeProperty('transition');
618
605
  };
619
- }, [messages.length, agentInBanner]);
606
+ }, []);
607
+ useLayoutEffect(() => {
608
+ const fromHeight = prevHeightRef.current;
609
+ if (!agentInBanner || !fromHeight || historyOpen)
610
+ return;
611
+ if (messages.length === 0 && !showInitialScreen)
612
+ return;
613
+ prevHeightRef.current = 0;
614
+ return animateHeightFrom(fromHeight);
615
+ }, [messages.length, agentInBanner, showInitialScreen, historyOpen, animateHeightFrom]);
620
616
  useEffect(() => {
621
617
  if (!agentInBanner)
622
618
  return;
@@ -825,14 +821,39 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
825
821
  const getGridColumns = () => {
826
822
  const multiCol = 'repeat(auto-fit, minmax(calc(100% / 4 - 1rem), 1fr))';
827
823
  const singleCol = '1fr';
828
- return !isSmallOrAbove ? singleCol : multiCol;
824
+ return simplifiedAgent || !isSmallOrAbove ? singleCol : multiCol;
829
825
  };
830
826
  useEffect(() => {
831
827
  if (voiceToTextError) {
832
828
  push({ content: voiceToTextError });
833
829
  }
834
830
  }, [voiceToTextError]);
835
- const genAIFooter = (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAIFooter, children: [_jsxs(StyledComposerWrapper, { focused: focused, hasQuestionnaire: !!questionnaireData && !questionnaireDismissed, onFocus: () => setFocused(true), onBlur: e => {
831
+ const showStaticSuggestions = !loading &&
832
+ !error &&
833
+ (agentInBanner ? showInitialScreen : messages.length === 0) &&
834
+ initialSuggestedMessages &&
835
+ initialSuggestedMessages.length > 0;
836
+ const suggestionItems = showStaticSuggestions
837
+ ? initialSuggestedMessages.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
838
+ if (guidedMode) {
839
+ onSend({
840
+ id: initialMessage.id,
841
+ message: initialMessage.message
842
+ });
843
+ }
844
+ else {
845
+ setMessage(initialMessage.message ?? '');
846
+ }
847
+ isUserTriggered.current = true;
848
+ textAreaRef.current?.focus();
849
+ }, testId: initialSuggestedMessage.id })))
850
+ : null;
851
+ const staticSuggestions = showStaticSuggestions &&
852
+ (agentInBanner ? (_jsx(Flex, { container: { wrap: 'wrap', gap: 0.75 }, as: StyledSimplifiedInitialMessageGrid, children: suggestionItems })) : (_jsx(Grid, { as: StyledInitialMessageGrid, container: {
853
+ cols: getGridColumns(),
854
+ gap: simplifiedAgent ? 0.75 : 1.5
855
+ }, children: suggestionItems })));
856
+ const genAIFooter = (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAIFooter, children: [_jsxs(StyledComposerWrapper, { focused: focused, hasQuestionnaire: !!questionnaireData && !questionnaireDismissed, "$agentInBanner": agentInBanner, onFocus: () => setFocused(true), onBlur: e => {
836
857
  if (!(e.relatedTarget instanceof Node) || !e.currentTarget.contains(e.relatedTarget)) {
837
858
  setFocused(false);
838
859
  }
@@ -844,7 +865,7 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
844
865
  justify: 'between',
845
866
  gap: 1,
846
867
  pad: [undefined, 1, 1, 1]
847
- }, children: [_jsxs(Flex, { container: { alignItems: 'center' }, children: [!(messages.length === 0 && suggestionCardsView) && suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'simple', icon: 'chat-typing', iconOnly: true, as: StyledMenuSuggestions, menu: {
868
+ }, children: [_jsxs(Flex, { container: { alignItems: 'center' }, children: [agentInBanner && onConversationHistoryOpen && (_jsx(Flex, { container: { alignItems: 'center' }, as: StyledConversationHistoryButton, children: _jsx(Button, { icon: true, variant: 'simple', label: t('your_chats'), onClick: onConversationHistoryOpen, children: _jsx(Icon, { name: 'clock-sla' }) }) })), !(messages.length === 0 && suggestionCardsView) && suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'simple', icon: 'chat-typing', iconOnly: true, as: StyledMenuSuggestions, menu: {
848
869
  items: suggestions,
849
870
  onItemClick: id => {
850
871
  const selected = menuHelpers.getItem(suggestions, id);
@@ -900,12 +921,12 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
900
921
  }, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] }));
901
922
  }
902
923
  return sendButton;
903
- })()] })] }) }) })] }), attachments && attachments.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Flex, { as: FileList, type: 'item', "aria-label": `${t('attachments')}`, items: attachments, container: { pad: [1, 0] } }), attachmentsError && (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, as: StyledErrorContainer, children: [_jsx(Icon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: `${t('error')} ` }), attachmentsError] }))] })), hasAgentResponse && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') }) }))] }));
924
+ })()] })] }) }) }), agentInBanner && !guidedMode && staticSuggestions] }), attachments && attachments.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Flex, { as: FileList, type: 'item', "aria-label": `${t('attachments')}`, items: attachments, container: { pad: [1, 0] } }), attachmentsError && (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, as: StyledErrorContainer, children: [_jsx(Icon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: `${t('error')} ` }), attachmentsError] }))] })), hasAgentResponse && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') }) }))] }));
904
925
  const isCompact = variant.placement === 'fullpage' &&
905
926
  !fullScreen &&
906
927
  !isInLandingPageUtilities &&
907
928
  messages.length === 0 &&
908
- !(simplifiedAgent && loading && conversationHistory);
929
+ !(agentInBanner && historyOpen);
909
930
  const fullPageAndInitialScreen = (fullScreen || (variant.placement === 'fullpage' && !isInLandingPageUtilities)) &&
910
931
  messages.length === 0;
911
932
  const renderTextArea = agentInBanner || !fullPageAndInitialScreen ? genAIFooter : null;
@@ -932,23 +953,11 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
932
953
  alignItems: 'center',
933
954
  gap: simplifiedAgent ? 2.5 : 2,
934
955
  pad: simplifiedAgent ? [0, 2, 1, 2] : [0, 2]
935
- }, as: simplifiedAgent ? StyledBannerSalutationBlock : undefined, isExpanded: agentExpanded, children: [!simplifiedAgent && _jsx(AgentIcon, {}), _jsx(StyledSalutation, { variant: simplifiedAgent ? 'h1' : 'h3', simplified: simplifiedAgent, children: salutation ?? t('welcome_text') }), simplifiedAgent && (_jsx(StyledSubHeading, { variant: 'primary', as: 'p', children: subHeading ?? t('what_can_i_help_you_with') }))] })), initialSuggestedMessages && initialSuggestedMessages.length > 0 && (_jsx(Grid, { as: StyledInitialMessageGrid, container: { cols: getGridColumns(), gap: 1.5 }, children: initialSuggestedMessages.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
936
- if (guidedMode) {
937
- onSend({
938
- id: initialMessage.id,
939
- message: initialMessage.message
940
- });
941
- }
942
- else {
943
- setMessage(initialMessage.message ?? '');
944
- }
945
- isUserTriggered.current = true;
946
- textAreaRef.current?.focus();
947
- }, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen &&
956
+ }, as: simplifiedAgent ? StyledBannerSalutationBlock : undefined, isExpanded: agentExpanded, children: [!simplifiedAgent && _jsx(AgentIcon, {}), _jsx(StyledSalutation, { variant: simplifiedAgent ? 'h1' : 'h3', simplified: simplifiedAgent, children: salutation ?? t('welcome_text') }), simplifiedAgent && (_jsx(StyledSubHeading, { variant: 'primary', as: 'p', children: subHeading ?? t('what_can_i_help_you_with') }))] })), (!agentInBanner || guidedMode) && staticSuggestions, fullPageAndInitialScreen &&
948
957
  !guidedMode &&
949
958
  !suggestionCardsView &&
950
959
  !agentInBanner &&
951
- genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, simplified: simplifiedAgent, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
960
+ genAIFooter] })) : (_jsxs(Flex, { as: StyledMessagesList, ref: conversationRef, simplified: simplifiedAgent, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
952
961
  mouseTriggeredFocusRef.current = true;
953
962
  const target = e.target instanceof Element ? e.target : null;
954
963
  const clickedMessage = getMessageContainingElement(target);
@@ -1039,41 +1048,41 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1039
1048
  }
1040
1049
  }
1041
1050
  }
1042
- }, children: messages.map((item, index) => {
1043
- let messageProps;
1044
- if (isCoachMessage(item)) {
1045
- messageProps = {
1046
- ...item,
1047
- suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
1048
- onSend,
1049
- showSenderInfo: simplifiedAgent ? showNextCoachSender.current : undefined,
1050
- onSubmit: item.isToolConfirmation
1051
- ? (tools) => {
1052
- onSend({
1053
- ...item,
1054
- message: typeof item.message === 'string' ? item.message : '',
1055
- tools
1056
- });
1051
+ }, children: [disclaimerMessage && (_jsx(StyledDisclaimerMessage, { children: _jsx(HTML, { content: disclaimerMessage }) })), messages.map((item, index) => {
1052
+ let messageProps;
1053
+ if (isCoachMessage(item)) {
1054
+ messageProps = {
1055
+ ...item,
1056
+ suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
1057
+ onSend,
1058
+ showSenderInfo: simplifiedAgent ? showNextCoachSender.current : undefined,
1059
+ onSubmit: item.isToolConfirmation
1060
+ ? (tools) => {
1061
+ onSend({
1062
+ ...item,
1063
+ message: typeof item.message === 'string' ? item.message : '',
1064
+ tools
1065
+ });
1066
+ }
1067
+ : undefined
1068
+ };
1069
+ showNextCoachSender.current = false;
1070
+ }
1071
+ else if (isUserMessage(item) && simplifiedAgent) {
1072
+ showNextCoachSender.current = true;
1073
+ messageProps = { ...item, userName: operatorName };
1074
+ }
1075
+ else {
1076
+ messageProps = item;
1077
+ }
1078
+ return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
1079
+ if (isCoachMessage(item)) {
1080
+ setAnimationInitialCursorPos(animatedTillCursor);
1057
1081
  }
1058
- : undefined
1059
- };
1060
- showNextCoachSender.current = false;
1061
- }
1062
- else if (isUserMessage(item) && simplifiedAgent) {
1063
- showNextCoachSender.current = true;
1064
- messageProps = { ...item, userName: operatorName };
1065
- }
1066
- else {
1067
- messageProps = item;
1068
- }
1069
- return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
1070
- if (isCoachMessage(item)) {
1071
- setAnimationInitialCursorPos(animatedTillCursor);
1072
- }
1073
- }, simplifiedAgent: simplifiedAgent, ...(prevFullScreen !== undefined && prevFullScreen !== fullScreen
1074
- ? { animationInitialCursorPos }
1075
- : {}) }, conversationId ? `${conversationId}:${index}` : index));
1076
- }) })) })) }), showScrollToBottom && (_jsx(StyledScrollButton, { ref: scrollButtonRef, icon: true, onClick: handleScrollToBottomClick, "aria-label": t('scroll_to_latest_message'), onKeyDown: focusLastMessageLi, children: _jsx(Icon, { name: 'caret-down' }) })), !loading && messages.length === 0 && suggestionCardsView ? (_jsxs(_Fragment, { children: [((isInUtilities(variant) && variant.state !== 'minimized') ||
1082
+ }, simplifiedAgent: simplifiedAgent, ...(prevFullScreen !== undefined && prevFullScreen !== fullScreen
1083
+ ? { animationInitialCursorPos }
1084
+ : {}) }, conversationId ? `${conversationId}:${index}` : index));
1085
+ })] })) })) }), showScrollToBottom && (_jsx(StyledScrollButton, { ref: scrollButtonRef, icon: true, onClick: handleScrollToBottomClick, "aria-label": t('scroll_to_latest_message'), onKeyDown: focusLastMessageLi, children: _jsx(Icon, { name: 'caret-down' }) })), !loading && messages.length === 0 && suggestionCardsView ? (_jsxs(_Fragment, { children: [((isInUtilities(variant) && variant.state !== 'minimized') ||
1077
1086
  !isInUtilities(variant)) &&
1078
1087
  !guidedMode && (_jsx(StyledStickyComposer, { children: _jsx(Flex, { container: { direction: 'column' }, as: StyledInputContainer, ref: setInputContainerRef, children: _jsx(StyledComposerSection, { children: genAIFooter }) }) })), _jsx(Flex, { container: { direction: 'column' }, as: StyledSuggestionCardsBottomHalf, children: _jsx(StyledSuggestionCardsView, { ref: setSuggestionCardsViewRef, children: suggestionCardsView }) })] })) : (((isInUtilities(variant) && variant.state !== 'minimized') ||
1079
1088
  !isInUtilities(variant)) &&
@@ -1140,6 +1149,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1140
1149
  conversationHistory.onItemClick?.(selectedConversationId);
1141
1150
  }, onDismiss: () => {
1142
1151
  focusTextArea.current = true;
1152
+ if (agentInBanner && messages.length === 0 && genAICoachRef.current) {
1153
+ prevHeightRef.current = genAICoachRef.current.getBoundingClientRect().height;
1154
+ }
1143
1155
  conversationHistory.onDismiss();
1144
1156
  }, inFullPage: !condition, ref: historyViewRef }));
1145
1157
  return (_jsxs(Flex, { ...restProps, container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, fullScreen: fullScreen, isCompact: isCompact, isPortalAgent: isPortalAgent, simplifiedAgent: simplifiedAgent, ref: genAICoachRef, children: [_jsx(Flex, { as: agentExpanded ? StyledHeaderContainer : undefined, container: {