diff --git a/.agents/notes/implemented/bug-fix/2026-11-13-viva-plugin-run-debug-lifecycle.md b/.agents/notes/implemented/bug-fix/2026-11-13-viva-plugin-run-debug-lifecycle.md index efa131462..7efd7fd2e 100644 --- a/.agents/notes/implemented/bug-fix/2026-11-13-viva-plugin-run-debug-lifecycle.md +++ b/.agents/notes/implemented/bug-fix/2026-11-13-viva-plugin-run-debug-lifecycle.md @@ -24,6 +24,17 @@ Run 的首次调试复用既有适配器加载入口,完成后检查原调用 真实插件测试在创建工作台后就登记无交互清理,不依赖成功路径的关闭动作。即使断言在断点暂停或文档未保存时中止,也直接关闭测试拥有的项目,等待后台任务、停止剩余运行,并验证 Core 调试会话已移除;不能把需要用户确认的关闭弹窗当作失败清理。 +## 当前文件入口与附加界面 + +标题栏运行按构建提供者给出的入口保存配置。提供者未声明入口或返回空列表时, +窗口复用当前文件行号栏已经提供的 Run 动作。标题栏调试优先使用相应的 Debug +动作。窗口只派发当前文档版本的动作,等待查询时切换文件或继续编辑都会使旧结果失效。 + +宿主从操作系统读取被启动进程及其子进程的监听状态,让调试适配器建立第一条 +连接。此前先拨号再断开的探测会让运行时记录一次握手失败,部分调试目标还会 +用掉唯一的附加机会。观察监听状态只在启动等待期进行。附加建立后显示 Debug +窗口,用户可以切回 Run 查看进程输出。 + ## 项目 JDK 与语言服务器的编译目标 普通源码目录没有 Maven 的目标版本约束时,Viva 曾只把项目选择的 JDK 交给 Run,没有在后端解析语言服务器启动时传入契约已有的可选 `tools`。JDT 因而按随包 Java 21 编译,Run 却使用用户选择的 Java 8,生成的 major 65 class 会被 Java 8 拒绝。只检查 Maven 构建的 class 无法发现这个问题,必须也检查 JDT 的运行前构建。 diff --git a/desktop/internal/pluginservice/runs.go b/desktop/internal/pluginservice/runs.go index b85f12162..e721a5493 100644 --- a/desktop/internal/pluginservice/runs.go +++ b/desktop/internal/pluginservice/runs.go @@ -21,6 +21,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/pluginhost" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginmanager" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" + "github.com/1lck/Lithe-IDEA/desktop/internal/sysinfo" ) const ( @@ -585,7 +586,10 @@ func (r *Runs) attachDebugger(ctx context.Context, run *hostRun) { r.stopRun(run, false) } } - if err := WaitForDebugPort(ctx, port, run.done, RunDebugConnectTimeout); err != nil { + err := waitForDebugPort(ctx, port, run.done, RunDebugConnectTimeout, func(context.Context) (bool, error) { + return debuggeeListening(run.pid, uint16(port)) + }) + if err != nil { fail(err) return } @@ -616,25 +620,64 @@ var ( // is closed, or the timeout passes. The probe connects and closes without a // handshake; a runtime suspended for a debugger keeps listening after it. func WaitForDebugPort(ctx context.Context, port int, ended <-chan struct{}, timeout time.Duration) error { - deadline := time.NewTimer(timeout) - defer deadline.Stop() - ticker := time.NewTicker(runDebugPollInterval) - defer ticker.Stop() address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port)) - for { + return waitForDebugPort(ctx, port, ended, timeout, func(ctx context.Context) (bool, error) { dialer := net.Dialer{Timeout: time.Second} connection, err := dialer.DialContext(ctx, "tcp", address) - if err == nil { - _ = connection.Close() - return nil + if err != nil { + // log-exempt: 预期的缺失:目标还没监听时继续等待,超时由调用方处理。 + return false, nil + } + // log-exempt: best-effort 清理:探测连接没有要送达的数据。 + _ = connection.Close() + return true, nil + }) +} + +// A connection probe can consume a debuggee's first handshake. For host-owned +// runs, observe the listener through the OS and leave the first connection to DAP. +func debuggeeListening(pid int, port uint16) (bool, error) { + processes, err := sysinfo.Processes(sysinfo.Options{}) + if err != nil { + return false, err + } + sockets, err := sysinfo.ListeningSockets(sysinfo.ProcessTreeIDs(pid, processes)) + if err != nil { + return false, err + } + for _, socket := range sockets { + if socket.Port == port { + return true, nil } + } + return false, nil +} + +func waitForDebugPort(ctx context.Context, port int, ended <-chan struct{}, timeout time.Duration, ready func(context.Context) (bool, error)) error { + probeContext, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + ticker := time.NewTicker(runDebugPollInterval) + defer ticker.Stop() + for { select { case <-ctx.Done(): return ctx.Err() case <-ended: return ErrDebuggeeEnded - case <-deadline.C: + case <-probeContext.Done(): return fmt.Errorf("%w (port %d)", ErrDebugPortTimeout, port) + default: + } + listening, err := ready(probeContext) + if err != nil { + return err + } + if listening { + return nil + } + select { + case <-probeContext.Done(): + case <-ended: case <-ticker.C: } } diff --git a/desktop/internal/pluginservice/runs_test.go b/desktop/internal/pluginservice/runs_test.go index 8824f6b6a..41fbea11f 100644 --- a/desktop/internal/pluginservice/runs_test.go +++ b/desktop/internal/pluginservice/runs_test.go @@ -67,12 +67,30 @@ func TestRunHelperProcess(t *testing.T) { fmt.Printf("file %x\n", data) } os.Exit(0) - case "listen": + case "listen", "listen-once": listener, err := net.Listen("tcp", "127.0.0.1:"+os.Getenv("LITHE_RUN_PORT")) if err != nil { os.Exit(2) } defer listener.Close() + if os.Getenv("LITHE_RUN_HELPER") == "listen-once" { + if err := listener.(*net.TCPListener).SetDeadline(time.Now().Add(10 * time.Second)); err != nil { + t.Fatal(err) + } + connection, err := listener.Accept() + if err != nil { + t.Fatal(err) + } + defer connection.Close() + if err := connection.SetReadDeadline(time.Now().Add(5 * time.Second)); err != nil { + t.Fatal(err) + } + var handshake [1]byte + if _, err := connection.Read(handshake[:]); err != nil || handshake[0] != 'D' { + t.Fatalf("first debugger connection did not handshake: %v", err) + } + return + } time.Sleep(time.Minute) os.Exit(0) } @@ -463,6 +481,42 @@ func TestRunStartAttachesTheDebuggerOnceThePortOpens(t *testing.T) { } } +func TestRunDebuggeeFirstConnectionBelongsToTheAdapter(t *testing.T) { + h := newRunHarness(t) + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + port := listener.Addr().(*net.TCPAddr).Port + if err := listener.Close(); err != nil { + t.Fatal(err) + } + h.service.Runs.Debug = func(ctx context.Context, request RunDebugRequest) (string, error) { + dialer := net.Dialer{Timeout: time.Second} + connection, err := dialer.DialContext(ctx, "tcp", net.JoinHostPort(request.Host, fmt.Sprint(request.Port))) + if err != nil { + return "", err + } + defer connection.Close() + if err := connection.SetWriteDeadline(time.Now().Add(time.Second)); err != nil { + return "", err + } + _, err = connection.Write([]byte{'D'}) + return "debug-session", err + } + params := h.params(t, "listen-once", map[string]any{ + "port": port, + "debug": map[string]any{"configurationType": "script", "target": map[string]any{"kind": "connection", "port": port}}, + }) + result, refusal := respond(t, h.service, runFixturePlugin, "run/start", params) + startedRunID(t, result, refusal) + events := h.await(t, "the fake debug handshake to finish", func(events []RunEvent) bool { return exitedEvent(events) != nil }) + exited := exitedEvent(events) + if exited.ExitCode == nil || *exited.ExitCode != 0 { + t.Fatalf("run never received the expected first debugger connection: %+v", events) + } +} + func TestRunDebugStopsTheRunWhenTheAdapterCannotAttach(t *testing.T) { h := newRunHarness(t) listener, err := net.Listen("tcp", "127.0.0.1:0") diff --git a/desktop/internal/sysinfo/process.go b/desktop/internal/sysinfo/process.go index ca9f68d1b..4a7cf4048 100644 --- a/desktop/internal/sysinfo/process.go +++ b/desktop/internal/sysinfo/process.go @@ -58,3 +58,35 @@ type Options struct { // Processes reads the process table: every process this user can see. A fact the system does // not give for one process is zero or nil; the error says the table could not be listed at all. func Processes(options Options) ([]Process, error) { return processes(options) } + +// ProcessTreeIDs returns the root and the descendants visible in a native process snapshot. +// Callers use it to scope native per-process queries before reading details. +func ProcessTreeIDs(rootPID int, table []Process) []int { + byPID := make(map[int]Process, len(table)) + children := make(map[int][]Process) + for _, row := range table { + if _, seen := byPID[row.PID]; row.PID <= 0 || seen { + continue + } + byPID[row.PID] = row + children[row.ParentPID] = append(children[row.ParentPID], row) + } + pids := []int{rootPID} + seen := map[int]bool{rootPID: true} + for index := 0; index < len(pids); index++ { + parentPID := pids[index] + parent, hasParent := byPID[parentPID] + for _, child := range children[parentPID] { + if seen[child.PID] { + continue + } + // Guard against OS PID reuse where a child appears older than its recycled parent. + if hasParent && parent.StartTime > 0 && child.StartTime > 0 && parent.StartTime > child.StartTime { + continue + } + seen[child.PID] = true + pids = append(pids, child.PID) + } + } + return pids +} diff --git a/desktop/internal/workbench/debug_start.go b/desktop/internal/workbench/debug_start.go index b8fed6d4f..7a2c7c10e 100644 --- a/desktop/internal/workbench/debug_start.go +++ b/desktop/internal/workbench/debug_start.go @@ -248,7 +248,13 @@ func (a *App) attachDebugForRun(ctx context.Context, request pluginservice.RunDe target: &core.DebugTargetFacts{Kind: "connection", Host: request.Host, Port: request.Port}, stopRun: request.StopRun, }) - result <- outcome{id: p.debug.activeSession().id} + session := p.debug.activeSession() + if session == nil { + result <- outcome{err: errors.New("the debug session did not start")} + return + } + a.openToolWindow(itemDebug) + result <- outcome{id: session.id} return } } diff --git a/desktop/internal/workbench/debug_test.go b/desktop/internal/workbench/debug_test.go index 334ca9c2a..b5d08e8fe 100644 --- a/desktop/internal/workbench/debug_test.go +++ b/desktop/internal/workbench/debug_test.go @@ -655,3 +655,40 @@ func TestRunAttachLoadsAdaptersWithoutOpeningDebugPanel(t *testing.T) { t.Fatalf("adapter discovery loaded=%v error=%v", p.debug.loaded, err) } } + +func attachRunDebugOptions(t *testing.T, theme string) Options { + t.Helper() + manifest := strings.Replace(debugAttachManifest, `"requests": ["attach"]`, `"requests": ["attach"], "configurationTypes": ["fixture-attach"]`, 1) + return debugPluginOptions(t, "dev.lithe.test.debug-attach", manifest, true, &testKernel{Client: core.NewClient()}, theme) +} + +func TestRunAttachShowsDebugWindow(t *testing.T) { + h := newHarnessWithOptions(t, attachRunDebugOptions(t, "dark")) + p := attachRunDebugFixture(t, h) + h.app.stopDebug(p) +} + +func attachRunDebugFixture(t *testing.T, h *harness) *project { + t.Helper() + root, _ := fixtureWorkspace(t) + h.open(root) + p := h.app.project + h.app.openToolWindow(itemRun) + ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) + defer cancel() + done := make(chan error, 1) + go func() { + _, err := h.app.attachDebugForRun(ctx, pluginservice.RunDebugRequest{ + PluginID: "dev.lithe.test.debug-attach", WorkspaceRoot: root, + ConfigurationType: "fixture-attach", Host: "127.0.0.1", Port: 12345, + }) + done <- err + }() + if err := awaitValueWithin(t, h, 10*time.Second, done, "the run's attach request"); err != nil { + t.Fatal(err) + } + if !h.app.chrome.isOpen(catalogIndex[itemDebug]) { + t.Fatal("the run started an attach session without showing the Debug window") + } + return p +} diff --git a/desktop/internal/workbench/editor_actions.go b/desktop/internal/workbench/editor_actions.go index 740bbd0ea..255810766 100644 --- a/desktop/internal/workbench/editor_actions.go +++ b/desktop/internal/workbench/editor_actions.go @@ -344,6 +344,124 @@ func (a *App) editorActionMenuItems(c ui.C, p *project, d *document, menu *ui.Me } } +// runCurrentFileEditorAction presents the same plugin invocation the gutter +// offers. An absent cached action may mean its initial collection is still in flight. +func (a *App) runCurrentFileEditorAction(p *project, d *document, mode titleAction) { + fallback := func(a *App) { + if mode == titleActionDebug { + a.whenDebugAdaptersLoaded(p, func() { + if p.selectedDocument(p.docs.group) == d { + a.startDebug(p) + } + }) + return + } + a.operationRejected("title_run_current_file", "no_entrypoint") + a.notifyInfo(i18n.Shared(a.language(), "desktop.title.currentFileNotRunnable")) + } + if d == nil || d.virtual || d.path == "" || a.plugins == nil { + fallback(a) + return + } + if p.runConfigs.findingEntrypoint { + return + } + start := func() { + if a.project != p || p.selectedDocument(p.docs.group) != d { + return + } + invoke := func(a *App, actions []pluginservice.EditorAction) bool { + choice := currentFileEditorChoice(actions, d.view.Revision(), mode) + if choice == nil { + return false + } + a.runEditorAction(p, d, choice.action, choice.alternative) + return true + } + if invoke(a, d.actions) { + return + } + p.runConfigs.findingEntrypoint = true + plugins := a.plugins + path, revision := d.path, d.view.Revision() + data, _ := d.view.Text() + text := string(data) + id := strconv.Itoa(d.id) + a.background(p, 10*time.Second, func(ctx context.Context) func(*App) { + actions, err := plugins.CollectEditorActions(ctx, p.root, path, id, revision, text) + return func(a *App) { + p.runConfigs.findingEntrypoint = false + if p.selectedDocument(p.docs.group) != d || d.path != path || d.view.Revision() != revision { + return + } + if invoke(a, actions) { + if err != nil { + a.backgroundFailed("editor_actions", err) + } + return + } + if err != nil { + a.operationFailed("title_run_current_file", err) + a.notifyError(i18n.Shared(a.language(), "desktop.editorActions.failed")) + return + } + fallback(a) + } + }) + } + if d.dirty() || d.saving || d.conflicted { + p.runConfigs.findingEntrypoint = true + a.saveBeforeClose(p, d, func(ok bool) { + p.runConfigs.findingEntrypoint = false + if ok { + start() + } + }) + return + } + start() +} + +// currentFileEditorChoice selects the first source-order action in the Run lane. +// Debug uses its Debug alternative, or a standalone Debug action if it has none. +func currentFileEditorChoice(actions []pluginservice.EditorAction, revision int, mode titleAction) *editorActionChoice { + var run, debug *pluginservice.EditorAction + first := func(current *pluginservice.EditorAction, action *pluginservice.EditorAction) *pluginservice.EditorAction { + if current == nil || action.Range.StartLine < current.Range.StartLine || + (action.Range.StartLine == current.Range.StartLine && action.Range.StartColumn < current.Range.StartColumn) { + return action + } + return current + } + for index := range actions { + action := &actions[index] + if action.Version() != revision { + continue + } + lane, _, _ := editorActionPresentation(action.Icon) + switch lane { + case "run": + run = first(run, action) + case "debug": + debug = first(debug, action) + } + } + if run != nil { + if mode == titleActionRun { + return &editorActionChoice{action: *run, alternative: -1} + } + for index, alternative := range run.Alternatives { + if alternative.Icon == "debug" { + return &editorActionChoice{action: *run, alternative: index} + } + } + } + if mode == titleActionDebug && debug != nil { + return &editorActionChoice{action: *debug, alternative: -1} + } + return nil +} + // runEditorAction calls the plugin for one action or alternative. The call is refused when the // document changed since the action was collected. Locations the result asks to reveal are opened; // only the first is opened for now, the others wait for the navigation list. diff --git a/desktop/internal/workbench/run_ports.go b/desktop/internal/workbench/run_ports.go index 7185b6bd1..d302e556c 100644 --- a/desktop/internal/workbench/run_ports.go +++ b/desktop/internal/workbench/run_ports.go @@ -142,51 +142,23 @@ func readRunPortsSnapshot( // candidateRunTree collects rootPID and its valid descendants so socket enumeration only // inspects the run's processes rather than unrelated processes on the host. func candidateRunTree(rootPID int, table []sysinfo.Process) ([]int, []core.PortProcess) { - byPID := make(map[int]sysinfo.Process, len(table)) - children := make(map[int][]sysinfo.Process) + seen := make(map[int]bool, len(table)) coreProcesses := make([]core.PortProcess, 0, len(table)) for _, proc := range table { - if proc.PID <= 0 { + if proc.PID <= 0 || seen[proc.PID] { continue } - if _, dup := byPID[proc.PID]; dup { - continue - } - byPID[proc.PID] = proc - children[proc.ParentPID] = append(children[proc.ParentPID], proc) + seen[proc.PID] = true var started *uint64 if proc.StartTime > 0 { v := proc.StartTime started = &v } coreProcesses = append(coreProcesses, core.PortProcess{ - ProcessID: int64(proc.PID), - ParentProcessID: int64(proc.ParentPID), - StartTime: started, + ProcessID: int64(proc.PID), ParentProcessID: int64(proc.ParentPID), StartTime: started, }) } - - pids := []int{rootPID} - seen := map[int]bool{rootPID: true} - queue := []int{rootPID} - for len(queue) > 0 { - parentPID := queue[0] - queue = queue[1:] - parent, hasParent := byPID[parentPID] - for _, child := range children[parentPID] { - if seen[child.PID] { - continue - } - // Guard against OS PID reuse where a child appears older than its recycled parent. - if hasParent && parent.StartTime > 0 && child.StartTime > 0 && parent.StartTime > child.StartTime { - continue - } - seen[child.PID] = true - pids = append(pids, child.PID) - queue = append(queue, child.PID) - } - } - return pids, coreProcesses + return sysinfo.ProcessTreeIDs(rootPID, table), coreProcesses } // openRunPort opens the listening endpoint's URL in the system browser. diff --git a/desktop/internal/workbench/title_run.go b/desktop/internal/workbench/title_run.go index f14da6bad..a43060719 100644 --- a/desktop/internal/workbench/title_run.go +++ b/desktop/internal/workbench/title_run.go @@ -269,12 +269,15 @@ func (p *project) titleConfigurationFacts(index int, reference core.RunProviderR return &core.TitleConfiguration{Kind: "modelLoaded", Debuggable: &debuggable} } -// performCurrentFileAction is Run or Debug on Current File. The Debug window starts the open -// file under its selected adapter; Run starts the entrypoint a build provider finds in the -// open file (runCurrentFileEntrypoint). +// performCurrentFileAction keeps build-provider runs on their existing path and +// offers the editor's Debug action before using the selected adapter directly. func (a *App) performCurrentFileAction(p *project, action titleAction) { if action == titleActionDebug { - a.whenDebugAdaptersLoaded(p, func() { a.startDebug(p) }) + if p.safeMode() { + a.askToTrustProject(p, func() { a.performCurrentFileAction(p, action) }) + return + } + a.runCurrentFileEditorAction(p, p.selectedDocument(p.docs.group), action) return } a.runCurrentFileEntrypoint(p) diff --git a/desktop/internal/workbench/title_run_entrypoints.go b/desktop/internal/workbench/title_run_entrypoints.go index 0db858101..8b588b4c6 100644 --- a/desktop/internal/workbench/title_run_entrypoints.go +++ b/desktop/internal/workbench/title_run_entrypoints.go @@ -76,7 +76,7 @@ func (a *App) runCurrentFileEntrypoint(p *project) { } candidates = slices.DeleteFunc(candidates, func(c entrypointCandidate) bool { return !c.instance.modelLoaded }) if len(candidates) == 0 { - a.notifyInfo(i18n.Shared(a.language(), "desktop.title.currentFileNotRunnable")) + a.runCurrentFileEditorAction(p, doc, titleActionRun) return } a.performed("title.run.currentFile", surfaceToolbar) @@ -96,8 +96,9 @@ func (a *App) runCurrentFileEntrypoint(p *project) { a.notifyError(err.Error()) return } - a.operationRejected("title_run_current_file", "no_entrypoint") - a.notifyInfo(i18n.Shared(a.language(), "desktop.title.currentFileNotRunnable")) + if p.selectedDocument(p.docs.group) == doc { + a.runCurrentFileEditorAction(p, doc, titleActionRun) + } } }) } diff --git a/desktop/internal/workbench/title_run_entrypoints_test.go b/desktop/internal/workbench/title_run_entrypoints_test.go index e2ad9a205..cda20456f 100644 --- a/desktop/internal/workbench/title_run_entrypoints_test.go +++ b/desktop/internal/workbench/title_run_entrypoints_test.go @@ -13,6 +13,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/pluginstate" "github.com/1lck/Lithe-IDEA/desktop/internal/store" ) @@ -198,3 +199,30 @@ func openSource(t *testing.T, h *harness, p *project, file string) { return doc != nil && doc.path == file }) } + +func TestCurrentFileUsesAnEditorRunActionWithoutABuildEntrypoint(t *testing.T) { + h := debugHarness(t) + root := t.TempDir() + writeFixture(t, root, map[string]string{"source.txt": "entry\n"}) + h.open(root) + p := h.app.project + openSource(t, h, p, filepath.Join(root, "source.txt")) + d := p.selectedDocument(p.docs.group) + if d.view.Revision() != 0 { + t.Fatalf("test needs the initial revision, got %d", d.view.Revision()) + } + h.app.post(func(a *App) { + p.build.loaded = true + d.actions = []pluginservice.EditorAction{{ + Title: "Run editor entry", Icon: "run", + Range: pluginservice.EditorActionRange{StartLine: 1, StartColumn: 1}, + }} + a.chooseTitleConfiguration(p, "") + a.titleRun(p) + }) + h.settle() + want := i18n.SharedFormat(h.app.language(), "desktop.editorActions.starting", map[string]string{"label": "Run editor entry"}) + if !slices.Contains(noticeTexts(h.app), want) { + t.Fatalf("Run did not invoke the editor entry: notices = %v", noticeTexts(h.app)) + } +} diff --git a/desktop/internal/workbench/title_run_entrypoints_visual_test.go b/desktop/internal/workbench/title_run_entrypoints_visual_test.go index 62249c98e..fe0a9184e 100644 --- a/desktop/internal/workbench/title_run_entrypoints_visual_test.go +++ b/desktop/internal/workbench/title_run_entrypoints_visual_test.go @@ -64,3 +64,35 @@ func TestVisualRunOnCurrentFile(t *testing.T) { }) } } + +func TestVisualRunAttachShowsDebugWindow(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 _, look := range []struct{ theme, language string }{{"dark", "zh-Hans"}, {"light", "en-US"}} { + t.Run(look.theme, func(t *testing.T) { + options := attachRunDebugOptions(t, look.theme) + options.Languages = []string{look.language} + var session *headless.Session + h := newHarnessWithDriver(t, options, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1200, 820 + var err error + session, err = headless.Open(config, nil, headless.Options{}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + p := attachRunDebugFixture(t, h) + h.settleChain() + if err := session.Screenshot(filepath.Join(out, "run-attach-debug-"+look.theme+".png")); err != nil { + t.Fatal(err) + } + h.app.stopDebug(p) + }) + } +} diff --git a/shared/platform-feature-matrix/features/plugin-backend-run-start.json b/shared/platform-feature-matrix/features/plugin-backend-run-start.json index 62e19f750..38258280d 100644 --- a/shared/platform-feature-matrix/features/plugin-backend-run-start.json +++ b/shared/platform-feature-matrix/features/plugin-backend-run-start.json @@ -36,8 +36,8 @@ ] }, "owner": "Extensions / Run", - "verification": "macOS:用声明 requires.serverProcess 4 与 permissions run.start 的测试插件,让后端依次发起(1)工具 ID 运行:Run 窗口出现以 label 命名的条目,进程使用用户在设置里选中的安装,参数、工作目录和环境符合请求,插件显式给出的环境变量覆盖工具导出;(2)插件包内可执行文件运行,路径逃出包目录、文件不存在或不可执行时返回 plugin.host.notFound;(3)带 temporaryFiles 的运行,进程内能读到文件内容,结束后临时目录被删除;(4)带 debug.target connection 的运行,进程监听后调试器附加并命中断点,声明 target launch 时宿主不启动进程,由适配器按 targetBindings 启动程序并命中断点,Run 窗口停止该运行会结束调试会话,会话结束后运行条目以退出码结束;(5)带 rerun 的运行,在 Run 窗口点击再次运行会调用插件函数,函数失败时用户看到提示;(6)run/stop 只停止调用方插件的运行,用户点击停止后后端收到不带 exitCode 的 lithe/host/run/didExit,进程自然退出时收到 exitCode。工具未安装时返回 plugin.host.toolUnresolved,details.reason 为 notFound,所选安装不可运行时为 unusable,两种情况都不启动进程。禁用插件或后端退出后,已启动的进程继续运行,后端不再收到通知。远程工作区返回 plugin.host.authorityUnsupported。启动后 app bundle 文件清单不变(scripts/desktop/verify/verify-runtime-bundle-immutability.sh)。Windows:宿主尚未接入 run/start,Core 校验通过不代表 Windows 能运行插件请求的进程。", - "notes": "Viva 注册 run/start、run/stop 并在进程结束时发送 run/didExit(只发给发起它的那次后端会话);Core 的 run.decodeStart 校验参数,宿主解析工具或包内可执行文件、写入临时文件、启动进程并把输出放进 Run 窗口中这次运行自己的标签,支持停止与再次运行。debug.target 为 connection 时等待端口打开再附加适配器;target 为 launch 时宿主不启动进程,而是按 configurationType 找到本插件能 launch 的适配器,把解析好的程序、参数、绝对工作目录与环境作为 executable 目标事实交给 Core,经适配器的 launch targetBindings 绑定后启动调试会话;运行条目代表该会话,停止运行即停止会话,会话释放后运行以 terminated 事件的退出码结束(适配器未报时不带 exitCode),进程输出在调试控制台。没有调试能力的宿主仍返回 plugin.host.unavailable。debug/start 已实现(见 plugin-debug-start-and-adapter-features)。原生产品验收仍 pending。 2026-11-13:插件 run/start 的调试附加与启动会按需读取适配器目录,不要求用户先打开 Debug 工具窗口;目录返回后检查调用取消,关闭项目不会启动旧请求。 Run 持有的进程在附加调试会话释放后由后台有界回收,Debug 工具栏停止不再留下暂停的 Run 进程;手动附加的外部进程保持原有所有权。", + "verification": "macOS:用声明 requires.serverProcess 4 与 permissions run.start 的测试插件,让后端依次发起(1)工具 ID 运行:Run 窗口出现以 label 命名的条目,进程使用用户在设置里选中的安装,参数、工作目录和环境符合请求,插件显式给出的环境变量覆盖工具导出;(2)插件包内可执行文件运行,路径逃出包目录、文件不存在或不可执行时返回 plugin.host.notFound;(3)带 temporaryFiles 的运行,进程内能读到文件内容,结束后临时目录被删除;(4)带 debug.target connection 的运行,进程监听后调试器附加并命中断点,声明 target launch 时宿主不启动进程,由适配器按 targetBindings 启动程序并命中断点,Run 窗口停止该运行会结束调试会话,会话结束后运行条目以退出码结束;(5)带 rerun 的运行,在 Run 窗口点击再次运行会调用插件函数,函数失败时用户看到提示;(6)run/stop 只停止调用方插件的运行,用户点击停止后后端收到不带 exitCode 的 lithe/host/run/didExit,进程自然退出时收到 exitCode。工具未安装时返回 plugin.host.toolUnresolved,details.reason 为 notFound,所选安装不可运行时为 unusable,两种情况都不启动进程。禁用插件或后端退出后,已启动的进程继续运行,后端不再收到通知。远程工作区返回 plugin.host.authorityUnsupported。启动后 app bundle 文件清单不变(scripts/desktop/verify/verify-runtime-bundle-immutability.sh)。Windows:宿主尚未接入 run/start,Core 校验通过不代表 Windows 能运行插件请求的进程。 合成回归验证仅接受一次连接的进程收到适配器的首个连接,并在附加后显示 Debug 窗口。", + "notes": "Viva 注册 run/start、run/stop 并在进程结束时发送 run/didExit(只发给发起它的那次后端会话);Core 的 run.decodeStart 校验参数,宿主解析工具或包内可执行文件、写入临时文件、启动进程并把输出放进 Run 窗口中这次运行自己的标签,支持停止与再次运行。debug.target 为 connection 时等待端口打开再附加适配器;target 为 launch 时宿主不启动进程,而是按 configurationType 找到本插件能 launch 的适配器,把解析好的程序、参数、绝对工作目录与环境作为 executable 目标事实交给 Core,经适配器的 launch targetBindings 绑定后启动调试会话;运行条目代表该会话,停止运行即停止会话,会话释放后运行以 terminated 事件的退出码结束(适配器未报时不带 exitCode),进程输出在调试控制台。没有调试能力的宿主仍返回 plugin.host.unavailable。debug/start 已实现(见 plugin-debug-start-and-adapter-features)。原生产品验收仍 pending。 2026-11-13:插件 run/start 的调试附加与启动会按需读取适配器目录,不要求用户先打开 Debug 工具窗口;目录返回后检查调用取消,关闭项目不会启动旧请求。 Run 持有的进程在附加调试会话释放后由后台有界回收,Debug 工具栏停止不再留下暂停的 Run 进程;手动附加的外部进程保持原有所有权。 对宿主启动的连接式调试,宿主通过系统套接字表观察进程树的监听状态,首条连接交给调试适配器。附加后自动打开 Debug 窗口,程序输出保留在 Run 窗口。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { diff --git a/shared/platform-feature-matrix/features/run-current-file-entrypoint.json b/shared/platform-feature-matrix/features/run-current-file-entrypoint.json index a86108423..f81175a47 100644 --- a/shared/platform-feature-matrix/features/run-current-file-entrypoint.json +++ b/shared/platform-feature-matrix/features/run-current-file-entrypoint.json @@ -2,10 +2,10 @@ "id": "run-current-file-entrypoint", "area": "运行与调试", "group": "运行配置", - "capability": "标题栏选“当前文件”后点运行:构建插件(buildProviders 1 的入口运行)找出当前打开文件里的运行入口,例如没有在构建文件里写明主类、但带 main 方法的 Java 类,宿主把它保存为本机运行配置(名称取类名,引用不指向构建目标,入口存为 extensions.build-run.entrypoint),在标题栏选中并运行;之后这条配置出现在运行配置下拉里,可以像其他构建提供者运行一样编辑参数、环境变量和工作目录;同一入口再次运行复用已保存的配置;文件里没有入口时提示原因", + "capability": "标题栏选择“当前文件”后可运行当前源码。构建提供者找到入口时自动保存、选中并运行配置,同一入口复用已保存的配置,可编辑参数、环境变量和工作目录。构建提供者没有返回入口时,运行复用编辑器行号栏的 Run 动作,调试复用它的 Debug 选项或独立的 Debug 动作。", "owner": "Run", - "notes": "Viva 共享实现。入口由插件按文件回答(lithe/build/runEntrypoints),Core 规划请求并校验答案;宿主不按语言或插件分支。一个文件有多个入口时运行第一个。本轮只支持运行,入口运行的调试以后再做。Maven 插件提供 main 类入口(测试源码除外)。", - "verification": "在一个没有配置主类的 Maven 模块里打开带 public static void main 的类,标题栏选“当前文件”点运行:Maven 编译模块后运行该类,运行窗口出现输出,标题栏下拉出现以类名命名的配置并已选中;修改该配置的程序参数后再次运行生效;打开没有 main 方法的类再点运行,提示当前文件没有可运行的入口。自动化:title_run_entrypoints_test.go 的 TestRunOnCurrentFileStartsTheEntrypointAndSavesItsConfiguration(合成构建提供者)。", + "notes": "Viva 共享实现。构建入口由提供者回答,Core 规划请求并校验答案。编辑器动作按源码位置选择并通过原有调用路径执行。显示通用的无入口提示前,先查看当前文档是否有可用的 Run 动作。", + "verification": "用合成构建提供者验证运行当前文件时保存并复用配置,无入口时提示原因。用合成编辑器动作提供者验证未声明构建入口的文件可从标题栏执行行号栏的动作。自动化入口在 title_run_entrypoints_test.go。", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -13,7 +13,8 @@ "desktop/internal/workbench/title_run_entrypoints.go", "desktop/internal/core/build_entrypoints.go", "desktop/internal/pluginservice/builds.go", - "desktop/internal/workbench/title_run_entrypoints_test.go" + "desktop/internal/workbench/title_run_entrypoints_test.go", + "desktop/internal/workbench/editor_actions.go" ] }, "windows": { @@ -23,7 +24,8 @@ "desktop/internal/workbench/title_run_entrypoints.go", "desktop/internal/core/build_entrypoints.go", "desktop/internal/pluginservice/builds.go", - "desktop/internal/workbench/title_run_entrypoints_test.go" + "desktop/internal/workbench/title_run_entrypoints_test.go", + "desktop/internal/workbench/editor_actions.go" ] } } diff --git a/shared/platform-feature-matrix/features/viva-title-run-debug.json b/shared/platform-feature-matrix/features/viva-title-run-debug.json index f66e83d09..60740c0d9 100644 --- a/shared/platform-feature-matrix/features/viva-title-run-debug.json +++ b/shared/platform-feature-matrix/features/viva-title-run-debug.json @@ -49,5 +49,5 @@ }, "owner": "Run", "verification": "打开带构建提供者的项目(测试内联的合成 Build Provider 即可):标题栏下拉列出检测到的运行配置并记住所选项;运行按钮启动所选配置并打开运行窗口;调试按钮对声明了调试适配器的运行准备并启动调试会话、打开调试窗口,未声明时提示该配置不能调试;声明了公共调试类型的服务运行(合成提供者 + 另一个合成插件的 attach 适配器),调试时提供者收到 `launchOptions.debug`(选中的适配器、类型、本机端口),服务监听后适配器以 attach 连接该端口,在调试窗口停止后服务结束、端口释放;没有或有两个匹配适配器时提示原因且不请求提供者;停用、再启用适配器所在插件后,调试适配器列表随之更新;运行超过准备时限的服务不会被结束(测试把时限缩短到 5 秒);语言服务器就绪后才声明命令时,宿主等到声明再请求端口,从不声明时在时限内结束;准备失败时结束“准备中”并显示原因;当前文件没有可运行的入口时提示原因(有入口时的运行见 run-current-file-entrypoint);项目没有运行配置时点“编辑运行配置…”提示原因,有旧版或其他提供方的已保存配置时说明隐藏了几条。提供者运行准备失败时,运行控制台显示提供者输出的构建日志;未声明名称的运行,配置名就是目标名。单元测试覆盖等待配置读出后运行、没有配置时编辑入口的提示和隐藏条数、当前文件提示、无适配器提示、不经构建提供者启动的配置提示、提供者准备请求、按名称选择适配器和拒绝插件未安装的适配器、准备运行时转发提供者输出、未命名运行按目标命名,声明提供者进程但用命令读取模型和写文件的依赖命令,以及按配置类型连接调试服务运行(选择、拒绝、停止联动)。", - "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行由构建插件按文件找出入口(run-current-file-entrypoint);同包适配器的提供者调试暂不携带运行配置的启动选项;按配置类型连接的服务运行调试一个项目同时只有一个调试会话。调试按钮可拖到左右侧栏,功能照旧,运行和运行配置下拉只留在标题栏(见 workbench-tool-window-docking)。macOS、Windows 原生窗口验收 pending。" + "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行优先使用构建提供者的入口,其次使用编辑器动作。当前文件调试优先使用编辑器动作(run-current-file-entrypoint);同包适配器的提供者调试暂不携带运行配置的启动选项;按配置类型连接的服务运行调试一个项目同时只有一个调试会话。调试按钮可拖到左右侧栏,功能照旧,运行和运行配置下拉只留在标题栏(见 workbench-tool-window-docking)。macOS、Windows 原生窗口验收 pending。" }