From 12f2c589ccc448b8f9344876acf4f4c77103ca8a Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Fri, 21 Nov 2025 15:19:45 +0800 Subject: [PATCH] feat: [AIChatInput] The newly added keepSkillAfterSend API allows users to set whether to delete the skill upon sending --- .../_story/aiChatInput.stories.jsx | 34 +++++++++++++++++++ packages/semi-ui/aiChatInput/index.tsx | 5 +-- packages/semi-ui/aiChatInput/interface.ts | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/packages/semi-ui/aiChatInput/_story/aiChatInput.stories.jsx b/packages/semi-ui/aiChatInput/_story/aiChatInput.stories.jsx index 61d40fe1b3..7b94d6e8d5 100644 --- a/packages/semi-ui/aiChatInput/_story/aiChatInput.stories.jsx +++ b/packages/semi-ui/aiChatInput/_story/aiChatInput.stories.jsx @@ -679,3 +679,37 @@ export const SetContent = () => { >点我查看富文本区域内容 ); } + +export const KeepSkill = () => { + const ref = useRef(); + const [generating, setGenerating] = useState(false); + + const onContentChange = useCallback((content) => { + console.log('onContentChange', content); + }, []); + + const toggleGenerate = useCallback((props) => { + setGenerating(value => !value); + }, []); + + return (<> + 帮我完成...`} + placeholder={'输入内容或者上传内容'} + uploadProps={uploadProps} + onContentChange={onContentChange} + onMessageSend={toggleGenerate} + onStopGenerate={toggleGenerate} + style={outerStyle} + /> + + ); +} \ No newline at end of file diff --git a/packages/semi-ui/aiChatInput/index.tsx b/packages/semi-ui/aiChatInput/index.tsx index 8237eaaeac..1b7cf9ec53 100644 --- a/packages/semi-ui/aiChatInput/index.tsx +++ b/packages/semi-ui/aiChatInput/index.tsx @@ -54,6 +54,7 @@ class AIChatInput extends BaseComponent { dropdownMatchTriggerWidth: true, round: true, topSlotPosition: 'top', + keepSkillAfterSend: false, } constructor(props: AIChatInputProps) { @@ -203,14 +204,14 @@ class AIChatInput extends BaseComponent { } componentDidUpdate(prevProps: Readonly): void { - const { suggestions } = this.props; + const { suggestions, keepSkillAfterSend } = this.props; if (!isEqual(suggestions, prevProps.suggestions)) { const newVisible = (suggestions && suggestions.length > 0) ? true : false; newVisible ? this.foundation.showSuggestionPanel() : this.foundation.hideSuggestionPanel(); } if (this.props.generating && (this.props.generating !== prevProps.generating)) { - this.adapter.clearContent(); + keepSkillAfterSend ? this.setContentWhileSaveTool('') : this.adapter.clearContent(); this.adapter.clearAttachments(); } } diff --git a/packages/semi-ui/aiChatInput/interface.ts b/packages/semi-ui/aiChatInput/interface.ts index 496c11a628..cf5b58efab 100644 --- a/packages/semi-ui/aiChatInput/interface.ts +++ b/packages/semi-ui/aiChatInput/interface.ts @@ -23,6 +23,7 @@ export interface AIChatInputState { export interface AIChatInputProps { dropdownMatchTriggerWidth?: boolean; + keepSkillAfterSend: boolean; className?: string; style?: React.CSSProperties; // Rich text editor related