diff --git a/web/frontend/src/pages/chat/ChatSettings.jsx b/web/frontend/src/pages/chat/ChatSettings.jsx index c1b7b8d2..1e2869f5 100644 --- a/web/frontend/src/pages/chat/ChatSettings.jsx +++ b/web/frontend/src/pages/chat/ChatSettings.jsx @@ -82,9 +82,61 @@ function SettingSelect({ label, ...props }) { ); } +export function ModelSettings({ model, busy, canReadConfig }) { + const t = useT(); + const defaultId = model.config.data?.default_channel; + const defaultName = defaultId ? modelChannelName(defaultId, model.config.data?.channels?.[defaultId]) : ''; + const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道'); + const channelOptions = [ + { value: '', label: defaultName ? `${defaultLabel} · ${defaultName}` : defaultLabel }, + ...modelChannelOptions(model.channels) + ]; + const reasoningLabels = { + default: t('chat.reasoningModeDefault', null, '跟随系统'), + off: t('chat.reasoningModeOff', null, '关闭'), + on: t('chat.reasoningModeOn', null, '开启'), + auto: t('chat.reasoningModeAuto', null, '自动') + }; + return ( + <> + {canReadConfig && ( + <> + + model.config.reload()} /> + + )} + ({ value, label: reasoningLabels[value] }))} + onSelect={model.setMode} + disabled={busy} + /> + ({ value, label: value })) + ]} + onSelect={model.setEffort} + disabled={busy || model.mode === 'off'} + /> + + ); +} + export default function ChatSettings({ onClose, narrow, busy, canReadConfig, canReadHitl, canEnableHitl, - model, conversationId, draftHitl, onDraftHitlChange + model, conversationId, draftHitl, onDraftHitlChange, section = 'all' }) { const t = useT(); const [saving, setSaving] = useState(false); @@ -109,19 +161,6 @@ export default function ChatSettings({ setToolsDirty(false); }, [approvals.data, conversationId]); - const defaultId = model.config.data?.default_channel; - const defaultName = defaultId ? modelChannelName(defaultId, model.config.data?.channels?.[defaultId]) : ''; - const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道'); - const channelOptions = [ - { value: '', label: defaultName ? `${defaultLabel} · ${defaultName}` : defaultLabel }, - ...modelChannelOptions(model.channels) - ]; - const reasoningLabels = { - default: t('chat.reasoningModeDefault', null, '跟随系统'), - off: t('chat.reasoningModeOff', null, '关闭'), - on: t('chat.reasoningModeOn', null, '开启'), - auto: t('chat.reasoningModeAuto', null, '自动') - }; const modeLabels = { off: t('chat.hitlModeOff', null, '关闭'), approval: t('chat.hitlModeApproval', null, '审批模式'), @@ -188,7 +227,7 @@ export default function ChatSettings({ return (
- {canReadConfig && ( - <> - - model.config.reload()} /> - - )} - ({ value, label: reasoningLabels[value] }))} - onSelect={model.setMode} - disabled={busy} - /> - ({ value, label: value })) - ]} - onSelect={model.setEffort} - disabled={busy || model.mode === 'off'} - /> + {section !== 'hitl' && } {canReadHitl && (
- {t('chat.hitlTitle', null, '人机协同')} + {section !== 'hitl' && {t('chat.hitlTitle', null, '人机协同')}} {t('chat.sessionSettingsHint', null, '人机协同设置只影响后续消息。')} diff --git a/web/frontend/src/pages/chat/Composer.jsx b/web/frontend/src/pages/chat/Composer.jsx index aaacf27d..aaacaed0 100644 --- a/web/frontend/src/pages/chat/Composer.jsx +++ b/web/frontend/src/pages/chat/Composer.jsx @@ -1,8 +1,9 @@ -/** 发送区:文本、附件、代理模式、项目选择、发送/停止。 */ -import { useRef } from 'react'; -import { Banner, Button, Select, Space, Tag, TextArea, Tooltip, Typography } from '@douyinfe/semi-ui'; -import { IconPaperclip, IconSend, IconStop } from '@douyinfe/semi-icons'; +import { useId, useRef } from 'react'; +import { Banner, Button, Popover, Select, Tag, TextArea, Tooltip, Typography } from '@douyinfe/semi-ui'; +import { IconArrowUp, IconChevronDown, IconDesktop, IconFolder, IconPaperclip, IconPlus, IconShield, IconStop } from '@douyinfe/semi-icons'; import { useT } from '../../lib/i18n'; +import { modelChannelName } from '../../lib/model-channel'; +import { ModelSettings } from './ChatSettings'; const { Text } = Typography; @@ -25,7 +26,10 @@ export default function Composer({ onProjectChange, onCreateProject, projects, - showProjectSelect, + projectDisabled, + model, + canReadConfig, + onOpenHitl, attachments, onPickFiles, onRemoveAttachment, @@ -33,6 +37,8 @@ export default function Composer({ }) { const t = useT(); const fileRef = useRef(null); + const modeLabelId = useId(); + const projectLabelId = useId(); const list = Array.isArray(attachments) ? attachments : []; const modeOptions = [ { value: 'single', label: t('chat.agentModePiSingle', null, '单代理') }, @@ -44,17 +50,28 @@ export default function Composer({ { value: '', label: t('chat.noProject', null, '不绑定项目') }, ...(Array.isArray(projects) ? projects : []).map(project => ({ value: project.id, label: project.name || project.id })) ]; + if (projectId && !projectOptions.some(option => option.value === projectId)) { + projectOptions.push({ value: projectId, label: projectId }); + } if (onCreateProject) { projectOptions.push({ value: CREATE_PROJECT, label: `+ ${t('projects.newProject', null, '新建项目')}` }); } const uploadingCount = Number(uploading) || list.filter(item => item.uploading).length; const blocked = !canWrite || !canExecute; + const busy = sending || checkingRun; + const channelId = model.channel || model.config.data?.default_channel; + const channelName = channelId + ? modelChannelName(channelId, model.config.data?.channels?.[channelId]) + : t('chat.aiChannelDefaultShort', null, '默认通道'); + const reasoningSummary = model.mode === 'off' + ? t('chat.reasoningModeOff', null, '关闭') + : model.effort || t('chat.reasoningSummaryFollow', null, '系统'); const handleKeyDown = event => { if (event.key !== 'Enter' || event.shiftKey) return; if (event.nativeEvent?.isComposing) return; event.preventDefault(); - if (sending || checkingRun || blocked || uploadingCount > 0) return; + if (busy || blocked || uploadingCount > 0) return; onSend(); }; @@ -71,107 +88,151 @@ export default function Composer({ : t('chat.noExecutePermission', null, '当前账号没有智能体执行权限(agent:execute),发送已禁用。')} /> )} - {list.length > 0 && ( -
- {list.map(file => ( - onRemoveAttachment(file.id)} - > - - {file.fileName} - - {file.uploading ? '上传中…' : (file.error ? '上传失败' : '已上传')} - - - ))} +
+
+ + { + if (value === CREATE_PROJECT) onCreateProject?.(); + else onProjectChange(value); + }} + prefix={} + className="chat-context-select chat-composer-project" + aria-labelledby={projectLabelId} + disabled={busy || projectDisabled || !canWrite} + />
- )} -
- { - if (event.target.files?.length) onPickFiles(Array.from(event.target.files)); - event.target.value = ''; - }} - /> -