Repository navigation
feat(desktop): 托管 tcpAnnounced 调试适配器 - #1954
Merged
Merged
Conversation
插件声明 tcpAnnounced 传输的调试适配器(例如 Delve 的 `dlv dap`) 现在由宿主拉起进程,按 Core 的 debug.adapters.readAnnouncement 逐行读取它声明的输出流,读到回环端点后用 Core 驱动的 TCP 生命周期连接。 - 公告行不进调试控制台,其余输出照常显示;单行超过 64 KiB 不缓存。 - 传输先于进程启动,Core 默认的 10 秒发现期限同时覆盖进程启动与公告。 - 公告前退出、公告非本机地址、超时都以明确原因结束并停止进程; 新增词条 desktop.debug.notAnnounced(中英)。 - 用户停止时先把 DAP disconnect 排空到网络栈,再停止进程树。 - PINNED_CORE_REVISION 升到 Lithe-core-rust main 的 a58e07e(#47 合入提交)。 - 新增无头截图场景 TestVisualDebugAnnouncedAdapterExitedFirst; debugPluginHarnessOn 拆出 debugPluginOptions 供它复用,行为不变。 - 功能矩阵与三份 Agent Note 去掉 tcpAnnounced 未实现的说法,只保留 tcpPort。 Refs #1953
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 05:01
This was referenced Nov 15, 2026
Closed
18 of 21 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
插件契约里早就有
tcpAnnounced调试传输:适配器进程自己挑一个本机端口监听,把端口打印在输出里,编辑器读到后再去连接。Viva 桌面端之前只接了stdio和tcpLanguageServer,声明tcpAnnounced的适配器在启动前就被拒绝(plugin.launch.unsupportedTransport)。只监听 TCP 的调试器因此接不进来,典型的是 Go 的 Delve:dlv dap没有 stdio 模式,启动后会在 stdout 打印DAP server listening at: 127.0.0.1:<端口>。本 PR 让宿主托管这类适配器。哪一行算公告、怎么解析、只接受回环地址,这些规则都在 Rust Core(Lithe-IDEA/Lithe-core-rust#47,已合入)。宿主只负责拉起进程、按行转交输出,然后用已有的 Core 驱动 TCP 生命周期去连接,不按插件或工具名加分支。
改动 / Changes
Core 接线(
desktop/internal/core)debug_transport.go:新增ReadDebugAnnouncement,调用 Core 的debug.adapters.readAnnouncement,返回三种结果:不是公告、公告了回环端点(host、port)、公告无效。debug_announcement_test.go(新):回放固定 Core 修订中rust/fixtures/debug/adapter-announcements-v1.json的全部用例。启动流程(
desktop/internal/workbench)debug_announced.go(新):openAnnouncedTransport先建 Core TCP 传输,让它进入端点发现阶段,再拉起适配器进程。Core 默认的 10 秒发现期限因此同时覆盖进程启动和等待公告。debugAnnouncementReader把清单launch.endpoint.stream指定的输出流拼成完整行,逐行交给 Core 判定。debug_start.go:debugTransportServed接受tcpAnnounced,启动方式与 stdio 一致:包内文件、系统命令或运行时。tcpPort仍在启动前拒绝。beginDebug新增announced分支:不创建 stdin 管道,走openAnnouncedTransport;initialize 等待窗口加上 Core 的发现期限,和tcpLanguageServer加语言服务器启动期限的做法相同。startAdapterProcess改为由调用方传入输出路由和“未连上就退出”时的错误。stdio 的输出路由抽成stdioDebugOutput,行为不变。tcpAnnounced进程不绑定会话的 context,这样用户停止时可以先把 disconnect 送出去。进程在连上之前退出时,退出码为 0 也算启动失败,日志 stage 记为launch。openHostedTransport中Connected、Deliver、Failure等回调抽成debugStreamHooks,两种 TCP 传输共用,tcpLanguageServer的行为不变。debug.go:releaseDebugSession的停止顺序改为:不需要排空时,先关闭传输再停止进程;用户停止、需要排空时,等 DAPdisconnect送进网络栈后再停止进程。停止开始后才存入的进程也会在这里停掉。停止进程沿用buildprocess.Stop:Unix 给进程组发 SIGTERM,宽限期后发 SIGKILL;Windows 由 Job Object 结束整棵进程树。debug_adapter_start.go:写入失败时用“是否经 TCP 连接”而不是“是否有进程”判断 stage,避免tcpAnnounced被当成 stdio。debug_launch.go:preparedDebugLaunch带上计划里的Endpoint描述,原样交给 Core 读公告用。app.go:Kernel接口增加ReadDebugAnnouncement。pluginhost.go、pluginservice/debug.go:更新能力说明注释,没有逻辑变化。失败处理
以下三种情况都会结束会话并停止适配器进程:
desktop.debug.notAnnounced:“调试适配器还没输出它监听的端口就退出了。” / “The debug adapter exited before printing the port it listens on.”desktop.debug.invalidEndpoint界面文案
shared/i18n/messages.json、locales/zh-CN.json、locales/en-US.json新增desktop.debug.notAnnounced,并重新生成desktop/internal/i18n/shared.generated.go。desktop/internal/i18n/debug_messages.go新增NotAnnounced。Core 固定版本
scripts/desktop/build-desktop-core.sh的PINNED_CORE_REVISION升到 Lithe-core-rust main 的a58e07e(fix: restore Maven project detection #47 的合入提交)。测试
debug_announced_test.go(新):dev.lithe.test.debug-announced,适配器进程是测试二进制本身。debugAnnouncementReader单元测试:分块拼行、各流的行互不混淆、判定后补显示未换行的输出、超长行直接显示、拒绝或读取失败时结束等待、context 取消时结束等待。debug_tcp_test.go:把debugPluginHarnessOn的选项构造抽成debugPluginOptions(…, theme),供截图场景复用,已有测试行为不变。visual_capture_test.go:新增无头截图场景TestVisualDebugAnnouncedAdapterExitedFirst(明暗 × 中英)。功能矩阵与 Agent Note
plugin-debug-adapters.json、debug-tcp-transport.json:两端登记新实现文件和测试;verification 改为tcpAnnounced的验收步骤,只有tcpPort仍在启动前拒绝。状态保持partial/pending。notes同时把旧的 “debugAdapters 1、2、3” 改为契约版本归 0 后的 “0”,并补上startDebugging子会话已接入。2026-10-27-debug-tcp-transport-lifecycle.md:新增tcpAnnounced决策要点(按行转交 Core、64 KiB 上限、传输先于进程、三种失败、停止顺序和两端的停止方式)。“后果”一节改为只剩tcpPort;验证与适用范围同步更新。2026-11-10-viva-java-admission-run-debug-output-links.md:缺口列表只保留tcpPort。2026-10-25-unified-debug-engine-and-adapter-registry.md(proposed):桌面已接 stdio、tcpAnnounced、tcpLanguageServer;tcpPort 与 runSelectedRuntime 未接。不在本 PR 范围内 / Out of scope
tcpPort传输(宿主先选端口再传给进程)仍未接入,启动前拒绝。adapterEndpoint)没有改动。dlv dap,tcpAnnounced),并通过projectGenerators在“新建项目”里加入 Go 项目。这一项在插件仓库 Lithe-IDEA/lithe-plugin-go 另提 PR,宿主不含任何 Go / Delve 专属代码。类型专属:feat
多平台对齐
buildprocess的 Unix 进程组与 Windows Job Object 实现;功能矩阵两端登记同一组文件。Windows 还没有在本机虚拟机上验证,见“验证”。platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/plugin-debug-adapters.json与debug-tcp-transport.json:证据路径和验证动作已更新;没有运行真实适配器验收,两端保持partial/pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空;另外检查了 diff,宿主代码和测试里没有 Go、Delve 或其他具体工具的写法dev.lithe.test.debug-announced)和 Core 契约 fixture(adapter-announcements-v1.json)shared/i18n/;没有改scripts/resources/、docs/ci-builds.mdtcpAnnounced,stdio 和tcpLanguageServer路径的行为不变(已有调试测试全部通过);目前没有已发布插件声明tcpAnnouncedUI 验证 / UI evidence
TestVisualDebugAnnouncedAdapterExitedFirst(提交1c79b718b,场景:适配器公告前退出后的调试面板错误状态,主题 dark / light,语言 zh-Hans / en-US,尺寸 1200×760)。已检查 4 张截图:错误文字完整显示,没有被提示框遮挡.artifacts/visual-evidence/debug-announced-exited/(debug-announced-exited-{dark,light}-{zh-Hans,en-US}.png),合入前需要手工上传统一日志系统 / Structured logging
recordDebugStart,带固定 stage(launch/exit/ 超时),沿用已声明的 debug 事件notAnnounced,不会重复记录会话失败界面文案 / i18n
desktop.debug.notAnnounced中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果;Viva 代码通过i18n.DebugMessages.NotAnnounced读取shared/i18n/node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check逻辑归属 / Logic placement
性能与内存 / Performance and memory
tcpAnnounced调试时才拉起适配器进程;没有轮询,等待公告靠 Core 下发的发现定时器;拆行缓冲每个流最多 64 KiB;会话结束时停止进程树post过来的控制台输出设置 / Settings
N/A:没有新增或修改设置。
插件契约 / Plugin contract
launch.endpoint的stream/prefix/value、debug.adapters.readAnnouncement、targetBindings.program: "target.directory")已在 feat(debug): tcpAnnounced 公告解析命令与 target.directory 程序绑定 Lithe-IDEA/Lithe-core-rust#47 里随执行代码一起提交,并登记了shared/plugins/reference/protocol-changelog.md;2026-11-15 合入 main,提交a58e07ePINNED_CORE_REVISION已升到a58e07e000627c37843b242525c46de5474ae37b;桌面测试经scripts/desktop/desktop-go.sh读取这份契约 fixturereadAnnouncement的归属debug.adapters.readAnnouncement是宿主调用 Core 的命令,不是暴露给插件的宿主方法发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
openHostedTransport的回调抽成了两种传输共用的debugStreamHooks,stdio 的输出路由抽成了stdioDebugOutput验证 / Verification
./scripts/desktop/desktop-go.sh test -count=1 -run 'DebugAnnounce' ./internal/workbench/ ./internal/core/(固定 Corea58e07e)./scripts/desktop/desktop-go.sh test -count=1 -run 'Debug|Breakpoint' ./internal/workbench/./scripts/desktop/desktop-go.sh test -race -count=1 -run 'DebugAnnounce|DebugTCP|DebugAdapter' ./internal/workbench/ ./internal/core/./scripts/desktop/desktop-go.sh test -race -count=1 ./internal/pluginhost/ ./internal/pluginservice/./scripts/desktop/desktop-go.sh test ./...internal/localshell的TestShellIsBusyWhileAForegroundCommandRuns在全量负载下失败一次(Ctrl+C 后 Busy 没有清除),单独运行 3/3 通过;它与本 PR 无关,是已有的负载敏感测试。其余全部通过LITHE_VISUAL_OUTPUT_DIR=<目录> ./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run TestVisualDebugAnnouncedAdapterExitedFirst ./internal/workbench/gofmt -l;go vet(带与不带vivahead lithevisual标签)node scripts/i18n/verify-app-language-localization.mjs;node scripts/i18n/generate-i18n.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;…-change.sh origin/preview HEAD./scripts/agent-notes/verify-agent-notes.sh./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.shdevelop-lithe第三节插件归属自查rg未能执行的检查和原因:
提交前确认 / Final checks
preview(061aecfe5)创建,目标分支preview.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图