Repository navigation
feat(desktop): 服务运行按调试类型连接其他插件的调试适配器 (#2107) - #2113
Merged
Merged
Conversation
- 构建插件的服务运行声明 debug.configurationType 时,宿主选出唯一一个已启用、 能以连接方式 attach 该类型的适配器,分配本机端口,带 launchOptions.debug 请求插件准备,端口打开后 attach;会话和服务一起结束。没有或有多个适配器时在 准备前提示原因。 - Build 窗口直接运行服务/任务类运行时带上 launchOptions(Core 否则拒绝)。 - 插件安装、启用、停用或卸载后重新读取调试适配器。 - 运行进程不再受 30 分钟准备时限约束,常驻服务不会被结束。 - 语言服务器里的调试适配器等服务器声明 executeCommand 后再请求端口。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Lithe Review
审查提交:1dc936d6dfde247f13d98b03c01be7ae96831894。
[P2] 等待调试适配器期间应保留发起操作的 Build 实例
位置:desktop/internal/workbench/build_connection_debug.go:139–142,以及 desktop/internal/workbench/build.go:1437–1442。
debugServiceTarget 把启动回调交给 prepareConnectionDebug,只捕获了 targetID 和 run。当适配器尚未加载、回调需要等待时,用户仍可切换 Build 实例;回调中的 startBuildTarget 随后重新读取 p.selectedBuildInstance(),使启动对象变成后来选中的实例,而不是点击“调试”的实例。
触发顺序:在实例 A 的目标上点击 Debug → 适配器加载尚未完成 → 切换到实例 B → 适配器加载完成。若 A、B 有相同目标 ID(例如两个构建根的同名服务目标),当前代码会把 B 传入 runBuildTargetWith,从而准备并运行错误项目的服务;若 B 没有该 ID,则原本有效的 A 操作被报告为目标不存在。
建议在发起时捕获实例的稳定身份及目标/运行身份,回调时核验该实例仍有效,并显式用捕获的实例启动,不能再把当前选择作为启动对象。请补充受控延迟适配器加载、期间切换实例的回归测试,断言启动的仍是 A,或在 A 已失效时安全取消,绝不启动 B。
我实际执行的验证与边界
- 环境:Linux、Go 1.27.3。
- 将通过 Bot 从上述提交取得的
debugServiceTarget与startBuildTarget原函数放入隔离 Go harness,仅调整类型命名空间,并以替身控制适配器回调和记录下游启动实例。执行go test -json -count=1 .:TestInstanceSwitchDuringAdapterLoad通过(0.002s),实际观察到A 发起 → 切换 B → 释放回调 → 启动 B。此处“通过”表示复现断言成立,不表示产品行为正确。 - 同批局部检查还实际执行了
WaitForDebugPort的真实 loopback 成功、进程结束、超时及取消分支,以及waitPluginServerFeature的延迟注册、超时及取消分支,均通过;后者使用受控窗口队列替身。 - 未完成完整应用无头、真实 DAP/服务生命周期及 macOS/Windows 验证,没有本轮应用截图。 当前尚无完整可核验 Bot 来源的应用依赖工作区;固定的
Lithe-IDEA/viva依赖不在当前 Bot 可访问仓库范围内。本轮遵守仅经 Bot 读取源码的限制,没有改用个人账号或匿名获取。 - PR 中作者报告的端到端测试与截图不计为我的实测。上述隔离测试只证明此处异步实例捕获问题,不构成整个 PR 全面通过的结论。
本次所有发现集中在这一条 Review,无零散行评论。
1lck
marked this pull request as ready for review
November 17, 2026 14:45
1 task done
1lck
added a commit
to Lithe-IDEA/lithe-plugin-maven
that referenced
this pull request
Nov 17, 2026
- 新增宿主端到端测试 TestOfficialMavenPluginDebugsASpringBootApplication:和 Java Support 一起安装,断点命中、继续后请求完成、停止后服务结束;登记进 lithe-host.json,宿主固定到 合入 1lck/Lithe-IDEA#2113 的 1ce4085e7。 - installOfficialPluginArchive 像 app.go 一样给插件服务接上 LogDirectory,语言服务器的 ${logDir} 才有值。 - README 和功能矩阵:调试已可用,记录验证结果。 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
31 of 37 tasks
1 task done
31 of 32 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
Maven 插件的 Spring Boot 运行配置已经可以运行,但点“调试”会提示“这个配置不能调试”。原因是:这类服务运行在清单里声明的是公共调试类型(
debug: {"configurationType": "java"}),意思是“由任意插件里能连接java类型的调试器来调试我”,而宿主还没实现 Core 契约里这段“注册表连接调试(Registry connection debugging)”流程。本 PR 实现这段流程。实测中还暴露了三个原有缺陷,它们会让这个功能用不起来或在使用中断掉,一并修复。改动 / Changes
按调试类型连接调试(新功能)
pluginservice/builds.go:运行声明读取debug.configurationType,新增BuildRunDeclaration.Debuggable()(自带适配器或声明了公共类型都算可调试);标题栏、Build 窗口树和右键菜单改用它判断。core/run_config.go:RunLaunchOptions增加debug(adapterID、configurationType、target{kind: connection, host, port}),按 Corecf2f260的契约编码,本 PR 不改 Core。workbench/build_connection_debug.go:attach、能以连接方式接入、configurationTypes含该类型。没有或有多个匹配时,在请求插件之前就提示原因,记operation_rejected。launchOptions.debug请求插件准备运行,服务以等待调试器的方式启动。attach。如果适配器在等待期间被停用或替换,就停止服务并提示;端口 30 秒没打开,也停止服务并提示。title_run.go、build.go、runconfig.go:标题栏“调试”和 Build 窗口的“调试”都走这条路径;运行配置里保存的参数照常生效;“重新运行”时会重新以调试方式启动。修复的原有缺陷
launchOptions,Core 会拒绝。现在带上空的launchOptions(build.go的startBuildTarget)。debug.go的invalidateDebugAdapters);读取进行中又发生变化时,读完后会再读一次;当前选中的适配器尽量保持不变。signal: killed)。现在只有准备阶段受时限(runPreparationTimeout),进程一直运行到自己退出、用户停止或项目关闭。Agent Note:2026-11-17-run-process-outlives-preparation-timeout.md。tcpLanguageServer),以前在服务器就绪后立刻执行端点命令。有的语言服务器(例如 JDT LS)在就绪之后才用client/registerCapability注册命令,Core 会在注册前以not_supported拒绝。现在宿主会等featuresChanged里出现executeCommand再发命令,最长等 2 分钟(debug_start.go的waitPluginServerFeature)。Agent Note:2026-11-17-hosted-debug-waits-for-registered-commands.md。其他
pluginservice/runs.go:等待调试端口的逻辑改成导出的WaitForDebugPort,并带有ErrDebuggeeEnded、ErrDebugPortTimeout,供工作台复用;行为不变。desktop.build.*文案(没有适配器、有多个适配器、适配器已失效、端口超时、已有调试会话)。viva-title-run-debug:能力、证据和验证说明同步更新。build_connection_debug_visual_test.go(vivahead标签),截图在docs/assets/service-debug/。不在本 PR 范围内 / Out of scope
Debugger failed to attach: handshake failed,之后继续等待真正的调试器,不影响调试。这是WaitForDebugPort原有的行为。类型专属:feat
多平台对齐
platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/viva-title-run-debug.json:能力说明、证据(新增build_connection_debug.go、build_connection_debug_test.go、plugins.go、debug_start.go、debug_tcp_test.go)、验证动作;两端验证状态保持pending(Windows 未实机验证)./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(197 条)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(通过).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空dev.lithe.test.provider-tests、fixture-attach类型的合成适配器);没有读取具体插件的包、检出或清单,没有“缺少插件时跳过”的测试shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillTestOfficialMavenPluginBuildsAReactor、TestOfficialMavenPluginRunsASpringBootApplication、新增的TestOfficialMavenPluginDebugsASpringBootApplication),使用 Java Support 4.0.1 发布包,对本分支全部通过(见“验证”)UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=<dir> scripts/desktop/desktop-go.sh test -tags vivahead ./internal/workbench/ -run TestVisualServiceDebugWithoutAnAdapter -count=1,提交08b1a188d0b20c75c6c0b90cdc489ff2efeb8890,1280×800,scale 1;场景:亮色/中文、暗色/英文;分别截取没有匹配适配器时点“调试”后的提示气泡,以及通知中心里的完整文字统一日志系统 / Structured logging
app.notification.operation_failed/operation_rejected事件(经operationFailed、operationRejected),operation取固定值:build_debug_connection(reason 为no_adapter、ambiguous_adapter、session_running)、build_debug_port、build_debug_attach;没有新事件,也没有print或直接写 stderrprepareConnectionDebug记一次;attach 失败在attachServiceDebugger或attachServiceDebugSession记一次,之后走正常的停止流程界面文案 / i18n
shared/i18n/补齐 5 条中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果shared/i18n/node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过逻辑归属 / Logic placement
launchOptions.debug的校验、execution == service、类型必须与声明一致)由 Corecf2f260执行,本 PR 没有改动。宿主只负责平台相关的部分:读取已安装的适配器、分配端口、等待端口、管理进程和会话的生命周期,这些是契约明确交给宿主的configurationTypes和声明的请求类型匹配性能与内存 / Performance and memory
设置 / Settings
N/A:没有新增或修改设置。
插件契约 / Plugin contract
N/A:使用 Core
cf2f260(已固定)里现有的“Registry connection debugging”契约,没有改契约、能力版本或宿主方法。发行包与资源 / Bundle and resources
N/A:没有新增运行时资源、缓存或下载物。
无用代码与重构 / Dead code and refactoring
pluginservice里未导出的waitForPort和runDebugConnectTimeout改为导出版本,没有保留两份)验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/workbench/ ./internal/pluginservice/ ./internal/core/ ./internal/i18n/ ./internal/buildprovider/ ./internal/buildprocess/ -count=1debug_start.go后再跑./internal/workbench/ ./internal/pluginservice/TestTitleDebugAttachesTheRegisteredAdapterToAServiceRun:标题栏调试 → 提供者收到launchOptions.debug(adapterID、类型、本机端口)→ 合成服务监听端口 → 合成适配器 attach → 在调试窗口点停止后服务结束TestServiceDebugRefusesAMissingOrAmbiguousAdapterBeforePreparing:没有或有两个匹配适配器时提示原因,不请求提供者TestDebugAdaptersAreReadAgainWhenPluginsChangeinvalidateDebugAdapters时失败(“the adapters without the disabled plugin did not happen before the deadline”),修复后通过TestServiceRunOutlivesItsPreparationBound(准备时限缩到 5 秒,服务需要运行到 6 秒)进程结束:signal: killed;修复后通过TestHostedDebugWaitsForTheServerToOfferCommands+ 现有TestDebugTCP*TestOfficialMavenPluginDebugsASpringBootApplicationGET /hello停在ShopApplication.java的断点,请求在断点处阻塞,点“继续”后返回Hello, Lithe from eu-west;在调试窗口点停止后服务结束、端口释放,插件包未被改动。加入命令等待之前,同一测试失败,报lsp.request: The language server did not advertise this capability. (not_supported)TestOfficialMavenPluginBuildsAReactor、TestOfficialMavenPluginRunsASpringBootApplicationTestVisualServiceDebugWithoutAnAdapter(vivahead)scripts/desktop/desktop-go.sh vet(workbench、pluginservice、core,以及-tags vivahead下的 workbench)、gofmt -lnode scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/agent-notes/verify-agent-notes.shrg未能执行的检查和原因: 没有在 Windows 上实机运行。代码没有平台分支,端口和进程都走已有的跨平台实现(
buildprocess、WaitForDebugPort);Windows 编译和测试由 CI 检查。提交前确认 / Final checks
main创建,并已合入最新的 main;目标分支main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图🤖 Generated with Claude Code