@redocly/theme 0.59.0-next.1 → 0.59.0-next.11
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.
- package/LICENSE +7 -1
- package/lib/components/Accordion/Accordion.js +17 -7
- package/lib/components/Accordion/AccordionBody.js +17 -7
- package/lib/components/Admonition/Admonition.js +17 -7
- package/lib/components/Badge/Badge.js +17 -7
- package/lib/components/Breadcrumbs/Breadcrumb.js +17 -7
- package/lib/components/Breadcrumbs/BreadcrumbDropdown.js +17 -7
- package/lib/components/Button/Button.js +17 -7
- package/lib/components/Buttons/AIAssistantButton.js +23 -9
- package/lib/components/Buttons/ConnectMCPButton.d.ts +8 -0
- package/lib/components/Buttons/ConnectMCPButton.js +145 -0
- package/lib/components/Buttons/CopyButton.js +17 -7
- package/lib/components/Buttons/variables.d.ts +1 -0
- package/lib/components/Buttons/variables.js +42 -2
- package/lib/components/Catalog/Catalog.d.ts +6 -0
- package/lib/components/Catalog/Catalog.js +7 -6
- package/lib/components/Catalog/CatalogEntities.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.js +1 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +17 -7
- package/lib/components/Catalog/CatalogEntityIcon.js +2 -1
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.js +4 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +17 -7
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +17 -7
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.js +17 -7
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.js +17 -7
- package/lib/components/Catalog/CatalogSortButton.js +17 -7
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +17 -7
- package/lib/components/Catalog/CatalogViewModeToggle.js +17 -7
- package/lib/components/Catalog/variables.js +1 -1
- package/lib/components/CatalogClassic/CatalogClassicActions.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicCard.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicHighlight.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicVirtualizedGroups.js +17 -7
- package/lib/components/CodeBlock/CodeBlock.js +17 -7
- package/lib/components/CodeBlock/CodeBlockContainer.js +17 -7
- package/lib/components/CodeBlock/CodeBlockTabs.js +17 -7
- package/lib/components/Dropdown/Dropdown.d.ts +16 -2
- package/lib/components/Dropdown/Dropdown.js +22 -12
- package/lib/components/Dropdown/DropdownMenuItem.js +17 -7
- package/lib/components/Feedback/Comment.js +17 -7
- package/lib/components/Feedback/Feedback.js +17 -7
- package/lib/components/Feedback/Mood.js +17 -7
- package/lib/components/Feedback/Rating.js +17 -7
- package/lib/components/Feedback/Reasons.js +17 -7
- package/lib/components/Feedback/Scale.js +17 -7
- package/lib/components/Feedback/Sentiment.js +17 -7
- package/lib/components/Feedback/Stars.js +17 -7
- package/lib/components/Filter/FilterContent.js +17 -7
- package/lib/components/Filter/FilterInput.js +17 -7
- package/lib/components/Image/Image.js +17 -7
- package/lib/components/JsonViewer/JsonViewer.js +17 -7
- package/lib/components/JsonViewer/helpers.js +17 -7
- package/lib/components/LastUpdated/LastUpdated.js +17 -7
- package/lib/components/Link/Link.js +17 -7
- package/lib/components/Markdown/Markdown.js +17 -7
- package/lib/components/Marker/Marker.js +17 -7
- package/lib/components/Menu/MenuContainer.js +17 -7
- package/lib/components/Menu/MenuItem.js +18 -8
- package/lib/components/Menu/MenuMobile.js +17 -7
- package/lib/components/Navbar/NavbarItem.js +3 -3
- package/lib/components/PageActions/PageActions.js +21 -8
- package/lib/components/PageActions/variables.js +2 -0
- package/lib/components/PageNavigation/NextButton.js +17 -7
- package/lib/components/Panel/Panel.js +17 -7
- package/lib/components/Panel/PanelBody.js +17 -7
- package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +17 -7
- package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +1 -2
- package/lib/components/Search/SearchAiActionButtons.d.ts +10 -0
- package/lib/components/Search/SearchAiActionButtons.js +43 -0
- package/lib/components/Search/SearchAiConversationInput.d.ts +3 -1
- package/lib/components/Search/SearchAiConversationInput.js +56 -14
- package/lib/components/Search/SearchAiDialog.d.ts +3 -6
- package/lib/components/Search/SearchAiDialog.js +37 -16
- package/lib/components/Search/SearchAiMessage.d.ts +9 -5
- package/lib/components/Search/SearchAiMessage.js +146 -22
- package/lib/components/Search/SearchAiNegativeFeedbackForm.d.ts +8 -0
- package/lib/components/Search/SearchAiNegativeFeedbackForm.js +169 -0
- package/lib/components/Search/SearchDialog.js +53 -12
- package/lib/components/Search/SearchFilter.js +17 -7
- package/lib/components/Search/SearchGroups.js +19 -9
- package/lib/components/Search/SearchHighlight.js +17 -7
- package/lib/components/Search/SearchItem.js +17 -7
- package/lib/components/Search/SearchRecent.js +17 -7
- package/lib/components/Search/SearchShortcut.js +17 -7
- package/lib/components/Search/SearchSuggestedPages.js +17 -7
- package/lib/components/Search/SearchTrigger.js +17 -7
- package/lib/components/Search/variables.js +36 -64
- package/lib/components/Segmented/Segmented.d.ts +1 -8
- package/lib/components/Segmented/Segmented.js +20 -8
- package/lib/components/Select/Select.js +17 -7
- package/lib/components/Select/SelectInput.js +18 -8
- package/lib/components/Sidebar/Sidebar.js +17 -7
- package/lib/components/SidebarActions/styled.js +17 -7
- package/lib/components/SkipContent/SkipContent.js +17 -7
- package/lib/components/Switch/Switch.js +17 -7
- package/lib/components/TableOfContent/TableOfContent.js +17 -7
- package/lib/components/Tag/Tag.d.ts +2 -1
- package/lib/components/Tag/Tag.js +67 -18
- package/lib/components/Tag/variables.dark.js +135 -36
- package/lib/components/Tag/variables.js +78 -61
- package/lib/components/Tooltip/Tooltip.js +17 -7
- package/lib/components/VersionPicker/VersionPicker.js +17 -7
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +1 -0
- package/lib/core/constants/mcp.d.ts +1 -0
- package/lib/core/constants/mcp.js +5 -0
- package/lib/core/constants/search.d.ts +5 -4
- package/lib/core/constants/search.js +4 -5
- package/lib/core/contexts/CodeSnippetContext.js +17 -7
- package/lib/core/hooks/index.d.ts +3 -0
- package/lib/core/hooks/index.js +3 -0
- package/lib/core/hooks/menu/use-nested-menu.js +1 -1
- package/lib/core/hooks/search/use-feedback-tooltip.d.ts +6 -0
- package/lib/core/hooks/search/use-feedback-tooltip.js +26 -0
- package/lib/core/hooks/use-connect-mcp-button.d.ts +13 -0
- package/lib/core/hooks/use-connect-mcp-button.js +50 -0
- package/lib/core/hooks/use-mcp-config.d.ts +9 -0
- package/lib/core/hooks/use-mcp-config.js +27 -0
- package/lib/core/hooks/use-page-actions.d.ts +1 -1
- package/lib/core/hooks/use-page-actions.js +98 -95
- package/lib/core/hooks/use-product-picker.js +2 -1
- package/lib/core/hooks/use-tabs.d.ts +3 -2
- package/lib/core/hooks/use-tabs.js +115 -57
- package/lib/core/hooks/use-telemetry-fallback.d.ts +10 -8
- package/lib/core/hooks/use-telemetry-fallback.js +10 -8
- package/lib/core/openapi/index.d.ts +1 -0
- package/lib/core/styles/dark.js +4 -0
- package/lib/core/styles/global.js +5 -0
- package/lib/core/templates/Markdown.js +17 -7
- package/lib/core/types/hooks.d.ts +6 -3
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.js +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/mcp.d.ts +6 -0
- package/lib/core/types/mcp.js +3 -0
- package/lib/core/types/search.d.ts +11 -4
- package/lib/core/types/search.js +6 -0
- package/lib/core/types/segmented.d.ts +12 -0
- package/lib/core/types/segmented.js +3 -0
- package/lib/core/utils/download-code-walkthrough.js +17 -7
- package/lib/core/utils/frontmatter-translate.d.ts +6 -0
- package/lib/core/utils/frontmatter-translate.js +14 -0
- package/lib/core/utils/get-file-icon.js +17 -7
- package/lib/core/utils/index.d.ts +2 -0
- package/lib/core/utils/index.js +2 -0
- package/lib/core/utils/mcp.d.ts +2 -0
- package/lib/core/utils/mcp.js +31 -0
- package/lib/icons/AiStarsGradientIcon/AiStarsGradientIcon.js +44 -4
- package/lib/icons/AiStarsIcon/AiStarsIcon.js +11 -2
- package/lib/icons/ConnectIcon/ConnectIcon.d.ts +9 -0
- package/lib/icons/ConnectIcon/ConnectIcon.js +17 -0
- package/lib/icons/CubeIcon/CubeIcon.d.ts +9 -0
- package/lib/icons/CubeIcon/CubeIcon.js +17 -0
- package/lib/icons/GenericIcon/GenericIcon.js +17 -7
- package/lib/icons/HashtagIcon/HashtagIcon.d.ts +9 -0
- package/lib/icons/HashtagIcon/HashtagIcon.js +22 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.js +4 -7
- package/lib/icons/Spinner/Spinner.js +17 -7
- package/lib/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.d.ts +9 -0
- package/lib/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.js +34 -0
- package/lib/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.d.ts +9 -0
- package/lib/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.js +34 -0
- package/lib/icons/VSCodeIcon/VSCodeIcon.d.ts +9 -0
- package/lib/icons/VSCodeIcon/VSCodeIcon.js +17 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -7
- package/lib/layouts/OIDCForbidden.js +17 -7
- package/lib/layouts/ThreePanelLayout.js +17 -7
- package/lib/markdoc/components/Cards/Card.js +1 -28
- package/lib/markdoc/components/Cards/Cards.js +17 -7
- package/lib/markdoc/components/CodeGroup/CodeGroup.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/Input.js +17 -7
- package/lib/markdoc/components/ConnectMCP/ConnectMCP.d.ts +8 -0
- package/lib/markdoc/components/ConnectMCP/ConnectMCP.js +19 -0
- package/lib/markdoc/components/Heading/Heading.js +17 -7
- package/lib/markdoc/components/HtmlBlock/HtmlBlock.js +17 -7
- package/lib/markdoc/components/InlineSvg/InlineSvg.js +17 -7
- package/lib/markdoc/components/MarkdocExample/MarkdocExample.js +17 -7
- package/lib/markdoc/components/Tabs/TabList.d.ts +3 -1
- package/lib/markdoc/components/Tabs/TabList.js +214 -54
- package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -1
- package/lib/markdoc/components/Tabs/Tabs.js +74 -19
- package/lib/markdoc/components/default.d.ts +1 -0
- package/lib/markdoc/components/default.js +1 -0
- package/lib/markdoc/default.d.ts +110 -1
- package/lib/markdoc/default.js +19 -7
- package/lib/markdoc/tags/card.js +0 -1
- package/lib/markdoc/tags/connect-mcp.d.ts +2 -0
- package/lib/markdoc/tags/connect-mcp.js +27 -0
- package/package.json +8 -8
- package/src/components/Buttons/AIAssistantButton.tsx +6 -2
- package/src/components/Buttons/ConnectMCPButton.tsx +180 -0
- package/src/components/Buttons/variables.ts +42 -1
- package/src/components/Catalog/Catalog.tsx +15 -4
- package/src/components/Catalog/CatalogEntity/CatalogEntityInfoBar.tsx +1 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntityIcon.tsx +2 -1
- package/src/components/Catalog/CatalogFilter/CatalogFilter.tsx +5 -0
- package/src/components/Catalog/variables.ts +1 -1
- package/src/components/Dropdown/Dropdown.tsx +84 -79
- package/src/components/Menu/MenuItem.tsx +1 -0
- package/src/components/Navbar/NavbarItem.tsx +6 -5
- package/src/components/PageActions/PageActions.tsx +5 -1
- package/src/components/PageActions/variables.ts +2 -0
- package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +3 -3
- package/src/components/Search/SearchAiActionButtons.tsx +76 -0
- package/src/components/Search/SearchAiConversationInput.tsx +61 -18
- package/src/components/Search/SearchAiDialog.tsx +52 -23
- package/src/components/Search/SearchAiMessage.tsx +172 -43
- package/src/components/Search/SearchAiNegativeFeedbackForm.tsx +210 -0
- package/src/components/Search/SearchDialog.tsx +49 -13
- package/src/components/Search/SearchGroups.tsx +2 -0
- package/src/components/Search/variables.ts +36 -64
- package/src/components/Segmented/Segmented.tsx +15 -20
- package/src/components/Select/SelectInput.tsx +1 -0
- package/src/components/Tag/Tag.tsx +36 -20
- package/src/components/Tag/variables.dark.ts +135 -36
- package/src/components/Tag/variables.ts +78 -61
- package/src/core/constants/index.ts +1 -0
- package/src/core/constants/mcp.ts +1 -0
- package/src/core/constants/search.ts +8 -4
- package/src/core/hooks/index.ts +3 -0
- package/src/core/hooks/menu/use-nested-menu.ts +2 -2
- package/src/core/hooks/search/use-feedback-tooltip.ts +32 -0
- package/src/core/hooks/use-connect-mcp-button.ts +79 -0
- package/src/core/hooks/use-mcp-config.ts +43 -0
- package/src/core/hooks/use-page-actions.ts +148 -126
- package/src/core/hooks/use-product-picker.ts +2 -1
- package/src/core/hooks/use-tabs.ts +168 -86
- package/src/core/hooks/use-telemetry-fallback.ts +10 -8
- package/src/core/openapi/index.ts +1 -0
- package/src/core/styles/dark.ts +4 -0
- package/src/core/styles/global.ts +6 -1
- package/src/core/types/hooks.ts +6 -1
- package/src/core/types/index.ts +1 -0
- package/src/core/types/l10n.ts +14 -0
- package/src/core/types/mcp.ts +8 -0
- package/src/core/types/search.ts +13 -4
- package/src/core/types/segmented.ts +14 -0
- package/src/core/utils/frontmatter-translate.ts +9 -0
- package/src/core/utils/index.ts +2 -0
- package/src/core/utils/mcp.ts +34 -0
- package/src/icons/AiStarsGradientIcon/AiStarsGradientIcon.tsx +13 -4
- package/src/icons/AiStarsIcon/AiStarsIcon.tsx +11 -2
- package/src/icons/ConnectIcon/ConnectIcon.tsx +27 -0
- package/src/icons/CubeIcon/CubeIcon.tsx +27 -0
- package/src/icons/HashtagIcon/HashtagIcon.tsx +23 -0
- package/src/icons/RedoclyIcon/RedoclyIcon.tsx +4 -22
- package/src/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.tsx +38 -0
- package/src/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.tsx +35 -0
- package/src/icons/VSCodeIcon/VSCodeIcon.tsx +29 -0
- package/src/index.ts +1 -0
- package/src/markdoc/components/Cards/Card.tsx +1 -28
- package/src/markdoc/components/ConnectMCP/ConnectMCP.tsx +28 -0
- package/src/markdoc/components/Tabs/TabList.tsx +312 -105
- package/src/markdoc/components/Tabs/Tabs.tsx +136 -11
- package/src/markdoc/components/default.ts +1 -0
- package/src/markdoc/default.ts +2 -0
- package/src/markdoc/tags/card.ts +0 -1
- package/src/markdoc/tags/connect-mcp.ts +25 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { memo, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
|
|
6
|
+
import { FeedbackType, type SearchAiMessageResource } from '@redocly/theme/core/types';
|
|
6
7
|
import { Link } from '@redocly/theme/components/Link/Link';
|
|
7
8
|
import { Tag } from '@redocly/theme/components/Tag/Tag';
|
|
8
9
|
import { AiSearchConversationRole } from '@redocly/theme/core/constants';
|
|
@@ -10,28 +11,72 @@ import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
|
10
11
|
import { Markdown } from '@redocly/theme/components/Markdown/Markdown';
|
|
11
12
|
import { DocumentIcon } from '@redocly/theme/icons/DocumentIcon/DocumentIcon';
|
|
12
13
|
import { AiStarsIcon } from '@redocly/theme/icons/AiStarsIcon/AiStarsIcon';
|
|
14
|
+
import { CheckmarkOutlineIcon } from '@redocly/theme/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon';
|
|
15
|
+
|
|
16
|
+
import { SearchAiActionButtons } from './SearchAiActionButtons';
|
|
17
|
+
import { SearchAiNegativeFeedbackForm } from './SearchAiNegativeFeedbackForm';
|
|
13
18
|
|
|
14
19
|
export type SearchAiMessageProps = {
|
|
15
20
|
role: AiSearchConversationRole;
|
|
16
21
|
content: string;
|
|
17
22
|
isThinking?: boolean;
|
|
18
|
-
resources?:
|
|
19
|
-
url: string;
|
|
20
|
-
title: string;
|
|
21
|
-
}[];
|
|
23
|
+
resources?: SearchAiMessageResource[];
|
|
22
24
|
className?: string;
|
|
25
|
+
messageId?: string;
|
|
26
|
+
feedback?: FeedbackType;
|
|
27
|
+
onFeedbackChange: (messageId: string, feedback: FeedbackType | undefined) => void;
|
|
23
28
|
};
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
function SearchAiMessageComponent({
|
|
26
31
|
role,
|
|
27
32
|
content,
|
|
28
33
|
isThinking,
|
|
29
34
|
resources,
|
|
30
35
|
className,
|
|
36
|
+
messageId,
|
|
37
|
+
feedback,
|
|
38
|
+
onFeedbackChange,
|
|
31
39
|
}: SearchAiMessageProps): JSX.Element {
|
|
32
|
-
const { useMarkdownText, useTranslate } = useThemeHooks();
|
|
40
|
+
const { useMarkdownText, useTranslate, useTelemetry } = useThemeHooks();
|
|
33
41
|
const markDownContent = useMarkdownText(content || '');
|
|
34
42
|
const { translate } = useTranslate();
|
|
43
|
+
const telemetry = useTelemetry();
|
|
44
|
+
const [feedbackSent, setFeedbackSent] = useState(false);
|
|
45
|
+
|
|
46
|
+
const hasResources = !isThinking && resources && resources.length > 0;
|
|
47
|
+
const resourcesCount = resources?.length ?? 0;
|
|
48
|
+
|
|
49
|
+
const showSuccessMessage = feedbackSent && feedback;
|
|
50
|
+
|
|
51
|
+
const sendFeedbackTelemetry = (feedbackValue: FeedbackType, dislikeReason?: string) => {
|
|
52
|
+
if (!messageId) return;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
telemetry.sendSearchAIFeedbackMessage({
|
|
56
|
+
feedback: feedbackValue,
|
|
57
|
+
messageId,
|
|
58
|
+
reason: dislikeReason,
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Error sending feedback', error);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleFeedbackClick = (feedbackValue: FeedbackType, reason?: string) => {
|
|
66
|
+
if (!messageId) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!reason) {
|
|
71
|
+
onFeedbackChange(messageId, feedbackValue);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
sendFeedbackTelemetry(feedbackValue, reason);
|
|
75
|
+
|
|
76
|
+
if (feedbackValue === FeedbackType.Like || reason) {
|
|
77
|
+
setFeedbackSent(true);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
35
80
|
|
|
36
81
|
return (
|
|
37
82
|
<SearchAiMessageWrapper
|
|
@@ -49,46 +94,99 @@ export function SearchAiMessage({
|
|
|
49
94
|
margin="0 var(--spacing-xs) 0 0"
|
|
50
95
|
/>
|
|
51
96
|
)}
|
|
52
|
-
<
|
|
53
|
-
{role
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
<MessageContentWrapper>
|
|
98
|
+
<MessageWrapper role={role}>
|
|
99
|
+
{role === AiSearchConversationRole.ASSISTANT ? (
|
|
100
|
+
<>
|
|
101
|
+
<ResponseText as="div" children={markDownContent} data-testid="response-text" />
|
|
102
|
+
{hasResources && (
|
|
103
|
+
<>
|
|
104
|
+
<ResourcesWrapper data-testid="resources-wrapper">
|
|
105
|
+
<ResourcesTitle data-translation-key="search.ai.resourcesFound">
|
|
106
|
+
{translate('search.ai.resourcesFound.basedOn', 'Based on')} {resourcesCount}{' '}
|
|
107
|
+
{translate('search.ai.resourcesFound.resources', 'resources')}
|
|
108
|
+
</ResourcesTitle>
|
|
109
|
+
<ResourceTagsWrapper>
|
|
110
|
+
{resources?.map((resource, idx) => (
|
|
111
|
+
<Link key={`${resource.url}-${idx}`} to={resource.url} target="_blank">
|
|
112
|
+
<ResourceTag
|
|
113
|
+
borderless
|
|
114
|
+
icon={<DocumentIcon color="--search-ai-resource-tag-icon-color" />}
|
|
115
|
+
>
|
|
116
|
+
{resource.title}
|
|
117
|
+
</ResourceTag>
|
|
118
|
+
</Link>
|
|
119
|
+
))}
|
|
120
|
+
</ResourceTagsWrapper>
|
|
121
|
+
</ResourcesWrapper>
|
|
122
|
+
<FeedbackWrapper>
|
|
123
|
+
<SearchAiActionButtons
|
|
124
|
+
content={content}
|
|
125
|
+
feedback={feedback}
|
|
126
|
+
onFeedback={handleFeedbackClick}
|
|
127
|
+
disabled={feedbackSent}
|
|
128
|
+
/>
|
|
129
|
+
</FeedbackWrapper>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
) : (
|
|
134
|
+
content
|
|
135
|
+
)}
|
|
136
|
+
{isThinking && content.length === 0 && (
|
|
137
|
+
<ThinkingDotsWrapper data-testid="thinking-dots-wrapper">
|
|
138
|
+
<ThinkingDot />
|
|
139
|
+
<ThinkingDot />
|
|
140
|
+
<ThinkingDot />
|
|
141
|
+
</ThinkingDotsWrapper>
|
|
142
|
+
)}
|
|
143
|
+
</MessageWrapper>
|
|
144
|
+
{messageId && feedback === FeedbackType.Dislike && !showSuccessMessage && (
|
|
145
|
+
<SearchAiNegativeFeedbackForm
|
|
146
|
+
messageId={messageId}
|
|
147
|
+
onClose={onFeedbackChange}
|
|
148
|
+
onSubmit={(reason) => handleFeedbackClick(FeedbackType.Dislike, reason)}
|
|
149
|
+
/>
|
|
79
150
|
)}
|
|
80
|
-
{
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
151
|
+
{showSuccessMessage && (
|
|
152
|
+
<SuccessMessageWrapper data-component-name="Search/SearchAiMessage/Success">
|
|
153
|
+
<CheckmarkOutlineIcon size="20px" color="var(--color-success-base)" />
|
|
154
|
+
<SuccessMessageText>
|
|
155
|
+
{translate('search.ai.feedback.thanks', 'Thank you for your feedback!')}
|
|
156
|
+
</SuccessMessageText>
|
|
157
|
+
</SuccessMessageWrapper>
|
|
86
158
|
)}
|
|
87
|
-
</
|
|
159
|
+
</MessageContentWrapper>
|
|
88
160
|
</SearchAiMessageWrapper>
|
|
89
161
|
);
|
|
90
162
|
}
|
|
91
163
|
|
|
164
|
+
function areResourcesEqual(
|
|
165
|
+
prev?: SearchAiMessageResource[],
|
|
166
|
+
next?: SearchAiMessageResource[],
|
|
167
|
+
): boolean {
|
|
168
|
+
if (prev === next) return true;
|
|
169
|
+
|
|
170
|
+
if (!prev || !next || prev.length !== next.length) return false;
|
|
171
|
+
|
|
172
|
+
return prev.every((resource, index) => {
|
|
173
|
+
const nextResource = next[index];
|
|
174
|
+
return resource.url === nextResource.url && resource.title === nextResource.title;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export const SearchAiMessage = memo(SearchAiMessageComponent, (prevProps, nextProps) => {
|
|
179
|
+
return (
|
|
180
|
+
prevProps.role === nextProps.role &&
|
|
181
|
+
prevProps.content === nextProps.content &&
|
|
182
|
+
prevProps.isThinking === nextProps.isThinking &&
|
|
183
|
+
prevProps.messageId === nextProps.messageId &&
|
|
184
|
+
prevProps.feedback === nextProps.feedback &&
|
|
185
|
+
prevProps.onFeedbackChange === nextProps.onFeedbackChange &&
|
|
186
|
+
areResourcesEqual(prevProps.resources, nextProps.resources)
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
92
190
|
const SearchAiMessageWrapper = styled.div<{ role: string }>`
|
|
93
191
|
display: flex;
|
|
94
192
|
flex-direction: row;
|
|
@@ -98,6 +196,14 @@ const SearchAiMessageWrapper = styled.div<{ role: string }>`
|
|
|
98
196
|
role === AiSearchConversationRole.USER ? 'flex-end' : 'flex-start'};
|
|
99
197
|
`;
|
|
100
198
|
|
|
199
|
+
const MessageContentWrapper = styled.div`
|
|
200
|
+
display: flex;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
gap: var(--spacing-sm);
|
|
203
|
+
max-width: 80%;
|
|
204
|
+
min-width: 0;
|
|
205
|
+
`;
|
|
206
|
+
|
|
101
207
|
const ResponseText = styled(Markdown)`
|
|
102
208
|
color: var(--search-ai-text-color);
|
|
103
209
|
font-size: var(--search-ai-text-font-size);
|
|
@@ -120,7 +226,8 @@ const MessageWrapper = styled.div<{ role: string }>`
|
|
|
120
226
|
role === AiSearchConversationRole.USER ? 'var(--spacing-sm)' : 'var(--spacing-xs)'}
|
|
121
227
|
var(--spacing-sm);
|
|
122
228
|
border-radius: var(--border-radius-lg);
|
|
123
|
-
|
|
229
|
+
width: fit-content;
|
|
230
|
+
max-width: 100%;
|
|
124
231
|
word-wrap: break-word;
|
|
125
232
|
white-space: pre-wrap;
|
|
126
233
|
background-color: ${({ role }) =>
|
|
@@ -139,7 +246,13 @@ const ResourcesWrapper = styled.div`
|
|
|
139
246
|
gap: var(--search-ai-resources-gap);
|
|
140
247
|
display: flex;
|
|
141
248
|
flex-direction: column;
|
|
142
|
-
margin:
|
|
249
|
+
margin: 0;
|
|
250
|
+
`;
|
|
251
|
+
const FeedbackWrapper = styled.div`
|
|
252
|
+
display: flex;
|
|
253
|
+
flex-direction: row;
|
|
254
|
+
gap: var(--search-ai-feedback-gap);
|
|
255
|
+
margin-top: var(--spacing-sm);
|
|
143
256
|
`;
|
|
144
257
|
|
|
145
258
|
const ResourcesTitle = styled.div`
|
|
@@ -210,3 +323,19 @@ const ThinkingDot = styled.div`
|
|
|
210
323
|
}
|
|
211
324
|
}
|
|
212
325
|
`;
|
|
326
|
+
|
|
327
|
+
const SuccessMessageWrapper = styled.div`
|
|
328
|
+
max-width: fit-content;
|
|
329
|
+
display: flex;
|
|
330
|
+
align-items: center;
|
|
331
|
+
gap: var(--spacing-sm);
|
|
332
|
+
padding: var(--spacing-sm);
|
|
333
|
+
background: var(--color-success-bg);
|
|
334
|
+
border: 1px solid var(--color-success-border);
|
|
335
|
+
border-radius: var(--border-radius-lg);
|
|
336
|
+
`;
|
|
337
|
+
|
|
338
|
+
const SuccessMessageText = styled.div`
|
|
339
|
+
font-size: var(--font-size-base);
|
|
340
|
+
color: var(--color-success-darker);
|
|
341
|
+
`;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { JSX } from 'react';
|
|
5
|
+
import type { FeedbackType } from '@redocly/theme/core/types';
|
|
6
|
+
|
|
7
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
8
|
+
import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
9
|
+
import { ArrowLeftIcon } from '@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon';
|
|
10
|
+
import { SendIcon } from '@redocly/theme/icons/SendIcon/SendIcon';
|
|
11
|
+
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
12
|
+
|
|
13
|
+
export type SearchAiNegativeFeedbackFormProps = {
|
|
14
|
+
messageId: string;
|
|
15
|
+
onClose: (messageId: string, feedback: FeedbackType | undefined) => void;
|
|
16
|
+
onSubmit: (reason: string) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const NEGATIVE_FEEDBACK_DEFAULT_REASONS = [
|
|
20
|
+
"Didn't answer my question",
|
|
21
|
+
"Couldn't find what I was looking for",
|
|
22
|
+
'Wrong topic',
|
|
23
|
+
'Partially helpful, but missing details',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export function SearchAiNegativeFeedbackForm({
|
|
27
|
+
messageId,
|
|
28
|
+
onClose,
|
|
29
|
+
onSubmit,
|
|
30
|
+
}: SearchAiNegativeFeedbackFormProps): JSX.Element {
|
|
31
|
+
const { useTranslate } = useThemeHooks();
|
|
32
|
+
const { translate } = useTranslate();
|
|
33
|
+
const [showMoreInput, setShowMoreInput] = useState(false);
|
|
34
|
+
const [detailedFeedback, setDetailedFeedback] = useState('');
|
|
35
|
+
const textAreaRef = React.useRef<HTMLTextAreaElement>(null);
|
|
36
|
+
|
|
37
|
+
const adjustTextAreaHeight = () => {
|
|
38
|
+
const textArea = textAreaRef.current;
|
|
39
|
+
if (textArea) {
|
|
40
|
+
textArea.style.height = 'auto';
|
|
41
|
+
textArea.style.height = `${textArea.scrollHeight}px`;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleTextChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
46
|
+
setDetailedFeedback(e.target.value);
|
|
47
|
+
adjustTextAreaHeight();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (showMoreInput) {
|
|
52
|
+
adjustTextAreaHeight();
|
|
53
|
+
}
|
|
54
|
+
}, [showMoreInput]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<FeedbackFormWrapper data-component-name="Search/SearchAiNegativeFeedbackForm">
|
|
58
|
+
<FeedbackHeader>
|
|
59
|
+
{showMoreInput ? (
|
|
60
|
+
<BackButton
|
|
61
|
+
variant="text"
|
|
62
|
+
size="small"
|
|
63
|
+
icon={<ArrowLeftIcon />}
|
|
64
|
+
onClick={() => setShowMoreInput(false)}
|
|
65
|
+
aria-label="Back to feedback reasons"
|
|
66
|
+
/>
|
|
67
|
+
) : null}
|
|
68
|
+
<FeedbackTitle data-translation-key="search.ai.feedback.title">
|
|
69
|
+
{translate('search.ai.feedback.title', "What didn't you like about this response?")}
|
|
70
|
+
</FeedbackTitle>
|
|
71
|
+
<CloseButton
|
|
72
|
+
variant="text"
|
|
73
|
+
size="small"
|
|
74
|
+
icon={<CloseIcon />}
|
|
75
|
+
onClick={() => onClose(messageId, undefined)}
|
|
76
|
+
aria-label="Close feedback form"
|
|
77
|
+
/>
|
|
78
|
+
</FeedbackHeader>
|
|
79
|
+
|
|
80
|
+
{!showMoreInput ? (
|
|
81
|
+
<FeedbackReasonsWrapper>
|
|
82
|
+
{NEGATIVE_FEEDBACK_DEFAULT_REASONS.map((reason) => (
|
|
83
|
+
<Button key={reason} variant="outlined" size="small" onClick={() => onSubmit(reason)}>
|
|
84
|
+
{reason}
|
|
85
|
+
</Button>
|
|
86
|
+
))}
|
|
87
|
+
<Button variant="outlined" size="small" onClick={() => setShowMoreInput(true)}>
|
|
88
|
+
More...
|
|
89
|
+
</Button>
|
|
90
|
+
</FeedbackReasonsWrapper>
|
|
91
|
+
) : (
|
|
92
|
+
<FeedbackInputWrapper>
|
|
93
|
+
<FeedbackTextArea
|
|
94
|
+
ref={textAreaRef}
|
|
95
|
+
placeholder={translate('search.ai.feedback.detailsPlaceholder', 'Add specific details')}
|
|
96
|
+
value={detailedFeedback}
|
|
97
|
+
onChange={handleTextChange}
|
|
98
|
+
rows={1}
|
|
99
|
+
autoFocus
|
|
100
|
+
/>
|
|
101
|
+
<SendButton
|
|
102
|
+
size="small"
|
|
103
|
+
icon={
|
|
104
|
+
<SendIcon
|
|
105
|
+
color={
|
|
106
|
+
!detailedFeedback.trim()
|
|
107
|
+
? '--button-content-color-disabled'
|
|
108
|
+
: 'var(--search-ai-conversation-input-send-button-icon-color)'
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
}
|
|
112
|
+
onClick={() => onSubmit(detailedFeedback)}
|
|
113
|
+
disabled={!detailedFeedback.trim()}
|
|
114
|
+
aria-label="Send feedback"
|
|
115
|
+
/>
|
|
116
|
+
</FeedbackInputWrapper>
|
|
117
|
+
)}
|
|
118
|
+
</FeedbackFormWrapper>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const FeedbackFormWrapper = styled.div`
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: var(--spacing-sm);
|
|
126
|
+
padding: var(--spacing-xs);
|
|
127
|
+
background: var(--search-ai-feedback-form-bg-color);
|
|
128
|
+
border: 1px solid var(--search-ai-feedback-form-border-color);
|
|
129
|
+
border-radius: var(--border-radius-lg);
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
const FeedbackHeader = styled.div`
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: space-between;
|
|
135
|
+
align-items: center;
|
|
136
|
+
gap: var(--spacing-sm);
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
const FeedbackTitle = styled.div`
|
|
140
|
+
font-size: var(--font-size-base);
|
|
141
|
+
color: var(--text-color);
|
|
142
|
+
flex: 1;
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
const BackButton = styled(Button)`
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const CloseButton = styled(Button)`
|
|
150
|
+
flex-shrink: 0;
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
const FeedbackReasonsWrapper = styled.div`
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-wrap: wrap;
|
|
156
|
+
gap: var(--spacing-xs);
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
const FeedbackInputWrapper = styled.div`
|
|
160
|
+
position: relative;
|
|
161
|
+
width: 100%;
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
const FeedbackTextArea = styled.textarea`
|
|
165
|
+
width: 100%;
|
|
166
|
+
min-height: 5rem;
|
|
167
|
+
max-height: 12.5rem;
|
|
168
|
+
padding: var(--spacing-xs);
|
|
169
|
+
padding-right: 3rem;
|
|
170
|
+
border: 1px solid var(--border-color-primary);
|
|
171
|
+
border-radius: var(--border-radius-md);
|
|
172
|
+
font-family: inherit;
|
|
173
|
+
font-size: var(--font-size-base);
|
|
174
|
+
line-height: var(--line-height-base);
|
|
175
|
+
background: var(--background-color);
|
|
176
|
+
color: var(--text-color);
|
|
177
|
+
resize: none;
|
|
178
|
+
overflow-y: auto;
|
|
179
|
+
|
|
180
|
+
&:focus {
|
|
181
|
+
outline: 1px solid var(--button-border-color-focused);
|
|
182
|
+
border-color: var(--button-border-color-focused);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&::placeholder {
|
|
186
|
+
color: var(--text-color-helper);
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
const SendButton = styled(Button)`
|
|
191
|
+
position: absolute;
|
|
192
|
+
right: var(--search-ai-conversation-input-send-button-right);
|
|
193
|
+
bottom: var(--spacing-sm);
|
|
194
|
+
transition: background-color 0.2s ease;
|
|
195
|
+
background-color: var(--search-ai-conversation-input-send-button-bg-color);
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
border-radius: var(--search-ai-conversation-input-send-button-border-radius);
|
|
200
|
+
padding: var(--search-ai-conversation-input-send-button-padding);
|
|
201
|
+
|
|
202
|
+
&:hover {
|
|
203
|
+
background-color: var(--search-ai-conversation-input-send-button-bg-color-hover);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&:disabled {
|
|
207
|
+
background-color: var(--search-ai-conversation-input-send-button-bg-color-disabled);
|
|
208
|
+
border: var(--search-ai-conversation-input-send-button-border-disabled);
|
|
209
|
+
}
|
|
210
|
+
`;
|
|
@@ -48,6 +48,7 @@ export function SearchDialog({
|
|
|
48
48
|
const products = useProducts();
|
|
49
49
|
const currentProduct = useCurrentProduct();
|
|
50
50
|
const [product, setProduct] = useState(currentProduct);
|
|
51
|
+
const searchSessionId = `search-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
51
52
|
const [mode, setMode] = useState<'search' | 'ai-dialog'>(initialMode);
|
|
52
53
|
const autoSearchDisabled = mode !== 'search';
|
|
53
54
|
const {
|
|
@@ -62,7 +63,7 @@ export function SearchDialog({
|
|
|
62
63
|
advancedSearch,
|
|
63
64
|
askAi,
|
|
64
65
|
groupField,
|
|
65
|
-
} = useSearch(product?.name, autoSearchDisabled);
|
|
66
|
+
} = useSearch(product?.name, autoSearchDisabled, searchSessionId);
|
|
66
67
|
const {
|
|
67
68
|
isFilterOpen,
|
|
68
69
|
onFilterToggle,
|
|
@@ -72,10 +73,24 @@ export function SearchDialog({
|
|
|
72
73
|
onQuickFilterReset,
|
|
73
74
|
} = useSearchFilter(filter, setFilter);
|
|
74
75
|
const { addSearchHistoryItem } = useRecentSearches();
|
|
75
|
-
const aiSearch = useAiSearch({ filter });
|
|
76
|
+
const aiSearch = useAiSearch({ filter }, searchSessionId);
|
|
76
77
|
|
|
77
78
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
78
79
|
const modalRef = useRef<HTMLDivElement>(null);
|
|
80
|
+
|
|
81
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const mediaQuery = window.matchMedia(`(max-width: ${breakpoints.small})`);
|
|
85
|
+
setIsMobile(mediaQuery.matches);
|
|
86
|
+
|
|
87
|
+
const handleChange = (e: MediaQueryListEvent) => {
|
|
88
|
+
setIsMobile(e.matches);
|
|
89
|
+
};
|
|
90
|
+
mediaQuery.addEventListener('change', handleChange);
|
|
91
|
+
return () => mediaQuery.removeEventListener('change', handleChange);
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
79
94
|
const aiQueryRef = useRef<HTMLDivElement>(null);
|
|
80
95
|
const firstSearchResultRef = useRef<HTMLAnchorElement>(null);
|
|
81
96
|
const searchKeysWithResults = items ? Object.keys(items).filter((key) => items[key]?.length) : [];
|
|
@@ -150,13 +165,14 @@ export function SearchDialog({
|
|
|
150
165
|
totalResults: results.length.toString(),
|
|
151
166
|
index: index.toString(),
|
|
152
167
|
searchEngine: mode,
|
|
168
|
+
searchSessionId,
|
|
153
169
|
});
|
|
154
170
|
onClose();
|
|
155
171
|
}}
|
|
156
172
|
/>
|
|
157
173
|
);
|
|
158
174
|
},
|
|
159
|
-
[onClose, product, products, addSearchHistoryItem, query, telemetry, mode],
|
|
175
|
+
[onClose, product, products, addSearchHistoryItem, query, telemetry, mode, searchSessionId],
|
|
160
176
|
);
|
|
161
177
|
|
|
162
178
|
const showLoadMore = useCallback(
|
|
@@ -226,6 +242,9 @@ export function SearchDialog({
|
|
|
226
242
|
if (query.trim()) {
|
|
227
243
|
aiSearch.askQuestion(query);
|
|
228
244
|
}
|
|
245
|
+
telemetry.sendSearchAiOpenedMessage({
|
|
246
|
+
method: 'ai_search_button',
|
|
247
|
+
});
|
|
229
248
|
}}
|
|
230
249
|
>
|
|
231
250
|
{translate('search.ai.button', 'Search with AI')}
|
|
@@ -249,17 +268,22 @@ export function SearchDialog({
|
|
|
249
268
|
tabIndex={0}
|
|
250
269
|
icon={<ChevronLeftIcon />}
|
|
251
270
|
>
|
|
252
|
-
{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
variant="secondary"
|
|
256
|
-
disabled={!aiSearch.conversation.length}
|
|
257
|
-
onClick={() => aiSearch.clearConversation()}
|
|
258
|
-
tabIndex={0}
|
|
259
|
-
icon={<EditIcon />}
|
|
260
|
-
>
|
|
261
|
-
{translate('search.ai.newConversation', 'New conversation')}
|
|
271
|
+
{isMobile
|
|
272
|
+
? translate('search.ai.back', 'Back')
|
|
273
|
+
: translate('search.ai.backToSearch', 'Back to search')}
|
|
262
274
|
</Button>
|
|
275
|
+
<AiDialogHeaderActionsWrapper>
|
|
276
|
+
<Button
|
|
277
|
+
variant="secondary"
|
|
278
|
+
disabled={!aiSearch.conversation.length}
|
|
279
|
+
onClick={() => aiSearch.clearConversation()}
|
|
280
|
+
tabIndex={0}
|
|
281
|
+
icon={<EditIcon />}
|
|
282
|
+
>
|
|
283
|
+
{translate('search.ai.newConversation', 'New conversation')}
|
|
284
|
+
</Button>
|
|
285
|
+
{isMobile && <Button variant="text" icon={<CloseIcon />} onClick={handleClose} />}
|
|
286
|
+
</AiDialogHeaderActionsWrapper>
|
|
263
287
|
</AiDialogHeaderWrapper>
|
|
264
288
|
)}
|
|
265
289
|
</SearchDialogHeader>
|
|
@@ -296,6 +320,9 @@ export function SearchDialog({
|
|
|
296
320
|
if (query.trim()) {
|
|
297
321
|
aiSearch.askQuestion(query);
|
|
298
322
|
}
|
|
323
|
+
telemetry.sendSearchAiOpenedMessage({
|
|
324
|
+
method: 'ai_search_input',
|
|
325
|
+
});
|
|
299
326
|
}}
|
|
300
327
|
onKeyDown={(e) => {
|
|
301
328
|
if (e.key === 'Enter') {
|
|
@@ -303,6 +330,9 @@ export function SearchDialog({
|
|
|
303
330
|
if (query.trim()) {
|
|
304
331
|
aiSearch.askQuestion(query);
|
|
305
332
|
}
|
|
333
|
+
telemetry.sendSearchAiOpenedMessage({
|
|
334
|
+
method: 'ai_search_input',
|
|
335
|
+
});
|
|
306
336
|
}
|
|
307
337
|
}}
|
|
308
338
|
ref={aiQueryRef}
|
|
@@ -389,6 +419,7 @@ export function SearchDialog({
|
|
|
389
419
|
telemetry.sendSearchRecentClickedMessage({
|
|
390
420
|
query,
|
|
391
421
|
index: index.toString(),
|
|
422
|
+
searchSessionId,
|
|
392
423
|
});
|
|
393
424
|
setQuery(query);
|
|
394
425
|
focusSearchInput();
|
|
@@ -524,6 +555,10 @@ const AiDialogHeaderWrapper = styled.div`
|
|
|
524
555
|
align-items: center;
|
|
525
556
|
width: 100%;
|
|
526
557
|
`;
|
|
558
|
+
const AiDialogHeaderActionsWrapper = styled.div`
|
|
559
|
+
display: flex;
|
|
560
|
+
gap: var(--spacing-xxs);
|
|
561
|
+
`;
|
|
527
562
|
|
|
528
563
|
const SearchDialogBody = styled.div`
|
|
529
564
|
display: flex;
|
|
@@ -640,6 +675,7 @@ const AiDisclaimer = styled.div`
|
|
|
640
675
|
line-height: var(--search-ai-disclaimer-line-height);
|
|
641
676
|
color: var(--search-ai-disclaimer-text-color);
|
|
642
677
|
margin: 0 auto;
|
|
678
|
+
text-align: center;
|
|
643
679
|
`;
|
|
644
680
|
|
|
645
681
|
const SearchWithAI = styled.div`
|
|
@@ -45,6 +45,7 @@ export function SearchGroups({
|
|
|
45
45
|
borderless
|
|
46
46
|
active={!searchFilter.some((item) => item.isQuickFilter)}
|
|
47
47
|
onClick={() => searchFilter.some((item) => item.isQuickFilter) && onQuickFilterReset()}
|
|
48
|
+
selectable
|
|
48
49
|
>
|
|
49
50
|
All
|
|
50
51
|
</GroupTag>
|
|
@@ -61,6 +62,7 @@ export function SearchGroups({
|
|
|
61
62
|
onClick={() => handleGroupTagClick(value, facet.field, active, currentValues)}
|
|
62
63
|
active={active}
|
|
63
64
|
borderless
|
|
65
|
+
selectable
|
|
64
66
|
>
|
|
65
67
|
{value} {isCounterVisible && <span>{count}</span>}
|
|
66
68
|
</GroupTag>
|