feat(desktop, agent-core): 接入 TypeScript LSP 诊断与 Agents 设置页#69
Conversation
引入 lsp 目录、PATH 解析 typescript-language-server、诊断文本格式化及单测;添加 vscode-jsonrpc 与 vscode-languageserver-protocol 依赖。
新增 LspConnection、文档同步与 LspService;支持 publishDiagnostics 缓存、防抖 didChange 及按路径拉取诊断。
HostToolExecutorProxy 与 DesktopToolExecutor 集成 LspService;PATH 无 typescript-language-server 时不暴露工具。
fileChangeObserver 触发文档同步;写类工具成功后追加 [lsp] 诊断摘要块。
补充 Ask 模式工具可见性、tool-request/write-append 单测与 lsp-typescript-smoke;eval:scenario:validate 通过。
host-bridge 进程退出前 dispose LSP;Desktop 切换工作区时释放非当前 workspace 的 LspService 缓存。
DesktopToolRequest 联合类型不含 LSP 工具;经 JsonValue 守卫后再读取 path,消除 build:electron 报错。
流式回合在 tool preview 后以 before-next-tool 固化思考;defer 仅在整轮尚无工具行时生效。timeline 新 segment 前完成上一段,UI 不再渲染空 Thought。Windows 上对 .cmd/.bat 使用 shell spawn,并补充 connection 单测。
正文已出现后不再 defer 到 aux;首个 tool preview 前以 before-next-tool 固化。stripSegmentAux 仅匹配同文 aux;before-next-tool 在无工具时落入 before-tools 段。UI 在后续仍有工具时保持已固化 Thought 可见。
TLS 5.x 须在 initialize 声明 publishDiagnostics,否则 diagnosticsSupport 为 false 且不会推送诊断。Windows 上统一 TLS 返回的 file URI(盘符大小写、d%3A 编码),避免诊断缓存键与 waiter 不一致。get_diagnostics 调用前清除旧缓存;新增集成测试覆盖类型错误上报与二次调用。 已撤销调试阶段基于错误根因的改动:diagnosticsQuietMs 静默等待、writeAppend 超时加长、sync 路径上的 invalidate 及 Cursor ingest 埋点。
写工具完成后等待诊断稳定并透传 hostUi 至 Desktop snapshot;工具卡 headline 旁显示 error/warning 计数与 Hover 详情,色阶与文件名一致。
在 Desktop 设置中新增「智能体」选项卡,含 LSP 总开关、provider 发现列表与 npm 全局安装;偏好写入 config.json agents.lsp,关闭时禁用诊断工具与写后检查。
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.
| const diagnostics = await lsp.getDiagnosticsForPath( | ||
| resolvedPath, | ||
| DEFAULT_LSP_TIMING.diagnosticsWaitMs, | ||
| ); |
There was a problem hiding this comment.
Write append uses wrong wait
Medium Severity
appendLspDiagnosticsAfterWriteIfNeeded waits on diagnosticsWaitMs (4s) instead of the dedicated writeAppendDiagnosticsWaitMs (1.5s), so every successful TS/JS write blocks tool completion on the longer agent-facing timeout.
Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.
| ctx.invalidateToolExecutors(); | ||
| await ctx.refreshLspSnapshot(); | ||
| ctx.activeBundle().deferredRuntimeRefreshWhileBusy = false; | ||
| await ctx.refreshRuntime(); |
There was a problem hiding this comment.
Install forces runtime refresh
Medium Severity
installLspProviderCommand clears deferredRuntimeRefreshWhileBusy and always calls refreshRuntime, even when the agent runtime is already busy, which can rebuild the active session runtime mid-turn instead of deferring like other config changes.
Reviewed by Cursor Bugbot for commit 73d87bc. Configure here.
write-append 改读 writeAppendDiagnosticsWaitMs(默认 4s,实测 1.5s 常无诊断); installLspProvider 在 runtime busy 时设 deferredRuntimeRefreshWhileBusy,与 config 变更一致。


Summary
get_diagnostics宿主工具,以及写文件后同步诊断并附摘要。npm install -g;偏好持久化至config.json的agents.lsp.enabled。get_diagnostics与写后诊断;配置变更后 dispose 缓存并重建 executor。Test plan
npm run build:agent-core与npm run build:desktopnode --test packages/agent-core/dist/lsp/providers.test.js packages/agent-core/dist/lsp/service-probe.test.jsnode --test apps/desktop/test/host/lsp-snapshot.test.mjsget_diagnostics与写后徽章