Skip to content

Commit 8f7b932

Browse files
authored
[Agent Builder] - Disable "Open in full screen" before conversation persistence (elastic#267699)
## Summary Fixes a bug where navigating to the full-screen chat from the embedded flyout immediately after starting a new conversation opens a new empty session instead of the current one. This occurred because the `conversationId` was not yet persisted by the server. This PR addresses the issue by disabling the "Open Full Screen" menu item until a stable `conversationId` is available. ### What was changed: * **UI/UX:** Disabled the `AgentBuilderFullScreenMenuItem` while the conversation is being created (no stable `conversationId` yet). * **Tooltip:** Wrapped the disabled `EuiContextMenuItem` in an `EuiToolTip` (using a wrapper `span` to bypass EUI pointer-event limitations on disabled items) to explain to users why the action is temporarily unavailable. * **Guard clause:** Updated `handleOpenFullScreen` in `more_actions_button.tsx` to early return if `conversationId` is missing, preventing inconsistent routing. ### How to test: **Manual testing steps:** 1. Open the Agent Builder embedded flyout. 2. Start a new conversation and immediately open the "More Actions" (...) menu. 3. Observe that the "Open Full Screen" button is **disabled** and shows a tooltip when hovered. 4. Wait for the server response (until the `conversationId` is persisted). 5. Observe that the button becomes **enabled**. 6. Click "Open Full Screen" and confirm it successfully navigates to the current conversation context (URL should contain the correct `conversationId`).
1 parent 92abf6c commit 8f7b932

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • x-pack/platform/plugins/shared/agent_builder/public/application/components/conversations/conversation_header

x-pack/platform/plugins/shared/agent_builder/public/application/components/conversations/conversation_header/more_actions_button.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
EuiPopover,
1212
EuiContextMenuPanel,
1313
EuiSpacer,
14+
EuiToolTip,
1415
} from '@elastic/eui';
1516
import { i18n } from '@kbn/i18n';
1617
import React, { useCallback, useMemo, useState } from 'react';
@@ -54,6 +55,12 @@ const fullscreenLabels = {
5455
fullScreen: i18n.translate('xpack.agentBuilder.conversationActions.fullScreen', {
5556
defaultMessage: 'Open in full screen',
5657
}),
58+
fullScreenDisabledTooltip: i18n.translate(
59+
'xpack.agentBuilder.conversationActions.fullScreenDisabledTooltip',
60+
{
61+
defaultMessage: 'Full-screen mode is available once this conversation has been created.',
62+
}
63+
),
5764
addToDataset: i18n.translate('xpack.agentBuilder.conversationActions.addToDataset', {
5865
defaultMessage: 'Add conversation to dataset',
5966
}),
@@ -147,6 +154,7 @@ export const MoreActionsButton: React.FC<MoreActionsButtonProps> = ({ onCloseSid
147154

148155
const handleOpenFullScreen = useCallback(() => {
149156
if (!application) return;
157+
if (!conversationId) return;
150158

151159
setIsPopoverOpen(false);
152160
onCloseSidebar?.();
@@ -158,6 +166,17 @@ export const MoreActionsButton: React.FC<MoreActionsButtonProps> = ({ onCloseSid
158166
navigateToAgentBuilderUrl(path);
159167
}, [application, agentId, conversationId, navigateToAgentBuilderUrl, onCloseSidebar]);
160168

169+
const fullScreenMenuItemLabel = useMemo(() => {
170+
if (conversationId) {
171+
return fullscreenLabels.fullScreen;
172+
}
173+
return (
174+
<EuiToolTip content={fullscreenLabels.fullScreenDisabledTooltip}>
175+
<span tabIndex={0}>{fullscreenLabels.fullScreen}</span>
176+
</EuiToolTip>
177+
);
178+
}, [conversationId]);
179+
161180
const addToDatasetMenuItem = showAddToDatasetItem
162181
? [
163182
<EuiContextMenuItem
@@ -189,10 +208,11 @@ export const MoreActionsButton: React.FC<MoreActionsButtonProps> = ({ onCloseSid
189208
key="full-screen"
190209
icon="fullScreen"
191210
size="s"
211+
disabled={!conversationId}
192212
data-test-subj="agentBuilderFullScreenMenuItem"
193213
onClick={handleOpenFullScreen}
194214
>
195-
{fullscreenLabels.fullScreen}
215+
{fullScreenMenuItemLabel}
196216
</EuiContextMenuItem>,
197217
]
198218
: []),

0 commit comments

Comments
 (0)