Feat: Add a think button to the chat box. #12742 (#12743)

### What problem does this PR solve?

Feat: Add a think button to the chat box. #12742
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2026-01-21 15:39:18 +08:00
committed by GitHub
parent f98abf14a8
commit e1143d40bc
12 changed files with 190 additions and 149 deletions

View File

@@ -1,3 +1,4 @@
import { NextMessageInputOnPressEnterParameter } from '@/components/message-input/next';
import sonnerMessage from '@/components/ui/message';
import { MessageType } from '@/constants/chat';
import {
@@ -289,6 +290,7 @@ export const useSendAgentMessage = ({
params.files = uploadResponseList;
params.session_id = sessionId;
params.reasoning = message.reasoning;
}
try {
@@ -355,28 +357,31 @@ export const useSendAgentMessage = ({
removeAllMessagesExceptFirst,
]);
const handlePressEnter = useCallback(() => {
if (trim(value) === '') return;
const msgBody = buildRequestBody(value);
if (done) {
setValue('');
sendMessage({
message: msgBody,
});
}
addNewestOneQuestion({ ...msgBody, files: fileList });
setTimeout(() => {
scrollToBottom();
}, 100);
}, [
value,
done,
addNewestOneQuestion,
fileList,
setValue,
sendMessage,
scrollToBottom,
]);
const handlePressEnter = useCallback(
(...[{ enableThinking }]: NextMessageInputOnPressEnterParameter) => {
if (trim(value) === '') return;
const msgBody = buildRequestBody(value);
if (done) {
setValue('');
sendMessage({
message: { ...msgBody, reasoning: enableThinking },
});
}
addNewestOneQuestion({ ...msgBody, files: fileList });
setTimeout(() => {
scrollToBottom();
}, 100);
},
[
value,
done,
addNewestOneQuestion,
fileList,
setValue,
sendMessage,
scrollToBottom,
],
);
const sendedTaskMessage = useRef<boolean>(false);

View File

@@ -164,7 +164,7 @@ const DebugContent = ({
render={({ field }) => (
<div className="space-y-6">
<FormItem className="w-full">
<FormLabel>{t('assistantAvatar')}</FormLabel>
<FormLabel>{props.label}</FormLabel>
<FormControl>
<FileUploadDirectUpload
value={field.value}
@@ -218,7 +218,7 @@ const DebugContent = ({
BeginQueryTypeMap[BeginQueryType.Paragraph]
);
},
[form, t],
[form],
);
const onSubmit = useCallback(