@@ -3,7 +3,7 @@ import React, { type JSX, useMemo, useState, useEffect } from 'react';
33
44import { AggregatedSearchBlock } from './AggregatedSearchBlock' ;
55import type { AskAiScreenStateProps } from './AskAiScreenState' ;
6- import { ToolCall } from './components/ui /ToolCall' ;
6+ import { ToolCall , type ToolCallTranslations } from './components/ToolCall' ;
77import { AlertIcon , LoadingIcon } from './icons' ;
88import { MemoizedMarkdown } from './MemoizedMarkdown' ;
99import type { StoredSearchPlugin } from './stored-searches' ;
@@ -12,56 +12,88 @@ import { type AIMessage, type ToolCalls } from './types/AskiAi';
1212import { extractLinksFromMessage , getMessageContent , isThreadDepthError , isAIToolPart } from './utils/ai' ;
1313import { groupConsecutiveToolResults } from './utils/groupConsecutiveToolResults' ;
1414
15- export type AskAiScreenTranslations = Partial < {
16- // Misc texts
17- disclaimerText : string ;
18- relatedSourcesText : string ;
19- thinkingText : string ;
20- copyButtonText : string ;
21- copyButtonCopiedText : string ;
22- // Feedback buttons
23- copyButtonTitle : string ;
24- likeButtonTitle : string ;
25- dislikeButtonTitle : string ;
26- thanksForFeedbackText : string ;
27- // Tool call texts
28- preToolCallText : string ;
29- duringToolCallText : string ;
30- afterToolCallText : string ;
31- /**
32- * Build the full jsx element for the aggregated search block.
33- * If provided, completely overrides the default english renderer.
34- */
35- aggregatedToolCallNode ?: ( queries : string [ ] , onSearchQueryClick : ( query : string ) => void ) => React . ReactNode ;
36-
37- /**
38- * Generate the list connective parts only (backwards compatibility).
39- * Receives full list of queries and should return translation parts for before/after/separators.
40- * Example: (qs) => ({ before: 'searched for ', separator: ', ', lastSeparator: ' and ', after: '' }).
41- */
42- aggregatedToolCallText ?: ( queries : string [ ] ) => {
43- before ?: string ;
44- separator ?: string ;
45- lastSeparator ?: string ;
46- after ?: string ;
15+ export type AskAiScreenTranslations = Partial <
16+ // Inherit the shared tool-call translations, but expose the search-related
17+ // keys under AskAiScreen's own public names (see mapping below).
18+ Omit < ToolCallTranslations , 'searchingText' | 'toolCallResultText' > & {
19+ // Misc texts
20+ disclaimerText : string ;
21+ relatedSourcesText : string ;
22+ thinkingText : string ;
23+ copyButtonText : string ;
24+ copyButtonCopiedText : string ;
25+ // Feedback buttons
26+ copyButtonTitle : string ;
27+ likeButtonTitle : string ;
28+ dislikeButtonTitle : string ;
29+ thanksForFeedbackText : string ;
30+ // Tool call texts
31+ /**
32+ * Text shown while assistant is performing search tool call.
33+ * Maps to `ToolCallTranslations.searchingText`.
34+ */
35+ duringToolCallText : string ;
36+ /**
37+ * Text shown while assistant is finished performing tool call.
38+ * Maps to `ToolCallTranslations.toolCallResultText`.
39+ */
40+ afterToolCallText : string ;
41+ /**
42+ * Build the full jsx element for the aggregated search block.
43+ * If provided, completely overrides the default english renderer.
44+ */
45+ aggregatedToolCallNode ?: ( queries : string [ ] , onSearchQueryClick : ( query : string ) => void ) => React . ReactNode ;
46+ /**
47+ * Generate the list connective parts only (backwards compatibility).
48+ * Receives full list of queries and should return translation parts for before/after/separators.
49+ * Example: (qs) => ({ before: 'searched for ', separator: ', ', lastSeparator: ' and ', after: '' }).
50+ */
51+ aggregatedToolCallText ?: ( queries : string [ ] ) => {
52+ before ?: string ;
53+ separator ?: string ;
54+ lastSeparator ?: string ;
55+ after ?: string ;
56+ } ;
57+ /**
58+ * Message that's shown when user has stopped the streaming of a message.
59+ */
60+ stoppedStreamingText : string ;
61+ /**
62+ * Error title shown if there is an error while chatting.
63+ */
64+ errorTitleText : string ;
65+ /**
66+ * Message shown when thread depth limit is exceeded (AI-217 error).
67+ */
68+ threadDepthExceededMessage : string ;
69+ /**
70+ * Button text for starting a new conversation after thread depth error.
71+ */
72+ startNewConversationButtonText : string ;
73+ }
74+ > ;
75+
76+ /**
77+ * Maps AskAiScreen's public translation keys to the shared `ToolCallTranslations`
78+ * shape consumed by the `ToolCall` component, applying default English values.
79+ */
80+ function toToolCallTranslations ( translations : AskAiScreenTranslations ) : ToolCallTranslations {
81+ const {
82+ preToolCallText = 'Searching...' ,
83+ duringToolCallText = 'Searching...' ,
84+ afterToolCallText = 'Searched for' ,
85+ savedMemoryToolResultText = 'Saved to memory' ,
86+ memoryToolResultText = 'Used memory to enhance results' ,
87+ } = translations ;
88+
89+ return {
90+ preToolCallText,
91+ searchingText : duringToolCallText ,
92+ toolCallResultText : afterToolCallText ,
93+ savedMemoryToolResultText,
94+ memoryToolResultText,
4795 } ;
48- /**
49- * Message that's shown when user has stopped the streaming of a message.
50- */
51- stoppedStreamingText : string ;
52- /**
53- * Error title shown if there is an error while chatting.
54- */
55- errorTitleText : string ;
56- /**
57- * Message shown when thread depth limit is exceeded (AI-217 error).
58- */
59- threadDepthExceededMessage : string ;
60- /**
61- * Button text for starting a new conversation after thread depth error.
62- */
63- startNewConversationButtonText : string ;
64- } > ;
96+ }
6597
6698type AskAiScreenProps = Omit < AskAiScreenStateProps < InternalDocSearchHit > , 'translations' > & {
6799 messages : AIMessage [ ] ;
@@ -71,6 +103,7 @@ type AskAiScreenProps = Omit<AskAiScreenStateProps<InternalDocSearchHit>, 'trans
71103 translations ?: AskAiScreenTranslations ;
72104 onNewConversation : ( ) => void ;
73105 agentStudio ?: boolean ;
106+ memoryEnabled ?: boolean ;
74107} ;
75108
76109interface AskAiScreenHeaderProps {
@@ -98,6 +131,7 @@ interface AskAiExchangeCardProps {
98131 conversations : StoredSearchPlugin < StoredAskAiState > ;
99132 onFeedback ?: ( messageId : string , thumbs : 0 | 1 ) => Promise < void > ;
100133 agentStudio ?: boolean ;
134+ memoryEnabled ?: boolean ;
101135}
102136
103137function AskAiExchangeCard ( {
@@ -111,16 +145,13 @@ function AskAiExchangeCard({
111145 conversations,
112146 onFeedback,
113147 agentStudio,
148+ memoryEnabled,
114149} : AskAiExchangeCardProps ) : JSX . Element {
115150 const { userMessage, assistantMessage } = exchange ;
116151
117- const {
118- stoppedStreamingText = 'You stopped this response' ,
119- errorTitleText = 'Chat error' ,
120- preToolCallText = 'Searching...' ,
121- afterToolCallText = 'Searched for' ,
122- duringToolCallText = 'Searching...' ,
123- } = translations ;
152+ const { stoppedStreamingText = 'You stopped this response' , errorTitleText = 'Chat error' } = translations ;
153+
154+ const toolCallTranslations = useMemo ( ( ) => toToolCallTranslations ( translations ) , [ translations ] ) ;
124155
125156 const isThreadDepth = isThreadDepthError ( askAiError ) ;
126157
@@ -191,13 +222,10 @@ function AskAiExchangeCard({
191222 return (
192223 < ToolCall
193224 key = { index }
194- translations = { {
195- preToolCallText,
196- searchingText : duringToolCallText ,
197- toolCallResultText : afterToolCallText ,
198- } }
225+ translations = { toolCallTranslations }
199226 part = { part }
200227 tools = { tools }
228+ memoryEnabled = { memoryEnabled }
201229 onSearchQueryClick = { onSearchQueryClick }
202230 />
203231 ) ;
@@ -377,7 +405,7 @@ export function AskAiScreen({ translations = {}, ...props }: AskAiScreenProps):
377405 startNewConversationButtonText = 'Start a new conversation' ,
378406 } = translations ;
379407
380- const { messages, tools, askAiError, status, agentStudio } = props ;
408+ const { messages, tools, askAiError, status, agentStudio, memoryEnabled } = props ;
381409
382410 // Check if there's a thread depth error
383411 const hasThreadDepthError = useMemo ( ( ) => {
@@ -454,6 +482,7 @@ export function AskAiScreen({ translations = {}, ...props }: AskAiScreenProps):
454482 tools = { tools }
455483 conversations = { props . conversations }
456484 agentStudio = { agentStudio }
485+ memoryEnabled = { memoryEnabled }
457486 onSearchQueryClick = { handleSearchQueryClick }
458487 onFeedback = { props . onFeedback }
459488 />
0 commit comments