From e0ad9947283e317194c40a7b936cbfee51fcc2ec Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Thu, 19 Nov 2026 20:42:30 -0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E8=A1=A5=E9=BD=90=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=8E=A2=E6=B5=8B=E8=B6=85=E6=97=B6=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E3=80=81=E7=83=AD=E9=87=8D=E8=BD=BD=E4=B8=8E=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=A0=8F=E6=A8=A1=E5=9E=8B=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=20(#2154,=20#2027,=20#2147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- desktop/internal/i18n/shared.generated.go | 4 + desktop/internal/workbench/build.go | 234 +++++++----- .../internal/workbench/build_probe_test.go | 357 ++++++++++++++++++ desktop/internal/workbench/plugins.go | 36 +- .../workbench/plugins_build_reload_test.go | 305 +++++++++++++++ desktop/internal/workbench/runconfig.go | 2 + desktop/internal/workbench/runconfig_edit.go | 20 +- .../internal/workbench/runconfig_edit_test.go | 65 ++++ desktop/internal/workbench/runconfig_view.go | 5 +- .../workbench/settings_toolchains_test.go | 3 + .../workbench/title_run_empty_visual_test.go | 74 ++++ desktop/internal/workbench/title_run_test.go | 112 ++++++ desktop/internal/workbench/title_run_view.go | 67 +++- shared/i18n/locales/en-US.json | 2 + shared/i18n/locales/zh-CN.json | 2 + shared/i18n/messages.json | 20 + .../features/build-model-sync-session.json | 12 +- .../features/run-discovery.json | 26 +- 18 files changed, 1220 insertions(+), 126 deletions(-) create mode 100644 desktop/internal/workbench/build_probe_test.go create mode 100644 desktop/internal/workbench/plugins_build_reload_test.go diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 6929b4a1e2..b4596f6ac8 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -2153,6 +2153,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.tests.summary": "{passed} passed, {failed} failed, {skipped} skipped", "desktop.tests.timedOut": "Tests timed out", "desktop.title.branchMenu": "Branch menu", + "desktop.title.buildModelFailed": "{name}: model load failed", + "desktop.title.buildModelSafeMode": "{name}: paused in safe mode", "desktop.title.cloneLater": "Cloning repositories comes later", "desktop.title.configurationNotStartable": "{name} cannot be started: no build plugin runs it.", "desktop.title.currentFileNotRunnable": "The current file has no entrypoint to run, such as a class with a main method. Open such a file, or choose a run configuration from the run configuration menu.", @@ -5380,6 +5382,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.tests.summary": "{passed} 通过,{failed} 失败,{skipped} 跳过", "desktop.tests.timedOut": "测试超时", "desktop.title.branchMenu": "分支菜单", + "desktop.title.buildModelFailed": "{name}:模型加载失败", + "desktop.title.buildModelSafeMode": "{name}:安全模式下已暂停加载", "desktop.title.cloneLater": "克隆仓库稍后提供", "desktop.title.configurationNotStartable": "无法启动 {name}:没有构建插件负责运行它。", "desktop.title.currentFileNotRunnable": "当前文件没有可运行的入口(例如带 main 方法的类)。请打开这样的文件,或在运行配置菜单里选择一个运行配置。", diff --git a/desktop/internal/workbench/build.go b/desktop/internal/workbench/build.go index a13965a8ec..306ae67721 100644 --- a/desktop/internal/workbench/build.go +++ b/desktop/internal/workbench/build.go @@ -36,6 +36,10 @@ const ( buildOutputBytes = 4 << 20 ) +// buildToolProbeTimeout bounds one version probe of a build tool or runtime candidate so a +// stalled wrapper or SDK cannot block model loading or candidate fallback. Tests shorten it. +var buildToolProbeTimeout = 10 * time.Second + // runPreparationTimeout bounds what precedes a run's process: planning, resolving its tools and // the provider's preparation. The process itself runs until it exits, the user stops it or the // project closes: a service runs for as long as the user works with it. Tests shorten it. @@ -1394,25 +1398,34 @@ func (a *App) resolveBuildExecutable(ctx context.Context, p *project, instance b return buildExecution{}, err } runtimes := make(map[string]buildExecution, len(invocation.RuntimeDependencies)) - var runtimeEnvironment map[string]string - for _, requirement := range invocation.RuntimeDependencies { - resolved, err := a.resolveBuildCandidates(ctx, p, instance.Root, requirement.Executables, requirement.MinimumVersion, messages, runtimes) - if err != nil { - return buildExecution{}, err + validateCandidate := func(requirementID, minimum string, versionSpec *core.BuildVersionProbe) func(buildExecution) error { + if minimum == "" || versionSpec == nil { + return nil } - resolved.Environment = applyToolchainSelection(resolved.Environment, core.ToolchainSelection{Environment: runtimeEnvironment}) - if requirement.MinimumVersion != "" && requirement.Version != nil { - output, err := probeBuildTool(ctx, resolved.Executable, requirement.Version.Arguments, p.root, applyToolchainSelection(nil, resolved.selection())) - if err != nil { - return buildExecution{}, err + return func(candidate buildExecution) error { + output, probeErr := probeBuildTool(ctx, candidate.Executable, versionSpec.Arguments, p.root, applyToolchainSelection(nil, candidate.selection())) + if probeErr != nil { + return probeErr } - version, err := a.kernel.CheckBuildToolVersion(ctx, instance.Manifest, instance.BuildSystemID, requirement.ID, output) - if err != nil { - return buildExecution{}, err + version, checkErr := a.kernel.CheckBuildToolVersion(ctx, instance.Manifest, instance.BuildSystemID, requirementID, output) + if checkErr != nil { + return checkErr } if !version.Satisfied { - return buildExecution{}, errors.New(messages.VersionTooOld(requirement.MinimumVersion, version.Version)) + return errors.New(messages.VersionTooOld(minimum, version.Version)) } + return nil + } + } + var runtimeEnvironment map[string]string + for _, requirement := range invocation.RuntimeDependencies { + resolved, err := a.resolveAndCheckBuildCandidates( + ctx, p, instance.Root, requirement.Executables, requirement.MinimumVersion, + messages, runtimes, runtimeEnvironment, + validateCandidate(requirement.ID, requirement.MinimumVersion, requirement.Version), + ) + if err != nil { + return buildExecution{}, err } if requirement.PathVariable != "" { if resolved.Environment == nil { @@ -1423,98 +1436,126 @@ func (a *App) resolveBuildExecutable(ctx context.Context, p *project, instance b runtimeEnvironment = applyToolchainSelection(runtimeEnvironment, resolved.selection()) runtimes[requirement.ID] = resolved } - execution, err := a.resolveBuildCandidates(ctx, p, instance.Root, invocation.Executables, invocation.MinimumVersion, messages, runtimes) + execution, err := a.resolveAndCheckBuildCandidates( + ctx, p, instance.Root, invocation.Executables, invocation.MinimumVersion, + messages, runtimes, runtimeEnvironment, + validateCandidate("", invocation.MinimumVersion, invocation.Version), + ) if err != nil { return buildExecution{}, err } - execution.Environment = applyToolchainSelection(execution.Environment, core.ToolchainSelection{Environment: runtimeEnvironment}) - if invocation.MinimumVersion != "" && invocation.Version != nil { - output, probeErr := probeBuildTool(ctx, execution.Executable, invocation.Version.Arguments, p.root, applyToolchainSelection(nil, execution.selection())) - if probeErr != nil { - return buildExecution{}, probeErr - } - version, checkErr := a.kernel.CheckBuildToolVersion(ctx, instance.Manifest, instance.BuildSystemID, "", output) - if checkErr != nil { - return buildExecution{}, checkErr - } - if !version.Satisfied { - return buildExecution{}, errors.New(messages.VersionTooOld(invocation.MinimumVersion, version.Version)) - } - } return execution, nil } // Native candidate lookup consumes Core's order and runtime bindings. Runtime // exports and version probes are applied before the build tool itself starts. func (a *App) resolveBuildCandidates(ctx context.Context, p *project, directory string, candidates []core.BuildExecutableCandidate, minimum string, messages i18n.BuildMessages, runtimes map[string]buildExecution) (buildExecution, error) { - execution := buildExecution{} + return a.resolveAndCheckBuildCandidates(ctx, p, directory, candidates, minimum, messages, runtimes, nil, nil) +} + +func (a *App) resolveAndCheckBuildCandidates( + ctx context.Context, p *project, directory string, + candidates []core.BuildExecutableCandidate, minimum string, + messages i18n.BuildMessages, runtimes map[string]buildExecution, + inheritedEnv map[string]string, validate func(buildExecution) error, +) (buildExecution, error) { + var lastErr error for _, candidate := range candidates { - switch candidate.Kind { - case "projectFile": - path := filepath.Join(p.root, filepath.FromSlash(candidate.Path)) - if !buildRequiresPresent(path, candidate.Requires, p.root) { - continue - } - if info, statErr := os.Stat(path); statErr == nil && info.Mode().IsRegular() && (runtime.GOOS == "windows" || info.Mode().Perm()&0o111 != 0) { - execution.Executable = path - } - case "environment": - base := os.Getenv(candidate.Variable) - if base == "" { - continue - } - path := filepath.Join(base, filepath.FromSlash(candidate.Path)) - if info, statErr := os.Stat(path); statErr == nil && info.Mode().IsRegular() { - execution.Executable = path - } - case "setting": - if candidate.Path == "" { + execution, terminal, resolved, err := a.resolveOneBuildCandidate(ctx, p, directory, candidate, minimum, runtimes) + if err != nil { + return buildExecution{}, err + } + if !resolved || execution.Executable == "" { + continue + } + // A runtime candidate keeps the source of the runtime it named. + if candidate.Kind != "runtime" { + execution.Source.Kind, execution.Source.Variable = candidate.Kind, candidate.Variable + } + execution.Environment = applyToolchainSelection(execution.Environment, core.ToolchainSelection{Environment: inheritedEnv}) + if validate != nil { + if checkErr := validate(execution); checkErr != nil { + if terminal || ctx.Err() != nil { + return buildExecution{}, checkErr + } + lastErr = checkErr continue } - // An explicit setting is terminal: native lookup failure must not - // silently select a different installed program. - path, lookupErr := exec.LookPath(candidate.Path) - if lookupErr != nil { - return buildExecution{}, lookupErr - } + } + return execution, nil + } + if lastErr != nil { + return buildExecution{}, lastErr + } + return buildExecution{}, errors.New(messages.ExecutableMissing) +} + +func (a *App) resolveOneBuildCandidate(ctx context.Context, p *project, directory string, candidate core.BuildExecutableCandidate, minimum string, runtimes map[string]buildExecution) (buildExecution, bool, bool, error) { + var execution buildExecution + terminal := false + resolved := false + switch candidate.Kind { + case "projectFile": + path := filepath.Join(p.root, filepath.FromSlash(candidate.Path)) + if !buildRequiresPresent(path, candidate.Requires, p.root) { + return buildExecution{}, false, false, nil + } + if info, statErr := os.Stat(path); statErr == nil && info.Mode().IsRegular() && (runtime.GOOS == "windows" || info.Mode().Perm()&0o111 != 0) { execution.Executable = path - execution.PathPrepend = []string{filepath.Dir(path)} - case "command": - if path, lookupErr := exec.LookPath(candidate.Command); lookupErr == nil { - execution.Executable = path - } - case "runtime": - // The tool runs on one of its declared runtimes, all resolved before the tool's - // own candidates; Core rejects a runtime that names another runtime. - if resolved, ok := runtimes[candidate.Runtime]; ok { - execution = resolved - } - case "toolchain": - selection, selectErr := a.resolveToolchainSelection(ctx, p.root, directory, candidate.ToolchainID, minimum) - if selectErr != nil { - var unavailable *toolchain.UnavailableError - if errors.As(selectErr, &unavailable) && !unavailable.Terminal { - continue - } - return buildExecution{}, selectErr - } - execution.Executable = selection.Executable - execution.Environment = selection.Environment - execution.PathPrepend = selection.PathPrepend - execution.Source.Version, execution.Source.Layer = selection.Version, selection.Layer + resolved = true + } + case "environment": + base := os.Getenv(candidate.Variable) + if base == "" { + return buildExecution{}, false, false, nil } - if execution.Executable != "" { - // A runtime candidate keeps the source of the runtime it named. - if candidate.Kind != "runtime" { - execution.Source.Kind, execution.Source.Variable = candidate.Kind, candidate.Variable + path := filepath.Join(base, filepath.FromSlash(candidate.Path)) + if info, statErr := os.Stat(path); statErr == nil && info.Mode().IsRegular() { + execution.Executable = path + resolved = true + } + case "setting": + if candidate.Path == "" { + return buildExecution{}, false, false, nil + } + // An explicit setting is terminal: native lookup or version failure must not + // silently select a different installed program. + path, lookupErr := exec.LookPath(candidate.Path) + if lookupErr != nil { + return buildExecution{}, true, false, lookupErr + } + execution.Executable = path + execution.PathPrepend = []string{filepath.Dir(path)} + terminal, resolved = true, true + case "command": + if path, lookupErr := exec.LookPath(candidate.Command); lookupErr == nil { + execution.Executable = path + resolved = true + } + case "runtime": + // The tool runs on one of its declared runtimes, all resolved before the tool's + // own candidates; Core rejects a runtime that names another runtime. + if rt, ok := runtimes[candidate.Runtime]; ok { + execution = rt + resolved = true + } + case "toolchain": + selection, selectErr := a.resolveToolchainSelection(ctx, p.root, directory, candidate.ToolchainID, minimum) + if selectErr != nil { + var unavailable *toolchain.UnavailableError + if errors.As(selectErr, &unavailable) && !unavailable.Terminal { + return buildExecution{}, false, false, nil } - break + return buildExecution{}, true, false, selectErr } + execution.Executable = selection.Executable + execution.Environment = selection.Environment + execution.PathPrepend = selection.PathPrepend + execution.Source.Version, execution.Source.Layer = selection.Version, selection.Layer + terminal = selection.Layer == "pinned" + resolved = true } - if execution.Executable == "" { - return buildExecution{}, errors.New(messages.ExecutableMissing) - } - return execution, nil + return execution, terminal, resolved, nil } func buildRequiresPresent(path string, required []string, root string) bool { @@ -1529,8 +1570,13 @@ func buildRequiresPresent(path string, required []string, root string) bool { } func probeBuildTool(ctx context.Context, executable string, arguments []string, workingDirectory string, environment map[string]string) (string, error) { - output, waitErr := captureBuildProcess(ctx, executable, arguments, workingDirectory, environment, false, nil) - if output.combined == "" { + probeCtx, cancel := context.WithTimeout(ctx, buildToolProbeTimeout) + defer cancel() + output, waitErr := captureBuildProcess(probeCtx, executable, arguments, workingDirectory, environment, false, nil) + if waitErr != nil { + if errors.Is(probeCtx.Err(), context.DeadlineExceeded) && ctx.Err() == nil { + return "", fmt.Errorf("version check timed out after %s: %w", buildToolProbeTimeout, waitErr) + } return "", waitErr } return output.combined, nil @@ -2270,8 +2316,10 @@ func (a *App) invalidateBuild(p *project) { a.stopBuildSessions(p, false) p.revokeAllBuildTests() // The Run window's sessions are what ran, not the models, so they stay. - runs, view, sessions := p.build.runs, p.build.view, p.build.sessions - p.build = buildState{runs: runs, view: view, sessions: sessions} + // generation keeps rising so any in-flight detection invalidated here cannot + // land its stale instances or run configurations afterward. + runs, view, sessions, generation := p.build.runs, p.build.view, p.build.sessions, p.build.generation+1 + p.build = buildState{runs: runs, view: view, sessions: sessions, generation: generation} } // streamBuildOutput decodes text op wrote, on the goroutine that read it, and posts the decoded diff --git a/desktop/internal/workbench/build_probe_test.go b/desktop/internal/workbench/build_probe_test.go new file mode 100644 index 0000000000..4a5b986288 --- /dev/null +++ b/desktop/internal/workbench/build_probe_test.go @@ -0,0 +1,357 @@ +package workbench + +import ( + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" +) + +const buildProbeHelperEnv = "LITHE_TEST_BUILD_PROBE_HELPER" + +func probeSidecarPath(exePath string) string { + if strings.EqualFold(filepath.Ext(exePath), ".exe") { + return strings.TrimSuffix(exePath, filepath.Ext(exePath)) + ".probe" + } + return exePath + ".probe" +} + +func maybeRunBuildProbeHelper() bool { + if os.Getenv(buildProbeHelperEnv) != "1" { + return false + } + modeBytes, err := os.ReadFile(probeSidecarPath(os.Args[0])) + if err != nil { + return false + } + mode := strings.TrimSpace(string(modeBytes)) + if len(os.Args) > 1 && os.Args[1] == "--require-env" { + key, want, _ := strings.Cut(os.Args[2], "=") + if os.Getenv(key) != want { + fmt.Fprintf(os.Stderr, "missing env %s=%s (got %q)\n", key, want, os.Getenv(key)) + os.Exit(4) + } + } + switch { + case strings.HasPrefix(mode, "ok:"): + fmt.Println(strings.TrimPrefix(mode, "ok:")) + os.Exit(0) + case strings.HasPrefix(mode, "fail:"): + fmt.Fprintln(os.Stderr, strings.TrimPrefix(mode, "fail:")) + os.Exit(2) + case strings.HasPrefix(mode, "hang:"): + marker := strings.TrimPrefix(mode, "hang:") + if marker != "" { + _ = os.WriteFile(marker, []byte("started\n"), 0o600) + } + timer := time.NewTimer(30 * time.Second) + defer timer.Stop() + <-timer.C + os.Exit(7) + default: + fmt.Fprintf(os.Stderr, "unknown probe mode %q\n", mode) + os.Exit(3) + } + return true +} + +func writeProbeTool(t *testing.T, dir, name, mode string) string { + t.Helper() + exeName := name + if runtime.GOOS == "windows" { + exeName += ".exe" + } + dest := filepath.Join(dir, exeName) + copyTestBinary(t, dest) + if err := os.WriteFile(probeSidecarPath(dest), []byte(mode+"\n"), 0o600); err != nil { + t.Fatal(err) + } + return dest +} + +type probeVersionKernel struct { + *invocationKernel + calls []string +} + +func (k *probeVersionKernel) CheckBuildToolVersion(_ context.Context, _ json.RawMessage, _, reqID, output string) (core.BuildToolVersion, error) { + k.calls = append(k.calls, reqID+":"+strings.TrimSpace(output)) + if strings.Contains(output, "Version 2.0.0") || strings.Contains(output, "Runtime 21.0.0") { + return core.BuildToolVersion{Satisfied: true, Version: "2.0.0"}, nil + } + if strings.Contains(output, "Version 1.0.0") || strings.Contains(output, "Runtime 8.0.0") { + return core.BuildToolVersion{Satisfied: false, Version: "1.0.0"}, nil + } + return core.BuildToolVersion{}, fmt.Errorf("unrecognized version output %q", output) +} + +func TestProbeBuildToolReturnsOutputOnZeroExit(t *testing.T) { + t.Setenv(buildProbeHelperEnv, "1") + dir := t.TempDir() + tool := writeProbeTool(t, dir, "good-tool", "ok:Version 2.0.0") + ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) + defer cancel() + out, err := probeBuildTool(ctx, tool, []string{"--version"}, dir, nil) + if err != nil { + t.Fatalf("probeBuildTool returned error on exit 0: %v", err) + } + if !strings.Contains(out, "Version 2.0.0") { + t.Fatalf("output = %q, want Version 2.0.0", out) + } +} + +func TestProbeBuildToolRejectsNonZeroExitWithOutput(t *testing.T) { + t.Setenv(buildProbeHelperEnv, "1") + dir := t.TempDir() + tool := writeProbeTool(t, dir, "broken-tool", "fail:broken banner Version 2.0.0") + ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) + defer cancel() + out, err := probeBuildTool(ctx, tool, []string{"--version"}, dir, nil) + if err == nil { + t.Fatalf("probeBuildTool succeeded on non-zero exit (output=%q), want error", out) + } +} + +func TestProbeBuildToolBoundsHangingProcess(t *testing.T) { + t.Setenv(buildProbeHelperEnv, "1") + origTimeout := buildToolProbeTimeout + buildToolProbeTimeout = 1200 * time.Millisecond + t.Cleanup(func() { buildToolProbeTimeout = origTimeout }) + + dir := t.TempDir() + started := filepath.Join(t.TempDir(), "started") + tool := writeProbeTool(t, dir, "hang-tool", "hang:"+started) + ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) + defer cancel() + begin := time.Now() + _, err := probeBuildTool(ctx, tool, []string{"--version"}, dir, nil) + elapsed := time.Since(begin) + if err == nil { + t.Fatal("probeBuildTool succeeded on hanging process") + } + if elapsed > 6*time.Second { + t.Fatalf("probeBuildTool took %s, expected bound near %s", elapsed, buildToolProbeTimeout) + } + if _, statErr := os.Stat(started); statErr != nil { + t.Fatalf("hanging probe did not start before timing out: %v", statErr) + } +} + +func TestResolveBuildExecutableFallsBackAcrossAutomaticCandidates(t *testing.T) { + t.Setenv(buildProbeHelperEnv, "1") + if runtime.GOOS == "windows" { + t.Setenv("PATHEXT", ".EXE") + } + origTimeout := buildToolProbeTimeout + buildToolProbeTimeout = 1500 * time.Millisecond + t.Cleanup(func() { buildToolProbeTimeout = origTimeout }) + + t.Run("non-zero command falls back to next command", func(t *testing.T) { + bin := t.TempDir() + writeProbeTool(t, bin, "tool-broken", "fail:broken candidate") + good := writeProbeTool(t, bin, "tool-good", "ok:Version 2.0.0") + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + + kernel := &probeVersionKernel{invocationKernel: &invocationKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + invocation: core.BuildInvocation{ + MinimumVersion: "2.0.0", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "command", Command: "tool-broken"}, + {Kind: "command", Command: "tool-good"}, + }, + }, + }} + h := newHarness(t, kernel) + h.open(t.TempDir()) + exec, err := h.app.resolveBuildExecutable(t.Context(), h.app.project, buildInstance{BuildInstance: core.BuildInstance{Root: "."}}, h.app.text.Build) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if filepath.Clean(exec.Executable) != filepath.Clean(good) { + t.Fatalf("executable = %q, want fallback %q", exec.Executable, good) + } + }) + + t.Run("old automatic toolchain falls back to command and applies runtime env before probing", func(t *testing.T) { + bin := t.TempDir() + oldRT := writeProbeTool(t, bin, "rt-old", "ok:Runtime 8.0.0") + goodRT := writeProbeTool(t, bin, "rt-good", "ok:Runtime 21.0.0") + oldTool := writeProbeTool(t, bin, "tool-old", "ok:Version 1.0.0") + goodTool := writeProbeTool(t, bin, "tool-env", "ok:Version 2.0.0") + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + + kernel := &probeVersionKernel{invocationKernel: &invocationKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + invocation: core.BuildInvocation{ + MinimumVersion: "2.0.0", + Version: &core.BuildVersionProbe{Arguments: []string{"--require-env", "RUNTIME_OK=yes"}}, + RuntimeDependencies: []core.BuildRuntimeRequirement{{ + ID: "jdk", + MinimumVersion: "21", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "toolchain", ToolchainID: "dev.example:jdk"}, + {Kind: "command", Command: "rt-good"}, + }, + }}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "toolchain", ToolchainID: "dev.example:tool"}, + {Kind: "command", Command: "tool-env"}, + }, + }, + }} + h := newHarness(t, kernel) + h.open(t.TempDir()) + h.app.toolchainResolve = func(_ context.Context, _, _, tool, _ string) (core.ToolchainSelection, error) { + switch tool { + case "dev.example:jdk": + return core.ToolchainSelection{Executable: oldRT, Layer: "automatic", Version: "8.0.0"}, nil + case "dev.example:tool": + return core.ToolchainSelection{Executable: oldTool, Layer: "global", Version: "1.0.0"}, nil + default: + return core.ToolchainSelection{}, fmt.Errorf("unexpected tool %q", tool) + } + } + // Inject an environment variable from a second runtime requirement after the first runtime passes, or wait: + // Wait: since rt-good is a command, test runtime env propagation via a non-pinned toolchain replacement or second runtime! + _ = goodRT + kernel.invocation.RuntimeDependencies = []core.BuildRuntimeRequirement{ + { + ID: "jdk", + MinimumVersion: "21", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "toolchain", ToolchainID: "dev.example:jdk-old"}, + {Kind: "toolchain", ToolchainID: "dev.example:jdk-new"}, + }, + }, + } + h.app.toolchainResolve = func(_ context.Context, _, _, tool, _ string) (core.ToolchainSelection, error) { + switch tool { + case "dev.example:jdk-old": + return core.ToolchainSelection{Executable: oldRT, Layer: "automatic", Environment: map[string]string{"RUNTIME_OK": "no"}}, nil + case "dev.example:jdk-new": + return core.ToolchainSelection{Executable: goodRT, Layer: "automatic", Environment: map[string]string{"RUNTIME_OK": "yes"}}, nil + case "dev.example:tool": + return core.ToolchainSelection{Executable: oldTool, Layer: "global"}, nil + default: + return core.ToolchainSelection{}, fmt.Errorf("unexpected tool %q", tool) + } + } + exec, err := h.app.resolveBuildExecutable(t.Context(), h.app.project, buildInstance{BuildInstance: core.BuildInstance{Root: "."}}, h.app.text.Build) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if filepath.Clean(exec.Executable) != filepath.Clean(goodTool) { + t.Fatalf("executable = %q, want %q", exec.Executable, goodTool) + } + if exec.Environment["RUNTIME_OK"] != "yes" { + t.Fatalf("runtime environment was not applied: %+v", exec.Environment) + } + }) + + t.Run("hanging projectFile falls back to command", func(t *testing.T) { + workspace := t.TempDir() + writeProbeTool(t, workspace, "wrapperw", "hang:"+filepath.Join(workspace, "hung")) + bin := t.TempDir() + good := writeProbeTool(t, bin, "tool-good", "ok:Version 2.0.0") + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + + wrapperRel := "wrapperw" + if runtime.GOOS == "windows" { + wrapperRel += ".exe" + } + kernel := &probeVersionKernel{invocationKernel: &invocationKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + invocation: core.BuildInvocation{ + MinimumVersion: "2.0.0", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "projectFile", Path: wrapperRel}, + {Kind: "command", Command: "tool-good"}, + }, + }, + }} + h := newHarness(t, kernel) + h.open(workspace) + exec, err := h.app.resolveBuildExecutable(t.Context(), h.app.project, buildInstance{BuildInstance: core.BuildInstance{Root: "."}}, h.app.text.Build) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if filepath.Clean(exec.Executable) != filepath.Clean(good) { + t.Fatalf("executable = %q, want %q", exec.Executable, good) + } + }) +} + +func TestResolveBuildExecutableDoesNotFallBackAfterTerminalCandidateFailure(t *testing.T) { + t.Setenv(buildProbeHelperEnv, "1") + if runtime.GOOS == "windows" { + t.Setenv("PATHEXT", ".EXE") + } + + t.Run("explicit setting does not fall back when version probe fails", func(t *testing.T) { + bin := t.TempDir() + explicit := writeProbeTool(t, t.TempDir(), "explicit-tool", "fail:broken explicit") + writeProbeTool(t, bin, "tool-fallback", "ok:Version 2.0.0") + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + + kernel := &probeVersionKernel{invocationKernel: &invocationKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + invocation: core.BuildInvocation{ + MinimumVersion: "2.0.0", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "setting", Path: explicit}, + {Kind: "command", Command: "tool-fallback"}, + }, + }, + }} + h := newHarness(t, kernel) + h.open(t.TempDir()) + if _, err := h.app.resolveBuildExecutable(t.Context(), h.app.project, buildInstance{BuildInstance: core.BuildInstance{Root: "."}}, h.app.text.Build); err == nil { + t.Fatal("explicit setting fell back to command after probe failure") + } + }) + + t.Run("pinned toolchain does not fall back when too old", func(t *testing.T) { + bin := t.TempDir() + pinned := writeProbeTool(t, t.TempDir(), "pinned-tool", "ok:Version 1.0.0") + writeProbeTool(t, bin, "tool-fallback", "ok:Version 2.0.0") + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + + kernel := &probeVersionKernel{invocationKernel: &invocationKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + invocation: core.BuildInvocation{ + MinimumVersion: "2.0.0", + Version: &core.BuildVersionProbe{Arguments: []string{"--version"}}, + Executables: []core.BuildExecutableCandidate{ + {Kind: "toolchain", ToolchainID: "dev.example:tool"}, + {Kind: "command", Command: "tool-fallback"}, + }, + }, + }} + h := newHarness(t, kernel) + h.open(t.TempDir()) + h.app.toolchainResolve = func(context.Context, string, string, string, string) (core.ToolchainSelection, error) { + return core.ToolchainSelection{Executable: pinned, Layer: "pinned", Version: "1.0.0"}, nil + } + _, err := h.app.resolveBuildExecutable(t.Context(), h.app.project, buildInstance{BuildInstance: core.BuildInstance{Root: "."}}, i18n.BuildMessages{ + ExecutableMissing: "missing", + VersionTooOld: func(want, got string) string { return "too old: " + got + " < " + want }, + }) + if err == nil || !strings.Contains(err.Error(), "too old") { + t.Fatalf("err = %v, want too-old error without fallback", err) + } + }) +} diff --git a/desktop/internal/workbench/plugins.go b/desktop/internal/workbench/plugins.go index 6114ad2e57..73bec4d777 100644 --- a/desktop/internal/workbench/plugins.go +++ b/desktop/internal/workbench/plugins.go @@ -247,8 +247,7 @@ func (a *App) commitPluginInstall(ctx context.Context, plan plugininstall.Plan, a.allowPluginPrograms(plan.ID) } a.stopDisplaced(displaced) - a.refreshPluginState() - a.reloadPluginLanguages() + a.applyPluginLifecycleChange(installed) if !installed && feedback.Failure != nil { feedback.Failure(err) } @@ -256,6 +255,25 @@ func (a *App) commitPluginInstall(ctx context.Context, plan plugininstall.Plan, } } +// applyPluginLifecycleChange updates plugin state across every tab and, when reload is +// true, clears stale build state, reloads languages and re-detects builds on open tabs. +func (a *App) applyPluginLifecycleChange(reload bool) { + for _, tab := range a.everyTab() { + if reload { + tab.invalidateBuild(tab.project) + tab.reloadPluginLanguages() + } + tab.refreshPluginState() + } + if reload { + for _, tab := range a.openTabs() { + if tab.project != nil { + tab.loadBuildSystems(tab.project) + } + } + } +} + // recordPluginRuntimeIssue records automatic repair and cleanup at the native I/O boundary. func (a *App) recordPluginRuntimeIssue(ctx context.Context, err error) { fields := core.LogErrorFields(err) @@ -294,10 +312,8 @@ func (a *App) setPluginEnabled(id string, enabled bool) { a.allowPluginPrograms(id) } a.stopDisplaced(displaced) - // Enabling and disabling both change the detected build systems. - a.invalidateBuild(a.project) - a.refreshPluginState() - a.reloadPluginLanguages() + // Enabling and disabling both change the detected build systems across tabs. + a.applyPluginLifecycleChange(err == nil) } }) } @@ -323,13 +339,7 @@ func (a *App) uninstallPlugin(id string) { if err != nil { a.operationFailed("plugin_uninstall", err) } - for _, tab := range a.everyTab() { - if err == nil { - tab.invalidateBuild(tab.project) - tab.reloadPluginLanguages() - } - tab.refreshPluginState() - } + a.applyPluginLifecycleChange(err == nil) } }) } diff --git a/desktop/internal/workbench/plugins_build_reload_test.go b/desktop/internal/workbench/plugins_build_reload_test.go new file mode 100644 index 0000000000..92a4dcde31 --- /dev/null +++ b/desktop/internal/workbench/plugins_build_reload_test.go @@ -0,0 +1,305 @@ +package workbench + +import ( + "archive/zip" + "context" + "encoding/json" + "errors" + "os" + "path/filepath" + "sync/atomic" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/settingswindow" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" +) + +const hotBuildPluginID = "io.github.example.hot-build" + +const hotBuildPluginManifest = `{ + "schemaVersion": 0, + "id": "io.github.example.hot-build", + "displayName": "Hot Build Fixture", + "version": "1.0.0", + "pluginAPIVersion": 0, + "requires": {"buildSystems": 0, "buildProviders": 0}, + "vendor": {"id": "io.github.example", "displayName": "Example", "signatureRequirement": "none"}, + "permissions": ["languageServer.launch", "process.build"], + "activationEvents": ["onBuildSystem:hot-fixture"], + "languages": [], + "buildSystems": [{ + "id": "hot-fixture", + "displayName": "Hot Fixture", + "detection": {"markers": ["hotfixture.toml"]}, + "invocation": {"executables": [{"kind": "command", "command": "hot-fixture"}]}, + "provider": { + "launch": {"kind": "packaged", "path": "bin/provider"}, + "executesProjectCode": false, + "mayUseNetwork": false + }, + "model": { + "source": "static", + "file": "hotfixture.toml", + "decoder": "toml", + "map": { + "projects": [{ + "each": "/package", + "name": "/name", + "targets": [{"each": "$/bin/*", "name": "/name", "tags": ["application"]}] + }] + } + }, + "run": [{ + "id": "app", + "source": "provider", + "fromTargets": {"tags": ["application"]}, + "execution": "application" + }] + }] +}` + +func writeHotBuildPluginArchive(t *testing.T, id, manifest string) string { + t.Helper() + archive := filepath.Join(t.TempDir(), id+".zip") + file, err := os.Create(archive) + if err != nil { + t.Fatal(err) + } + writer := zip.NewWriter(file) + for name, content := range map[string]string{ + id + "/plugin.json": manifest, + id + "/bin/provider": "#!/bin/sh\n", + } { + entry, err := writer.Create(name) + if err != nil { + t.Fatal(err) + } + if _, err := entry.Write([]byte(content)); err != nil { + t.Fatal(err) + } + } + if err := errors.Join(writer.Close(), file.Close()); err != nil { + t.Fatal(err) + } + return archive +} + +func setupHotBuildWorkspace(t *testing.T, dir, appName string) { + t.Helper() + content := "[package]\nname = \"" + appName + "\"\nversion = \"0.1.0\"\n\n[[bin]]\nname = \"" + appName + "\"\n" + if err := os.WriteFile(filepath.Join(dir, "hotfixture.toml"), []byte(content), 0o600); err != nil { + t.Fatal(err) + } +} + +type blockedBuildDetectionKernel struct { + *testKernel + armed atomic.Bool + started chan struct{} + release chan struct{} +} + +func (k *blockedBuildDetectionKernel) DetectBuildSystemsWithOptions(ctx context.Context, root string, manifests []json.RawMessage, options core.BuildDetectOptions) (core.BuildDetection, error) { + if k.armed.Load() { + close(k.started) + select { + case <-ctx.Done(): + return core.BuildDetection{}, ctx.Err() + case <-k.release: + return core.BuildDetection{}, nil + } + } + return k.Client.DetectBuildSystemsWithOptions(ctx, root, manifests, options) +} + +func newBuildReloadStore(t *testing.T) *store.Store { + t.Helper() + dir := t.TempDir() + if err := os.WriteFile(filepath.Join(dir, settingsFile), []byte(`{"theme":"dark"}`), 0o600); err != nil { + t.Fatal(err) + } + return store.At(dir) +} + +func TestInvalidateBuildIncrementsGenerationAndDropsStaleDetection(t *testing.T) { + kernel := &blockedBuildDetectionKernel{ + testKernel: &testKernel{Client: core.NewClient()}, + started: make(chan struct{}), + release: make(chan struct{}), + } + h := newHarnessWithOptions(t, Options{ + Kernel: kernel, + PluginKernel: kernel, + PluginRoot: t.TempDir(), + Store: newBuildReloadStore(t), + }) + h.open(t.TempDir()) + p := h.app.project + h.settle() + + kernel.armed.Store(true) + var oldGen uint64 + h.app.post(func(a *App) { + a.invalidateBuild(p) + a.loadBuildSystems(p) + oldGen = p.build.generation + }) + awaitStateWithin(t, h, 8*time.Second, "in-flight detection to start", func() bool { + select { + case <-kernel.started: + return true + default: + return false + } + }) + + var invalidated bool + var invalidatedGen uint64 + h.app.post(func(a *App) { + a.invalidateBuild(p) + invalidatedGen = p.build.generation + invalidated = true + }) + h.await("invalidateBuild to run", func() bool { return invalidated }) + if invalidatedGen <= oldGen { + close(kernel.release) + t.Fatalf("invalidateBuild did not increment generation: got %d, want > %d", invalidatedGen, oldGen) + } + if p.build.loading { + close(kernel.release) + t.Fatal("invalidateBuild kept p.build.loading true") + } + var staleChecked bool + h.app.post(func(a *App) { + a.finishBuildDetection(p, oldGen, []buildInstance{{BuildInstance: core.BuildInstance{ID: "stale"}}}, nil) + staleChecked = true + }) + h.await("stale finishBuildDetection check", func() bool { return staleChecked }) + if len(p.build.instances) != 0 { + close(kernel.release) + t.Fatalf("stale detection landed after invalidateBuild: %+v", p.build.instances) + } + close(kernel.release) + h.settle() + if len(p.build.instances) != 0 { + t.Fatalf("blocked detection landed stale instances: %+v", p.build.instances) + } +} + +func TestPluginHotInstallEnableDisableUninstallReloadsBuildsAcrossTabs(t *testing.T) { + client := &testKernel{Client: core.NewClient()} + root := t.TempDir() + alpha, beta := filepath.Join(root, "alpha"), filepath.Join(root, "beta") + for _, dir := range []string{alpha, beta} { + if err := os.Mkdir(dir, 0o755); err != nil { + t.Fatal(err) + } + } + h := newHarnessWithOptions(t, Options{ + Kernel: client, + PluginKernel: client, + PluginRoot: t.TempDir(), + Store: newBuildReloadStore(t), + }) + h.app.settings.ProjectOpenDestination = settingswindow.ProjectOpenThisWindow + t.Cleanup(func() { h.disposeTabs() }) + setupHotBuildWorkspace(t, alpha, "AlphaApp") + setupHotBuildWorkspace(t, beta, "BetaApp") + + h.open(alpha) + h.app.openProject(beta) + h.settleTabs() + first := h.app + var second *App + for _, tab := range h.app.openTabs() { + if tab != first { + second = tab + } + } + if second == nil || second.project == nil { + t.Fatal("beta did not open in a second tab") + } + if first.project.titleConfiguration() != nil || second.project.titleConfiguration() != nil { + t.Fatal("projects detected a run configuration before any build plugin was installed") + } + + archive := writeHotBuildPluginArchive(t, hotBuildPluginID, hotBuildPluginManifest) + done := make(chan bool, 1) + var installErr error + feedback := approvingPluginInstall(t) + feedback.Failure = func(err error) { installErr = err } + feedback.Finish = func(failed bool) { done <- failed } + h.app.installPluginFromFile(archive, feedback) + awaitStateWithin(t, h, 20*time.Second, "install completion", func() bool { + select { + case failed := <-done: + if failed { + t.Fatalf("hot plugin install failed: %v", installErr) + } + return true + default: + return false + } + }) + + awaitBuilds := func(what string, check func() bool) { + t.Helper() + deadline := time.Now().Add(5 * time.Second) + for time.Now().Before(deadline) { + h.settleTabs() + if check() { + return + } + // Drain driver wakes for any posted tab completions. + select { + case <-h.driver.Wakes(): + _ = h.driver.Pump() + default: + } + } + t.Fatalf("%s did not happen\nfirst: loaded=%v failed=%q instances=%+v runs=%+v\nsecond: loaded=%v failed=%q instances=%+v runs=%+v\nnotice=%q logFailed=%q", + what, + first.project.build.loaded, first.project.build.failed, first.project.build.instances, first.project.runConfigs.list, + second.project.build.loaded, second.project.build.failed, second.project.build.instances, second.project.runConfigs.list, + first.notice, lastNotice(h)) + } + awaitBuilds("both tabs to detect build configs after hot install", func() bool { + a := first.project.titleConfiguration() + b := second.project.titleConfiguration() + return a != nil && b != nil && a.Name != b.Name && + len(first.project.build.instances) == 1 && len(second.project.build.instances) == 1 + }) + + // Disabling clears detected instances and title run configurations on every open tab. + h.app.post(func(a *App) { a.setPluginEnabled(hotBuildPluginID, false) }) + awaitBuilds("both tabs to clear builds after disable", func() bool { + return first.project.build.loaded && len(first.project.build.instances) == 0 && first.project.titleConfiguration() == nil && + second.project.build.loaded && len(second.project.build.instances) == 0 && second.project.titleConfiguration() == nil + }) + + // Enabling restores detected instances and title run configurations on every open tab. + h.app.post(func(a *App) { a.setPluginEnabled(hotBuildPluginID, true) }) + awaitBuilds("both tabs to reload builds after enable", func() bool { + a := first.project.titleConfiguration() + b := second.project.titleConfiguration() + return a != nil && b != nil && a.Name != b.Name && + len(first.project.build.instances) == 1 && len(second.project.build.instances) == 1 + }) + + // Uninstalling removes detected instances and title run configurations on every open tab. + h.app.post(func(a *App) { a.uninstallPlugin(hotBuildPluginID) }) + state := func() settingswindow.PluginState { + states := h.app.pluginState.Load() + if states == nil { + return settingswindow.PluginState{} + } + return (*states)[hotBuildPluginID] + } + awaitBuilds("both tabs to clear builds after uninstall", func() bool { + return !state().Installed && + first.project.build.loaded && len(first.project.build.instances) == 0 && first.project.titleConfiguration() == nil && + second.project.build.loaded && len(second.project.build.instances) == 0 && second.project.titleConfiguration() == nil + }) +} diff --git a/desktop/internal/workbench/runconfig.go b/desktop/internal/workbench/runconfig.go index 3c9067f977..d4a2874695 100644 --- a/desktop/internal/workbench/runconfig.go +++ b/desktop/internal/workbench/runconfig.go @@ -141,6 +141,8 @@ func (a *App) refreshRunConfigurations(p *project) { return } snapshot = data + } else if p.build.loaded && len(p.build.instances) == 0 && p.build.failed == "" { + snapshot = json.RawMessage("[]") } root, kernel := p.root, a.kernel a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { diff --git a/desktop/internal/workbench/runconfig_edit.go b/desktop/internal/workbench/runconfig_edit.go index fe3b480ab9..715d68cc99 100644 --- a/desktop/internal/workbench/runconfig_edit.go +++ b/desktop/internal/workbench/runconfig_edit.go @@ -31,10 +31,14 @@ type runConfigEditor struct { directory string environment string // scope is "local" or "project": which layer file the edit is saved into. - scope string - loading bool - saving bool - failure string + // generated says the configuration is an unsaved generated entry, so explicitly + // picking its Save-to scope marks the editor dirty even if it keeps "local". + scope string + generated bool + explicitSave bool + loading bool + saving bool + failure string // provider says the configuration is a build provider run, whose choices are edited // too. runtimeArguments is one argument per line; entrypoint is the provider's entry. provider bool @@ -117,7 +121,7 @@ func (a *App) openRunConfigEditor(p *project, id string) *runConfigEditor { e := &runConfigEditor{ open: true, generation: 1, id: id, name: configuration.Name, directory: configuration.Cwd, environment: environmentText(configuration.Env), - scope: "local", loading: true, + scope: "local", generated: configuration.Source == "generated", loading: true, } var buildInstance *buildInstance var optionSnapshot map[string]json.RawMessage @@ -216,9 +220,10 @@ func (e *runConfigEditor) fingerprint() string { return string(raw) } -// dirty says a value changed since the editor was read or last saved. +// dirty says a value changed since the editor was read or last saved, or an +// unsaved generated configuration had its save scope explicitly chosen. func (e *runConfigEditor) dirty() bool { - return e.ready() && e.fingerprint() != e.baseline + return e.ready() && (e.explicitSave || e.fingerprint() != e.baseline) } // saveRunConfigEditor has Core apply the edit to the chosen layer and applies the file changes @@ -293,6 +298,7 @@ func (a *App) saveRunConfigEditor(p *project, e *runConfigEditor, done func(ok b field := &e.optionFields[i] field.initFlag, field.initText, field.initPick = field.flag, field.text, slices.Clone(field.picks) } + e.generated, e.explicitSave = false, false e.baseline, e.savedBeforeLaunch = e.fingerprint(), slices.Clone(steps) } done(true) diff --git a/desktop/internal/workbench/runconfig_edit_test.go b/desktop/internal/workbench/runconfig_edit_test.go index 4ac9b3c62e..06371b51ad 100644 --- a/desktop/internal/workbench/runconfig_edit_test.go +++ b/desktop/internal/workbench/runconfig_edit_test.go @@ -175,3 +175,68 @@ func TestEnvironmentTextRoundTrips(t *testing.T) { t.Fatalf("line = %d, want 2", line) } } + +// Re-picking the already selected Save-to layer on an unsaved generated configuration counts as +// an explicit save request so OK persists the generated configuration to disk (#2147). +func TestRunConfigEditorSavesGeneratedConfigOnExplicitScopePick(t *testing.T) { + root := t.TempDir() + h, p := loadedRunConfigs(t, &testKernel{Client: core.NewClient()}, root) + if source := p.runConfigs.list[0].Source; source != "generated" { + t.Fatalf("initial configuration source = %q, want generated", source) + } + id := p.runConfigs.selected + d := &p.runConfigs.dialog + open := func() *runConfigEditor { + t.Helper() + h.app.post(func(a *App) { a.editRunConfiguration(p, id) }) + var e *runConfigEditor + awaitStateWithin(t, h, 10*time.Second, "the editor to finish loading", func() bool { + if draft := d.drafts[id]; d.open && draft != nil { + e = draft.editor + } + return e != nil && !e.loading + }) + return e + } + _ = open() + h.settle() + if d.dirty() { + t.Fatal("unmodified editor should not start dirty") + } + + language := h.app.language() + trigger := h.hitLabeled(i18n.Shared(language, "desktop.runConfig.scope")) + h.click(center(trigger)) + h.settle() + localLabel := i18n.Shared(language, "desktop.runConfig.scopeLocal") + var optionHit gfx.Hit + for _, hit := range h.driver.Snapshot().Hits { + if hit.Label == localLabel && !hit.IsLabel && hit.Bounds != trigger { + optionHit = hit + } + } + if optionHit.Bounds == (gfx.Rect{}) { + t.Fatalf("scope popup did not list option %q (hits: %+v)", localLabel, h.driver.Snapshot().Hits) + } + h.click(center(optionHit.Bounds)) + h.settle() + if !d.dirty() { + t.Fatal("explicitly picking the Save-to scope on a generated configuration did not mark the editor dirty") + } + + ok := h.hitLabeled(i18n.Shared(language, "desktop.runConfig.ok")) + h.click(center(ok)) + localLayer := filepath.Join(root, ".lithe", "run", "plugin", "dev.example.engine.local.toml") + awaitStateWithin(t, h, 10*time.Second, "the generated configuration saved to disk", func() bool { + if d.open || p.runConfigs.loading { + return false + } + _, err := os.Stat(localLayer) + return err == nil + }) + _ = open() + h.settle() + if d.dirty() { + t.Fatal("reopened configuration after saving should not start dirty") + } +} diff --git a/desktop/internal/workbench/runconfig_view.go b/desktop/internal/workbench/runconfig_view.go index 7a51ce68f2..41fa4b9ce4 100644 --- a/desktop/internal/workbench/runconfig_view.go +++ b/desktop/internal/workbench/runconfig_view.go @@ -339,8 +339,11 @@ func (a *App) drawRunConfigEditorPane(c ui.C, p *project, e *runConfigEditor) { } } labels := map[string]string{"local": i18n.Shared(language, "desktop.runConfig.scopeLocal"), "project": i18n.Shared(language, "desktop.runConfig.scopeProject")} - ui.Select(c.Part("scope"), &e.scope, []string{"local", "project"}, func(scope string) string { return labels[scope] }). + sel := ui.Select(c.Part("scope"), &e.scope, []string{"local", "project"}, func(scope string) string { return labels[scope] }). Label(i18n.Shared(language, "desktop.runConfig.scope")).FillWidth().Disabled(!ready) + if _, picked := sel.Picked(); picked && e.generated { + e.explicitSave = true + } if e.beforeLaunch != nil { a.drawRunConfigBeforeLaunch(c.Part("before-launch-field"), p, e.beforeLaunch, i18n.Shared(language, "desktop.runConfig.fieldBeforeLaunch"), i18n.Shared(language, "desktop.runConfig.beforeLaunchHelp"), e.beforeLaunchCandidates, e.beforeLaunchTasks, ready, nil) diff --git a/desktop/internal/workbench/settings_toolchains_test.go b/desktop/internal/workbench/settings_toolchains_test.go index 5b614d1450..23b8c68d77 100644 --- a/desktop/internal/workbench/settings_toolchains_test.go +++ b/desktop/internal/workbench/settings_toolchains_test.go @@ -265,6 +265,9 @@ func TestToolchainSettingsReadbackFailureReportsCommittedSource(t *testing.T) { const syntheticWorkbenchInterpMarkerEnv = "LITHE_TEST_SYNTHETIC_INTERP_MARKER" func TestMain(m *testing.M) { + if maybeRunBuildProbeHelper() { + return + } if marker := os.Getenv(syntheticWorkbenchInterpMarkerEnv); marker != "" && len(os.Args) == 2 && os.Args[1] == "--version" { _ = os.WriteFile(marker, []byte("probed\n"), 0o600) fmt.Println("SyntheticInterp 3.12.4") diff --git a/desktop/internal/workbench/title_run_empty_visual_test.go b/desktop/internal/workbench/title_run_empty_visual_test.go index 90de8952d3..f3dfad2fda 100644 --- a/desktop/internal/workbench/title_run_empty_visual_test.go +++ b/desktop/internal/workbench/title_run_empty_visual_test.go @@ -10,6 +10,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" "github.com/1lck/Lithe-IDEA/desktop/internal/store" "github.com/vivaui/viva/app" "github.com/vivaui/viva/headless" @@ -89,3 +90,76 @@ func TestVisualTitleRunWithoutConfigurations(t *testing.T) { }) } } + +func openVisualTitleRunSession(t *testing.T, theme, language, root string) (*harness, *headless.Session) { + t.Helper() + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, map[string]string{"theme": theme}); err != nil { + t.Fatal(err) + } + var session *headless.Session + h := newHarnessWithDriver(t, Options{Kernel: &testKernel{Client: core.NewClient()}, Store: prefs, Languages: []string{language}}, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1280, 800 + var err error + session, err = headless.Open(config, nil, headless.Options{Scale: 1}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + h.open(root) + return h, session +} + +// TestVisualTitleRunBuildModelIssues captures the title run menu when a build instance +// fails to load its model or is paused in safe mode (#2027). +func TestVisualTitleRunBuildModelIssues(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0755); err != nil { + t.Fatal(err) + } + for _, scene := range []struct{ theme, language string }{{"light", "zh-CN"}, {"dark", "en-US"}} { + name := scene.theme + "-" + scene.language + t.Run(name, func(t *testing.T) { + for _, kind := range []string{"failed", "safe-mode"} { + t.Run(kind, func(t *testing.T) { + h, session := openVisualTitleRunSession(t, scene.theme, scene.language, runConfigRoot(t)) + p := h.app.project + since := p.runConfigs.generation + h.app.post(func(a *App) { + instance := buildInstance{ + BuildInstance: core.BuildInstance{ID: "engine@app", BuildSystemID: "engine", Root: "app", DisplayName: "Engine"}, + PluginID: "dev.example.engine", + System: pluginservice.BuildSystemDeclaration{DisplayName: "Engine"}, + } + if kind == "failed" { + instance.modelError = "JAVA_HOME is not defined and no fallback JDK matched" + } else { + a.skipUntrustedModel(&instance) + } + setDetected(p, []buildInstance{instance}) + a.refreshRunConfigurations(p) + }) + awaitRunConfigsAfter(t, h, p, since) + h.click(center(h.button(itemRunConfig))) + h.settle() + if err := session.Screenshot(filepath.Join(out, "title-run-model-"+kind+"-"+name+".png")); err != nil { + t.Fatal(err) + } + language := h.app.language() + key := "desktop.title.buildModelFailed" + if kind == "safe-mode" { + key = "desktop.title.buildModelSafeMode" + } + want := i18n.SharedFormat(language, key, map[string]string{"name": "Engine (app)"}) + if !h.shows(want) { + t.Fatalf("title run menu did not paint %q", want) + } + }) + } + }) + } +} diff --git a/desktop/internal/workbench/title_run_test.go b/desktop/internal/workbench/title_run_test.go index c19905624c..04bd13947f 100644 --- a/desktop/internal/workbench/title_run_test.go +++ b/desktop/internal/workbench/title_run_test.go @@ -311,3 +311,115 @@ func TestEditRunConfigurationsOpensTheChosenOnesEditor(t *testing.T) { t.Fatalf("selected %q, want %q; notice %q", d.selected, id, lastNotice(h)) } } + +// When a build instance fails to load its model (#2027), the title run menu explains why +// instead of claiming there are no run configurations, and clicking opens the sync log in +// the Run window (or the Build window when no sync session exists). +func TestTitleRunMenuShowsFailedBuildModelAndOpensLogOrBuildWindow(t *testing.T) { + t.Run("with sync session opens Run window session", func(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(runConfigRoot(t)) + p := h.app.project + since := p.runConfigs.generation + h.app.post(func(a *App) { + instance := buildInstance{ + BuildInstance: core.BuildInstance{ID: "engine@.", BuildSystemID: "engine", Root: ".", DisplayName: "Engine"}, + PluginID: "dev.example.engine", + System: pluginservice.BuildSystemDeclaration{DisplayName: "Engine"}, + modelError: "JAVA_HOME is not defined\nsecond detail line", + } + setDetected(p, []buildInstance{instance}) + entry := &runEntry{id: "sync-1", sync: &buildSync{instance: instance.ID}, outcome: runFailed, summary: "JAVA_HOME is not defined"} + p.build.runs = append(p.build.runs, entry) + a.refreshRunConfigurations(p) + }) + awaitRunConfigsAfter(t, h, p, since) + language := h.app.language() + wantItem := i18n.SharedFormat(language, "desktop.title.buildModelFailed", map[string]string{"name": "Engine"}) + noConfigs := i18n.Shared(language, "desktop.title.noRunConfigurations") + + h.click(center(h.button(itemRunConfig))) + h.settle() + if !h.shows(wantItem) { + t.Fatalf("title run menu did not show %q", wantItem) + } + if h.shows(noConfigs) { + t.Fatalf("title run menu showed misleading %q alongside build model failure", noConfigs) + } + h.click(center(h.menuItemHit(wantItem))) + h.settle() + if !h.app.chrome.isOpen(catalogIndex[itemRun]) || p.build.view != "sync-1" { + t.Fatalf("click did not show sync session in Run window: runOpen=%v view=%q", h.app.chrome.isOpen(catalogIndex[itemRun]), p.build.view) + } + }) + + t.Run("without sync session selects instance and opens Build window", func(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(runConfigRoot(t)) + p := h.app.project + since := p.runConfigs.generation + h.app.post(func(a *App) { + first := runConfigInstance("alpha") + first.modelLoaded = true + second := buildInstance{ + BuildInstance: core.BuildInstance{ID: "engine@app", BuildSystemID: "engine", Root: "app", DisplayName: "Engine"}, + PluginID: "dev.example.engine", + System: pluginservice.BuildSystemDeclaration{DisplayName: "Engine"}, + modelError: "missing wrapper", + } + setDetected(p, []buildInstance{first, second}) + a.refreshRunConfigurations(p) + }) + awaitRunConfigsAfter(t, h, p, since) + language := h.app.language() + wantItem := i18n.SharedFormat(language, "desktop.title.buildModelFailed", map[string]string{"name": "Engine (app)"}) + + h.click(center(h.button(itemRunConfig))) + h.settle() + if !h.shows(wantItem) { + t.Fatalf("title run menu did not show %q", wantItem) + } + h.click(center(h.menuItemHit(wantItem))) + h.settle() + if !h.app.chrome.isOpen(catalogIndex[itemBuild]) || p.build.selected != 1 { + t.Fatalf("click did not select failed instance in Build window: buildOpen=%v selected=%d", h.app.chrome.isOpen(catalogIndex[itemBuild]), p.build.selected) + } + }) +} + +// When safe mode paused build model loading (#2027), the title run menu explains why +// and clicking opens the workspace trust prompt. +func TestTitleRunMenuShowsSafeModePausedModelAndAsksToTrust(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(runConfigRoot(t)) + p := h.app.project + since := p.runConfigs.generation + h.app.post(func(a *App) { + instance := buildInstance{ + BuildInstance: core.BuildInstance{ID: "engine@.", BuildSystemID: "engine", Root: ".", DisplayName: "Engine"}, + PluginID: "dev.example.engine", + System: pluginservice.BuildSystemDeclaration{DisplayName: "Engine"}, + } + a.skipUntrustedModel(&instance) + setDetected(p, []buildInstance{instance}) + a.refreshRunConfigurations(p) + }) + awaitRunConfigsAfter(t, h, p, since) + language := h.app.language() + wantItem := i18n.SharedFormat(language, "desktop.title.buildModelSafeMode", map[string]string{"name": "Engine"}) + noConfigs := i18n.Shared(language, "desktop.title.noRunConfigurations") + + h.click(center(h.button(itemRunConfig))) + h.settle() + if !h.shows(wantItem) { + t.Fatalf("title run menu did not show %q", wantItem) + } + if h.shows(noConfigs) { + t.Fatalf("title run menu showed misleading %q in safe mode", noConfigs) + } + h.click(center(h.menuItemHit(wantItem))) + h.settle() + if !p.trust.asking || len(h.app.prompts.queue) != 1 { + t.Fatalf("clicking safe mode item did not ask to trust: asking=%v queue=%d", p.trust.asking, len(h.app.prompts.queue)) + } +} diff --git a/desktop/internal/workbench/title_run_view.go b/desktop/internal/workbench/title_run_view.go index 594b1a2bcf..7da977c1cc 100644 --- a/desktop/internal/workbench/title_run_view.go +++ b/desktop/internal/workbench/title_run_view.go @@ -3,6 +3,7 @@ package workbench import ( "path" "path/filepath" + "strings" "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" @@ -57,10 +58,48 @@ func (a *App) titleRunConfigMenu(c ui.C, anchor ui.Box) { menu.Item(i18n.SharedFormat(lang, "desktop.runConfig.loadFailed", map[string]string{"reason": s.failure})).Disabled(true) case p.build.failed != "": menu.Item(p.build.failed).Disabled(true) - case len(s.list) == 0: - menu.Item(i18n.Shared(lang, "desktop.title.noRunConfigurations")).Disabled(true) - if s.hidden > 0 { - menu.Item(hiddenRunConfigurations(lang, s.hidden)).Disabled(true) + default: + hasModelIssue := false + for i := range p.build.instances { + instance := &p.build.instances[i] + if !instance.modelUntrusted && instance.modelError == "" { + continue + } + hasModelIssue = true + instanceName := titleBuildInstanceName(instance) + var label string + if instance.modelUntrusted { + label = i18n.SharedFormat(lang, "desktop.title.buildModelSafeMode", map[string]string{"name": instanceName}) + } else { + label = i18n.SharedFormat(lang, "desktop.title.buildModelFailed", map[string]string{"name": instanceName}) + } + item := menu.Item(label).Icon(icons.CircleAlert) + if desc := firstNonEmptyLine(instance.modelError); desc != "" { + item.Description(desc) + } + if item.Clicked() { + instanceID, instanceIndex, untrusted := instance.ID, i, instance.modelUntrusted + c.After(func() { + if untrusted { + a.askToTrustProject(p, nil) + return + } + if session := p.buildSyncSession(instanceID); session != nil { + a.showBuildSync(p, session.id) + return + } + p.build.selected = instanceIndex + a.openToolWindow(itemBuild) + }) + } + } + if len(s.list) == 0 { + if !hasModelIssue { + menu.Item(i18n.Shared(lang, "desktop.title.noRunConfigurations")).Disabled(true) + } + if s.hidden > 0 { + menu.Item(hiddenRunConfigurations(lang, s.hidden)).Disabled(true) + } } } // A saved file Core did not read is named by its file name, which fits the menu, and @@ -100,3 +139,23 @@ func (a *App) runConfigMenuNote(configuration core.RunConfiguration) string { } return a.runConfigUnavailableText(configuration) } + +// titleBuildInstanceName names a build instance concisely for the title run menu, appending +// its root only when it lives in a subdirectory. +func titleBuildInstanceName(instance *buildInstance) string { + name := buildSystemName(instance) + if detail := buildRootDetail(instance); detail != "" { + return name + " (" + detail + ")" + } + return name +} + +// firstNonEmptyLine returns the first non-blank line of text for menu descriptions. +func firstNonEmptyLine(text string) string { + for _, line := range strings.FieldsFunc(text, func(r rune) bool { return r == '\n' || r == '\r' }) { + if trimmed := strings.TrimSpace(line); trimmed != "" { + return trimmed + } + } + return "" +} diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index cfbd14bd03..26df276217 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -11315,6 +11315,8 @@ "desktop.plugins.commandInstallCommandsMissing": "The installation finished, but {commands} was not found in {directory}.", "desktop.plugins.commandInstallToolMissing": "{tool} not found. Install it first, or set where it is in Settings > Build, Execution, Deployment > Toolchains.", "desktop.plugins.commandInstallError": "Could not install: {reason}", + "desktop.title.buildModelFailed": "{name}: model load failed", + "desktop.title.buildModelSafeMode": "{name}: paused in safe mode", "desktop.title.configurationNotStartable": "{name} cannot be started: no build plugin runs it.", "desktop.title.currentFileNotRunnable": "The current file has no entrypoint to run, such as a class with a main method. Open such a file, or choose a run configuration from the run configuration menu.", "desktop.title.hiddenRunConfigurations": "{count} saved configurations hidden (not runnable)", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index f576c50fcf..45322a06ad 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -11315,6 +11315,8 @@ "desktop.plugins.commandInstallCommandsMissing": "安装已完成,但在 {directory} 中没有找到 {commands}。", "desktop.plugins.commandInstallToolMissing": "未找到 {tool}。请先安装它,或在 设置 > 构建、执行、部署 > 工具链 中指定它的位置。", "desktop.plugins.commandInstallError": "无法安装:{reason}", + "desktop.title.buildModelFailed": "{name}:模型加载失败", + "desktop.title.buildModelSafeMode": "{name}:安全模式下已暂停加载", "desktop.title.configurationNotStartable": "无法启动 {name}:没有构建插件负责运行它。", "desktop.title.currentFileNotRunnable": "当前文件没有可运行的入口(例如带 main 方法的类)。请打开这样的文件,或在运行配置菜单里选择一个运行配置。", "desktop.title.hiddenRunConfigurations": "已隐藏 {count} 条无法运行的已保存配置", diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index 09c1aecb0a..3a238339fe 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -19894,6 +19894,26 @@ "desktop" ] }, + { + "id": "desktop.title.buildModelFailed", + "description": "Desktop title bar: a detected build system failed to load its project model so its run configurations could not be discovered", + "platforms": [ + "desktop" + ], + "parameters": { + "name": "string" + } + }, + { + "id": "desktop.title.buildModelSafeMode", + "description": "Desktop title bar: a detected build system is paused because the workspace is in safe mode", + "platforms": [ + "desktop" + ], + "parameters": { + "name": "string" + } + }, { "id": "desktop.title.cloneLater", "description": "Desktop title bar: CloneLater", diff --git a/shared/platform-feature-matrix/features/build-model-sync-session.json b/shared/platform-feature-matrix/features/build-model-sync-session.json index be872bea31..a4eebce5dd 100644 --- a/shared/platform-feature-matrix/features/build-model-sync-session.json +++ b/shared/platform-feature-matrix/features/build-model-sync-session.json @@ -4,8 +4,8 @@ "group": "运行输出", "capability": "加载构建模型时,Run 窗口为每次加载开一个“同步 <构建系统>”执行标签,实时显示构建工具下载、解析依赖时打印的日志,带状态、开始时间、耗时、停止和再次运行;Build 窗口里正在加载的那一行显示最新一行输出,点击打开对应标签", "owner": "Run", - "notes": "Viva 共享实现。命令来源的模型从 stdout 读取时只解码 stdout,stderr(如 go: downloading …)只进同步标签的控制台,不再混进模型文档;模型写到输出文件时两路输出都进控制台。Provider 来源把 lithe/build/progress 的 output 写进控制台、message 作为最新一行。同步标签不抢占正在运行的执行标签,也不主动把 Run 窗口调到前台;同名的已结束同步标签被新一次加载替换,标签数超出上限时先移除已结束的同步标签。用户停止后结果为“构建模型加载已停止”,Build 窗口不显示失败警告,也不会因文件变化自动重新加载,直到用户点 Reload 或再次运行。文案走 shared/i18n 的 desktop.build.syncSession*、desktop.build.modelStopped、desktop.build.showSyncOutput。", - "verification": "打开一个首次加载需要下载依赖的 Go 模块项目(清空模块缓存),在 Build 窗口点加载或 Reload:Run 窗口出现“同步 Go Modules”标签并显示 go: downloading 行,Build 窗口加载行显示最新一行输出,点击后 Run 窗口打开并选中该标签;加载结束后标签显示成功、开始时间和耗时,Build 树正常展开。再次加载时点停止:标签结果为已停止,Build 窗口不显示警告也不自动重试,点再次运行在同一个标签重新加载。正在运行一个任务时触发加载,确认 Run 窗口仍停在那个任务上。自动化:build_sync_test.go 的 TestBuildModelLoadShowsTheToolsLogInARunWindowSession、TestBuildModelLoadTheUserStopsEndsStoppedAndRerunsInItsTab,build_command_record_test.go 的 download 场景。", + "notes": "Viva 共享实现。命令来源的模型从 stdout 读取时只解码 stdout,stderr(如 go: downloading …)只进同步标签的控制台,不再混进模型文档;模型写到输出文件时两路输出都进控制台。Provider 来源把 lithe/build/progress 的 output 写进控制台、message 作为最新一行。同步标签不抢占正在运行的执行标签,也不主动把 Run 窗口调到前台;同名的已结束同步标签被新一次加载替换,标签数超出上限时先移除已结束的同步标签。用户停止后结果为“构建模型加载已停止”,Build 窗口不显示失败警告,也不会因文件变化自动重新加载,直到用户点 Reload 或再次运行。文案走 shared/i18n 的 desktop.build.syncSession*、desktop.build.modelStopped、desktop.build.showSyncOutput。2026-11-20(#2027):模型加载失败或处于安全模式时,titleRunConfigMenu 也会列出对应条目及首行原因,点击失败条目优先调用 showBuildSync 打开同步会话标签(无会话则打开 Build 窗口并选中该实例),点击安全模式条目触发工作区信任弹窗。", + "verification": "打开一个首次加载需要下载依赖的 Go 模块项目(清空模块缓存),在 Build 窗口点加载或 Reload:Run 窗口出现“同步 Go Modules”标签并显示 go: downloading 行,Build 窗口加载行显示最新一行输出,点击后 Run 窗口打开并选中该标签;加载结束后标签显示成功、开始时间和耗时,Build 树正常展开。再次加载时点停止:标签结果为已停止,Build 窗口不显示警告也不自动重试,点再次运行在同一个标签重新加载。正在运行一个任务时触发加载,确认 Run 窗口仍停在那个任务上。标题栏运行配置下拉在模型加载失败或安全模式暂停时直接显示提示行,点击可打开对应同步会话标签或工作区信任。自动化:build_sync_test.go 的 TestBuildModelLoadShowsTheToolsLogInARunWindowSession、TestBuildModelLoadTheUserStopsEndsStoppedAndRerunsInItsTab,build_command_record_test.go 的 download 场景,以及 title_run_test.go 与 title_run_empty_visual_test.go(#2027)。", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -14,9 +14,11 @@ "desktop/internal/workbench/build.go", "desktop/internal/workbench/build_tree.go", "desktop/internal/workbench/build_tree_view.go", + "desktop/internal/workbench/title_run_view.go", "desktop/internal/workbench/runs.go", "desktop/internal/workbench/build_sync_test.go", - "desktop/internal/workbench/build_command_record_test.go" + "desktop/internal/workbench/build_command_record_test.go", + "desktop/internal/workbench/title_run_test.go" ] }, "windows": { @@ -27,9 +29,11 @@ "desktop/internal/workbench/build.go", "desktop/internal/workbench/build_tree.go", "desktop/internal/workbench/build_tree_view.go", + "desktop/internal/workbench/title_run_view.go", "desktop/internal/workbench/runs.go", "desktop/internal/workbench/build_sync_test.go", - "desktop/internal/workbench/build_command_record_test.go" + "desktop/internal/workbench/build_command_record_test.go", + "desktop/internal/workbench/title_run_test.go" ] } } diff --git a/shared/platform-feature-matrix/features/run-discovery.json b/shared/platform-feature-matrix/features/run-discovery.json index 98666e75c1..e9d90bfb67 100644 --- a/shared/platform-feature-matrix/features/run-discovery.json +++ b/shared/platform-feature-matrix/features/run-discovery.json @@ -8,7 +8,16 @@ "verificationStatus": "pending", "evidence": [ "desktop/internal/core/run_discovery.go", - "desktop/internal/workbench/runconfig.go" + "desktop/internal/workbench/runconfig.go", + "desktop/internal/workbench/runconfig_edit.go", + "desktop/internal/workbench/runconfig_view.go", + "desktop/internal/workbench/build.go", + "desktop/internal/workbench/plugins.go", + "desktop/internal/workbench/title_run_view.go", + "desktop/internal/workbench/build_probe_test.go", + "desktop/internal/workbench/runconfig_edit_test.go", + "desktop/internal/workbench/plugins_build_reload_test.go", + "desktop/internal/workbench/title_run_test.go" ] }, "windows": { @@ -16,12 +25,21 @@ "verificationStatus": "pending", "evidence": [ "desktop/internal/core/run_discovery.go", - "desktop/internal/workbench/runconfig.go" + "desktop/internal/workbench/runconfig.go", + "desktop/internal/workbench/runconfig_edit.go", + "desktop/internal/workbench/runconfig_view.go", + "desktop/internal/workbench/build.go", + "desktop/internal/workbench/plugins.go", + "desktop/internal/workbench/title_run_view.go", + "desktop/internal/workbench/build_probe_test.go", + "desktop/internal/workbench/runconfig_edit_test.go", + "desktop/internal/workbench/plugins_build_reload_test.go", + "desktop/internal/workbench/title_run_test.go" ] }, "owner": "Run", - "verification": "Windows Run Actions 仍处于关闭状态;扩展 Run Actions 测试验证插件启用、禁用和声明的执行计划,TypeScript 检查所有调用方;重新启用前需完成实际应用验收。 多模块项目把服务工作目录改成模块目录后,服务仍留在列表中并以该目录启动;填写不存在的目录或 ${workspaceFolder} 等变量时,保存被拒绝并提示原因;在 Windows 确认重新扫描服务使用双箭头刷新图标,配置按语言生态、类型与实例呈现三栏布局;语言切换和外部选中能定位配置,空生态不显示,语言和配置栏不显示重复栏头,生态不显示配置数量;语言侧栏通过拖动阈值折叠和展开,收起与展开阈值不同以避免边界跳动,不显示专门折叠按钮;键盘可调整宽度及恢复展开,保存展开宽度与拖动折叠状态,拖动期间只更新局部宽度和紧凑标记,文字与图标对齐即时切换,结束后保存;语言行、类型行和实例行使用一致的紧凑行高,去掉列表上下留白和选中实例的圆角边距;窄面板自动缩成带提示的图标栏且扩大后恢复,右侧输出保留可用空间,窗口缩放或卸载时清理正在进行的拖动;所选配置的日志、运行状态、顶部停止按钮、清空输出与标准输入均指向其自身会话;保持选中 application 并后台启动服务后,顶部停止仍指向该应用的独立会话,不停止后台服务,左侧使用 SVG 箭头和类型图标,基础设施默认折叠,选择配置自动展开所在分组,运行、停止、编辑和完整名称提示可用;根据 Core 提供的元数据展示明确识别的框架图标,构建与测试任务保留工具图标,未知类型回退通用图标;同名自定义 provider 与已知框架分别分组且折叠状态独立,相同已知框架跨 provider 合组,项目与基础设施不合组;macOS Run 缺少配置且可重新生成时,检查空状态文字与链接在深浅主题下按 IDEA 工具窗口样式显示、窄面板不截断,并确认“识别并生成”仍触发原有生成流程;应用语言设为英文而系统语言为中文时,Run 空状态及其他本面板文案仍应显示英文;Run 顶部标题字号、颜色、41pt 高度和底部分隔线应与 Terminal、Git Log 等工具窗口一致;有项目配置或 Current File 正在运行/已有退出结果时,运行、重启、重新扫描和软换行按钮显示在独立的 36pt 操作栏,检查 16pt IDEA 图标、22pt 共享按钮的悬停、按下、选中及禁用状态;操作栏只保留一个运行/重运行动作:首次启动显示 Run,当前配置已运行过后显示 Rerun;右侧固定停止按钮,未运行禁用、运行中启用,两者始终指向当前选中配置;操作栏不重复显示 Running 圆点及状态文字,重运行按钮复用顶部工具栏的绿色 rerun_stroke 图标;标题栏菜单中的清空输出与原操作一致,收起按钮沿用共享样式;仅有 Current File 的项目启动后也可从 Run 操作栏停止,结束后保留重运行入口;Run 内容区不额外插入语言服务准备状态行,准备进度和失败入口保留在工作台状态栏;Run 标题、操作栏、配置列表标题、控制台标签底边及两侧纵向分割线统一使用工具窗口边框颜色和 1pt 绘制,左侧图标栏不出现 5pt 实心粗线,栏内分组线与 Git Log 一致使用共享 divider 颜色、22pt 宽度、1pt 高度及上下 3pt 间距;操作按钮组之间使用专用 ActionToolbar.separator,详情编辑按钮的边框由共享按钮样式负责,拖动命中范围保持不变;配置树直接显示分组与数量,不显示 Application types 标题;默认隐藏勾选框,通过更多菜单或右键进入批量选择,退出清空选择;配置单行显示名称,类型及服务地址放到悬停提示,行内仅运行/停止,编辑/固定/打开服务保留在共享右键菜单,固定后显示标记;分组与配置使用共享树行高、缩进及焦点选择样式;Run 范围筛选以固定图标栏呈现,应用范围筛选及当前运行导航使用中性 ToolWindowRun 图标,实际运行操作继续使用绿色 Execute 图标;全部采用 IDEA groups、服务采用 server 图标,固定、应用及任务沿用对应 IDEA 原始资源;检查所有图标的 16pt 尺寸、明暗 SVG 自动切换、提示和筛选,右键勾选范围和配置行勾选共享同一批量选择;配置行使用 IDEA 固定、编辑、运行及停止图标,悬停与点击维持箭头光标;配置过期提示使用共享中性通知表面及警告图标,操作仍可重新识别;Run 标题栏仅显示 Run,移除重复配置名与右侧状态胶囊;Console 和 Configuration details 标签位于运行操作按钮组右侧,配置列表选中项表示当前配置,内容区直接显示日志或详情;配置详情使用共享 13pt 字体、原生 Grid 自适应标签列、可选择且可换行的路径及值,编辑配置按钮复用共享 LitheCommitDialogButtonStyle 与 IDEA EditSource 图标,检查深浅主题、窄列及点击跳转设置,服务链接保留原动作;两个标签使用共享 LitheToolWindowTabStyle,检查 13pt 文字、28pt 标签、原始明暗 SVG、悬停及内容区聚焦/失焦状态,保留标签切换;Run 与 Debug 均启用共享 OutputTextView 的 IDEA 渲染入口,运行日志采用一致的 13pt 字体、1.2 倍行高和 ANSI 配色,不给普通 INFO 日志整行染蓝,源码链接继续跳转;Copy 与 Jump to latest 为共享图标按钮,复制不带 ANSI,向上滚动后可恢复跟随;其他配置恢复状态保留各自提示。 Current File 运行一次后修改未保存并切换编辑标签,重运行应先保存原运行文件再构建启动计划;原文件保存失败时提示错误并中止重启,当前焦点文档不被误保存;调整 Run 面板高度,外层横向操作栏固定为 36pt,剩余高度交给配置树和控制台。 保存构建任务后重启,确认用户任务和自动入口同时恢复;再次加载不重复生成。 #1562:Windows 普通应用 A/B 独立会话和输出;先启动 A 再 B,停止及重跑 B 不影响 A,切换配置只显示所属输出,关闭项目清理两者。 IDE API 在 primary 忙碌时仍能启动独立应用,同一配置准备期间拒绝重复启动;保存期间会话可见且可停止,停止后不再启动进程,顶部停止不影响后台服务;旧 Debug 回调不能停止重跑后的应用。 缺少工具链时错误只归属目标应用,不覆盖 primary 或后台会话,也不把已运行的目标实例标记为退出。 macOS 通用 Provider 运行发现:按当前公开声明及目标标签生成 build.provider;名称/执行类型变化保留 ID 和参数、环境、目录覆盖;模型撤回、重排、恢复、停用及重新生成核对指纹,撤回目标不从旧检测层复活。默认项优先 service,不依赖框架名单。 通用 Provider 选项:团队/本机层覆盖运行时 argv、入口与 Build 选项,覆盖空字符串参数、引号、反斜杠、Unicode、false/空数组、显式清空、旧调用者省略、未知/超限字段和重存目录保持。 旧 Run v2 转换:验证稳定 ID、默认项、两层覆盖和目标唯一性;转换前预检两层,覆盖源文件变化、未改写输入变化、偏好变化、各写入阶段取消、外部修改与回滚冲突。工作区/模型/任务取消及新生成撤销写入资格;只读安装目录和越界链接不写入。 当前 Provider 归属投影改用 build={pluginID,buildSystemID,root,projectID}。共享 provider-project-ownership fixture 由 Rust、Swift bridge 与 Windows 映射回归共同读取,覆盖同名类、非标准源码根、角色、稳定身份和 cwd 覆盖;团队/本机伪造 build 身份被当前模型拥有的值替换。原生精确导入查找拒绝错误插件/构建声明/根/项目以及已撤销模型。旧 Windows 生成路径在未提供 Provider 归属时保留,删除前需先迁移真实消费者。 macOS Debug 缺少精确源码路径时,使用通用 Build 归属根加模块路径定位源码;嵌套实例与工作区根实例优先,当前实例没有源码时不得选择其他实例的同名类。原生源码选择回归不替代 Registry/DAP 与完整产品验收。 编辑器行首入口的运行、调试及编辑配置使用 Core 的同一选择规则:精确匹配入口和源码、排除禁用项,优先已选配置,再优先用户配置;配置或工作区在异步选择期间发生变化时不得启动旧结果。 Viva 桌面端运行配置列表:范围选择器依次为全部配置、置顶及 Core 给出的服务/应用/任务/组合,各带数量;配置按提供它的构建系统分组、组按名称排序且可折叠,组内按名称排序;行内运行/停止,Enter 或双击运行,右键菜单运行/停止、编辑运行配置、置顶/取消置顶;置顶写入客户端数据目录 run-configuration-pins.json,不写项目或安装目录,重开后读回。批量选择与并发运行、服务地址尚未迁移。", - "notes": "Viva:构建模型加载后,宿主把已加载实例中每个运行声明适用的目标作为 providerRuns 交给 Core 的 runConfig.generate(不写工作区),再用 runConfig.resolve 合并生成层与已保存的项目层、本机层(2026-11-18 起为 .lithe/run/configurations.yaml、local.yaml 与插件运行的 .lithe/run/plugin/<插件>.toml、<插件>.local.toml,旧版 JSON 在没有对应 YAML 时仍读取,见 builtin-process-runs);Run 窗口顶部的“运行配置”选择器列出 build.provider 配置(默认选 Core 给出的默认项),“运行”经 runConfig.providerLaunchInputs 取出保存的参数、环境、工作目录与入口,按 buildProviders 10 的 launchOptions 交给 provider 的 prepareRun 与 decodeRunPreparation;没有任何自定义的 application 运行不带 launchOptions,保持旧 provider 可用。选择器旁的“编辑”打开运行配置编辑对话框:程序参数经 runConfig.argumentText 回显为可逆文本,工作目录与环境变量(每行 KEY=VALUE)回显当前生效值,保存时由 runConfig.updateOptions 生成所选层(插件运行写 .lithe/run/plugin/<插件>.local.toml 或 <插件>.toml)的文档,宿主用 configfile 按读取时的字节做冲突检查后原子替换,再重新解析。尚未实现:provider 运行时参数/入口/工具等 providerRunOptions 的编辑、未加载模型的实例的运行(快照只含已加载实例)、调试配置。 2026-11-12:运行配置检测走 Core(GenerateRunConfigurations/ResolveRunConfigurations/ResolveExecutionEnvironment),宿主没有 GOOS 分支,矩阵原记的 windows=missing 属失真:两个平台共缺 providerRunOptions 编辑与调试配置,与平台无关。 2026-11-16(#1856 第 4 项,Core #77):Core 删除内置运行发现探测器(Cargo、Go、npm/pnpm/yarn/bun、Python、Make、just、Procfile、Compose)、项目内容指纹和工具链需求,Run 列表的自动条目只来自已启用构建插件声明的 buildSystems[].run,加上用户保存的配置;没有插件声明 run 的生态不再出现自动条目。桌面端删除只有测试使用的 InspectRunConfigurations,GenerateRunConfigurations 不再传缓存目录;run_discovery_test.go 用合成的 provider run 验证生成不写工作区。 2026-11-19:打开项目时(openProjectHere)就识别构建系统并加载每个实例的模型,标题栏直接列出插件声明的运行并选中 Core 的默认项,不再停在“当前文件”、等用户先按运行或打开下拉;TestOpeningAProjectListsItsDeclaredRuns 用合成 provider 插件验证,macOS 上用真实 Maven 多模块 Spring Boot 工程无头验证;Windows 未本机验证,宿主无平台分支。", + "verification": "Windows Run Actions 仍处于关闭状态;扩展 Run Actions 测试验证插件启用、禁用和声明的执行计划,TypeScript 检查所有调用方;重新启用前需完成实际应用验收。 多模块项目把服务工作目录改成模块目录后,服务仍留在列表中并以该目录启动;填写不存在的目录或 ${workspaceFolder} 等变量时,保存被拒绝并提示原因;在 Windows 确认重新扫描服务使用双箭头刷新图标,配置按语言生态、类型与实例呈现三栏布局;语言切换和外部选中能定位配置,空生态不显示,语言和配置栏不显示重复栏头,生态不显示配置数量;语言侧栏通过拖动阈值折叠和展开,收起与展开阈值不同以避免边界跳动,不显示专门折叠按钮;键盘可调整宽度及恢复展开,保存展开宽度与拖动折叠状态,拖动期间只更新局部宽度和紧凑标记,文字与图标对齐即时切换,结束后保存;语言行、类型行和实例行使用一致的紧凑行高,去掉列表上下留白和选中实例的圆角边距;窄面板自动缩成带提示的图标栏且扩大后恢复,右侧输出保留可用空间,窗口缩放或卸载时清理正在进行的拖动;所选配置的日志、运行状态、顶部停止按钮、清空输出与标准输入均指向其自身会话;保持选中 application 并后台启动服务后,顶部停止仍指向该应用的独立会话,不停止后台服务,左侧使用 SVG 箭头和类型图标,基础设施默认折叠,选择配置自动展开所在分组,运行、停止、编辑和完整名称提示可用;根据 Core 提供的元数据展示明确识别的框架图标,构建与测试任务保留工具图标,未知类型回退通用图标;同名自定义 provider 与已知框架分别分组且折叠状态独立,相同已知框架跨 provider 合组,项目与基础设施不合组;macOS Run 缺少配置且可重新生成时,检查空状态文字与链接在深浅主题下按 IDEA 工具窗口样式显示、窄面板不截断,并确认“识别并生成”仍触发原有生成流程;应用语言设为英文而系统语言为中文时,Run 空状态及其他本面板文案仍应显示英文;Run 顶部标题字号、颜色、41pt 高度和底部分隔线应与 Terminal、Git Log 等工具窗口一致;有项目配置或 Current File 正在运行/已有退出结果时,运行、重启、重新扫描和软换行按钮显示在独立的 36pt 操作栏,检查 16pt IDEA 图标、22pt 共享按钮的悬停、按下、选中及禁用状态;操作栏只保留一个运行/重运行动作:首次启动显示 Run,当前配置已运行过后显示 Rerun;右侧固定停止按钮,未运行禁用、运行中启用,两者始终指向当前选中配置;操作栏不重复显示 Running 圆点及状态文字,重运行按钮复用顶部工具栏的绿色 rerun_stroke 图标;标题栏菜单中的清空输出与原操作一致,收起按钮沿用共享样式;仅有 Current File 的项目启动后也可从 Run 操作栏停止,结束后保留重运行入口;Run 内容区不额外插入语言服务准备状态行,准备进度和失败入口保留在工作台状态栏;Run 标题、操作栏、配置列表标题、控制台标签底边及两侧纵向分割线统一使用工具窗口边框颜色和 1pt 绘制,左侧图标栏不出现 5pt 实心粗线,栏内分组线与 Git Log 一致使用共享 divider 颜色、22pt 宽度、1pt 高度及上下 3pt 间距;操作按钮组之间使用专用 ActionToolbar.separator,详情编辑按钮的边框由共享按钮样式负责,拖动命中范围保持不变;配置树直接显示分组与数量,不显示 Application types 标题;默认隐藏勾选框,通过更多菜单或右键进入批量选择,退出清空选择;配置单行显示名称,类型及服务地址放到悬停提示,行内仅运行/停止,编辑/固定/打开服务保留在共享右键菜单,固定后显示标记;分组与配置使用共享树行高、缩进及焦点选择样式;Run 范围筛选以固定图标栏呈现,应用范围筛选及当前运行导航使用中性 ToolWindowRun 图标,实际运行操作继续使用绿色 Execute 图标;全部采用 IDEA groups、服务采用 server 图标,固定、应用及任务沿用对应 IDEA 原始资源;检查所有图标的 16pt 尺寸、明暗 SVG 自动切换、提示和筛选,右键勾选范围和配置行勾选共享同一批量选择;配置行使用 IDEA 固定、编辑、运行及停止图标,悬停与点击维持箭头光标;配置过期提示使用共享中性通知表面及警告图标,操作仍可重新识别;Run 标题栏仅显示 Run,移除重复配置名与右侧状态胶囊;Console 和 Configuration details 标签位于运行操作按钮组右侧,配置列表选中项表示当前配置,内容区直接显示日志或详情;配置详情使用共享 13pt 字体、原生 Grid 自适应标签列、可选择且可换行的路径及值,编辑配置按钮复用共享 LitheCommitDialogButtonStyle 与 IDEA EditSource 图标,检查深浅主题、窄列及点击跳转设置,服务链接保留原动作;两个标签使用共享 LitheToolWindowTabStyle,检查 13pt 文字、28pt 标签、原始明暗 SVG、悬停及内容区聚焦/失焦状态,保留标签切换;Run 与 Debug 均启用共享 OutputTextView 的 IDEA 渲染入口,运行日志采用一致的 13pt 字体、1.2 倍行高和 ANSI 配色,不给普通 INFO 日志整行染蓝,源码链接继续跳转;Copy 与 Jump to latest 为共享图标按钮,复制不带 ANSI,向上滚动后可恢复跟随;其他配置恢复状态保留各自提示。 Current File 运行一次后修改未保存并切换编辑标签,重运行应先保存原运行文件再构建启动计划;原文件保存失败时提示错误并中止重启,当前焦点文档不被误保存;调整 Run 面板高度,外层横向操作栏固定为 36pt,剩余高度交给配置树和控制台。 保存构建任务后重启,确认用户任务和自动入口同时恢复;再次加载不重复生成。 #1562:Windows 普通应用 A/B 独立会话和输出;先启动 A 再 B,停止及重跑 B 不影响 A,切换配置只显示所属输出,关闭项目清理两者。 IDE API 在 primary 忙碌时仍能启动独立应用,同一配置准备期间拒绝重复启动;保存期间会话可见且可停止,停止后不再启动进程,顶部停止不影响后台服务;旧 Debug 回调不能停止重跑后的应用。 缺少工具链时错误只归属目标应用,不覆盖 primary 或后台会话,也不把已运行的目标实例标记为退出。 macOS 通用 Provider 运行发现:按当前公开声明及目标标签生成 build.provider;名称/执行类型变化保留 ID 和参数、环境、目录覆盖;模型撤回、重排、恢复、停用及重新生成核对指纹,撤回目标不从旧检测层复活。默认项优先 service,不依赖框架名单。 通用 Provider 选项:团队/本机层覆盖运行时 argv、入口与 Build 选项,覆盖空字符串参数、引号、反斜杠、Unicode、false/空数组、显式清空、旧调用者省略、未知/超限字段和重存目录保持。 旧 Run v2 转换:验证稳定 ID、默认项、两层覆盖和目标唯一性;转换前预检两层,覆盖源文件变化、未改写输入变化、偏好变化、各写入阶段取消、外部修改与回滚冲突。工作区/模型/任务取消及新生成撤销写入资格;只读安装目录和越界链接不写入。 当前 Provider 归属投影改用 build={pluginID,buildSystemID,root,projectID}。共享 provider-project-ownership fixture 由 Rust、Swift bridge 与 Windows 映射回归共同读取,覆盖同名类、非标准源码根、角色、稳定身份和 cwd 覆盖;团队/本机伪造 build 身份被当前模型拥有的值替换。原生精确导入查找拒绝错误插件/构建声明/根/项目以及已撤销模型。旧 Windows 生成路径在未提供 Provider 归属时保留,删除前需先迁移真实消费者。 macOS Debug 缺少精确源码路径时,使用通用 Build 归属根加模块路径定位源码;嵌套实例与工作区根实例优先,当前实例没有源码时不得选择其他实例的同名类。原生源码选择回归不替代 Registry/DAP 与完整产品验收。 编辑器行首入口的运行、调试及编辑配置使用 Core 的同一选择规则:精确匹配入口和源码、排除禁用项,优先已选配置,再优先用户配置;配置或工作区在异步选择期间发生变化时不得启动旧结果。 Viva 桌面端运行配置列表:范围选择器依次为全部配置、置顶及 Core 给出的服务/应用/任务/组合,各带数量;配置按提供它的构建系统分组、组按名称排序且可折叠,组内按名称排序;行内运行/停止,Enter 或双击运行,右键菜单运行/停止、编辑运行配置、置顶/取消置顶;置顶写入客户端数据目录 run-configuration-pins.json,不写项目或安装目录,重开后读回。批量选择与并发运行、服务地址尚未迁移。 #2154/#2147/#2027 与插件热重载:build_probe_test.go、runconfig_edit_test.go、plugins_build_reload_test.go、title_run_test.go 与 title_run_empty_visual_test.go 在 macOS 核对超时/错误探测回退、显式作用域保存自动生成配置、全标签页热重载及最后一个构建插件停用后清空 Core 生成项、标题栏展示模型失败/安全模式并渲染无截图回归。", + "notes": "Viva:构建模型加载后,宿主把已加载实例中每个运行声明适用的目标作为 providerRuns 交给 Core 的 runConfig.generate(不写工作区),再用 runConfig.resolve 合并生成层与已保存的项目层、本机层(2026-11-18 起为 .lithe/run/configurations.yaml、local.yaml 与插件运行的 .lithe/run/plugin/<插件>.toml、<插件>.local.toml,旧版 JSON 在没有对应 YAML 时仍读取,见 builtin-process-runs);Run 窗口顶部的“运行配置”选择器列出 build.provider 配置(默认选 Core 给出的默认项),“运行”经 runConfig.providerLaunchInputs 取出保存的参数、环境、工作目录与入口,按 buildProviders 10 的 launchOptions 交给 provider 的 prepareRun 与 decodeRunPreparation;没有任何自定义的 application 运行不带 launchOptions,保持旧 provider 可用。选择器旁的“编辑”打开运行配置编辑对话框:程序参数经 runConfig.argumentText 回显为可逆文本,工作目录与环境变量(每行 KEY=VALUE)回显当前生效值,保存时由 runConfig.updateOptions 生成所选层(插件运行写 .lithe/run/plugin/<插件>.local.toml 或 <插件>.toml)的文档,宿主用 configfile 按读取时的字节做冲突检查后原子替换,再重新解析。尚未实现:provider 运行时参数/入口/工具等 providerRunOptions 的编辑、未加载模型的实例的运行(快照只含已加载实例)、调试配置。 2026-11-12:运行配置检测走 Core(GenerateRunConfigurations/ResolveRunConfigurations/ResolveExecutionEnvironment),宿主没有 GOOS 分支,矩阵原记的 windows=missing 属失真:两个平台共缺 providerRunOptions 编辑与调试配置,与平台无关。 2026-11-16(#1856 第 4 项,Core #77):Core 删除内置运行发现探测器(Cargo、Go、npm/pnpm/yarn/bun、Python、Make、just、Procfile、Compose)、项目内容指纹和工具链需求,Run 列表的自动条目只来自已启用构建插件声明的 buildSystems[].run,加上用户保存的配置;没有插件声明 run 的生态不再出现自动条目。桌面端删除只有测试使用的 InspectRunConfigurations,GenerateRunConfigurations 不再传缓存目录;run_discovery_test.go 用合成的 provider run 验证生成不写工作区。 2026-11-19:打开项目时(openProjectHere)就识别构建系统并加载每个实例的模型,标题栏直接列出插件声明的运行并选中 Core 的默认项,不再停在“当前文件”、等用户先按运行或打开下拉;TestOpeningAProjectListsItsDeclaredRuns 用合成 provider 插件验证,macOS 上用真实 Maven 多模块 Spring Boot 工程无头验证;Windows 未本机验证,宿主无平台分支。 2026-11-20(#2154、#2147、#2027、插件热重载):buildToolProbeTimeout(10s)限制单个构建工具/运行时候选探测并在非零退出时自动回退后续候选,但保留明确 setting 或 pinned 工具链拒绝;runConfigEditor 对未修改的 source==\"generated\" 配置在显式选择 Save-to 作用域时标记 dirty 并保存;applyPluginLifecycleChange 在插件热装/启停/卸载时递增值失效构建代次并跨全部标签页刷新构建检测与运行配置(并在无构建实例时向 Core 传入 [] 清空已撤回配置);titleRunConfigMenu 直接展示模型失败与安全模式条目并跳转到构建同步日志或工作区信任。macOS 完成单测与无头截图验证;Windows 共享 Workbench 逻辑待实机确认。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": {