@@ -22,8 +22,18 @@ export type PromptFormTranslations = Partial<{
2222 * Disclaimer text displayed beneath the prompt form.
2323 **/
2424 promptDisclaimerText : string ;
25+ /**
26+ * Visually hidden label text (`aria-labelledby`); usually keyboard hints for the textarea.
27+ **/
2528 promptLabelText : string ;
29+ /**
30+ * Accessible name for the textarea (`aria-label`).
31+ **/
2632 promptAriaLabelText : string ;
33+ /**
34+ * Placeholder when the conversation hit the thread depth limit (AI-217).
35+ **/
36+ threadDepthErrorPlaceholder : string ;
2737} > ;
2838
2939type Props = {
@@ -32,12 +42,17 @@ type Props = {
3242 translations ?: PromptFormTranslations ;
3343 onSend : ( prompt : string ) => void ;
3444 onStopStreaming : ( ) => void ;
45+ /** When true, the prompt is disabled (same as modal SearchBox in Ask AI mode). */
46+ isThreadDepthError ?: boolean ;
3547} ;
3648
3749const MAX_PROMPT_ROWS = 8 ;
3850
3951export const PromptForm = React . forwardRef < HTMLTextAreaElement , Props > (
40- ( { exchanges, isStreaming, translations = { } , onSend, onStopStreaming } , ref ) : JSX . Element => {
52+ (
53+ { exchanges, isStreaming, translations = { } , onSend, onStopStreaming, isThreadDepthError = false } ,
54+ ref ,
55+ ) : JSX . Element => {
4156 const isMobile = useIsMobile ( ) ;
4257 const [ userPrompt , setUserPrompt ] = React . useState ( '' ) ;
4358 const promptRef = React . useRef < HTMLTextAreaElement > ( null ) ;
@@ -51,6 +66,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
5166 promptDisclaimerText = 'Answers are generated with AI which can make mistakes.' ,
5267 promptLabelText = 'Press Enter to send, or Shift and Enter for new line.' ,
5368 promptAriaLabelText = 'Prompt input' ,
69+ threadDepthErrorPlaceholder = 'Conversation limit reached' ,
5470 } = translations ;
5571
5672 const managePromptHeight = ( ) : void => {
@@ -74,7 +90,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
7490 } ;
7591
7692 const handleSend = ( ) : void => {
77- if ( isStreaming ) return ;
93+ if ( isStreaming || isThreadDepthError ) return ;
7894
7995 const prompt = userPrompt . trim ( ) ;
8096
@@ -93,7 +109,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
93109
94110 const handleKeyDown = ( e : React . KeyboardEvent < HTMLTextAreaElement > ) : void => {
95111 // Allow Enter to work normally (new line) when streaming
96- if ( isStreaming ) return ;
112+ if ( isStreaming || isThreadDepthError ) return ;
97113
98114 if ( e . key === 'Enter' && ! e . shiftKey ) {
99115 e . preventDefault ( ) ;
@@ -108,7 +124,9 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
108124
109125 let promptPlaceholder = promptPlaceholderText ;
110126
111- if ( isStreaming ) {
127+ if ( isThreadDepthError ) {
128+ promptPlaceholder = threadDepthErrorPlaceholder ;
129+ } else if ( isStreaming ) {
112130 promptPlaceholder = promptAnsweringText ;
113131 } else if ( exchanges . length > 0 ) {
114132 promptPlaceholder = promptAskAnotherQuestionText ;
@@ -121,7 +139,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
121139 onSubmit = { ( e ) => {
122140 e . preventDefault ( ) ;
123141
124- if ( isStreaming ) return ;
142+ if ( isStreaming || isThreadDepthError ) return ;
125143
126144 handleSend ( ) ;
127145 } }
@@ -136,6 +154,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
136154 autoComplete = "off"
137155 translate = "no"
138156 rows = { isMobile ? 1 : 2 }
157+ disabled = { isThreadDepthError }
139158 onKeyDown = { handleKeyDown }
140159 onInput = { managePromptHeight }
141160 onChange = { ( e ) => setUserPrompt ( e . target . value ) }
@@ -154,7 +173,7 @@ export const PromptForm = React.forwardRef<HTMLTextAreaElement, Props>(
154173 < StopIcon />
155174 </ button >
156175 ) }
157- { ! isStreaming && (
176+ { ! isStreaming && ! isThreadDepthError && (
158177 < button
159178 type = "submit"
160179 aria-label = "Send question"
0 commit comments