Skip to content

fix(desktop): 补齐构建探测超时回退、热重载与标题栏模型错误提示 (#2154, #2027, #2147) - #2222

Merged
1lck merged 1 commit into
mainfrom
fix/startup-class-detection-and-launch
Nov 20, 2026
Merged

1lck merged 1 commit into
mainfrom
fix/startup-class-detection-and-launch

Conversation

@1lck

@1lck 1lck commented Nov 20, 2026

Copy link
Copy Markdown
Owner

关联 Issue / Linked issue

PR 类型 / Type

  • fix:缺陷修复

改动说明 / What changes

背景 / Why

用户在打开 Maven/Java/Spring Boot 项目时,多处问题叠加导致启动类无法识别或无法正常启动:

  1. [Bug] macOS Maven 同步在 java -version 探测阶段长时间无进度 #2154:构建工具或运行时探测遇到卡死脚本或返回非零退出码时,probeBuildTool 没有单次探测超时保护,且错误退出或损坏的 wrapper 输出被继续校验或直接终止,未能自动回退到后续 PATH/环境候选。
  2. [Bug] Maven 多模块项目无法把聚合根设为运行工作目录,相对路径配置全部失效 #2147:对于构建插件自动生成的运行配置(Source == "generated"),用户在运行配置编辑器里未修改其它字段、仅显式选择 Save to 作用域(如保持 local 并确认保存)时,dirty() 返回 false,导致确定/应用按钮不会将其写入 .lithe/run/。
  3. 插件热加载与过时构建代次:运行时安装、启用、禁用或卸载构建插件时,invalidateBuild 将 generation 重置为 0,且热装/禁用未跨打开的标签页重新触发构建探测;在停用/卸载最后一个构建插件后,providerRuns 返回 loaded=false 导致 Core 未收到空快照 [],旧的自动生成运行配置仍残留在标题栏和列表里。
  4. [Bug] Maven 构建模型失败时未显示 JAVA_HOME 配置错误,构建选项也无法回显该字段 #2027:某个构建实例模型加载失败或处于安全模式被暂停时,标题栏运行配置下拉只显示“没有运行配置”(或仅能看到其它正常配置),用户既看不到具体构建系统的失败/安全模式原因,也不能一键跳转到同步日志、Build 工具窗口或信任弹窗。

改动 / Changes

  • 构建工具探测超时与候选回退([Bug] macOS Maven 同步在 java -version 探测阶段长时间无进度 #2154)
    • desktop/internal/workbench/build.go:新增 buildToolProbeTimeout = 10 * time.Second 限制 probeBuildTool 单次执行时间,任何非零退出立即拒绝并返回错误,不采信失败输出;重构 resolveBuildExecutable 与 resolveAndCheckBuildCandidates / resolveOneBuildCandidate,非终态(非 setting、非 pinned toolchain)候选在版本探测或检查失败时自动回退到下一个候选,保持明确设置/锁定工具链的终态拒绝语义。
    • desktop/internal/workbench/build_probe_test.go、settings_toolchains_test.go:补充进程内自重启探测替身测试(覆盖 0 退出、非零退出拒绝、超时中断、自动候选回退与 runtime 环境传递、终态拒绝)。
  • 未修改自动配置显式选作用域保存([Bug] Maven 多模块项目无法把聚合根设为运行工作目录,相对路径配置全部失效 #2147)
    • 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:新增热装、启用/禁用跨多标签页重载及生成配置清理的集成测试与代次单测。
  • 标题栏运行配置下拉显示构建模型失败与安全模式([Bug] Maven 构建模型失败时未显示 JAVA_HOME 配置错误,构建选项也无法回显该字段 #2027)
    • 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

  • Maven 插件侧的默认工作目录回退到 request.root(#2147 另一半)、组合/自定义 @interface Boot 注解探测、provided 依赖加入运行类路径、Java 21+/25 main() 识别,以及 desktop-v0.8.10 / 插件 v1.0.2 发布将在后续 PR 完成。

类型专属:fix

复现与根因

检查项

  • 已先写回归测试,确认它在修复前失败、修复后通过;测试路径与修复前的失败输出:
    • 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:安全模式下已暂停加载 处失败)
  • [N/A] 无法自动化时,已写明手动复现与验证步骤:上述场景均已自动化并补充无头视觉测试
  • 已搜索被修改函数、类型、契约字段的全部调用方(核对 resolveBuildCandidates 保留供 build_options_runtime.go 使用,providerRuns 保持供 runconfig_test.go 使用,invalidateBuild/loadBuildSystems 覆盖全部标签页)
  • 已检查另一平台是否有同类缺陷(改动完全位于 Viva 跨平台共享工作台 desktop/internal/workbench,Windows 使用同一套逻辑;Maven 插件侧将在对应插件仓库修复)
  • 只改了修复所需的代码,没有夹带重构;PR #2220 验证期间发现的 filetree_test.go:119 既有 macos-26 测试偶发波动已独立建单 [Bug] TestProjectTreeDirectoryReadCancelsWhenProjectCloses intermittently times out on macOS CI #2221
  • [N/A] 修复改变了行为约束或容易复发,已在 .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/
  • [N/A] 未修改通用扩展点契约;Maven 插件端端到端与单测将在 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

  • [N/A] 未新增操作终态或独立日志边界,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

  • 运行配置生成/合并与工具版本判定规则留在 Rust Core;宿主只做进程探测超时、UI 状态呈现与标签页刷新调度,无按具体工具名分支

性能与内存 / Performance and memory

  • 10s buildToolProbeTimeout + context 取消终止阻断了卡死探针子进程导致的模型加载挂起;插件热重载仅刷新打开的标签页且无新增轮询

设置 / Settings

  • [N/A] 未修改设置页(仅修复运行配置编辑对话框对自动生成配置的 Save to 作用域脏标记)

插件契约 / Plugin contract

  • [N/A] 本次未改动 Rust Core 插件契约、协议版本或宿主方法

发行包与资源 / Bundle and resources

  • 已运行 zsh scripts/desktop/verify/verify-runtime-bundle-immutability.sh 通过;未新增运行时写入路径或打包下载资源

无用代码与重构 / Dead code and refactoring


验证 / Verification

命令或操作 平台 结果
cd desktop && gofmt -l . macOS arm64 无输出(干净)
./scripts/desktop/desktop-go.sh vet ./... 与 vet -tags dev ./... macOS arm64 通过
./scripts/desktop/desktop-go.sh test -race -count=1 ./internal/workbench -run 'TestProbeBuildTool|TestResolveBuildExecutable|TestRunConfigEditor|TestPluginHotInstall|TestInvalidateBuild|TestTitleRun|TestEditRunConfigurations|TestOpeningAProject|TestBuildExecutable|TestBuildModel|TestWorkspaceTrust|TestRunConfiguration' macOS arm64 通过(40.094s)
./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/buildinfo macOS arm64 全部通过(workbench 285.596s 等)
LITHE_VISUAL_OUTPUT_DIR=... ./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run TestVisualTitleRun -count=1 macOS arm64 通过(2.429s),截图已逐张人工核验
node scripts/i18n/generate-i18n.mjs --check、verify-app-language-localization.mjs、node --test scripts/i18n/test-i18n.mjs macOS arm64 通过(11850/11850,62/62)
./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh 与 verify-platform-feature-matrix-change.sh origin/main HEAD macOS arm64 通过(validated 215)
./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 自查 macOS arm64 全部通过

未能执行的检查和原因:

  • Windows 本机虚拟机实机验收未在本次 PR 执行(改动全在共用 Viva 工作台层,待 PR Ready 后由 GitHub Actions Windows CI 校验)。

提交前确认 / Final checks

  • 分支从最新的 main(0119f4107)创建,目标分支为 main
  • 以 Draft 提交,全部本地检查通过后标记 ready
  • 没有无关改动、产物、凭据或个人路径
  • 测试启动的进程已全部结束,无 Lithe 进程残留

@1lck
1lck marked this pull request as ready for review November 20, 2026 04:44
@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 20, 2026

@lithe-support lithe-support Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lithe Review

结论: 建议合入前把插件刷新和运行会话清理分开。另有一个已实测的探测超时边界。

范围: main@0119f410 ← e0ad9947,18 个变更文件。

  1. [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 和运行状态保持。该项尚未在完整桌面应用中复现。
  2. [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 尚未结束。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

1 participant