@pega/cosmos-react-work 9.8.1 → 9.10.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":"AAuGA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AA8BhF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAypDyB,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;iCAm2DyB,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
- const streamBufferLh = 5;
104
+ const streamBufferLh = simplifiedAgent ? 15 : 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);
@@ -444,6 +472,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
444
472
  isCoachMessageLoading ||
445
473
  (latestMessage && isCoachMessage(latestMessage) && latestMessage.isToolConfirmation))
446
474
  return;
475
+ if (simplifiedAgent) {
476
+ userInitiatedSendRef.current = true;
477
+ }
447
478
  onSend({
448
479
  id: createUID(),
449
480
  message,
@@ -481,11 +512,33 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
481
512
  } }));
482
513
  }, [coachOptions, selectedCoach, isPortalAgent, pagePanel?.visible]);
483
514
  const headerContent = useMemo(() => {
515
+ if (simplifiedAgent && showInitialScreen)
516
+ return null;
484
517
  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: () => {
485
518
  variant.onStateChange('maximized');
486
519
  isUserTriggered.current = true;
487
- }, 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' }) }))] })] }));
488
- }, [variant, coachOptions, activeCases, actions, allowFullScreen, onNewChat]);
520
+ }, 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: () => {
521
+ if (simplifiedAgent && genAICoachRef.current) {
522
+ prevExpandedHeightRef.current =
523
+ genAICoachRef.current.getBoundingClientRect().height;
524
+ }
525
+ userInitiatedNewChatRef.current = true;
526
+ if (simplifiedAgent && conversationHistory) {
527
+ conversationHistory.onDismiss();
528
+ }
529
+ onNewChat?.();
530
+ }, 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' }) }))] })] }));
531
+ }, [
532
+ variant,
533
+ coachOptions,
534
+ activeCases,
535
+ actions,
536
+ allowFullScreen,
537
+ onNewChat,
538
+ simplifiedAgent,
539
+ showInitialScreen,
540
+ messages.length
541
+ ]);
489
542
  const getMessageContainingElement = (element) => {
490
543
  if (element)
491
544
  return Array.from(messageEls.values()).find(el => el && el.contains(element));
@@ -530,6 +583,70 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
530
583
  textAreaRef.current?.focus();
531
584
  }
532
585
  }, [draftMessage, suggestionCardsView]);
586
+ useLayoutEffect(() => {
587
+ if (!agentInBanner ||
588
+ !genAICoachRef.current ||
589
+ messages.length !== 0 ||
590
+ (loading && conversationHistory))
591
+ return;
592
+ const el = genAICoachRef.current;
593
+ const currentHeight = el.getBoundingClientRect().height;
594
+ const storedHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
595
+ if (storedHeight > 0 && Math.abs(currentHeight - storedHeight) > scrollTolerancePx)
596
+ return;
597
+ el.style.removeProperty('--compact-height');
598
+ const naturalHeight = el.getBoundingClientRect().height;
599
+ el.style.setProperty('--compact-height', `${naturalHeight}px`);
600
+ });
601
+ useLayoutEffect(() => {
602
+ if (!agentInBanner || messages.length !== 0)
603
+ return;
604
+ if (!userInitiatedNewChatRef.current || !genAICoachRef.current)
605
+ return;
606
+ userInitiatedNewChatRef.current = false;
607
+ const el = genAICoachRef.current;
608
+ const fromHeight = prevExpandedHeightRef.current;
609
+ const toHeight = parseFloat(el.style.getPropertyValue('--compact-height')) || 0;
610
+ if (!fromHeight || !toHeight)
611
+ return;
612
+ el.style.height = `${fromHeight}px`;
613
+ el.style.transition = 'none';
614
+ const removeListener = onHeightTransitionEnd(el, () => {
615
+ el.style.removeProperty('height');
616
+ prevExpandedHeightRef.current = 0;
617
+ });
618
+ const rafId = requestAnimationFrame(() => {
619
+ el.getBoundingClientRect();
620
+ el.style.removeProperty('transition');
621
+ el.style.height = `${toHeight}px`;
622
+ });
623
+ return () => {
624
+ cancelAnimationFrame(rafId);
625
+ removeListener();
626
+ };
627
+ }, [messages.length, agentInBanner]);
628
+ useEffect(() => {
629
+ if (!agentInBanner)
630
+ return;
631
+ if (messages.length === 0) {
632
+ if (!(loading && conversationHistory)) {
633
+ setShowInitialScreen(true);
634
+ }
635
+ userInitiatedSendRef.current = false;
636
+ return;
637
+ }
638
+ if (!showInitialScreen)
639
+ return;
640
+ if (!userInitiatedSendRef.current) {
641
+ setShowInitialScreen(false);
642
+ return;
643
+ }
644
+ const timer = setTimeout(() => {
645
+ setShowInitialScreen(false);
646
+ userInitiatedSendRef.current = false;
647
+ }, bannerTransitionMs);
648
+ return () => clearTimeout(timer);
649
+ }, [messages.length, agentInBanner, showInitialScreen]);
533
650
  useEffect(() => {
534
651
  if (isUserTriggered.current) {
535
652
  if (isInUtilities(variant) &&
@@ -719,10 +836,10 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
719
836
  if (!(e.relatedTarget instanceof Node) || !e.currentTarget.contains(e.relatedTarget)) {
720
837
  setFocused(false);
721
838
  }
722
- }, 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: () => {
839
+ }, 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: () => {
723
840
  if (active)
724
841
  stop();
725
- }, autoResize: true }), _jsxs(Flex, { container: {
842
+ }, autoResize: true, simplified: simplifiedAgent }), _jsxs(Flex, { container: {
726
843
  direction: 'row',
727
844
  justify: 'between',
728
845
  gap: 1,
@@ -764,13 +881,13 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
764
881
  return (_jsx(StyledStopGeneratingButton, { variant: 'primary', icon: true, label: t('stop'), "aria-label": t('stop'), onClick: () => {
765
882
  textAreaRef.current?.focus();
766
883
  onStopFn?.();
767
- }, children: _jsx(Icon, { name: 'square-solid' }) }));
884
+ }, simplified: simplifiedAgent, children: _jsx(Icon, { name: 'square-solid' }) }));
768
885
  }
769
886
  const isLoading = latestMessage &&
770
887
  isCoachMessage(latestMessage) &&
771
888
  latestMessage.loading &&
772
889
  !latestMessage.error;
773
- 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' }) }));
890
+ 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' }) }));
774
891
  if (isLoading) {
775
892
  if (isCreatingConversation) {
776
893
  return sendButton;
@@ -787,15 +904,22 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
787
904
  const isCompact = variant.placement === 'fullpage' &&
788
905
  !fullScreen &&
789
906
  !isInLandingPageUtilities &&
790
- messages.length === 0;
907
+ messages.length === 0 &&
908
+ !(simplifiedAgent && loading && conversationHistory);
791
909
  const fullPageAndInitialScreen = (fullScreen || (variant.placement === 'fullpage' && !isInLandingPageUtilities)) &&
792
910
  messages.length === 0;
793
- const renderTextArea = fullPageAndInitialScreen ? null : genAIFooter;
794
- 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
911
+ const renderTextArea = agentInBanner || !fullPageAndInitialScreen ? genAIFooter : null;
912
+ 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
795
913
  ? { direction: 'column', pad: [0, 2], justify: 'center' }
796
914
  : { direction: 'column', pad: [0, 2] }, ...(!loading && !error && messages.length === 0 && suggestionCardsView
797
915
  ? {}
798
- : { 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: {
916
+ : { item: { grow: 1 } }), onScroll: updateScrollStateOnScrollEvent, children: loading || error ? (_jsx(Flex, { container: { justify: 'center', alignItems: 'center' }, children: loading ? (_jsx(ThemeOverride, { theme: {
917
+ base: {
918
+ palette: {
919
+ 'primary-background': theme.components.agent.background
920
+ }
921
+ }
922
+ }, 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: {
799
923
  justify: suggestionCardsView ? undefined : 'center',
800
924
  direction: 'column',
801
925
  alignItems: 'center',
@@ -806,9 +930,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
806
930
  showSalutation && (_jsxs(Flex, { container: {
807
931
  direction: 'column',
808
932
  alignItems: 'center',
809
- gap: 2,
810
- pad: [0, 2]
811
- }, 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 => {
933
+ gap: simplifiedAgent ? 2.5 : 2,
934
+ 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 => {
812
936
  if (guidedMode) {
813
937
  onSend({
814
938
  id: initialMessage.id,
@@ -820,7 +944,11 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
820
944
  }
821
945
  isUserTriggered.current = true;
822
946
  textAreaRef.current?.focus();
823
- }, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen && !guidedMode && !suggestionCardsView && genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
947
+ }, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen &&
948
+ !guidedMode &&
949
+ !suggestionCardsView &&
950
+ !agentInBanner &&
951
+ genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, simplified: simplifiedAgent, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
824
952
  mouseTriggeredFocusRef.current = true;
825
953
  const target = e.target instanceof Element ? e.target : null;
826
954
  const clickedMessage = getMessageContainingElement(target);
@@ -912,11 +1040,13 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
912
1040
  }
913
1041
  }
914
1042
  }, children: messages.map(item => {
915
- const messageProps = isCoachMessage(item)
916
- ? {
1043
+ let messageProps;
1044
+ if (isCoachMessage(item)) {
1045
+ messageProps = {
917
1046
  ...item,
918
1047
  suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
919
1048
  onSend,
1049
+ showSenderInfo: simplifiedAgent ? showNextCoachSender.current : undefined,
920
1050
  onSubmit: item.isToolConfirmation
921
1051
  ? (tools) => {
922
1052
  onSend({
@@ -926,13 +1056,21 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
926
1056
  });
927
1057
  }
928
1058
  : undefined
929
- }
930
- : item;
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
+ }
931
1069
  return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
932
1070
  if (isCoachMessage(item)) {
933
1071
  setAnimationInitialCursorPos(animatedTillCursor);
934
1072
  }
935
- }, ...(prevFullScreen !== fullScreen ? { animationInitialCursorPos } : {}) }));
1073
+ }, simplifiedAgent: simplifiedAgent, ...(prevFullScreen !== fullScreen ? { animationInitialCursorPos } : {}) }));
936
1074
  }) })) })) }), 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') ||
937
1075
  !isInUtilities(variant)) &&
938
1076
  !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') ||
@@ -1002,7 +1140,11 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1002
1140
  focusTextArea.current = true;
1003
1141
  conversationHistory.onDismiss();
1004
1142
  }, inFullPage: !condition, ref: historyViewRef }));
1005
- 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 })] }));
1143
+ 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: {
1144
+ justify: 'between',
1145
+ alignItems: 'center',
1146
+ pad: simplifiedAgent ? [0, 2, 0.5] : [1.5, 2, 0.5]
1147
+ }, 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 })] }));
1006
1148
  };
1007
1149
  const GenAICoach = (props) => (_jsx(Toaster, { children: _jsx(StyledFullscreenWrapper, { children: _jsx(GenAICoachContent, { ...props }) }) }));
1008
1150
  export default withTestIds(GenAICoach, getGenAICoachTestIds);