feat(ui): 实现 LSP UI 集成

- 添加 LSP 相关类型定义 (LSPServer, FileDiagnostic, DiagnosticsResponse)
- 添加 LSP API 函数 (listLSPServers, installLSPServer, startLSPServer 等)
- 创建 LSPPanel 组件: 语言服务器管理面板
- 创建 DiagnosticsPanel 组件: 诊断详情面板 (含搜索过滤)
- 创建 DiagnosticsIndicator 组件: 状态栏指示器
- 集成到 Web 模块 (App.tsx, Chat.tsx)
This commit is contained in:
2025-12-17 11:17:00 +08:00
parent c5b92e740c
commit 1019ba7c9c
8 changed files with 1673 additions and 1 deletions
+96
View File
@@ -50,6 +50,9 @@ import type {
CompressionResult,
// File search types
FileSearchResponse,
// LSP types
LSPServer,
DiagnosticsResponse,
} from './types.js';
// Re-export types
@@ -135,6 +138,13 @@ export type {
QuestionOption,
Question,
QuestionMessagePart,
// LSP types
LSPServer,
FileDiagnostic,
DiagnosticsSummary,
SingleFileDiagnosticsResponse,
AllFilesDiagnosticsResponse,
DiagnosticsResponse,
} from './types.js';
// API Configuration
@@ -1003,3 +1013,89 @@ export async function searchFiles(
});
return request('GET', `/files/search?${params}`);
}
// ============ LSP API ============
/**
* 获取所有语言服务器列表
*/
export async function listLSPServers(): Promise<{
success: boolean;
data: LSPServer[];
error?: string;
}> {
return request('GET', '/lsp/servers');
}
/**
* 获取单个语言服务器详情
*/
export async function getLSPServer(id: string): Promise<{
success: boolean;
data?: LSPServer;
error?: string;
}> {
return request('GET', `/lsp/servers/${encodeURIComponent(id)}`);
}
/**
* 安装语言服务器
*/
export async function installLSPServer(id: string): Promise<{
success: boolean;
data?: { message: string; server: LSPServer };
error?: string;
}> {
return request('POST', `/lsp/servers/${encodeURIComponent(id)}/install`);
}
/**
* 启动语言服务器
* @param id 服务器 ID
* @param filePath 需要提供一个文件路径来触发对应语言的服务器
*/
export async function startLSPServer(
id: string,
filePath: string
): Promise<{
success: boolean;
data?: { message: string; isFirstStart: boolean; runningServers: string[] };
error?: string;
}> {
return request('POST', `/lsp/servers/${encodeURIComponent(id)}/start`, { filePath });
}
/**
* 停止语言服务器
*/
export async function stopLSPServer(id: string): Promise<{
success: boolean;
data?: { message: string; runningServers: string[] };
error?: string;
}> {
return request('POST', `/lsp/servers/${encodeURIComponent(id)}/stop`);
}
/**
* 获取正在运行的语言服务器列表
*/
export async function getRunningLSPServers(): Promise<{
success: boolean;
data: string[];
error?: string;
}> {
return request('GET', '/lsp/running');
}
/**
* 获取诊断信息
* @param file 可选,指定文件路径获取单个文件的诊断
*/
export async function getLSPDiagnostics(file?: string): Promise<{
success: boolean;
data: DiagnosticsResponse;
error?: string;
}> {
const params = file ? `?file=${encodeURIComponent(file)}` : '';
return request('GET', `/lsp/diagnostics${params}`);
}