-
Notifications
You must be signed in to change notification settings - Fork 448
feat: improve LLM context service enhance logic #4527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9cbf8e9
bbe9031
3e0c66c
6807973
ef93e42
91eff91
90cf1d5
d88160f
e9b42d9
b78e787
a3edb91
c4c255e
1664b45
b6cc5cb
12a9683
22e2db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -201,14 +201,14 @@ export class MCPConfigService extends Disposable { | |||||||||||||||||||||||||||||||||||||||||||||
| delete servers[prev.name]; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| servers[data.name] = serverConfig; | ||||||||||||||||||||||||||||||||||||||||||||||
| await this.sumiMCPServerBackendProxy.$addOrUpdateServer(data as MCPServerDescription); | ||||||||||||||||||||||||||||||||||||||||||||||
| // 更新情况下,如果原有服务是启用状态,则进行如下操作: | ||||||||||||||||||||||||||||||||||||||||||||||
| // 1. 关闭旧的服务 | ||||||||||||||||||||||||||||||||||||||||||||||
| // 2. 启动新的服务 | ||||||||||||||||||||||||||||||||||||||||||||||
| await this.preferenceService.set('mcp', { mcpServers: servers }); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (prev?.enabled) { | ||||||||||||||||||||||||||||||||||||||||||||||
| await this.sumiMCPServerBackendProxy.$removeServer(prev.name); | ||||||||||||||||||||||||||||||||||||||||||||||
| this.sumiMCPServerBackendProxy.$removeServer(prev.name); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| await this.preferenceService.set('mcp', { mcpServers: servers }); | ||||||||||||||||||||||||||||||||||||||||||||||
| this.sumiMCPServerBackendProxy.$addOrUpdateServer(data as MCPServerDescription); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+207
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 调整了保存服务器配置的操作顺序和异步行为 代码改动将首先更新偏好设置,然后异步执行后端服务器操作而不等待完成。这种变更有以下影响:
建议添加错误处理机制以捕获后端操作可能出现的错误: await this.preferenceService.set('mcp', { mcpServers: servers });
if (prev?.enabled) {
- this.sumiMCPServerBackendProxy.$removeServer(prev.name);
+ this.sumiMCPServerBackendProxy.$removeServer(prev.name).catch(error => {
+ this.logger.error(`无法移除服务器 ${prev.name}:`, error);
+ this.messageService.error(localize('ai.native.mcp.error.remove.server', '无法移除服务器: {0}', error.message || error));
+ });
}
-this.sumiMCPServerBackendProxy.$addOrUpdateServer(data as MCPServerDescription);
+this.sumiMCPServerBackendProxy.$addOrUpdateServer(data as MCPServerDescription).catch(error => {
+ this.logger.error(`无法添加或更新服务器 ${data.name}:`, error);
+ this.messageService.error(localize('ai.native.mcp.error.add.server', '无法添加或更新服务器: {0}', error.message || error));
+});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents (early access) |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| async deleteServer(serverName: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.