@redocly/theme 0.70.0-next.4 → 0.70.0-next.6

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.
Files changed (113) hide show
  1. package/lib/components/Buttons/ConnectMCPButton.js +8 -13
  2. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.d.ts +1 -1
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.js +1 -1
  4. package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +30 -11
  5. package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.js +2 -1
  6. package/lib/components/Dropdown/Dropdown.d.ts +4 -2
  7. package/lib/components/Dropdown/Dropdown.js +28 -8
  8. package/lib/components/Dropdown/DropdownMenu.d.ts +1 -0
  9. package/lib/components/Dropdown/DropdownMenu.js +1 -1
  10. package/lib/components/Feedback/Reasons.js +3 -2
  11. package/lib/components/Filter/FilterCheckboxes.js +30 -11
  12. package/lib/components/Filter/FilterDateRange.js +36 -2
  13. package/lib/components/Image/Image.js +24 -4
  14. package/lib/components/Search/SearchAiActivity.d.ts +10 -0
  15. package/lib/components/Search/SearchAiActivity.js +278 -0
  16. package/lib/components/Search/SearchAiDialog.js +5 -1
  17. package/lib/components/Search/SearchAiMessage.d.ts +2 -1
  18. package/lib/components/Search/SearchAiMessage.js +20 -108
  19. package/lib/components/Search/SearchItem.js +1 -8
  20. package/lib/components/Search/variables.js +15 -2
  21. package/lib/components/Segmented/Segmented.js +23 -3
  22. package/lib/components/Select/Select.js +10 -3
  23. package/lib/components/Select/SelectInput.d.ts +1 -0
  24. package/lib/components/Select/SelectInput.js +5 -11
  25. package/lib/components/SplitButton/SplitButton.js +37 -3
  26. package/lib/core/constants/mcp.d.ts +2 -2
  27. package/lib/core/constants/mcp.js +3 -8
  28. package/lib/core/constants/search.js +5 -1
  29. package/lib/core/hooks/index.d.ts +2 -0
  30. package/lib/core/hooks/index.js +2 -0
  31. package/lib/core/hooks/menu/use-collapse.js +1 -1
  32. package/lib/core/hooks/search/use-search-ai-activity.d.ts +11 -0
  33. package/lib/core/hooks/search/use-search-ai-activity.js +15 -0
  34. package/lib/core/hooks/use-connect-mcp-button.js +2 -1
  35. package/lib/core/hooks/use-full-height.d.ts +1 -1
  36. package/lib/core/hooks/use-full-height.js +8 -8
  37. package/lib/core/hooks/use-tab-list.d.ts +31 -0
  38. package/lib/core/hooks/use-tab-list.js +49 -0
  39. package/lib/core/styles/global.d.ts +2 -0
  40. package/lib/core/styles/global.js +80 -76
  41. package/lib/core/styles/index.d.ts +1 -0
  42. package/lib/core/styles/index.js +3 -1
  43. package/lib/core/styles/search-ai-appear.d.ts +1 -0
  44. package/lib/core/styles/search-ai-appear.js +18 -0
  45. package/lib/core/types/dropdown.d.ts +1 -0
  46. package/lib/core/types/dropdown.js +3 -0
  47. package/lib/core/types/index.d.ts +1 -0
  48. package/lib/core/types/l10n.d.ts +1 -1
  49. package/lib/core/types/mcp.d.ts +2 -1
  50. package/lib/core/types/search.d.ts +23 -0
  51. package/lib/core/utils/Dynamic.d.ts +8 -1
  52. package/lib/core/utils/Dynamic.js +34 -3
  53. package/lib/core/utils/assign-ref.d.ts +2 -0
  54. package/lib/core/utils/assign-ref.js +12 -0
  55. package/lib/core/utils/content-segments.d.ts +12 -1
  56. package/lib/core/utils/content-segments.js +90 -5
  57. package/lib/core/utils/dropdown.d.ts +2 -0
  58. package/lib/core/utils/dropdown.js +12 -0
  59. package/lib/core/utils/index.d.ts +2 -0
  60. package/lib/core/utils/index.js +2 -0
  61. package/lib/core/utils/mcp.d.ts +2 -1
  62. package/lib/core/utils/mcp.js +5 -0
  63. package/lib/core/utils/search-ai-activity.d.ts +4 -0
  64. package/lib/core/utils/search-ai-activity.js +83 -0
  65. package/lib/markdoc/tags/connect-mcp.js +15 -0
  66. package/package.json +2 -2
  67. package/src/components/Buttons/ConnectMCPButton.tsx +8 -14
  68. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.tsx +3 -1
  69. package/src/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.tsx +37 -22
  70. package/src/components/Catalog/CatalogFilter/CatalogFilterDateRange.tsx +3 -2
  71. package/src/components/Dropdown/Dropdown.tsx +28 -6
  72. package/src/components/Dropdown/DropdownMenu.tsx +7 -1
  73. package/src/components/Feedback/Reasons.tsx +3 -2
  74. package/src/components/Filter/FilterCheckboxes.tsx +33 -18
  75. package/src/components/Filter/FilterDateRange.tsx +3 -2
  76. package/src/components/Image/Image.tsx +26 -5
  77. package/src/components/Search/SearchAiActivity.tsx +318 -0
  78. package/src/components/Search/SearchAiDialog.tsx +4 -3
  79. package/src/components/Search/SearchAiMessage.tsx +27 -135
  80. package/src/components/Search/SearchItem.tsx +2 -9
  81. package/src/components/Search/variables.ts +15 -2
  82. package/src/components/Segmented/Segmented.tsx +25 -16
  83. package/src/components/Select/Select.tsx +12 -6
  84. package/src/components/Select/SelectInput.tsx +10 -18
  85. package/src/components/SplitButton/SplitButton.tsx +8 -2
  86. package/src/core/constants/mcp.ts +3 -9
  87. package/src/core/constants/search.ts +5 -1
  88. package/src/core/hooks/__mocks__/index.ts +1 -0
  89. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
  90. package/src/core/hooks/index.ts +2 -0
  91. package/src/core/hooks/menu/use-collapse.ts +1 -1
  92. package/src/core/hooks/search/use-search-ai-activity.ts +31 -0
  93. package/src/core/hooks/use-connect-mcp-button.ts +7 -2
  94. package/src/core/hooks/use-full-height.ts +8 -8
  95. package/src/core/hooks/use-tab-list.ts +63 -0
  96. package/src/core/styles/global.ts +80 -75
  97. package/src/core/styles/index.ts +2 -1
  98. package/src/core/styles/search-ai-appear.ts +16 -0
  99. package/src/core/types/dropdown.ts +1 -0
  100. package/src/core/types/index.ts +1 -0
  101. package/src/core/types/l10n.ts +1 -1
  102. package/src/core/types/mcp.ts +3 -1
  103. package/src/core/types/search.ts +21 -0
  104. package/src/core/utils/Dynamic.tsx +67 -35
  105. package/src/core/utils/assign-ref.ts +9 -0
  106. package/src/core/utils/content-segments.ts +98 -6
  107. package/src/core/utils/dropdown.ts +14 -0
  108. package/src/core/utils/index.ts +2 -0
  109. package/src/core/utils/mcp.ts +7 -1
  110. package/src/core/utils/search-ai-activity.ts +110 -0
  111. package/src/icons/CheckboxIcon/CheckboxIcon.tsx +1 -0
  112. package/src/icons/ChevronSortIcon/ChevronSortIcon.tsx +1 -0
  113. package/src/markdoc/tags/connect-mcp.ts +16 -1
@@ -117,6 +117,27 @@ export type ToolCall = {
117
117
 
118
118
  export type ContentSegment = { type: 'text'; text: string } | { type: 'tool'; toolCall: ToolCall };
119
119
 
120
+ export type GroupedContentSegment =
121
+ | { type: 'text'; text: string }
122
+ /** `isActive`: the assistant still works on this group, with nothing written after it yet. */
123
+ | { type: 'tools'; toolCalls: ToolCall[]; isActive: boolean };
124
+
125
+ export type SearchAiActivityKind = 'thinking' | 'search' | 'code' | 'support';
126
+
127
+ export type SearchAiActivityStatus = {
128
+ label: string;
129
+ detail?: string;
130
+ kind: SearchAiActivityKind;
131
+ isRunning: boolean;
132
+ };
133
+
134
+ export type SearchAiActivityStep = {
135
+ id: string;
136
+ label: string;
137
+ kind: SearchAiActivityKind;
138
+ isRunning: boolean;
139
+ };
140
+
120
141
  export type AiSearchConversationItem = {
121
142
  role: AiSearchConversationRole;
122
143
  content: string;
@@ -5,60 +5,86 @@ interface DynamicOptions<TProps extends Record<string, unknown>> {
5
5
  loading?: React.ComponentType<TProps>;
6
6
  }
7
7
 
8
+ /**
9
+ * A component from `dynamic()`. After `preload()` resolves, the component renders without a
10
+ * loading state. On the server, `preload()` does not load a client-only component (`ssr: false`).
11
+ */
12
+ export type DynamicComponent<TProps> = React.ComponentType<TProps> & {
13
+ preload(): Promise<void>;
14
+ };
15
+
8
16
  export function dynamic<TProps extends Record<string, unknown>>(
9
17
  factory: () => Promise<
10
18
  React.ComponentType<TProps> | { default: React.ComponentType<TProps> } | Record<string, unknown>
11
19
  >,
12
20
  { ssr = true, loading }: DynamicOptions<TProps> = {},
13
- ): React.ComponentType<TProps> {
14
- const Component = React.lazy(() =>
15
- factory().then((mod) => {
16
- // Case 1: factory() => import('./SomeModule') - direct import
17
- // Case 2: factory() => import('./SomeModule').then(mod => mod.default) - extract default
18
- if (typeof mod === 'function') {
19
- return { default: mod };
20
- }
21
-
22
- // Case 3: factory() => import('./SomeModule').then(mod => ({ default: mod.default })) - manual wrap
23
- // Case 4: factory() => import('./SomeModule').then(mod => ({ default: mod.Named })) - manual wrap named
24
- if (mod && typeof mod === 'object' && 'default' in mod) {
25
- const defaultExport = mod.default;
26
-
27
- // Handle both function components and React component objects (e.g., memo/forwardRef)
28
- if (typeof defaultExport === 'function') {
29
- return { default: defaultExport as React.ComponentType<TProps> };
21
+ ): DynamicComponent<TProps> {
22
+ let loaded: React.ComponentType<TProps> | undefined;
23
+ let pending: Promise<{ default: React.ComponentType<TProps> }> | undefined;
24
+
25
+ const load = () =>
26
+ (pending ??= factory()
27
+ .then((mod) => {
28
+ // Case 1: factory() => import('./SomeModule') - direct import
29
+ // Case 2: factory() => import('./SomeModule').then(mod => mod.default) - extract default
30
+ if (typeof mod === 'function') {
31
+ return { default: mod };
30
32
  }
31
33
 
32
- if (defaultExport && typeof defaultExport === 'object' && '$$typeof' in defaultExport) {
33
- return { default: defaultExport as React.ComponentType<TProps> };
34
+ // Case 3: factory() => import('./SomeModule').then(mod => ({ default: mod.default })) - manual wrap
35
+ // Case 4: factory() => import('./SomeModule').then(mod => ({ default: mod.Named })) - manual wrap named
36
+ if (mod && typeof mod === 'object' && 'default' in mod) {
37
+ const defaultExport = mod.default;
38
+
39
+ // Handle both function components and React component objects (e.g., memo/forwardRef)
40
+ if (typeof defaultExport === 'function') {
41
+ return { default: defaultExport as React.ComponentType<TProps> };
42
+ }
43
+
44
+ if (defaultExport && typeof defaultExport === 'object' && '$$typeof' in defaultExport) {
45
+ return { default: defaultExport as React.ComponentType<TProps> };
46
+ }
34
47
  }
35
- }
36
48
 
37
- // Case 5: factory() => import('./SomeModule').then(mod => mod.Named) - find named export
38
- if (mod && typeof mod === 'object') {
39
- const modObj = mod as Record<string, unknown>;
49
+ // Case 5: factory() => import('./SomeModule').then(mod => mod.Named) - find named export
50
+ if (mod && typeof mod === 'object') {
51
+ const modObj = mod as Record<string, unknown>;
40
52
 
41
- for (const key in modObj) {
42
- const value = modObj[key];
53
+ for (const key in modObj) {
54
+ const value = modObj[key];
43
55
 
44
- if (typeof value === 'function') {
45
- return { default: value as React.ComponentType<TProps> };
46
- }
56
+ if (typeof value === 'function') {
57
+ return { default: value as React.ComponentType<TProps> };
58
+ }
47
59
 
48
- if (value && typeof value === 'object' && '$$typeof' in value) {
49
- return { default: value as React.ComponentType<TProps> };
60
+ if (value && typeof value === 'object' && '$$typeof' in value) {
61
+ return { default: value as React.ComponentType<TProps> };
62
+ }
50
63
  }
51
64
  }
52
- }
53
65
 
54
- throw new Error('Dynamic import did not return a valid React component');
55
- }),
56
- );
66
+ throw new Error('Dynamic import did not return a valid React component');
67
+ })
68
+ .then(
69
+ (module) => {
70
+ loaded = module.default;
71
+ return module;
72
+ },
73
+ (error: unknown) => {
74
+ // A failed load is not kept, so the next preload tries again.
75
+ pending = undefined;
76
+ throw error;
77
+ },
78
+ ));
79
+
80
+ const LazyComponent = React.lazy(load);
57
81
 
58
82
  const LoadingComponent: React.ComponentType<TProps> = loading || (() => null);
59
83
 
60
- return (props: TProps) => {
84
+ const DynamicComponent = (props: TProps) => {
61
85
  const [hasMounted, setHasMounted] = React.useState(false);
86
+ // Fixed per instance: a change of the element type would remount the component.
87
+ const [Component] = React.useState(() => loaded ?? LazyComponent);
62
88
 
63
89
  React.useEffect(() => {
64
90
  setHasMounted(true);
@@ -82,4 +108,10 @@ export function dynamic<TProps extends Record<string, unknown>>(
82
108
  </React.Suspense>
83
109
  );
84
110
  };
111
+
112
+ return Object.assign(DynamicComponent, {
113
+ async preload() {
114
+ if (ssr || typeof window !== 'undefined') await load();
115
+ },
116
+ });
85
117
  }
@@ -0,0 +1,9 @@
1
+ import type { Ref } from 'react';
2
+
3
+ export function assignRef<T>(ref: Ref<T> | undefined, value: T): void {
4
+ if (typeof ref === 'function') {
5
+ ref(value);
6
+ } else if (ref) {
7
+ ref.current = value;
8
+ }
9
+ }
@@ -1,5 +1,13 @@
1
- import type { ToolCall, ContentSegment } from '../types/search';
1
+ import type { ToolCall, ContentSegment, GroupedContentSegment } from '../types/search';
2
2
 
3
+ const SENTENCE_END_MARKS = '.!?:;';
4
+ const CLOSING_MARKS = `"')]*_\``;
5
+ const CODE_FENCE = /^[ \t]*(```|~~~)/gm;
6
+
7
+ /**
8
+ * Splits an answer at its tool calls. A call made in the middle of a sentence or a code block is
9
+ * placed at the end of that paragraph, so the sentence reads as one piece.
10
+ */
3
11
  export function splitContentByToolCalls(
4
12
  content: string | undefined,
5
13
  toolCalls: ToolCall[] | undefined,
@@ -8,20 +16,104 @@ export function splitContentByToolCalls(
8
16
  return [{ type: 'text', text: content || '' }];
9
17
  }
10
18
 
19
+ const text = content ?? '';
20
+ const fences = Array.from(text.matchAll(CODE_FENCE), (match) => match.index);
11
21
  const segments: ContentSegment[] = [];
12
22
  let lastPos = 0;
13
23
 
14
24
  for (const toolCall of toolCalls) {
15
- if (content && toolCall.position > lastPos) {
16
- segments.push({ type: 'text', text: content.substring(lastPos, toolCall.position) });
25
+ const position = Math.max(lastPos, getBlockBoundary(text, toolCall.position, fences));
26
+ if (position > lastPos) {
27
+ segments.push({ type: 'text', text: text.substring(lastPos, position) });
17
28
  }
18
29
  segments.push({ type: 'tool', toolCall });
19
- lastPos = toolCall.position;
30
+ lastPos = position;
20
31
  }
21
32
 
22
- if (content && lastPos < content.length) {
23
- segments.push({ type: 'text', text: content.substring(lastPos) });
33
+ if (lastPos < text.length) {
34
+ segments.push({ type: 'text', text: text.substring(lastPos) });
24
35
  }
25
36
 
26
37
  return segments;
27
38
  }
39
+
40
+ function getBlockBoundary(content: string, position: number, fences: number[]): number {
41
+ if (position <= 0 || position >= content.length) {
42
+ return position;
43
+ }
44
+ const isInsideCodeFence = (index: number) => {
45
+ let count = 0;
46
+ while (count < fences.length && fences[count] < index) count++;
47
+ return count % 2 === 1;
48
+ };
49
+ if (!isInsideCodeFence(position) && endsBlockOrSentence(content, position)) {
50
+ return position;
51
+ }
52
+ for (
53
+ let boundary = content.indexOf('\n\n', position);
54
+ boundary !== -1;
55
+ boundary = content.indexOf('\n\n', boundary + 2)
56
+ ) {
57
+ if (!isInsideCodeFence(boundary)) {
58
+ return boundary;
59
+ }
60
+ }
61
+ return content.length;
62
+ }
63
+
64
+ function endsBlockOrSentence(content: string, position: number): boolean {
65
+ let index = position - 1;
66
+ while (index >= 0 && /\s/.test(content[index])) {
67
+ if (content[index] === '\n') return true;
68
+ index--;
69
+ }
70
+ while (index >= 0 && CLOSING_MARKS.includes(content[index])) index--;
71
+ return index >= 0 && SENTENCE_END_MARKS.includes(content[index]);
72
+ }
73
+
74
+ /**
75
+ * Groups consecutive tool calls and drops text that is only whitespace. While the answer is
76
+ * generated, an answer with nothing to show yet is one empty active group (the thinking status),
77
+ * and the last group is active until text that is not whitespace follows it.
78
+ */
79
+ export function groupToolCallSegments(
80
+ segments: ContentSegment[],
81
+ isGenerating?: boolean,
82
+ ): GroupedContentSegment[] {
83
+ const grouped: GroupedContentSegment[] = [];
84
+ let text = '';
85
+
86
+ for (const segment of segments) {
87
+ if (segment.type === 'text') {
88
+ text += segment.text;
89
+ if (segment.text.trim()) {
90
+ grouped.push(segment);
91
+ }
92
+ continue;
93
+ }
94
+ const previous = grouped.at(-1);
95
+ if (previous?.type === 'tools') {
96
+ previous.toolCalls.push(segment.toolCall);
97
+ } else {
98
+ grouped.push({ type: 'tools', toolCalls: [segment.toolCall], isActive: false });
99
+ }
100
+ }
101
+
102
+ if (!isGenerating) {
103
+ return grouped;
104
+ }
105
+ const last = grouped.at(-1);
106
+ if (last?.type === 'tools') {
107
+ last.isActive = !text.slice(last.toolCalls.at(-1)?.position ?? 0).trim();
108
+ } else if (grouped.length === 0) {
109
+ return [{ type: 'tools', toolCalls: [], isActive: true }];
110
+ }
111
+ return grouped;
112
+ }
113
+
114
+ export function hasToolCallsAndText(segments: ContentSegment[]): boolean {
115
+ return (
116
+ segments.some((segment) => segment.type === 'tool') &&
117
+ segments.some((segment) => segment.type === 'text' && segment.text.trim().length > 0)
118
+ );
119
+ }
@@ -0,0 +1,14 @@
1
+ import type { DropdownAlignment } from '../types/dropdown';
2
+
3
+ export function fitDropdownAlignment(
4
+ anchor: DOMRect,
5
+ menuWidth: number,
6
+ alignment: DropdownAlignment = 'start',
7
+ ): DropdownAlignment {
8
+ const fits: Record<DropdownAlignment, boolean> = {
9
+ start: anchor.left + menuWidth <= window.innerWidth,
10
+ end: anchor.right - menuWidth >= 0,
11
+ };
12
+ const other: DropdownAlignment = alignment === 'end' ? 'start' : 'end';
13
+ return fits[alignment] || !fits[other] ? alignment : other;
14
+ }
@@ -51,3 +51,5 @@ export * from './telemetry/get-base-data-attributes';
51
51
  export * from './telemetry/generate-before-after-context';
52
52
  export * from './RenderWithLink';
53
53
  export * from './consent-settings-link-placement';
54
+ export * from './assign-ref';
55
+ export * from './dropdown';
@@ -1,4 +1,10 @@
1
- import type { MCPClientType, McpConnectionParams } from '../types';
1
+ import type { MCPClientType, McpConnectionParams, MCPOption } from '../types';
2
+
3
+ import { MCP_OPTIONS } from '../constants/mcp';
4
+
5
+ export function isMCPOption(value: unknown): value is MCPOption {
6
+ return (MCP_OPTIONS as readonly unknown[]).includes(value);
7
+ }
2
8
 
3
9
  function generateCursorMCPDeepLink(config: McpConnectionParams): string {
4
10
  const cursorConfig = {
@@ -0,0 +1,110 @@
1
+ import type { TFunction } from '../types/l10n';
2
+
3
+ import {
4
+ ToolCallName,
5
+ type SearchAiActivityStatus,
6
+ type SearchAiActivityStep,
7
+ type ToolCall,
8
+ type SearchAiActivityKind,
9
+ } from '../types/search';
10
+ import { TOOL_CALL_DISPLAY_TEXT } from '../constants/search';
11
+ import { isObject } from './type-guards';
12
+
13
+ export function getSearchAiActivityStatus(
14
+ toolCalls: ToolCall[],
15
+ isActive: boolean,
16
+ runningToolCall: ToolCall | undefined,
17
+ translate: TFunction,
18
+ ): SearchAiActivityStatus {
19
+ const latestToolCall = toolCalls.at(-1);
20
+ if (!latestToolCall) {
21
+ return {
22
+ label: translate('search.ai.thinkingText', 'Thinking...'),
23
+ kind: 'thinking',
24
+ isRunning: true,
25
+ };
26
+ }
27
+
28
+ if (isActive || toolCalls.length === 1) {
29
+ const toolCall = runningToolCall ?? latestToolCall;
30
+ return {
31
+ ...getToolCallLabel(toolCall, !isActive, translate),
32
+ kind: getSearchAiActivityKind(toolCall.name),
33
+ isRunning: isActive,
34
+ };
35
+ }
36
+
37
+ const isSameTool = toolCalls.every((toolCall) => toolCall.name === latestToolCall.name);
38
+ const sharedText = isSameTool
39
+ ? TOOL_CALL_DISPLAY_TEXT[latestToolCall.name]?.completedText
40
+ : undefined;
41
+ return {
42
+ label: sharedText ?? translate('search.ai.toolCall.usedTools', 'Used tools'),
43
+ kind: isSameTool ? getSearchAiActivityKind(latestToolCall.name) : 'code',
44
+ isRunning: false,
45
+ };
46
+ }
47
+
48
+ export function getSearchAiActivityStep(
49
+ toolCall: ToolCall,
50
+ isRunning: boolean,
51
+ translate: TFunction,
52
+ ): SearchAiActivityStep {
53
+ const detail = getToolCallDetail(toolCall);
54
+ const kind = getSearchAiActivityKind(toolCall.name);
55
+
56
+ if (toolCall.name === ToolCallName.SearchDocumentation && detail) {
57
+ return { id: toolCall.id, label: `“${detail}”`, kind, isRunning };
58
+ }
59
+ const { label } = getToolCallLabel(toolCall, !isRunning, translate);
60
+ return { id: toolCall.id, label: detail ? label : stripEllipsis(label), kind, isRunning };
61
+ }
62
+
63
+ function getToolCallLabel(
64
+ toolCall: ToolCall,
65
+ isCompleted: boolean,
66
+ translate: TFunction,
67
+ ): { label: string; detail?: string } {
68
+ const detail = getToolCallDetail(toolCall);
69
+ if (toolCall.name === ToolCallName.Execute && detail) {
70
+ return { label: detail };
71
+ }
72
+ const builtInText = TOOL_CALL_DISPLAY_TEXT[toolCall.name];
73
+ if (builtInText) {
74
+ const text = isCompleted ? builtInText.completedText : builtInText.inProgressText;
75
+ return detail ? { label: stripEllipsis(text), detail } : { label: text };
76
+ }
77
+ const prefix = isCompleted
78
+ ? translate('search.ai.toolCall.executed', 'Executed')
79
+ : translate('search.ai.toolCall.executing', 'Executing');
80
+ return { label: `${prefix} ${toolCall.name}` };
81
+ }
82
+
83
+ function getSearchAiActivityKind(name: string): SearchAiActivityKind {
84
+ if (name === ToolCallName.SearchDocumentation) return 'search';
85
+ if (name === ToolCallName.ContactSupport) return 'support';
86
+ return 'code';
87
+ }
88
+
89
+ function getToolCallDetail(toolCall: ToolCall): string | undefined {
90
+ switch (toolCall.name) {
91
+ case ToolCallName.SearchDocumentation:
92
+ return getStringArg(toolCall.args, 'query');
93
+ case ToolCallName.Execute:
94
+ return getStringArg(toolCall.args, 'description');
95
+ default:
96
+ return undefined;
97
+ }
98
+ }
99
+
100
+ function getStringArg(args: unknown, name: string): string | undefined {
101
+ if (!isObject(args) || !(name in args)) {
102
+ return undefined;
103
+ }
104
+ const value: unknown = Reflect.get(args, name);
105
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
106
+ }
107
+
108
+ function stripEllipsis(text: string): string {
109
+ return text.replace(/(\.{3}|…)$/, '');
110
+ }
@@ -11,6 +11,7 @@ const Icon = ({
11
11
  checked?: boolean;
12
12
  onClick?: () => void;
13
13
  }) => (
14
+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- the control that renders the icon handles the keyboard
14
15
  <span className={className} onClick={onClick}>
15
16
  {checked ? (
16
17
  <svg
@@ -6,6 +6,7 @@ import type { IconProps } from '@redocly/theme/icons/types';
6
6
  import { getCssColorVariable } from '@redocly/theme/core/utils';
7
7
 
8
8
  const Icon = ({ className, onClick }: IconProps & { onClick?: () => void }) => (
9
+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- the control that renders the icon handles the keyboard
9
10
  <svg
10
11
  className={className}
11
12
  onClick={onClick}
@@ -1,6 +1,7 @@
1
1
  import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
2
2
 
3
- import { DEFAULT_MCP_OPTIONS } from '@redocly/theme/core/constants';
3
+ import { DEFAULT_MCP_OPTIONS, MCP_OPTIONS } from '@redocly/theme/core/constants';
4
+ import { isMCPOption } from '@redocly/theme/core/utils';
4
5
 
5
6
  export const connectMcp: MarkdocSchemaWrapper = {
6
7
  schema: {
@@ -19,6 +20,20 @@ export const connectMcp: MarkdocSchemaWrapper = {
19
20
  options: {
20
21
  type: Array,
21
22
  default: DEFAULT_MCP_OPTIONS,
23
+ validate(value) {
24
+ if (!Array.isArray(value)) return [];
25
+
26
+ const unknownOptions = value.filter((option) => !isMCPOption(option));
27
+ if (unknownOptions.length === 0) return [];
28
+
29
+ return [
30
+ {
31
+ id: 'invalid-connect-mcp-options',
32
+ level: 'error',
33
+ message: `Invalid connect-mcp options: ${unknownOptions.join(', ')}. Must be one of: ${MCP_OPTIONS.join(', ')}`,
34
+ },
35
+ ];
36
+ },
22
37
  },
23
38
  },
24
39
  selfClosing: true,