@pega/cosmos-react-work 10.0.0-build.2.5 → 10.0.0-build.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"GenAICoach.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":"AAuGA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AA8BhF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAopDyB,eAAe;;;AAQ1C,wBAA6D"}
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;iCA81DyB,eAAe;;;AAQ1C,wBAA6D"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
3
3
  import { getLuminance } from 'polished';
4
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';
5
5
  import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
@@ -12,19 +12,30 @@ import * as warnSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icon
12
12
  import * as sendSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/send-solid.icon';
13
13
  import * as squareSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/square-solid.icon';
14
14
  import * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';
15
+ import * as moreAltIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/more-alt.icon';
15
16
  import * as dockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/dock.icon';
16
17
  import * as undockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/undock.icon';
17
18
  import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
18
19
  import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
19
20
  import { getGenAICoachTestIds } from './GenAICoach.test-ids';
20
21
  import { getSelectedKeys, isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
21
- import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledComposerWrapper } from './GenAICoach.styles';
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';
22
23
  import ActiveCases from './ActiveCases';
23
24
  import CaseWorkflow from './CaseWorkflow';
24
25
  import ConversationHistory from './ConversationHistory';
25
26
  import Questionnaire from './Questionnaire';
26
27
  import { GenAIMessage, InitialSuggestedMessage } from '.';
27
- registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon, squareSolidIcon, sendSolidIcon, plusIcon, dockIcon, undockIcon, caretLeftIcon, caretRightIcon);
28
+ registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon, squareSolidIcon, sendSolidIcon, plusIcon, dockIcon, undockIcon, caretLeftIcon, caretRightIcon, moreAltIcon);
29
+ const onHeightTransitionEnd = (el, callback) => {
30
+ const handler = (e) => {
31
+ if (e.propertyName !== 'height' || e.target !== el)
32
+ return;
33
+ el.removeEventListener('transitionend', handler);
34
+ callback();
35
+ };
36
+ el.addEventListener('transitionend', handler);
37
+ return () => el.removeEventListener('transitionend', handler);
38
+ };
28
39
  const buildInitialFormAnswers = (questions = []) => Object.fromEntries(questions.map(question => [
29
40
  question.field,
30
41
  {
@@ -45,11 +56,11 @@ export const AISuggestedBadge = () => {
45
56
  const t = useI18n();
46
57
  return (_jsxs(StyledAISuggestedBadge, { container: { alignItems: 'center', gap: 0.5 }, children: [_jsx(Icon, { name: 'polaris-solid', "aria-hidden": true, size: 'font-size' }), _jsx(Text, { children: t('ai_suggestion') })] }));
47
58
  };
48
- const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef, onFullscreenToggle, isFullscreen, selectedCoach, actionsTestId }) => {
59
+ const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef, onFullscreenToggle, isFullscreen, selectedCoach, actionsTestId, simplifiedAgent }) => {
49
60
  const t = useI18n();
50
61
  const fullscreenIcon = isFullscreen ? 'dock' : 'undock';
51
62
  const extraItems = [
52
- ...(allowFullScreen
63
+ ...(allowFullScreen && !simplifiedAgent
53
64
  ? [
54
65
  {
55
66
  id: 'fullscreen',
@@ -76,15 +87,25 @@ const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef,
76
87
  const mergedItems = [...(actions?.items ?? []), ...extraItems];
77
88
  if (mergedItems.length === 0)
78
89
  return null;
90
+ if (simplifiedAgent) {
91
+ return (_jsx(MenuButton, { "data-testid": actionsTestId, text: t('actions'), "aria-label": selectedCoach ? t('actions_for', [selectedCoach]) : undefined, iconOnly: true, icon: 'more-alt', variant: 'simple', menu: {
92
+ items: mergedItems.map(({ text, onClick, ...rest }) => ({
93
+ ...rest,
94
+ primary: text,
95
+ onClick: onClick ? (id, e) => onClick(id, e) : undefined
96
+ }))
97
+ } }));
98
+ }
79
99
  return (_jsx(Actions, { ...(actions ?? {}), menuAt: 1, "data-testid": actionsTestId, contextualLabel: selectedCoach, items: mergedItems }));
80
100
  };
81
- 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, conversationError, questionnaireData, onQuestionnaireDismiss, ...restProps }) => {
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, conversationError, questionnaireData, onQuestionnaireDismiss, simplifiedAgent = false, subHeading, operatorName, ...restProps }) => {
82
102
  const scrollTolerancePx = 2;
83
103
  const scrollThresholdPx = 50;
84
104
  const streamBufferLh = 5;
85
105
  const bufferExtensionLh = 2;
86
106
  const scrollThrottleMs = 50;
87
107
  const resizeThrottleMs = 33;
108
+ const bannerTransitionMs = 600;
88
109
  const theme = useTheme();
89
110
  const t = useI18n();
90
111
  const testIds = useTestIds(testId, getGenAICoachTestIds);
@@ -93,9 +114,16 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
93
114
  const conversationRef = useRef(null);
94
115
  const genAICoachRef = useRef(null);
95
116
  const [messageEls, getMessageCbRef] = useRefMap();
117
+ const [showInitialScreen, setShowInitialScreen] = useState(true);
118
+ const prevExpandedHeightRef = useRef(0);
119
+ const agentInBanner = simplifiedAgent && variant.placement === 'fullpage';
120
+ const agentExpanded = simplifiedAgent && messages.length > 0;
96
121
  const focusInMessageListRef = useRef(false);
97
122
  const mouseTriggeredFocusRef = useRef(false);
98
123
  const isUserTriggered = useRef(false);
124
+ const userInitiatedSendRef = useRef(false);
125
+ const userInitiatedNewChatRef = useRef(false);
126
+ const showNextCoachSender = useRef(true);
99
127
  const lastFocusedMessageRef = useRef(null);
100
128
  const initialFocusedElementRef = useRef(null);
101
129
  const inputContainerRef = useRef(null);
@@ -443,6 +471,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
443
471
  isCoachMessageLoading ||
444
472
  (latestMessage && isCoachMessage(latestMessage) && latestMessage.isToolConfirmation))
445
473
  return;
474
+ if (simplifiedAgent) {
475
+ userInitiatedSendRef.current = true;
476
+ }
446
477
  onSend({
447
478
  id: createUID(),
448
479
  message,
@@ -480,11 +511,33 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
480
511
  } }));
481
512
  }, [coachOptions, selectedCoach, isPortalAgent, pagePanel?.visible]);
482
513
  const headerContent = useMemo(() => {
514
+ if (simplifiedAgent && showInitialScreen)
515
+ return null;
483
516
  return isInUtilities(variant) && variant.state === 'minimized' ? (_jsxs(_Fragment, { children: [_jsx(Text, { variant: 'h2', children: selectedCoach }), _jsx(Flex, { container: { alignItems: 'center' }, children: _jsx(Button, { icon: true, label: t('maximize'), "aria-label": t('agent_noun', [t('maximize')]), variant: 'simple', onClick: () => {
484
517
  variant.onStateChange('maximized');
485
518
  isUserTriggered.current = true;
486
- }, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, _jsxs(Flex, { container: { gap: 0.5 }, as: StyledActionsContainer, children: [activeCases && _jsx(ActiveCases, { activeCases: activeCases }), onNewChat && (_jsx(Button, { icon: true, variant: 'simple', label: t('new_chat'), "aria-label": t('new_chat'), onClick: onNewChat, children: _jsx(Icon, { name: 'plus' }) })), _jsx(HeaderActions, { actions: actions, allowFullScreen: allowFullScreen, variant: variant, isUserTriggeredRef: isUserTriggered, onFullscreenToggle: toggleFullscreen, isFullscreen: fullScreen, selectedCoach: selectedCoach, actionsTestId: testIds.actions }), variant.placement === 'dialog' && !fullScreen && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('close_chat_with_ai'), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] })] }));
487
- }, [variant, coachOptions, activeCases, actions, allowFullScreen, onNewChat]);
519
+ }, 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: () => {
520
+ if (simplifiedAgent && genAICoachRef.current) {
521
+ prevExpandedHeightRef.current =
522
+ genAICoachRef.current.getBoundingClientRect().height;
523
+ }
524
+ userInitiatedNewChatRef.current = true;
525
+ if (simplifiedAgent && conversationHistory) {
526
+ conversationHistory.onDismiss();
527
+ }
528
+ onNewChat?.();
529
+ }, children: _jsx(Icon, { name: simplifiedAgent ? 'times' : 'plus' }) })), !simplifiedAgent && (_jsx(HeaderActions, { actions: actions, allowFullScreen: allowFullScreen, variant: variant, isUserTriggeredRef: isUserTriggered, onFullscreenToggle: toggleFullscreen, isFullscreen: fullScreen, selectedCoach: selectedCoach, actionsTestId: testIds.actions })), variant.placement === 'dialog' && !fullScreen && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('close_chat_with_ai'), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] })] }));
530
+ }, [
531
+ variant,
532
+ coachOptions,
533
+ activeCases,
534
+ actions,
535
+ allowFullScreen,
536
+ onNewChat,
537
+ simplifiedAgent,
538
+ showInitialScreen,
539
+ messages.length
540
+ ]);
488
541
  const getMessageContainingElement = (element) => {
489
542
  if (element)
490
543
  return Array.from(messageEls.values()).find(el => el && el.contains(element));
@@ -529,6 +582,70 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
529
582
  textAreaRef.current?.focus();
530
583
  }
531
584
  }, [draftMessage, suggestionCardsView]);
585
+ useLayoutEffect(() => {
586
+ if (!agentInBanner ||
587
+ !genAICoachRef.current ||
588
+ messages.length !== 0 ||
589
+ (loading && conversationHistory))
590
+ return;
591
+ const el = genAICoachRef.current;
592
+ const currentHeight = el.getBoundingClientRect().height;
593
+ const storedHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
594
+ if (storedHeight > 0 && Math.abs(currentHeight - storedHeight) > scrollTolerancePx)
595
+ return;
596
+ el.style.removeProperty('--compact-height');
597
+ const naturalHeight = el.getBoundingClientRect().height;
598
+ el.style.setProperty('--compact-height', `${naturalHeight}px`);
599
+ });
600
+ useLayoutEffect(() => {
601
+ if (!agentInBanner || messages.length !== 0)
602
+ return;
603
+ if (!userInitiatedNewChatRef.current || !genAICoachRef.current)
604
+ return;
605
+ userInitiatedNewChatRef.current = false;
606
+ const el = genAICoachRef.current;
607
+ const fromHeight = prevExpandedHeightRef.current;
608
+ const toHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
609
+ if (!fromHeight || !toHeight)
610
+ return;
611
+ el.style.height = `${fromHeight}px`;
612
+ el.style.transition = 'none';
613
+ const removeListener = onHeightTransitionEnd(el, () => {
614
+ el.style.removeProperty('height');
615
+ prevExpandedHeightRef.current = 0;
616
+ });
617
+ const rafId = requestAnimationFrame(() => {
618
+ el.getBoundingClientRect();
619
+ el.style.removeProperty('transition');
620
+ el.style.height = `${toHeight}px`;
621
+ });
622
+ return () => {
623
+ cancelAnimationFrame(rafId);
624
+ removeListener();
625
+ };
626
+ }, [messages.length, agentInBanner]);
627
+ useEffect(() => {
628
+ if (!agentInBanner)
629
+ return;
630
+ if (messages.length === 0) {
631
+ if (!(loading && conversationHistory)) {
632
+ setShowInitialScreen(true);
633
+ }
634
+ userInitiatedSendRef.current = false;
635
+ return;
636
+ }
637
+ if (!showInitialScreen)
638
+ return;
639
+ if (!userInitiatedSendRef.current) {
640
+ setShowInitialScreen(false);
641
+ return;
642
+ }
643
+ const timer = setTimeout(() => {
644
+ setShowInitialScreen(false);
645
+ userInitiatedSendRef.current = false;
646
+ }, bannerTransitionMs);
647
+ return () => clearTimeout(timer);
648
+ }, [messages.length, agentInBanner, showInitialScreen]);
532
649
  useEffect(() => {
533
650
  if (isUserTriggered.current) {
534
651
  if (isInUtilities(variant) &&
@@ -718,10 +835,10 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
718
835
  if (!(e.relatedTarget instanceof Node) || !e.currentTarget.contains(e.relatedTarget)) {
719
836
  setFocused(false);
720
837
  }
721
- }, children: [questionnaireData && !questionnaireDismissed && !questionnaireData.inline && (_jsx(Questionnaire, { data: questionnaireData, onChange: handleFormChange, onCancel: handleFormCancel }, questionnaireKey)), _jsx(FormField, { label: t('message_pega_gen_ai_coach'), labelHidden: true, labelFor: composerId, info: conversationError || undefined, status: conversationError ? 'error' : undefined, children: _jsx(StyledGenAIFormControl, { focused: (!questionnaireData || questionnaireDismissed) && focused, status: conversationError ? 'error' : undefined, children: _jsxs(Flex, { container: { direction: 'column', gap: 0.25 }, children: [_jsx(StyledGenAITextArea, { id: composerId, ref: textAreaRef, value: interimMessage ? `${message}${interimMessage}` : message, placeholder: t('write_message'), onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: () => {
838
+ }, children: [questionnaireData && !questionnaireDismissed && !questionnaireData.inline && (_jsx(Questionnaire, { data: questionnaireData, onChange: handleFormChange, onCancel: handleFormCancel }, questionnaireKey)), _jsx(FormField, { label: t('message_pega_gen_ai_coach'), labelHidden: true, labelFor: composerId, info: conversationError || undefined, status: conversationError ? 'error' : undefined, children: _jsx(StyledGenAIFormControl, { focused: (!questionnaireData || questionnaireDismissed) && focused, status: conversationError ? 'error' : undefined, children: _jsxs(Flex, { container: { direction: 'column', gap: 0.25 }, children: [_jsx(StyledGenAITextArea, { id: composerId, ref: textAreaRef, value: interimMessage ? `${message}${interimMessage}` : message, placeholder: simplifiedAgent ? t('ask_anything', [selectedCoach ?? '']) : t('write_message'), onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: () => {
722
839
  if (active)
723
840
  stop();
724
- }, autoResize: true }), _jsxs(Flex, { container: {
841
+ }, autoResize: true, simplified: simplifiedAgent }), _jsxs(Flex, { container: {
725
842
  direction: 'row',
726
843
  justify: 'between',
727
844
  gap: 1,
@@ -763,13 +880,13 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
763
880
  return (_jsx(StyledStopGeneratingButton, { variant: 'primary', icon: true, label: t('stop'), "aria-label": t('stop'), onClick: () => {
764
881
  textAreaRef.current?.focus();
765
882
  onStopFn?.();
766
- }, children: _jsx(Icon, { name: 'square-solid' }) }));
883
+ }, simplified: simplifiedAgent, children: _jsx(Icon, { name: 'square-solid' }) }));
767
884
  }
768
885
  const isLoading = latestMessage &&
769
886
  isCoachMessage(latestMessage) &&
770
887
  latestMessage.loading &&
771
888
  !latestMessage.error;
772
- const sendButton = (_jsx(StyledSendButton, { variant: 'primary', onClick: isCreatingConversation ? undefined : handleSendMessage, icon: true, label: t('send'), "aria-label": t('send_message'), children: _jsx(Icon, { name: 'send-solid' }) }));
889
+ const sendButton = (_jsx(StyledSendButton, { variant: 'primary', onClick: isCreatingConversation ? undefined : handleSendMessage, icon: true, label: t('send'), "aria-label": t('send_message'), simplified: simplifiedAgent, children: _jsx(Icon, { name: 'send-solid' }) }));
773
890
  if (isLoading) {
774
891
  if (isCreatingConversation) {
775
892
  return sendButton;
@@ -786,15 +903,22 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
786
903
  const isCompact = variant.placement === 'fullpage' &&
787
904
  !fullScreen &&
788
905
  !isInLandingPageUtilities &&
789
- messages.length === 0;
906
+ messages.length === 0 &&
907
+ !(simplifiedAgent && loading && conversationHistory);
790
908
  const fullPageAndInitialScreen = (fullScreen || (variant.placement === 'fullpage' && !isInLandingPageUtilities)) &&
791
909
  messages.length === 0;
792
- const renderTextArea = fullPageAndInitialScreen ? null : genAIFooter;
793
- const GenAICoachElement = (_jsx(_Fragment, { children: ((isInUtilities(variant) && variant.state !== 'minimized') || !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column' }, as: StyledFlexWrapper, children: [caseWorkflow && _jsx(CaseWorkflow, { ...caseWorkflow }), _jsx(Flex, { as: StyledMessagesContainer, ref: setMessageContainerRef, withSuggestionCards: !loading && !error && messages.length === 0 && !!suggestionCardsView, container: loading || error
910
+ const renderTextArea = agentInBanner || !fullPageAndInitialScreen ? genAIFooter : null;
911
+ const GenAICoachElement = (_jsx(_Fragment, { children: ((isInUtilities(variant) && variant.state !== 'minimized') || !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column' }, as: StyledFlexWrapper, isExpanded: agentInBanner && agentExpanded, children: [caseWorkflow && _jsx(CaseWorkflow, { ...caseWorkflow }), _jsx(Flex, { as: StyledMessagesContainer, ref: setMessageContainerRef, withSuggestionCards: !loading && !error && messages.length === 0 && !!suggestionCardsView, container: loading || error
794
912
  ? { direction: 'column', pad: [0, 2], justify: 'center' }
795
913
  : { direction: 'column', pad: [0, 2] }, ...(!loading && !error && messages.length === 0 && suggestionCardsView
796
914
  ? {}
797
- : { item: { grow: 1 } }), onScroll: updateScrollStateOnScrollEvent, children: loading || error ? (_jsx(Flex, { container: { justify: 'center', alignItems: 'center' }, children: loading ? (_jsx(Progress, { variant: 'ring', placement: 'block', message: typeof loading === 'string' ? loading : t('loading') })) : (_jsx(ErrorState, { message: error })) })) : (_jsx(_Fragment, { children: messages.length === 0 ? (_jsxs(Flex, { as: StyledInitialMessageContainer, container: {
915
+ : { item: { grow: 1 } }), onScroll: updateScrollStateOnScrollEvent, children: loading || error ? (_jsx(Flex, { container: { justify: 'center', alignItems: 'center' }, children: loading ? (_jsx(ThemeOverride, { theme: {
916
+ base: {
917
+ palette: {
918
+ 'primary-background': theme.components.agent.background
919
+ }
920
+ }
921
+ }, children: _jsx(Progress, { variant: 'ring', placement: 'block', message: typeof loading === 'string' ? loading : t('loading') }) })) : (_jsx(ErrorState, { message: error })) })) : (_jsx(_Fragment, { children: (agentInBanner ? showInitialScreen : messages.length === 0) ? (_jsxs(Flex, { as: StyledInitialMessageContainer, container: {
798
922
  justify: suggestionCardsView ? undefined : 'center',
799
923
  direction: 'column',
800
924
  alignItems: 'center',
@@ -805,9 +929,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
805
929
  showSalutation && (_jsxs(Flex, { container: {
806
930
  direction: 'column',
807
931
  alignItems: 'center',
808
- gap: 2,
809
- pad: [0, 2]
810
- }, children: [_jsx(AgentIcon, {}), _jsx(Text, { variant: 'h3', as: StyledSalutation, children: salutation ?? t('welcome_text') })] })), initialSuggestedMessages && initialSuggestedMessages.length > 0 && (_jsx(Grid, { as: StyledInitialMessageGrid, container: { cols: getGridColumns(), gap: 1.5 }, children: initialSuggestedMessages.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
932
+ gap: simplifiedAgent ? 2.5 : 2,
933
+ pad: simplifiedAgent ? [0, 2, 1, 2] : [0, 2]
934
+ }, 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 => {
811
935
  if (guidedMode) {
812
936
  onSend({
813
937
  id: initialMessage.id,
@@ -819,7 +943,11 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
819
943
  }
820
944
  isUserTriggered.current = true;
821
945
  textAreaRef.current?.focus();
822
- }, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen && !guidedMode && !suggestionCardsView && genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
946
+ }, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen &&
947
+ !guidedMode &&
948
+ !suggestionCardsView &&
949
+ !agentInBanner &&
950
+ genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, simplified: simplifiedAgent, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
823
951
  mouseTriggeredFocusRef.current = true;
824
952
  const target = e.target instanceof Element ? e.target : null;
825
953
  const clickedMessage = getMessageContainingElement(target);
@@ -911,11 +1039,13 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
911
1039
  }
912
1040
  }
913
1041
  }, children: messages.map(item => {
914
- const messageProps = isCoachMessage(item)
915
- ? {
1042
+ let messageProps;
1043
+ if (isCoachMessage(item)) {
1044
+ messageProps = {
916
1045
  ...item,
917
1046
  suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
918
1047
  onSend,
1048
+ showSenderInfo: simplifiedAgent ? showNextCoachSender.current : undefined,
919
1049
  onSubmit: item.isToolConfirmation
920
1050
  ? (tools) => {
921
1051
  onSend({
@@ -925,13 +1055,21 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
925
1055
  });
926
1056
  }
927
1057
  : undefined
928
- }
929
- : item;
1058
+ };
1059
+ showNextCoachSender.current = false;
1060
+ }
1061
+ else if (isUserMessage(item) && simplifiedAgent) {
1062
+ showNextCoachSender.current = true;
1063
+ messageProps = { ...item, userName: operatorName };
1064
+ }
1065
+ else {
1066
+ messageProps = item;
1067
+ }
930
1068
  return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
931
1069
  if (isCoachMessage(item)) {
932
1070
  setAnimationInitialCursorPos(animatedTillCursor);
933
1071
  }
934
- }, ...(prevFullScreen !== fullScreen ? { animationInitialCursorPos } : {}) }));
1072
+ }, simplifiedAgent: simplifiedAgent, ...(prevFullScreen !== fullScreen ? { animationInitialCursorPos } : {}) }));
935
1073
  }) })) })) }), showScrollToBottom && (_jsx(StyledScrollButton, { ref: scrollButtonRef, icon: true, onClick: handleScrollToBottomClick, ariaLabel: 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') ||
936
1074
  !isInUtilities(variant)) &&
937
1075
  !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') ||
@@ -1001,7 +1139,11 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1001
1139
  focusTextArea.current = true;
1002
1140
  conversationHistory.onDismiss();
1003
1141
  }, inFullPage: !condition, ref: historyViewRef }));
1004
- return (_jsxs(Flex, { ...restProps, container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, fullScreen: fullScreen, isCompact: isCompact, isPortalAgent: isPortalAgent, ref: genAICoachRef, children: [_jsx(Flex, { container: { justify: 'between', alignItems: 'center', pad: [1.5, 2, 0.5] }, children: headerContent }), condition ? (_jsx(_Fragment, { children: conversationHistory ? historyView : GenAICoachElement })) : (_jsxs(Grid, { container: { gap: 0.5, cols: '2fr 3fr' }, as: StyledGridContainer, conversationHistory: !!conversationHistory, children: [historyView, GenAICoachElement] })), lightboxPreviewProps && _jsx(Lightbox, { ...lightboxPreviewProps })] }));
1142
+ 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: {
1143
+ justify: 'between',
1144
+ alignItems: 'center',
1145
+ pad: simplifiedAgent ? [0, 2, 0.5] : [1.5, 2, 0.5]
1146
+ }, children: headerContent }), condition ? (_jsx(_Fragment, { children: conversationHistory ? historyView : GenAICoachElement })) : (_jsxs(Grid, { container: { gap: 0.5, cols: '2fr 3fr' }, as: StyledGridContainer, conversationHistory: !!conversationHistory, children: [historyView, GenAICoachElement] })), lightboxPreviewProps && _jsx(Lightbox, { ...lightboxPreviewProps })] }));
1005
1147
  };
1006
1148
  const GenAICoach = (props) => (_jsx(Toaster, { children: _jsx(StyledFullscreenWrapper, { children: _jsx(GenAICoachContent, { ...props }) }) }));
1007
1149
  export default withTestIds(GenAICoach, getGenAICoachTestIds);