fix(Inputbar): enhance message usage estimation and clean up code structure

This commit is contained in:
kangfenmao 2025-04-04 10:34:08 +08:00
parent 10848f7a45
commit 3768c135d8
2 changed files with 14 additions and 4 deletions

View File

@ -180,11 +180,13 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
if (mentionModels) {
userMessage.mentions = mentionModels
}
if (isFunctionCallingModel(model)) {
if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) {
userMessage.enabledMCPs = activedMcpServers.filter((server) => enabledMCPs?.some((s) => s.id === server.id))
}
}
userMessage.usage = await estimateMessageUsage(userMessage)
currentMessageId.current = userMessage.id

View File

@ -90,8 +90,7 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ resolve, tab, ...prop
content: {
padding: 0,
overflow: 'hidden',
background: 'var(--color-background)',
border: `1px solid var(--color-frame-border)`
background: 'var(--color-background)'
},
header: { padding: '10px 15px', borderBottom: '0.5px solid var(--color-border)', margin: 0 }
}}
@ -100,8 +99,7 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ resolve, tab, ...prop
centered>
<HStack>
<LeftMenu>
<Menu
style={{ width: 220, padding: 5, background: 'transparent' }}
<StyledMenu
defaultSelectedKeys={[tab || 'prompt']}
mode="vertical"
items={items}
@ -195,6 +193,16 @@ const StyledModal = styled(Modal)`
}
`
const StyledMenu = styled(Menu)`
width: 220px;
padding: 5px;
background: transparent;
margin-top: 2px;
.ant-menu-item {
margin-bottom: 7px;
}
`
export default class AssistantSettingsPopup {
static show(props: AssistantSettingPopupShowParams) {
return new Promise<Assistant>((resolve) => {