From 80444f076e3fa3137541d7bc34c84d01bfbe8081 Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Fri, 28 Nov 2025 11:24:29 +0800 Subject: [PATCH 1/2] feat: Chat add canSend API --- content/plus/chat/index-en-US.md | 1 + content/plus/chat/index.md | 1 + packages/semi-foundation/chat/inputboxFoundation.ts | 7 ++++++- packages/semi-ui/chat/index.tsx | 4 +++- packages/semi-ui/chat/interface.ts | 2 ++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/content/plus/chat/index-en-US.md b/content/plus/chat/index-en-US.md index 71cc8e90d7..9c2815f682 100644 --- a/content/plus/chat/index-en-US.md +++ b/content/plus/chat/index-en-US.md @@ -1606,6 +1606,7 @@ render(DefaultChat); |------|--------|-------|-------| | align | Dialog layout, supports `leftRight`,`leftAlign` | string | `leftRight` | | bottomSlot | bottom slot for chat | React.ReactNode | - | +| canSend | Whether the send button is enabled. Normally, no settings are needed; the component internally determines whether sending is enabled. If settings are configured, the settings will prevail. Added in v2.89.0. | boolean | | chatBoxRenderConfig | chatBox rendering configuration | ChatBoxRenderConfig | - | | chats | Controlled conversation list | Message | - | | className | Custom class name | string | - | diff --git a/content/plus/chat/index.md b/content/plus/chat/index.md index 66f4d0d443..741fd96145 100644 --- a/content/plus/chat/index.md +++ b/content/plus/chat/index.md @@ -1609,6 +1609,7 @@ render(DefaultChat); |------|--------|-------|-------| | align | 对话布局方式,支持 `leftRight`、`leftAlign` | string | `leftRight` | | bottomSlot | 底部插槽 | React.ReactNode | - | +| canSend | 发送按钮是否可以发送。通常无需设置,由内部逻辑决定。如有设置,以此设置为准,v2.89.0 新增 | boolean | | chatBoxRenderConfig | chatBox 渲染配置 | ChatBoxRenderConfig | - | | chats | 受控对话列表 | Message | - | | className | 自定义类名 | string | - | diff --git a/packages/semi-foundation/chat/inputboxFoundation.ts b/packages/semi-foundation/chat/inputboxFoundation.ts index 9f2331693f..0f2bb32148 100644 --- a/packages/semi-foundation/chat/inputboxFoundation.ts +++ b/packages/semi-foundation/chat/inputboxFoundation.ts @@ -60,7 +60,12 @@ export default class InputBoxFoundation

, S = Record { const { content, attachment } = this.getStates(); - const { disableSend: disableSendInProps } = this.getProps(); + const { disableSend: disableSendInProps, canSend } = this.getProps(); + // 如果用户设置了 canSend API,则使用 canSend 值 + // If the user has configured the canSend API, then the canSend value will be used. + if (typeof canSend === 'boolean') { + return !canSend; + } /** 不能发送的条件:(满足任1) * 1. props 中禁止发送;2. 没有文本输入,且没有上传文件; 3.上传文件中有状态不为 success 的 * Conditions under which content cannot be sent: (any one of the following conditions must be met) diff --git a/packages/semi-ui/chat/index.tsx b/packages/semi-ui/chat/index.tsx index b5fb01f317..bf2840e386 100644 --- a/packages/semi-ui/chat/index.tsx +++ b/packages/semi-ui/chat/index.tsx @@ -291,7 +291,8 @@ class Chat extends BaseComponent { customMarkDownComponents, mode, showClearContext, placeholder, inputBoxCls, inputBoxStyle, hintStyle, hintCls, uploadProps, uploadTipProps, - sendHotKey, renderDivider, markdownRenderProps, enableUpload + sendHotKey, renderDivider, markdownRenderProps, enableUpload, + canSend, } = this.props; const { backBottomVisible, chats, wheelScroll, uploadAreaVisible } = this.state; let showStopGenerateFlag = false; @@ -389,6 +390,7 @@ class Chat extends BaseComponent { )} {/* input area */} void}) => React.ReactNode; onHintClick?: (hint: string) => void; @@ -158,6 +159,7 @@ export interface ChatBoxProps extends Omit { } export interface InputBoxProps { + canSend?: boolean; showClearContext?: boolean; sendHotKey?: 'enter' | 'shift+enter'; placeholder: string; From 370e766d294893f9362243749216a6ec511f58eb Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Mon, 15 Dec 2025 15:34:44 +0800 Subject: [PATCH 2/2] chore: Modify the API version number in the documentation --- content/plus/chat/index-en-US.md | 2 +- content/plus/chat/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/plus/chat/index-en-US.md b/content/plus/chat/index-en-US.md index 9c2815f682..ad4efe7657 100644 --- a/content/plus/chat/index-en-US.md +++ b/content/plus/chat/index-en-US.md @@ -1606,7 +1606,7 @@ render(DefaultChat); |------|--------|-------|-------| | align | Dialog layout, supports `leftRight`,`leftAlign` | string | `leftRight` | | bottomSlot | bottom slot for chat | React.ReactNode | - | -| canSend | Whether the send button is enabled. Normally, no settings are needed; the component internally determines whether sending is enabled. If settings are configured, the settings will prevail. Added in v2.89.0. | boolean | +| canSend | Whether the send button is enabled. Normally, no settings are needed; the component internally determines whether sending is enabled. If settings are configured, the settings will prevail. Added in v2.90.0. | boolean | | chatBoxRenderConfig | chatBox rendering configuration | ChatBoxRenderConfig | - | | chats | Controlled conversation list | Message | - | | className | Custom class name | string | - | diff --git a/content/plus/chat/index.md b/content/plus/chat/index.md index 741fd96145..14c7aba277 100644 --- a/content/plus/chat/index.md +++ b/content/plus/chat/index.md @@ -1609,7 +1609,7 @@ render(DefaultChat); |------|--------|-------|-------| | align | 对话布局方式,支持 `leftRight`、`leftAlign` | string | `leftRight` | | bottomSlot | 底部插槽 | React.ReactNode | - | -| canSend | 发送按钮是否可以发送。通常无需设置,由内部逻辑决定。如有设置,以此设置为准,v2.89.0 新增 | boolean | +| canSend | 发送按钮是否可以发送。通常无需设置,由内部逻辑决定。如有设置,以此设置为准,v2.90.0 新增 | boolean | | chatBoxRenderConfig | chatBox 渲染配置 | ChatBoxRenderConfig | - | | chats | 受控对话列表 | Message | - | | className | 自定义类名 | string | - |