File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/gitbook/src/components/AI Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ export function useAIChatController(): AIChatController {
138
138
// Post a message to the AI chat
139
139
const onPostMessage = React . useCallback (
140
140
async ( input : { message : string } ) => {
141
- const { messages } = globalState . getState ( ) . state ;
141
+ const { query , messages } = globalState . getState ( ) . state ;
142
142
143
143
// For first message, update the ask parameter in URL
144
144
if ( messages . length === 0 ) {
@@ -150,6 +150,11 @@ export function useAIChatController(): AIChatController {
150
150
} ) ) ;
151
151
}
152
152
153
+ if ( query === input . message ) {
154
+ // Return early if the message is the same as the previous message
155
+ return ;
156
+ }
157
+
153
158
trackEvent ( { type : 'ask_question' , query : input . message } ) ;
154
159
155
160
// Add user message and placeholder for AI response
You can’t perform that action at this time.
0 commit comments