Repository navigation
fix(desktop): 补齐构建探测超时回退、热重载与标题栏模型错误提示 (#2154, #2027, #2147) - #2222
Merged
Merged
Conversation
1lck
marked this pull request as ready for review
November 20, 2026 04:44
Contributor
There was a problem hiding this comment.
Lithe Review
结论: 建议合入前把插件刷新和运行会话清理分开。另有一个已实测的探测超时边界。
范围: main@0119f410 ← e0ad9947,18 个变更文件。
- [P1 / 本次引入,调用链核实] 安装无关插件会取消其他标签页的运行任务。
desktop/internal/workbench/plugins.go:250,263–267对每次成功安装都遍历标签页执行invalidateBuild,不区分插件是否参与构建。该方法在desktop/internal/workbench/build.go:2315–2316调用stopBuildSessions,后者在:2278–2290取消当前构建和正在运行的任务;保留的是 Run 历史,不是进程。比如 A 标签页正在运行应用,B 中安装主题或语言插件,A 的任务也进入停止路径,而旧安装流程只刷新插件状态和语言。建议将模型缓存失效与会话终止拆开,仅在停用、卸载或替换确实影响该会话的插件时停止它;补一条跨标签页测试,断言安装无关插件后 A 的 PID 和运行状态保持。该项尚未在完整桌面应用中复现。 - [P2 / 本次超时修复遗漏,已实测] 探针超时后处理 SIGTERM 并退出 0,会被当作成功。
desktop/internal/workbench/build.go:1573–1584只在waitErr != nil时检查截止时间。在 Unix 开启优雅停止宽限时,探针若先打印版本、等到超时、收到 SIGTERM 后退出 0,当前函数仍返回版本和 nil,候选回退不会因超时启动。建议先检查父上下文和探针截止状态,再判断退出码;补上“先输出版本、超时收到终止信号后退出 0”的测试。
验证: Linux amd64 / Go 1.27.3,从此 head 提取原样 probeBuildTool、captureBuildProcess 和实际 Unix 子进程实现,在隔离 harness 用真实子进程执行 go test ./internal/probereview -run TestProbe -count=3 -v。探测时限 1s、停止宽限 2s:超时用例 3/3 在约 1s 后返回版本且报错为 nil;正常退出对照 3/3 通过。仅在隔离副本改为优先检查上下文后,两用例均 3/3 通过。未修改仓库。此测试不覆盖完整运行配置 UI、热装、Windows 或 macOS 本机行为。精确 head 的 Desktop CI 已通过 Linux、macOS、pins 和格式,提交此评审时 Windows 尚未结束。
This was referenced Nov 20, 2026
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
Lithe-IDEA/lithe-plugin-maven跟进)PR 类型 / Type
改动说明 / What changes
背景 / Why
用户在打开 Maven/Java/Spring Boot 项目时,多处问题叠加导致启动类无法识别或无法正常启动:
probeBuildTool没有单次探测超时保护,且错误退出或损坏的 wrapper 输出被继续校验或直接终止,未能自动回退到后续PATH/环境候选。Source == "generated"),用户在运行配置编辑器里未修改其它字段、仅显式选择Save to作用域(如保持local并确认保存)时,dirty()返回false,导致确定/应用按钮不会将其写入.lithe/run/。invalidateBuild将generation重置为0,且热装/禁用未跨打开的标签页重新触发构建探测;在停用/卸载最后一个构建插件后,providerRuns返回loaded=false导致 Core 未收到空快照[],旧的自动生成运行配置仍残留在标题栏和列表里。改动 / Changes
desktop/internal/workbench/build.go:新增buildToolProbeTimeout = 10 * time.Second限制probeBuildTool单次执行时间,任何非零退出立即拒绝并返回错误,不采信失败输出;重构resolveBuildExecutable与resolveAndCheckBuildCandidates/resolveOneBuildCandidate,非终态(非setting、非pinnedtoolchain)候选在版本探测或检查失败时自动回退到下一个候选,保持明确设置/锁定工具链的终态拒绝语义。desktop/internal/workbench/build_probe_test.go、settings_toolchains_test.go:补充进程内自重启探测替身测试(覆盖 0 退出、非零退出拒绝、超时中断、自动候选回退与 runtime 环境传递、终态拒绝)。desktop/internal/workbench/runconfig_edit.go、runconfig_view.go:runConfigEditor记录generated(configuration.Source == "generated")与explicitSave;用户在下拉中显式选择Save to作用域且为generated时置位explicitSave,使dirty()为真并在保存成功后复位这两个标记。desktop/internal/workbench/runconfig_edit_test.go:新增TestRunConfigEditorSavesGeneratedConfigOnExplicitScopePick。desktop/internal/workbench/build.go:invalidateBuild保留并递增p.build.generation(p.build.generation + 1),确保已失效的异步构建探测结果不会覆盖新代次。desktop/internal/workbench/plugins.go:提取applyPluginLifecycleChange(reload bool)并统一接入commitPluginInstall、setPluginEnabled与uninstallPlugin,跨标签页失效构建、重载插件语言、刷新状态,并在打开的标签页上重新触发loadBuildSystems。desktop/internal/workbench/runconfig.go:refreshRunConfigurations在p.build.loaded && len(p.build.instances) == 0 && p.build.failed == ""时传出json.RawMessage("[]"),使禁用或卸载最后一个构建插件后 Core 清理先前生成的运行配置。desktop/internal/workbench/plugins_build_reload_test.go:新增热装、启用/禁用跨多标签页重载及生成配置清理的集成测试与代次单测。shared/i18n/messages.json、shared/i18n/locales/{en-US,zh-CN}.json、desktop/internal/i18n/shared.generated.go:新增desktop.title.buildModelFailed与desktop.title.buildModelSafeMode中英词条并重新生成。desktop/internal/workbench/title_run_view.go:在titleRunConfigMenu中列出模型加载失败或处于安全模式的构建实例(显示构造名与根目录提示及首行原因),不误报“没有运行配置”;点击安全模式项触发工作区信任弹窗askToTrustProject,点击失败项优先打开对应sync-*会话标签(无同步会话则选中该实例并打开Build工具窗口)。desktop/internal/workbench/title_run_test.go、title_run_empty_visual_test.go:新增功能单测与 1280×800 无头视觉截图测试(亮色zh-CN/ 暗色en-US)。shared/platform-feature-matrix/features/run-discovery.json与build-model-sync-session.json的证据路径、验证说明与进展记录。不在本 PR 范围内 / Out of scope
request.root(#2147另一半)、组合/自定义@interfaceBoot 注解探测、provided依赖加入运行类路径、Java 21+/25main()识别,以及desktop-v0.8.10/ 插件v1.0.2发布将在后续 PR 完成。类型专属:fix
复现与根因
#2154:使用挂起或报错退出的 wrapper/工具链时,探测无单次超时且无法回退后续可用候选;修复后超过 10s 或非零退出均被拒绝并尝试下一个候选。#2147:在运行配置弹窗打开自动生成配置并点击Save to下拉选项后不改参数点 OK,原本不写入.lithe/run/;修复后明确选择作用域即视为 dirty 并写入。invalidateBuild把generation重置为0还会接收在途旧结果;修复后代次单调递增,热操作跨所有标签页即时同步并在 0 实例时清空生成配置。#2027:构建模型报错或受安全模式阻塞时,标题栏下拉仅显示“没有运行配置”且不可点;修复后直接展示失败/安全模式条目、首行错误原因并可一键定位日志或信任工作区。probeBuildTool、invalidateBuild源自 Viva 迁移提交0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799);titleRunConfigMenu空菜单分支源自bc5c0f8a3(feat(run): 运行/调试配置对话框,cmd 批处理在 macOS 和 Linux 上可编辑但不能运行 #2129);runConfigEditor.dirty()指纹比对未纳入对生成项显式选层意图(b8a173f88feat(desktop): 运行配置类型 ⓘ、插件包图标、脚本文本自动增高与启动前插件任务(API-29) #2169、bc5c0f8a3feat(run): 运行/调试配置对话框,cmd 批处理在 macOS 和 Linux 上可编辑但不能运行 #2129)。desktop/internal/workbench共享代码,无平台分支)。检查项
desktop/internal/workbench/build_probe_test.go(修复前TestProbeBuildTool、TestResolveBuildExecutableFallsBack失败)desktop/internal/workbench/runconfig_edit_test.go(修复前TestRunConfigEditorSavesGeneratedConfigOnExplicitScopePick在断言e.dirty()处失败)desktop/internal/workbench/plugins_build_reload_test.go(修复前TestInvalidateBuild...与TestPluginHotInstall...失败)desktop/internal/workbench/title_run_test.go(修复前TestTitleRunMenuShowsFailedBuildModelAndOpensLogOrBuildWindow与TestTitleRunMenuShowsSafeModePausedModelAndAsksToTrust在菜单未展示Engine:模型加载失败/Engine (app):模型加载失败/Engine:安全模式下已暂停加载处失败)resolveBuildCandidates保留供build_options_runtime.go使用,providerRuns保持供runconfig_test.go使用,invalidateBuild/loadBuildSystems覆盖全部标签页)desktop/internal/workbench,Windows 使用同一套逻辑;Maven 插件侧将在对应插件仓库修复)#2220验证期间发现的filetree_test.go:119既有macos-26测试偶发波动已独立建单 [Bug] TestProjectTreeDirectoryReadCancelsWhenProjectCloses intermittently times out on macOS CI #2221.agents/notes/implemented/bug-fix/记录:本次为补齐探测超时回退、dirty 标记、生命周期刷新和标题栏入口缺口,未引入新架构约束范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/run-discovery.json和shared/platform-feature-matrix/features/build-model-sync-session.json(Windows 未在本机实机运行,按实保持pending)./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(validated 215)与./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节自查命令(rg -n -i 'io\.github\.lithe-idea\.|lithe-idea/lithe-plugin-|PLUGIN_(ARCHIVE|MANIFEST|PACKAGE)\b|"plugin-provided"' ...),结果为空dev.lithe.test.*、io.github.example.*、dev.example.engine),不依赖具体插件包或源码shared/i18n/lithe-plugin-maven跟进 PR 验证UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=... ./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run TestVisualTitleRun -count=1(1280×800,scale 1),覆盖亮色zh-CN与暗色en-US下的模型加载失败、安全模式暂停以及原有空运行配置场景,已人工通过图片检查确认排版、图标与文字无截断和重叠统一日志系统 / Structured logging
applyPluginLifecycleChange、probeBuildTool与titleRunConfigMenu复用既有错误处理与 Core 日志机制(已知scripts/logging/已移除,等价门禁待统一恢复)界面文案 / i18n
desktop.title.buildModelFailed与desktop.title.buildModelSafeMode已补齐en-US/zh-CN并运行node scripts/i18n/generate-i18n.mjs生成,未手改生成产物node scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs与node --test --test-timeout=60000 scripts/i18n/test-i18n.mjs(62/62 通过)逻辑归属 / Logic placement
性能与内存 / Performance and memory
buildToolProbeTimeout+ context 取消终止阻断了卡死探针子进程导致的模型加载挂起;插件热重载仅刷新打开的标签页且无新增轮询设置 / Settings
Save to作用域脏标记)插件契约 / Plugin contract
发行包与资源 / Bundle and resources
zsh scripts/desktop/verify/verify-runtime-bundle-immutability.sh通过;未新增运行时写入路径或打包下载资源无用代码与重构 / Dead code and refactoring
probeSidecarPath与测试替身均自清理filetree_test.go:119既有 macOS 竞态测试波动已提交 [Bug] TestProjectTreeDirectoryReadCancelsWhenProjectCloses intermittently times out on macOS CI #2221验证 / Verification
cd desktop && gofmt -l ../scripts/desktop/desktop-go.sh vet ./...与vet -tags dev ./..../scripts/desktop/desktop-go.sh test -race -count=1 ./internal/workbench -run 'TestProbeBuildTool|TestResolveBuildExecutable|TestRunConfigEditor|TestPluginHotInstall|TestInvalidateBuild|TestTitleRun|TestEditRunConfigurations|TestOpeningAProject|TestBuildExecutable|TestBuildModel|TestWorkspaceTrust|TestRunConfiguration'./scripts/desktop/desktop-go.sh test -count=1 ./internal/workbench ./internal/core ./internal/toolchain ./internal/pluginservice ./internal/settingswindow ./internal/editorview ./internal/buildinfo与-tags dev ./internal/buildinfoLITHE_VISUAL_OUTPUT_DIR=... ./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run TestVisualTitleRun -count=1node scripts/i18n/generate-i18n.mjs --check、verify-app-language-localization.mjs、node --test scripts/i18n/test-i18n.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.sh、zsh scripts/desktop/verify/verify-runtime-bundle-immutability.sh、./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/main、develop-lithe插件零依赖rg自查未能执行的检查和原因:
提交前确认 / Final checks
main(0119f4107)创建,目标分支为main