@pega/cosmos-react-work 9.30.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":"AA4GA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AAyChF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAi4DyB,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, StyledSimplifiedInitialMessageGrid } 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;
@@ -869,7 +865,7 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
869
865
  justify: 'between',
870
866
  gap: 1,
871
867
  pad: [undefined, 1, 1, 1]
872
- }, 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: {
873
869
  items: suggestions,
874
870
  onItemClick: id => {
875
871
  const selected = menuHelpers.getItem(suggestions, id);
@@ -930,7 +926,7 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
930
926
  !fullScreen &&
931
927
  !isInLandingPageUtilities &&
932
928
  messages.length === 0 &&
933
- !(simplifiedAgent && loading && conversationHistory);
929
+ !(agentInBanner && historyOpen);
934
930
  const fullPageAndInitialScreen = (fullScreen || (variant.placement === 'fullpage' && !isInLandingPageUtilities)) &&
935
931
  messages.length === 0;
936
932
  const renderTextArea = agentInBanner || !fullPageAndInitialScreen ? genAIFooter : null;
@@ -961,7 +957,7 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
961
957
  !guidedMode &&
962
958
  !suggestionCardsView &&
963
959
  !agentInBanner &&
964
- 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) => {
965
961
  mouseTriggeredFocusRef.current = true;
966
962
  const target = e.target instanceof Element ? e.target : null;
967
963
  const clickedMessage = getMessageContainingElement(target);
@@ -1052,41 +1048,41 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1052
1048
  }
1053
1049
  }
1054
1050
  }
1055
- }, children: messages.map((item, index) => {
1056
- let messageProps;
1057
- if (isCoachMessage(item)) {
1058
- messageProps = {
1059
- ...item,
1060
- suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
1061
- onSend,
1062
- showSenderInfo: simplifiedAgent ? showNextCoachSender.current : undefined,
1063
- onSubmit: item.isToolConfirmation
1064
- ? (tools) => {
1065
- onSend({
1066
- ...item,
1067
- message: typeof item.message === 'string' ? item.message : '',
1068
- tools
1069
- });
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);
1070
1081
  }
1071
- : undefined
1072
- };
1073
- showNextCoachSender.current = false;
1074
- }
1075
- else if (isUserMessage(item) && simplifiedAgent) {
1076
- showNextCoachSender.current = true;
1077
- messageProps = { ...item, userName: operatorName };
1078
- }
1079
- else {
1080
- messageProps = item;
1081
- }
1082
- return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
1083
- if (isCoachMessage(item)) {
1084
- setAnimationInitialCursorPos(animatedTillCursor);
1085
- }
1086
- }, simplifiedAgent: simplifiedAgent, ...(prevFullScreen !== undefined && prevFullScreen !== fullScreen
1087
- ? { animationInitialCursorPos }
1088
- : {}) }, conversationId ? `${conversationId}:${index}` : index));
1089
- }) })) })) }), 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') ||
1090
1086
  !isInUtilities(variant)) &&
1091
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') ||
1092
1088
  !isInUtilities(variant)) &&
@@ -1153,6 +1149,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
1153
1149
  conversationHistory.onItemClick?.(selectedConversationId);
1154
1150
  }, onDismiss: () => {
1155
1151
  focusTextArea.current = true;
1152
+ if (agentInBanner && messages.length === 0 && genAICoachRef.current) {
1153
+ prevHeightRef.current = genAICoachRef.current.getBoundingClientRect().height;
1154
+ }
1156
1155
  conversationHistory.onDismiss();
1157
1156
  }, inFullPage: !condition, ref: historyViewRef }));
1158
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: {