From 5aaea6de72c36eb81c83ceea87a8b0b29342770d Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:26:37 +0000 Subject: [PATCH 01/12] fix(toolchains): log incomplete project catalog reads (#1986) --- .../internal/workbench/settings_toolchains.go | 5 ++ .../workbench/settings_toolchains_test.go | 64 +++++++++++++++++++ .../features/plugin-toolchain-providers.json | 10 +-- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/desktop/internal/workbench/settings_toolchains.go b/desktop/internal/workbench/settings_toolchains.go index 2c512ed1f..4c962948d 100644 --- a/desktop/internal/workbench/settings_toolchains.go +++ b/desktop/internal/workbench/settings_toolchains.go @@ -193,6 +193,11 @@ func (s settingsToolchains) loadAt(ctx context.Context, root string) (toolchain. if err != nil && len(manifests) == 0 { return toolchain.Snapshot{}, err } + if err != nil { + // Keep the valid manifests visible, but never silently drop the reason + // why a different enabled provider did not appear in this catalog. + s.recordFailure(ctx, "toolchain_settings_discovery", err) + } return toolchain.Load(ctx, s.app.kernel, root, ".", manifests, s.app.toolchainOptions(ctx, root, manifests)) } diff --git a/desktop/internal/workbench/settings_toolchains_test.go b/desktop/internal/workbench/settings_toolchains_test.go index 51bff9975..1c5f71721 100644 --- a/desktop/internal/workbench/settings_toolchains_test.go +++ b/desktop/internal/workbench/settings_toolchains_test.go @@ -83,6 +83,70 @@ func TestGlobalToolchainsDoNotHideAnUnreadableEnabledPlugin(t *testing.T) { } } +// A readable plugin remains in project settings when another plugin's +// manifest disappeared. The partial failure must be logged once at the +// boundary instead of silently turning into a complete-looking tool list. +func TestProjectToolchainPartialManifestReadReportsDegradation(t *testing.T) { + preferences, pluginRoot, projectRoot := store.At(t.TempDir()), t.TempDir(), t.TempDir() + service, err := pluginservice.Open(core.NewClient(), preferences, pluginRoot) + if err != nil { + t.Fatal(err) + } + for _, id := range []string{"dev.example.catalog-readable", "dev.example.catalog-unreadable"} { + staging, err := pluginpkg.NewStaging(pluginRoot) + if err != nil { + t.Fatal(err) + } + fixture, err := os.ReadFile("../toolchain/testdata/compiler.plugin.json") + if err != nil { + t.Fatal(err) + } + var document map[string]any + if err := json.Unmarshal(fixture, &document); err != nil { + t.Fatal(err) + } + document["id"] = id + definition := document["toolDefinitions"].([]any)[0].(map[string]any) + definition["id"] = id + ":compiler" + manifest, err := json.Marshal(document) + if err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(staging, pluginpkg.ManifestFile), manifest, 0o600); err != nil { + t.Fatal(err) + } + installed, err := pluginpkg.Install(pluginRoot, id, "1.0.0", staging) + if err != nil { + t.Fatal(err) + } + if err := pluginstate.New(preferences).SetEnabled(id, true); err != nil { + t.Fatal(err) + } + if id == "dev.example.catalog-unreadable" { + if err := os.Remove(filepath.Join(installed.Path, pluginpkg.ManifestFile)); err != nil { + t.Fatal(err) + } + } + } + log := &treeRecordingLog{} + app := &App{kernel: &catalogSourceKernel{&testKernel{Client: core.NewClient()}}, store: preferences, plugins: service, logSink: log} + app.toolchainRoot.Store(&projectRoot) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + snapshot, err := (settingsToolchains{app: app}).Load(ctx) + if err != nil { + t.Fatalf("readable manifests should still load project settings: %v", err) + } + if len(snapshot.Tools) == 0 { + t.Fatal("the readable plugin was lost after another manifest failed") + } + log.mu.Lock() + defer log.mu.Unlock() + if len(log.events) != 1 || log.events[0].Fields["operation"] != "toolchain_settings_discovery" { + t.Fatalf("missing one degradation event: %+v", log.events) + } +} + func TestToolchainSettingsRejectSaveForAnotherOrClosedProject(t *testing.T) { for _, closed := range []bool{false, true} { name := "another-project" diff --git a/shared/platform-feature-matrix/features/plugin-toolchain-providers.json b/shared/platform-feature-matrix/features/plugin-toolchain-providers.json index 613802649..f7114b309 100644 --- a/shared/platform-feature-matrix/features/plugin-toolchain-providers.json +++ b/shared/platform-feature-matrix/features/plugin-toolchain-providers.json @@ -11,7 +11,8 @@ "desktop/internal/pluginservice/toolchain_provider_test.go", "desktop/internal/toolchain/provider.go", "desktop/internal/toolchain/provider_observation.go", - "desktop/internal/workbench/settings_toolchains.go" + "desktop/internal/workbench/settings_toolchains.go", + "desktop/internal/workbench/settings_toolchains_test.go" ] }, "windows": { @@ -23,10 +24,11 @@ "desktop/internal/toolchain/provider.go", "desktop/internal/toolchain/provider_observation.go", "desktop/internal/toolchain/native_path_windows.go", - "desktop/internal/workbench/settings_toolchains.go" + "desktop/internal/workbench/settings_toolchains.go", + "desktop/internal/workbench/settings_toolchains_test.go" ] }, "owner": "Plugins", - "verification": "使用 TestToolchainProviderQueriesThroughSharedBackendAndReobservesSources 核对合成插件协商、安装与项目版本要求、生效层、全局发现、源文件变化、复用和关闭清理。使用 TestToolchainProviderCancellationDoesNotCompleteTheNextQuery 核对取消与迟到回复。使用 TestToolchainProviderQueriesTheInstalledVersionAfterUpgrade 核对升级后的版本和路径,使用 TestNewProjectOnlyDiscoversToolsRequestedByTheForm 核对表单工具范围。原生设置工作流还需核对打开项目、改写版本要求、重新加载和关闭窗口。", - "notes": "Core 从提供方回包与本机文件事实得出候选和有效安装。桌面按选定清单版本启动共享后端,并为短期缓存观察输入变化。查询期限耗尽时保留已完成的答复和本机候选,由 TestToolchainProviderRoundPreservesAnswersAtItsDeadline 覆盖。安装与工作区目录沿用原有信任检查。" + "verification": "使用 TestToolchainProviderQueriesThroughSharedBackendAndReobservesSources 核对合成插件协商、安装与项目版本要求、生效层、全局发现、源文件变化、复用和关闭清理。使用 TestToolchainProviderCancellationDoesNotCompleteTheNextQuery 核对取消与迟到回复。使用 TestToolchainProviderQueriesTheInstalledVersionAfterUpgrade 核对升级后的版本和路径,使用 TestNewProjectOnlyDiscoversToolsRequestedByTheForm 核对表单工具范围。原生设置工作流还需核对打开项目、改写版本要求、重新加载和关闭窗口。 #1986:TestProjectToolchainPartialManifestReadReportsDegradation 使用两个合成插件(一项清单缺失)要求保留可读工具并只记录一次降级事件;完整 Go 1.27 测试、macOS/Windows 原生设置提示待验证。", + "notes": "Core 从提供方回包与本机文件事实得出候选和有效安装。桌面按选定清单版本启动共享后端,并为短期缓存观察输入变化。查询期限耗尽时保留已完成的答复和本机候选,由 TestToolchainProviderRoundPreservesAnswersAtItsDeadline 覆盖。安装与工作区目录沿用原有信任检查。 #1986 第一阶段:项目工具链页遇到部分启用插件清单无法读取,仍显示可用工具,但会用 toolchain_settings_discovery 记一次错误,不再把部分发现当成完整成功;设置页显式遗漏提示与执行消费者策略仍待统一。" } From 2543926fe7a666ba6e331e74412a27bc3a662326 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:40:52 +0000 Subject: [PATCH 02/12] fix(toolchains): unify partial-catalog policy for settings and run consumers (#1986) --- desktop/internal/toolchain/toolchain.go | 3 +++ .../internal/workbench/settings_toolchains.go | 23 +++++++++---------- .../workbench/settings_toolchains_test.go | 22 +++++++++++++----- desktop/internal/workbench/toolchains.go | 17 +++++++++++++- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/desktop/internal/toolchain/toolchain.go b/desktop/internal/toolchain/toolchain.go index 59126e02e..873fa1ced 100644 --- a/desktop/internal/toolchain/toolchain.go +++ b/desktop/internal/toolchain/toolchain.go @@ -105,6 +105,9 @@ type Tool struct { type Snapshot struct { Global bool `json:"global,omitempty"` ProjectCodeAllowed bool `json:"projectCodeAllowed,omitempty"` + // DiscoveryIncomplete reports that another enabled plugin could not be + // read; usable tools remain available but this is not a complete catalog. + DiscoveryIncomplete bool `json:"discoveryIncomplete,omitempty"` catalog *catalogSource Root string `json:"root"` Directory string `json:"directory"` diff --git a/desktop/internal/workbench/settings_toolchains.go b/desktop/internal/workbench/settings_toolchains.go index 4c962948d..ba155a4b6 100644 --- a/desktop/internal/workbench/settings_toolchains.go +++ b/desktop/internal/workbench/settings_toolchains.go @@ -16,7 +16,7 @@ func (s settingsToolchains) Inspect(ctx context.Context, snapshot toolchain.Snap ctx = s.app.performedIn(ctx, "toolchain.inspectDirectory", surfaceButton) defer func() { s.recordFailure(ctx, "toolchain_settings_inspect", err) }() if snapshot.Global { - manifests, readErr := s.app.toolchainManifests(ctx) + manifests, _, readErr := s.app.usableToolchainManifests(ctx, "toolchain_settings_discovery") if readErr != nil { return selection, readErr } @@ -29,7 +29,7 @@ func (s settingsToolchains) Inspect(ctx context.Context, snapshot toolchain.Snap if err := snapshot.CheckWorkspace(ctx, *root); err != nil { return selection, errors.Join(toolchain.ErrPinConflict, err) } - manifests, err := s.app.toolchainManifests(ctx) + manifests, _, err := s.app.usableToolchainManifests(ctx, "toolchain_settings_discovery") if err != nil { return selection, err } @@ -181,24 +181,23 @@ func (s settingsToolchains) LoadScope(ctx context.Context, scope string) (snapsh return s.Load(ctx) } defer func() { s.recordFailure(ctx, "toolchain_settings_load", err) }() - manifests, err := s.app.toolchainManifests(ctx) + manifests, incomplete, err := s.app.usableToolchainManifests(ctx, "toolchain_settings_discovery") if err != nil { return snapshot, err } - return toolchain.Load(ctx, s.app.kernel, "", ".", manifests, s.app.toolchainOptions(ctx, "", manifests)) + snapshot, err = toolchain.Load(ctx, s.app.kernel, "", ".", manifests, s.app.toolchainOptions(ctx, "", manifests)) + snapshot.DiscoveryIncomplete = incomplete + return snapshot, err } func (s settingsToolchains) loadAt(ctx context.Context, root string) (toolchain.Snapshot, error) { - manifests, err := s.app.toolchainManifests(ctx) - if err != nil && len(manifests) == 0 { - return toolchain.Snapshot{}, err - } + manifests, incomplete, err := s.app.usableToolchainManifests(ctx, "toolchain_settings_discovery") if err != nil { - // Keep the valid manifests visible, but never silently drop the reason - // why a different enabled provider did not appear in this catalog. - s.recordFailure(ctx, "toolchain_settings_discovery", err) + return toolchain.Snapshot{}, err } - return toolchain.Load(ctx, s.app.kernel, root, ".", manifests, s.app.toolchainOptions(ctx, root, manifests)) + snapshot, err := toolchain.Load(ctx, s.app.kernel, root, ".", manifests, s.app.toolchainOptions(ctx, root, manifests)) + snapshot.DiscoveryIncomplete = incomplete + return snapshot, err } // Save applies all draft changes in one Core edit, against the exact diff --git a/desktop/internal/workbench/settings_toolchains_test.go b/desktop/internal/workbench/settings_toolchains_test.go index 1c5f71721..9006a3da8 100644 --- a/desktop/internal/workbench/settings_toolchains_test.go +++ b/desktop/internal/workbench/settings_toolchains_test.go @@ -29,7 +29,7 @@ func (*catalogSourceKernel) ToolchainDiscoveryPlanOf(context.Context, json.RawMe return core.ToolchainDiscoveryPlan{}, nil } -func TestGlobalToolchainsDoNotHideAnUnreadableEnabledPlugin(t *testing.T) { +func TestGlobalToolchainsRetainValidPluginAndReportUnreadableOne(t *testing.T) { preferences, root := store.At(t.TempDir()), t.TempDir() service, err := pluginservice.Open(core.NewClient(), preferences, root) if err != nil { @@ -74,10 +74,20 @@ func TestGlobalToolchainsDoNotHideAnUnreadableEnabledPlugin(t *testing.T) { app := &App{kernel: &catalogSourceKernel{&testKernel{Client: core.NewClient()}}, store: preferences, plugins: service} ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - _, err = (settingsToolchains{app: app}).LoadScope(ctx, "global") - if !errors.Is(err, os.ErrNotExist) { - t.Fatalf("global SDK settings discarded the native read failure: %v", err) + log := &treeRecordingLog{} + app.logSink = log + snapshot, err := (settingsToolchains{app: app}).LoadScope(ctx, "global") + if err != nil { + t.Fatalf("global catalog should retain valid tools: %v", err) + } + if len(snapshot.Tools) == 0 || !snapshot.DiscoveryIncomplete { + t.Fatalf("catalog lost tools or partial warning: %+v", snapshot) + } + log.mu.Lock() + if len(log.events) != 1 || log.events[0].Fields["operation"] != "toolchain_settings_discovery" { + t.Errorf("partial global catalog recorded events %+v", log.events) } + log.mu.Unlock() if _, err := os.Stat(filepath.Join(preferences.Dir(), "toolchains", "global.json")); !errors.Is(err, os.ErrNotExist) { t.Fatalf("a failed read wrote a global catalog: %v", err) } @@ -137,8 +147,8 @@ func TestProjectToolchainPartialManifestReadReportsDegradation(t *testing.T) { if err != nil { t.Fatalf("readable manifests should still load project settings: %v", err) } - if len(snapshot.Tools) == 0 { - t.Fatal("the readable plugin was lost after another manifest failed") + if len(snapshot.Tools) == 0 || !snapshot.DiscoveryIncomplete { + t.Fatal("the readable plugin was lost or incomplete status was not reported") } log.mu.Lock() defer log.mu.Unlock() diff --git a/desktop/internal/workbench/toolchains.go b/desktop/internal/workbench/toolchains.go index 35163ae23..418b60121 100644 --- a/desktop/internal/workbench/toolchains.go +++ b/desktop/internal/workbench/toolchains.go @@ -50,6 +50,21 @@ func (a *App) toolchainManifests(ctx context.Context) ([]json.RawMessage, error) return manifests, err } +// usableToolchainManifests is the shared policy for partial plugin reads. A +// missing manifest must not conceal other valid tools; consumers still rely +// on Core to resolve the requested ID. Log the degradation once per discovery. +func (a *App) usableToolchainManifests(ctx context.Context, operation string) ([]json.RawMessage, bool, error) { + manifests, err := a.toolchainManifests(ctx) + if err == nil { + return manifests, false, nil + } + if len(manifests) == 0 { + return nil, false, err + } + a.backgroundFailedIn(ctx, operation, err) + return manifests, true, nil +} + // resolveToolchainSelection resolves one tool for one operation. A caller may // replace the selector in tests through toolchainResolve. func (a *App) resolveToolchainSelection(ctx context.Context, root, directory, tool, minimumVersion string) (core.ToolchainSelection, error) { @@ -74,7 +89,7 @@ func (a *App) managedToolchainOptions(ctx context.Context, manifests []json.RawM } func (a *App) defaultToolchainSelection(ctx context.Context, root, directory, tool, minimumVersion string) (core.ToolchainSelection, error) { - manifests, err := a.toolchainManifests(ctx) + manifests, _, err := a.usableToolchainManifests(ctx, "toolchain_selection_discovery") if err != nil { return core.ToolchainSelection{}, err } From 15e8290fb66c48a5f2ef5d561091ba742fcce494 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:43:03 +0000 Subject: [PATCH 03/12] feat(toolchains): visibly warn when enabled plugin tool catalog is incomplete (#1986) --- desktop/internal/i18n/shared.generated.go | 2 ++ desktop/internal/settingswindow/toolchains_view.go | 11 ++++++++++- shared/i18n/features/build-settings.json | 13 +++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index b12c1fb2a..29efe08ea 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -2895,6 +2895,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.toolchains.conflict": "{tool} is defined by {plugins}; disable all but one of those plugins.", "desktop.toolchains.custom": "Custom…", "desktop.toolchains.description": "Tools declared by enabled plugins. The effective value and its source come from the shared Core resolver; nothing is written until Save.", + "desktop.toolchains.discoveryIncomplete": "Some enabled plugins could not be read. The tool list may be incomplete; check the logs and reload after fixing them.", "desktop.toolchains.directory": "Installation directory", "desktop.toolchains.directoryHelp": "Choose the installation root containing the tool executable, such as a JDK directory rather than its bin folder. Checking the version only updates the draft; Save writes the project selection.", "desktop.toolchains.effective": "Effective: {value}", @@ -6881,6 +6882,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.toolchains.conflict": "{tool} 同时由 {plugins} 定义;请只保留其中一个插件。", "desktop.toolchains.custom": "自定义…", "desktop.toolchains.description": "已启用插件声明的工具。生效值与来源由共享 Core 解析得出;点击保存前不会写入任何文件。", + "desktop.toolchains.discoveryIncomplete": "部分已启用插件的配置无法读取,工具列表可能不完整。请查看日志,修复后重新加载。", "desktop.toolchains.directory": "安装目录", "desktop.toolchains.directoryHelp": "选择包含工具程序的安装根目录,例如 JDK 目录,而不是 bin 目录。验证版本只修改草稿;点击保存后才写入项目选择。", "desktop.toolchains.effective": "生效:{value}", diff --git a/desktop/internal/settingswindow/toolchains_view.go b/desktop/internal/settingswindow/toolchains_view.go index cbb3f6733..08b078e17 100644 --- a/desktop/internal/settingswindow/toolchains_view.go +++ b/desktop/internal/settingswindow/toolchains_view.go @@ -249,7 +249,7 @@ func (w *window) toolchainsNotices(c ui.C, language i18n.Language, scope *toolch case t.inspecting: busy = i18n.Shared(language, "desktop.toolchains.loading") } - if !banner && scope.failed == nil && t.failed == nil && t.view.failed == nil && busy == "" { + if !banner && !scope.snapshot.DiscoveryIncomplete && scope.failed == nil && t.failed == nil && t.view.failed == nil && busy == "" { return } ui.Column(c).FillWidth().Shrink(0).PadSides(8, 14, 0, 14).Gap(8).Children(func() { @@ -267,6 +267,15 @@ func (w *window) toolchainsNotices(c ui.C, language i18n.Language, scope *toolch } }) } + if scope.loaded && scope.snapshot.DiscoveryIncomplete { + w.box(c.Part("discovery-incomplete"), boxWarn, func(words gfx.Color) { + boxIcon(c, icons.CircleAlert, words) + boxText(c, i18n.Shared(language, "desktop.toolchains.discoveryIncomplete"), words) + if w.button(c.Part("discovery-reload"), buttonSmall, i18n.Shared(language, "desktop.toolchains.reload"), t.busy()) { + t.reload() + } + }) + } if scope.failed != nil { message := toolchainFailureMessage(language, scope.failed) w.box(c.Part("load-failed"), boxErr, func(words gfx.Color) { diff --git a/shared/i18n/features/build-settings.json b/shared/i18n/features/build-settings.json index f474f6eb4..bab524f67 100644 --- a/shared/i18n/features/build-settings.json +++ b/shared/i18n/features/build-settings.json @@ -1077,6 +1077,13 @@ "parameters": { "count": "string" } + }, + { + "id": "desktop.toolchains.discoveryIncomplete", + "description": "Warning when an enabled plugin manifest is unreadable but other tools remain available.", + "platforms": [ + "desktop" + ] } ], "locales": { @@ -1215,7 +1222,8 @@ "desktop.buildSettings.searchTools": "Tools in Toolchains", "desktop.buildSettings.searchDebuggers": "Debuggers", "desktop.buildSettings.steppingTab": "Debuggers › Stepping", - "desktop.buildSettings.searchAllTools": "View all {count} in Toolchains…" + "desktop.buildSettings.searchAllTools": "View all {count} in Toolchains…", + "desktop.toolchains.discoveryIncomplete": "Some enabled plugins could not be read. The tool list may be incomplete; check the logs and reload after fixing them." }, "zh-CN": { "desktop.buildSettings.directoryNote": "这一页只列子页和状态摘要,不直接展示插件注入的内容。", @@ -1352,7 +1360,8 @@ "desktop.buildSettings.searchTools": "工具链中的工具", "desktop.buildSettings.searchDebuggers": "调试器", "desktop.buildSettings.steppingTab": "调试器 › 单步", - "desktop.buildSettings.searchAllTools": "在工具链中查看全部 {count} 个…" + "desktop.buildSettings.searchAllTools": "在工具链中查看全部 {count} 个…", + "desktop.toolchains.discoveryIncomplete": "部分已启用插件的配置无法读取,工具列表可能不完整。请查看日志,修复后重新加载。" } } } From 90245741931f09904661d171d7af046369a3e6a6 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:46:47 +0000 Subject: [PATCH 04/12] style(toolchains): align Snapshot fields with gofmt --- desktop/internal/toolchain/toolchain.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/desktop/internal/toolchain/toolchain.go b/desktop/internal/toolchain/toolchain.go index 873fa1ced..1d31c6a51 100644 --- a/desktop/internal/toolchain/toolchain.go +++ b/desktop/internal/toolchain/toolchain.go @@ -108,11 +108,11 @@ type Snapshot struct { // DiscoveryIncomplete reports that another enabled plugin could not be // read; usable tools remain available but this is not a complete catalog. DiscoveryIncomplete bool `json:"discoveryIncomplete,omitempty"` - catalog *catalogSource - Root string `json:"root"` - Directory string `json:"directory"` - Tools []Tool `json:"tools"` - Conflicts []core.ToolchainConflict `json:"conflicts"` + catalog *catalogSource + Root string `json:"root"` + Directory string `json:"directory"` + Tools []Tool `json:"tools"` + Conflicts []core.ToolchainConflict `json:"conflicts"` // Baseline is the exact bytes of .lithe/toolchains/local.json that the // snapshot was built from, nil when the file did not exist. Baseline []byte `json:"-"` From 176403545cba1a0da92c3d41a1dad5f90c8aa593 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:50:25 +0000 Subject: [PATCH 05/12] fix(i18n): keep generated toolchain warning catalog in key order --- desktop/internal/i18n/shared.generated.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 29efe08ea..6e87fcb85 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -2895,9 +2895,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.toolchains.conflict": "{tool} is defined by {plugins}; disable all but one of those plugins.", "desktop.toolchains.custom": "Custom…", "desktop.toolchains.description": "Tools declared by enabled plugins. The effective value and its source come from the shared Core resolver; nothing is written until Save.", - "desktop.toolchains.discoveryIncomplete": "Some enabled plugins could not be read. The tool list may be incomplete; check the logs and reload after fixing them.", "desktop.toolchains.directory": "Installation directory", "desktop.toolchains.directoryHelp": "Choose the installation root containing the tool executable, such as a JDK directory rather than its bin folder. Checking the version only updates the draft; Save writes the project selection.", + "desktop.toolchains.discoveryIncomplete": "Some enabled plugins could not be read. The tool list may be incomplete; check the logs and reload after fixing them.", "desktop.toolchains.effective": "Effective: {value}", "desktop.toolchains.global": "Global defaults", "desktop.toolchains.globalHelp": "Manage detected and manually added SDKs for all projects. Save writes to the application’s user settings; projects can override the default. Existing processes use the new SDK after restarting.", @@ -6882,9 +6882,9 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.toolchains.conflict": "{tool} 同时由 {plugins} 定义;请只保留其中一个插件。", "desktop.toolchains.custom": "自定义…", "desktop.toolchains.description": "已启用插件声明的工具。生效值与来源由共享 Core 解析得出;点击保存前不会写入任何文件。", - "desktop.toolchains.discoveryIncomplete": "部分已启用插件的配置无法读取,工具列表可能不完整。请查看日志,修复后重新加载。", "desktop.toolchains.directory": "安装目录", "desktop.toolchains.directoryHelp": "选择包含工具程序的安装根目录,例如 JDK 目录,而不是 bin 目录。验证版本只修改草稿;点击保存后才写入项目选择。", + "desktop.toolchains.discoveryIncomplete": "部分已启用插件的配置无法读取,工具列表可能不完整。请查看日志,修复后重新加载。", "desktop.toolchains.effective": "生效:{value}", "desktop.toolchains.global": "全局默认", "desktop.toolchains.globalHelp": "统一管理自动识别和手动添加的 SDK,保存到应用的用户设置。项目可单独覆盖默认版本;已启动的进程需重启后使用新版本。", From 131c5709b8dc3284cf54eed3bcd987e4258c8eba Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:31:25 +0000 Subject: [PATCH 06/12] fix(toolchains): share a partial-safe manifest snapshot across run and debug launches (#1986) --- desktop/internal/workbench/debug_launch.go | 4 ++-- desktop/internal/workbench/runs.go | 13 +++++++------ desktop/internal/workbench/toolchains.go | 10 ++++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/desktop/internal/workbench/debug_launch.go b/desktop/internal/workbench/debug_launch.go index 89d9ccb21..2f2174628 100644 --- a/desktop/internal/workbench/debug_launch.go +++ b/desktop/internal/workbench/debug_launch.go @@ -71,7 +71,7 @@ func (a *App) resolveAdapterProcess(ctx context.Context, adapter debugAdapter, p if _, err := pluginhost.ResolvePackagePaths(adapter.Directory, plan.RequiredPackagePaths); err != nil { return "", nil, nil, err } - manifests, err := a.toolchainManifests(ctx) + manifests, _, err := a.usableToolchainManifests(ctx, "toolchain_debug_discovery") if err != nil { return "", nil, nil, err } @@ -86,7 +86,7 @@ func (a *App) resolveAdapterProcess(ctx context.Context, adapter debugAdapter, p return "", nil, nil, err } } else { - selected, err = a.resolveToolchainSelection(ctx, root, ".", plan.Launch.Tool, plan.Launch.MinimumVersion) + selected, err = a.resolveToolchainSelectionFrom(ctx, root, ".", plan.Launch.Tool, plan.Launch.MinimumVersion, manifests) if err != nil { return "", nil, nil, err } diff --git a/desktop/internal/workbench/runs.go b/desktop/internal/workbench/runs.go index f361d4aa1..d00ce17c2 100644 --- a/desktop/internal/workbench/runs.go +++ b/desktop/internal/workbench/runs.go @@ -173,18 +173,19 @@ func (a *App) resolveBackendTool(ctx context.Context, _, workingDirectory, tool // resolveBackendToolEntry supplies native installation facts and the verified // entry to Core. The definition, not the host, decides how a tool loads it. func (a *App) resolveBackendToolEntry(ctx context.Context, _ string, workingDirectory string, input pluginbackend.ToolEntryLaunch) (pluginbackend.ToolExecutable, error) { + // Share one validated manifest snapshot between the selected executable + // and Core's launch template, including when one unrelated plugin is unreadable. + manifests, _, err := a.usableToolchainManifests(ctx, "toolchain_run_entry_discovery") + if err != nil { + return pluginbackend.ToolExecutable{}, err + } selection := core.ToolchainSelection{Executable: input.Executable} if selection.Executable == "" { - var err error - selection, err = a.resolveToolchainSelection(ctx, workingDirectory, ".", input.Tool, input.MinimumVersion) + selection, err = a.resolveToolchainSelectionFrom(ctx, workingDirectory, ".", input.Tool, input.MinimumVersion, manifests) if err != nil { return pluginbackend.ToolExecutable{}, err } } - manifests, err := a.toolchainManifests(ctx) - if err != nil { - return pluginbackend.ToolExecutable{}, err - } registry, err := toolchain.RegistryInput(manifests) if err != nil { return pluginbackend.ToolExecutable{}, err diff --git a/desktop/internal/workbench/toolchains.go b/desktop/internal/workbench/toolchains.go index 418b60121..eab5a2ba7 100644 --- a/desktop/internal/workbench/toolchains.go +++ b/desktop/internal/workbench/toolchains.go @@ -93,6 +93,16 @@ func (a *App) defaultToolchainSelection(ctx context.Context, root, directory, to if err != nil { return core.ToolchainSelection{}, err } + return a.resolveToolchainSelectionFrom(ctx, root, directory, tool, minimumVersion, manifests) +} + +// resolveToolchainSelectionFrom reuses a catalog read by a run or debugger. +// Looking it up a second time could report the same partial-manifest failure twice, +// or select a different plugin version between resolving and launching a tool. +func (a *App) resolveToolchainSelectionFrom(ctx context.Context, root, directory, tool, minimumVersion string, manifests []json.RawMessage) (core.ToolchainSelection, error) { + if a.toolchainResolve != nil { + return a.toolchainResolve(ctx, root, directory, tool, minimumVersion) + } if directory == "" { directory = "." } From ea44b65c4a03e005bf31d509b522da31981bd661 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:31:50 +0000 Subject: [PATCH 07/12] fix(toolchains): diagnose partial manifests in project generation and installer labels (#1986) --- desktop/internal/workbench/command_installers.go | 2 +- desktop/internal/workbench/new_project.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/internal/workbench/command_installers.go b/desktop/internal/workbench/command_installers.go index 69f9047d0..c9fabadcb 100644 --- a/desktop/internal/workbench/command_installers.go +++ b/desktop/internal/workbench/command_installers.go @@ -172,7 +172,7 @@ func commandConsumerCapability(kind string) string { // toolNames are the display names of the enabled plugins' tool definitions by ID; nil when // the registry cannot be read, which shows the IDs. func (s settingsCommandInstalls) toolNames(ctx context.Context) map[string]string { - manifests, _ := s.app.toolchainManifests(ctx) + manifests, _, _ := s.app.usableToolchainManifests(ctx, "command_installer_tool_discovery") if len(manifests) == 0 { return nil } diff --git a/desktop/internal/workbench/new_project.go b/desktop/internal/workbench/new_project.go index ad6631770..a223836b7 100644 --- a/desktop/internal/workbench/new_project.go +++ b/desktop/internal/workbench/new_project.go @@ -319,8 +319,8 @@ func (a *App) loadProjectTools(ctx context.Context, tools []string) (map[string] if a.projectToolLists != nil { return a.projectToolLists(ctx, tools) } - manifests, err := a.toolchainManifests(ctx) - if err != nil && len(manifests) == 0 { + manifests, _, err := a.usableToolchainManifests(ctx, "new_project_toolchain_discovery") + if err != nil { return nil, err } options := a.toolchainOptions(ctx, "", manifests) From 206201f3bf9b01643754d1553ea76a4d99c5efc7 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:34:10 +0000 Subject: [PATCH 08/12] test(toolchains): verify partial-catalog warning and valid tools in both scopes --- .../settingswindow/toolchains_view_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/desktop/internal/settingswindow/toolchains_view_test.go b/desktop/internal/settingswindow/toolchains_view_test.go index de46d44ef..8243df596 100644 --- a/desktop/internal/settingswindow/toolchains_view_test.go +++ b/desktop/internal/settingswindow/toolchains_view_test.go @@ -115,6 +115,36 @@ func (d *windowDriver) applyBuild() { d.pump() } +// An unreadable enabled plugin must not make the remaining valid tools look +// like a complete catalog. The same warning is visible in both scopes. +func TestToolchainsShowPartialDiscoveryWarningInBothScopes(t *testing.T) { + for _, scope := range []string{scopeGlobal, scopeProject} { + t.Run(scope, func(t *testing.T) { + fixture := fixtureSnapshot() + fixture.DiscoveryIncomplete = true + loader := &scopedToolchainLoader{fakeToolchainLoader{snapshot: fixture}} + w, d := toolchainWindow(t, loader) + if scope == scopeProject { + w.toolchains.setScope(scopeProject) + w.inv.Invalidate() + d.until("the project scope", func() bool { + return w.toolchains.current().loaded && w.toolchains.scope == scopeProject + }) + d.pump() + } + if !d.has(en("desktop.toolchains.discoveryIncomplete")) { + t.Fatal("partial tool discovery is not visible to the user") + } + if !d.text("Compiler") { + t.Fatal("the readable tool was hidden by another plugin's missing manifest") + } + if !d.has(en("desktop.toolchains.reload")) { + t.Fatal("no way to reload after repairing the unreadable plugin") + } + }) + } +} + // The chosen tool lists what it falls back to, each installation once and the link that opens // the directory field, which stays closed until it is asked for and writes no draft. func TestToolchainChoicesListAutomaticAndOpenTheDirectoryOnDemand(t *testing.T) { From 73cfa99a648c6d5b9a33996a465228e1692bb684 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:09:00 +0000 Subject: [PATCH 09/12] fix(toolchains): prevent partially loaded catalog from surviving caller cancellation (#1986) --- desktop/internal/workbench/toolchains.go | 21 ++++++++++--- desktop/internal/workbench/toolchains_test.go | 30 +++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/desktop/internal/workbench/toolchains.go b/desktop/internal/workbench/toolchains.go index eab5a2ba7..4969e6c6f 100644 --- a/desktop/internal/workbench/toolchains.go +++ b/desktop/internal/workbench/toolchains.go @@ -54,14 +54,27 @@ func (a *App) toolchainManifests(ctx context.Context) ([]json.RawMessage, error) // missing manifest must not conceal other valid tools; consumers still rely // on Core to resolve the requested ID. Log the degradation once per discovery. func (a *App) usableToolchainManifests(ctx context.Context, operation string) ([]json.RawMessage, bool, error) { - manifests, err := a.toolchainManifests(ctx) - if err == nil { + manifests, readErr := a.toolchainManifests(ctx) + usable, incomplete, err := partialToolchainCatalog(ctx, manifests, readErr) + if incomplete { + a.backgroundFailedIn(ctx, operation, readErr) + } + return usable, incomplete, err +} + +// partialToolchainCatalog accepts valid manifests from a partially unreadable +// plugin set, but cancellation of the *whole request* is always terminal. +// A nested provider may time out independently without canceling ctx. +func partialToolchainCatalog(ctx context.Context, manifests []json.RawMessage, readErr error) ([]json.RawMessage, bool, error) { + if err := ctx.Err(); err != nil { + return nil, false, err + } + if readErr == nil { return manifests, false, nil } if len(manifests) == 0 { - return nil, false, err + return nil, false, readErr } - a.backgroundFailedIn(ctx, operation, err) return manifests, true, nil } diff --git a/desktop/internal/workbench/toolchains_test.go b/desktop/internal/workbench/toolchains_test.go index d83e2197e..6567b538d 100644 --- a/desktop/internal/workbench/toolchains_test.go +++ b/desktop/internal/workbench/toolchains_test.go @@ -190,3 +190,33 @@ func TestBuildRuntimeRefusesAnInvalidPinBeforeFallback(t *testing.T) { t.Fatalf("invalid pin fell through to another installation: %v", err) } } + +func TestPartialToolchainCatalogRejectsCancellationAndKeepsValidPlugins(t *testing.T) { + valid := []json.RawMessage{json.RawMessage(`{"id":"dev.example.valid"}`)} + broken := errors.New("another enabled plugin manifest is unreadable") + for _, tc := range []struct { + name string + manifests []json.RawMessage + err error + cancel bool + wantCount int + wantIncomplete bool + wantErr error + }{ + {name: "complete", manifests: valid, wantCount: 1}, + {name: "partial", manifests: valid, err: broken, wantCount: 1, wantIncomplete: true}, + {name: "all missing", err: broken, wantErr: broken}, + {name: "canceled partial", manifests: valid, err: broken, cancel: true, wantErr: context.Canceled}, + {name: "canceled complete", manifests: valid, cancel: true, wantErr: context.Canceled}, + } { + t.Run(tc.name, func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if tc.cancel { cancel() } + manifests, incomplete, err := partialToolchainCatalog(ctx, tc.manifests, tc.err) + if len(manifests) != tc.wantCount || incomplete != tc.wantIncomplete || !errors.Is(err, tc.wantErr) { + t.Fatalf("manifests=%d incomplete=%v err=%v, want %d %v %v", len(manifests), incomplete, err, tc.wantCount, tc.wantIncomplete, tc.wantErr) + } + }) + } +} From efbfc3cacfe6ade0401820a57c6772fc3ee1bd67 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:09:28 +0000 Subject: [PATCH 10/12] style(toolchains): format partial-catalog policy regression --- desktop/internal/workbench/toolchains_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/desktop/internal/workbench/toolchains_test.go b/desktop/internal/workbench/toolchains_test.go index 6567b538d..c5f263a2d 100644 --- a/desktop/internal/workbench/toolchains_test.go +++ b/desktop/internal/workbench/toolchains_test.go @@ -195,13 +195,13 @@ func TestPartialToolchainCatalogRejectsCancellationAndKeepsValidPlugins(t *testi valid := []json.RawMessage{json.RawMessage(`{"id":"dev.example.valid"}`)} broken := errors.New("another enabled plugin manifest is unreadable") for _, tc := range []struct { - name string - manifests []json.RawMessage - err error - cancel bool - wantCount int + name string + manifests []json.RawMessage + err error + cancel bool + wantCount int wantIncomplete bool - wantErr error + wantErr error }{ {name: "complete", manifests: valid, wantCount: 1}, {name: "partial", manifests: valid, err: broken, wantCount: 1, wantIncomplete: true}, @@ -212,7 +212,9 @@ func TestPartialToolchainCatalogRejectsCancellationAndKeepsValidPlugins(t *testi t.Run(tc.name, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - if tc.cancel { cancel() } + if tc.cancel { + cancel() + } manifests, incomplete, err := partialToolchainCatalog(ctx, tc.manifests, tc.err) if len(manifests) != tc.wantCount || incomplete != tc.wantIncomplete || !errors.Is(err, tc.wantErr) { t.Fatalf("manifests=%d incomplete=%v err=%v, want %d %v %v", len(manifests), incomplete, err, tc.wantCount, tc.wantIncomplete, tc.wantErr) From b62fabf82eea5c474b1058dbc0e8fb2512f35db9 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:13:34 +0000 Subject: [PATCH 11/12] test(toolchains): reject duplicate and invalid versions while preserving healthy providers (#1986) --- .../pluginservice/toolchains_partial_test.go | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 desktop/internal/pluginservice/toolchains_partial_test.go diff --git a/desktop/internal/pluginservice/toolchains_partial_test.go b/desktop/internal/pluginservice/toolchains_partial_test.go new file mode 100644 index 000000000..cc4a55907 --- /dev/null +++ b/desktop/internal/pluginservice/toolchains_partial_test.go @@ -0,0 +1,82 @@ +package pluginservice + +import ( + "context" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginmanager" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" +) + +// Real Core version selection must reject ambiguous/invalid installed facts +// without letting a bad version mask a healthy enabled plugin. +func TestToolchainPluginsKeepValidVersionsAndReportRejectedFacts(t *testing.T) { + root := t.TempDir() + entry := func(id, version string, valid bool) pluginmanager.Entry { + t.Helper() + dir := filepath.Join(root, id, version) + if valid { + if err := os.MkdirAll(dir, 0o700); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(dir, pluginpkg.ManifestFile), []byte(`{"id":"`+id+`"}`), 0o600); err != nil { + t.Fatal(err) + } + } + return pluginmanager.Entry{ + Installed: pluginpkg.Installed{ID: id, Version: version, Path: dir}, + Enabled: true, + } + } + healthy := entry("dev.lithe.test.healthy", "1.0.0", true) + first := entry("dev.lithe.test.duplicate", "2.0.0", true) + duplicate := first + duplicate.Installed.Path = filepath.Join(root, "unreadable-duplicate") + broken := entry("dev.lithe.test.invalid", "not-semver", false) + + for _, tc := range []struct { + name, wantCode string + entries []pluginmanager.Entry + wantIDs []string + }{ + { + name: "same version rejected without replacing the first", + wantCode: "plugin.installed.duplicateVersion", + entries: []pluginmanager.Entry{first, duplicate, healthy}, + wantIDs: []string{first.Installed.ID, healthy.Installed.ID}, + }, + { + name: "invalid version leaves healthy tools", + wantCode: "plugin.installed.invalidVersion", + entries: []pluginmanager.Entry{broken, healthy}, + wantIDs: []string{healthy.Installed.ID}, + }, + } { + t.Run(tc.name, func(t *testing.T) { + service := &Service{kernel: core.NewClient()} + plugins, err := service.ToolchainPlugins(context.Background(), tc.entries) + if err == nil || !strings.Contains(err.Error(), tc.wantCode) { + t.Fatalf("expected %s alongside usable plugins, got %v", tc.wantCode, err) + } + found := make(map[string]bool) + for _, plugin := range plugins { + found[plugin.PluginID] = true + if plugin.PluginID == first.Installed.ID && plugin.Directory != first.Installed.Path { + t.Fatalf("duplicate took precedence: %s", plugin.Directory) + } + } + if len(found) != len(tc.wantIDs) { + t.Fatalf("valid plugin count %d, want %d: %+v", len(found), len(tc.wantIDs), plugins) + } + for _, id := range tc.wantIDs { + if !found[id] { + t.Fatalf("valid plugin %q was lost after rejecting another version", id) + } + } + }) + } +} From 2c38774199123e4417a2b087883705b22f3186fb Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:15:49 +0000 Subject: [PATCH 12/12] style(toolchains): apply gofmt to multi-version rejection regression --- .../pluginservice/toolchains_partial_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/desktop/internal/pluginservice/toolchains_partial_test.go b/desktop/internal/pluginservice/toolchains_partial_test.go index cc4a55907..2ce4c228d 100644 --- a/desktop/internal/pluginservice/toolchains_partial_test.go +++ b/desktop/internal/pluginservice/toolchains_partial_test.go @@ -40,20 +40,20 @@ func TestToolchainPluginsKeepValidVersionsAndReportRejectedFacts(t *testing.T) { for _, tc := range []struct { name, wantCode string - entries []pluginmanager.Entry - wantIDs []string + entries []pluginmanager.Entry + wantIDs []string }{ { - name: "same version rejected without replacing the first", + name: "same version rejected without replacing the first", wantCode: "plugin.installed.duplicateVersion", - entries: []pluginmanager.Entry{first, duplicate, healthy}, - wantIDs: []string{first.Installed.ID, healthy.Installed.ID}, + entries: []pluginmanager.Entry{first, duplicate, healthy}, + wantIDs: []string{first.Installed.ID, healthy.Installed.ID}, }, { - name: "invalid version leaves healthy tools", + name: "invalid version leaves healthy tools", wantCode: "plugin.installed.invalidVersion", - entries: []pluginmanager.Entry{broken, healthy}, - wantIDs: []string{healthy.Installed.ID}, + entries: []pluginmanager.Entry{broken, healthy}, + wantIDs: []string{healthy.Installed.ID}, }, } { t.Run(tc.name, func(t *testing.T) {