diff --git a/.agents/notes/implemented/bug-fix/2026-11-17-run-process-outlives-preparation-timeout.md b/.agents/notes/implemented/bug-fix/2026-11-17-run-process-outlives-preparation-timeout.md index 1d2f85c5a8..31c25486b3 100644 --- a/.agents/notes/implemented/bug-fix/2026-11-17-run-process-outlives-preparation-timeout.md +++ b/.agents/notes/implemented/bug-fix/2026-11-17-run-process-outlives-preparation-timeout.md @@ -36,11 +36,11 @@ a.background(p, 0, func(ctx context.Context) func(*App) { - 把 `buildRequestTimeout` 调大(例如 24 小时)。服务仍然会在某个时刻被无故结束,只是更难发现;准备阶段的保护也随之失效。 - 进程用 `context.Background()` 启动。项目关闭时进程不再随上下文结束,只能依赖其他清理路径,容易留下孤儿进程。 -- 构建任务(`runBuildTask`)也一起改。任务是有终点的构建,30 分钟时限能防止卡死的构建一直占着唯一的操作位;这次没有改,任务时限是否合适另行判断。 +- 构建任务(`runBuildTask`)也一起改。任务是有终点的构建,30 分钟时限能防止卡死的构建一直占着任务的操作位;这次没有改,任务时限是否合适另行判断。 ## 后果 -- 常驻服务和调试中的服务可以一直运行;停止仍然走 `stopBuildOperation`,项目关闭仍然结束进程。 +- 常驻服务和调试中的服务可以一直运行;停止走 `stopOperation`,项目关闭仍然结束进程。运行已经不占唯一的操作位,见 [多个运行并行](../feature/2026-11-17-concurrent-run-executions.md)。 - 准备阶段的时限变成包级变量 `runPreparationTimeout`(默认仍是 30 分钟),测试可以缩短它。 - 进程的生命周期不再有兜底时限:一个忘了停的服务会一直占用资源,直到用户停止或关闭项目,这和 IDEA 的行为一致。 diff --git a/.agents/notes/implemented/feature/2026-11-17-concurrent-run-executions.md b/.agents/notes/implemented/feature/2026-11-17-concurrent-run-executions.md new file mode 100644 index 0000000000..af5f843032 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-17-concurrent-run-executions.md @@ -0,0 +1,58 @@ +# Agent 笔记:多个运行并行,构建任务仍然独占 + +状态:已实现 + +## 先说结论 + +工作台原来只有一个执行位 `buildState.operation`,构建任务和应用运行共用。启动一个 Spring Boot 服务后,第二个服务、甚至另一个配置都启动不了,和 IntelliJ IDEA 的行为不符(#2071、“可以同时运行多个服务”)。现在: + +- 应用运行放进 `buildState.running`,每个运行有一个键:运行配置 `config:`、构建目标 `target:<实例>/<目标>/<运行>`、命令入口 `entry:<实例>/<入口>`。不同键的运行并行。 +- 同一个键再次运行时走 `startRun`:先停旧进程,旧运行结束(`endBuildOperation`)后再调用新的启动函数(`op.then`),两个进程不会同时占用端口或文件。这就是 IDEA 的“停止并重新运行”。 +- 构建任务、模型加载、IDE API 的构建配置仍然只占 `buildState.operation`,一次一个,和运行互不阻塞。 +- 调试仍是每个项目一个会话(用户明确不需要同时调试多个项目)。 +- Run 标签在准备阶段显示转圈,进程启动后(`attachProcess` 设置 `runEntry.processRunning`)显示静态的绿色运行图标;常驻服务会运行几个小时,一直转圈说明不了它已经启动。 + +## 问题 + +`buildState.operation` 是唯一的执行位,`runConfiguration`、构建目标运行和命令入口都通过 `beginBuildOperation` 占用它,后续的输出、状态、停止和 IDE API 都用 `p.build.operation == op` 判断执行是否还在。于是一个服务在运行时,其他配置的运行按钮全部禁用;Run 标签只要进程还活着就一直转圈,看不出服务是否已经启动。 + +## 决策 + +运行和任务分开存放:运行按键放进 `buildState.running`,任务留在 `buildState.operation`。同一个键的运行先停后启,不同键并行;任务之间仍然互斥。下面是实现时必须遵守的规则。 + + +- 判断“某个执行还属于窗口”一律用 `p.build.owns(op)`,不要再写 `p.build.operation == op`:运行不在 `operation` 里,这样写会让运行的输出、状态和停止全部失效。 +- 停止某个执行用 `stopOperation(p, op)`。`stopBuildOperation(p)` 只停 `latest()`(任务优先,否则最新的运行),只给没有自己标签的控件用,例如 Build 窗口工具栏的停止;IDE API 按执行 ID 找到对应的执行再停止。 +- 每个执行有自己的状态行 `op.status`,用 `setOperationStatus` 更新;`p.build.status` 只是最近一次的状态,不能拿来显示某个运行。 +- 新增启动应用进程的路径时(内置进程运行 `startProcessRun` 就是这样做的),用 `beginRunOperation` 并给出键,通过 `startRun` 启动;不要用 `beginBuildOperation`,否则它会和构建任务互斥。 +- `latest()` 先返回最新开始且仍在运行的执行(`buildState.newest`),所以启动后 `showBuildConsole` 显示的就是刚启动的那个,即使有任务在运行。 +- 项目关闭(`stopBuildSessions`)时清掉所有 `then`,等待重启的运行不会在关闭后启动。 +- IDE API 对正在运行的配置再次 `start` 返回 `BUSY`(`errRunRunning`):外部调用方需要明确先停止,不替它决定重启。 + +## 考虑过的备选方案 + +- 同一配置允许多个实例(IDEA 的 “Allow multiple instances”)。服务大多监听固定端口,多实例默认会失败;先做默认的“停止并重新运行”,以后由 `runOptions` 扩展点加开关。 +- 运行和构建任务全部并行。构建任务会写同一个输出目录,并行构建会互相破坏产物,保持独占。 +- 同一键再次运行时直接拒绝。用户点运行就是想要新的进程,拒绝会让人以为按钮坏了。 + +## 后果 + +- 用户可以像 IDEA 一样同时开着前端、后端和工作进程,各自停止、各自重跑。 +- 每个运行都占用自己的进程和端口,忘了停的服务会一直运行到用户停止或关闭项目。 +- 依赖“窗口只有一个执行”的代码(IDE API 的停止、Build 窗口工具栏)改为按执行 ID 或 `latest()` 找目标;以后加控件时要先决定它作用于哪个执行。 + +## 验证 + +- `./scripts/desktop/desktop-go.sh test ./internal/workbench/ -run 'TestRunsOfDifferentKeysRunTogether|TestStartRunReplacesTheRunOfItsKeyOnceItEnded|TestServiceRunShowsRunningAndRestartsInPlace' -count=1` +- `TestServiceRunShowsRunningAndRestartsInPlace` 用合成插件的真实服务进程:运行后状态为“正在运行”,再次运行时旧运行以“已停止”结束后新进程才启动,最后只剩一个运行。 + +## 适用范围 + +- `desktop/internal/workbench/build.go` +- `desktop/internal/workbench/runconfig.go` +- `desktop/internal/workbench/runconfig_view.go` +- `desktop/internal/workbench/run_view.go` +- `desktop/internal/workbench/runs.go` +- `desktop/internal/workbench/runconfig_process.go` +- `desktop/internal/workbench/build_connection_debug.go` +- `desktop/internal/workbench/ide_api_dispatch.go` diff --git a/desktop/internal/core/output_links.go b/desktop/internal/core/output_links.go index 65ce517fb5..7ca8b63421 100644 --- a/desktop/internal/core/output_links.go +++ b/desktop/internal/core/output_links.go @@ -33,7 +33,9 @@ type OutputLinkRequest struct { } // OutputLink is one clickable range of a console line. Start and Length count -// UTF-16 code units of the line. Exactly one of Location and Resolve is set. +// UTF-16 code units of the line. Exactly one of Location, Resolve and URL is set: +// a plugin's link has Location or Resolve, and a web address the line prints has +// URL alone, with no plugin, which opens in the browser. type OutputLink struct { Line int `json:"line"` Start int `json:"start"` @@ -45,6 +47,7 @@ type OutputLink struct { Function string `json:"function"` Groups json.RawMessage `json:"groups"` } `json:"resolve"` + URL string `json:"url,omitempty"` } // OutputLocation is where a link opens. Paths are candidates (the host opens diff --git a/desktop/internal/workbench/build.go b/desktop/internal/workbench/build.go index 3090887d72..e6c596cd08 100644 --- a/desktop/internal/workbench/build.go +++ b/desktop/internal/workbench/build.go @@ -62,7 +62,14 @@ type buildState struct { targetID string taskID string + // operation is the Build window's one task, model or IDE API build at a time; running are + // the applications and services that run, any number at once but one per run key + // (buildOperation.key), oldest first. operation *buildOperation + running []*buildOperation + // newest is the execution begun last, which the Run window shows when a control starts + // one; it may have ended since. + newest *buildOperation // runs are the Run window's sessions, oldest first: the host's executions and the // runs plugins started. view is the ID of the one it shows, and sessions numbers the // host's executions. @@ -103,19 +110,27 @@ type buildInstance struct { trees buildTrees } -// buildOperation is the one Build execution the window runs: a task or a run, from the -// moment its start is accepted until it ends. beginBuildOperation takes it before the plan, -// the saves and the provider request, so a second start is refused and Stop works while the -// execution is still being prepared; the provider request or host process it started is +// buildOperation is one Build execution the window runs: a task or a run, from the moment its +// start is accepted until it ends. beginBuildOperation takes it before the plan, the saves and +// the provider request, so a second start is refused, or replaces a run of the same key, and +// Stop works while the execution is still being prepared; the provider request or host process it started is // attached once it exists. Its fields belong to the window thread; the goroutine preparing it // reads only stopped, through bind. type buildOperation struct { // configuration is the run configuration the operation runs, "" for anything else. configuration string - provider *buildprovider.Client - request *buildprovider.Operation - process *buildprocess.Process - cancelled bool + // key names what an application run runs: its configuration, or its target or command + // entry when it has none; "" for a task. A second start of the same key replaces the run + // (startRun), as IDEA stops and reruns a configuration that runs. + key string + // status is the operation's last line: preparing, running, stopping or how it ended. + status string + // then starts the run that replaces this one once it ended (startRun). + then func(*App, *project) + provider *buildprovider.Client + request *buildprovider.Operation + process *buildprocess.Process + cancelled bool // stopped is closed by stop. stopped chan struct{} // ide is the execution's IDE API identity and state (ide_api_dispatch.go). @@ -136,7 +151,18 @@ type buildOperation struct { // from that tab. Every path that follows ends it with finishBuildTask, finishBuildRun or // finishBuildError for this operation. func (a *App) beginBuildOperation(p *project, kind, label, configuration string, restart func(*App, *project)) *buildOperation { - operation := &buildOperation{configuration: configuration, stopped: make(chan struct{}), decoder: newOutputDecoder(a.kernel)} + return a.beginOperation(p, kind, label, configuration, "", restart) +} + +// beginRunOperation begins an application run of key, which runs beside the Build window's +// operation and the other runs (beginOperation). +func (a *App) beginRunOperation(p *project, label, configuration, key string, restart func(*App, *project)) *buildOperation { + return a.beginOperation(p, "run", label, configuration, key, restart) +} + +// beginOperation begins a task, or with key an application run, as beginBuildOperation says. +func (a *App) beginOperation(p *project, kind, label, configuration, key string, restart func(*App, *project)) *buildOperation { + operation := &buildOperation{configuration: configuration, key: key, stopped: make(chan struct{}), decoder: newOutputDecoder(a.kernel)} p.build.sessions++ operation.session = &runEntry{ id: "build-" + strconv.Itoa(p.build.sessions), label: label, restart: restart, operation: operation, @@ -145,11 +171,81 @@ func (a *App) beginBuildOperation(p *project, kind, label, configuration string, a.addRunSession(p, operation.session) operation.ide = p.recordIDEOperation(kind, label, configuration) operation.ide.output = &operation.session.output - p.build.operation = operation - p.build.status = a.text.Build.Preparing + if key != "" { + p.build.running = append(p.build.running, operation) + } else { + p.build.operation = operation + } + p.build.newest = operation + a.setOperationStatus(p, operation, a.text.Build.Preparing) return operation } +// setOperationStatus makes text op's line and the Build window's latest one. +func (a *App) setOperationStatus(p *project, op *buildOperation, text string) { + op.status = text + p.build.status = text +} + +// owns reports whether op is still one of the window's executions: not ended, and not detached +// by a closing project or a plugin change. Everything that arrives for an operation checks it, +// so late output and results of an execution that ended change nothing. +func (b *buildState) owns(op *buildOperation) bool { + return op != nil && (b.operation == op || slices.Contains(b.running, op)) +} + +// release drops op from the window's executions. +func (b *buildState) release(op *buildOperation) { + if b.operation == op { + b.operation = nil + } + b.running = slices.DeleteFunc(b.running, func(running *buildOperation) bool { return running == op }) +} + +// runOf is the application run of key that runs, or nil. +func (b *buildState) runOf(key string) *buildOperation { + for _, op := range b.running { + if op.key == key { + return op + } + } + return nil +} + +// latest is the execution a control without a tab of its own acts on, such as the Build +// window's Stop or the console a start shows: the execution begun last while it runs, else the +// Build window's operation, else the newest run. +func (b *buildState) latest() *buildOperation { + if b.owns(b.newest) { + return b.newest + } + if b.operation != nil { + return b.operation + } + if len(b.running) > 0 { + return b.running[len(b.running)-1] + } + return nil +} + +// active reports whether any execution runs. +func (b *buildState) active() bool { return b.operation != nil || len(b.running) > 0 } + +// startRun starts the application run of key through start, at once when none of that key +// runs; otherwise it stops the one that runs and starts the new one once it ended, so the two +// never share a port or files. A start that is asked again while one waits replaces it. +func (a *App) startRun(p *project, key string, start func(*App, *project)) { + running := p.build.runOf(key) + if running == nil { + start(a, p) + return + } + running.then = start + if !running.cancelled { + a.stopOperation(p, running) + } +} + // restartWithInstance is a session's restart that selects the build instance it ran under // again, by ID, before start runs it; an instance that is gone starts nothing. func restartWithInstance(instanceID string, start func(a *App, p *project)) func(*App, *project) { @@ -230,16 +326,21 @@ func refuseBuild(code, message string) error { return &buildRefusal{code: code, // errBuildBusy refuses a start while the window runs another execution. var errBuildBusy = refuseBuild(refusalBusy, "the Build window is already running an operation") +// errRunRunning refuses a tool call's start of a run configuration that already runs; the Run +// window stops and reruns it instead (startRun). +var errRunRunning = refuseBuild(refusalBusy, "the run configuration is already running") + // attachProcess makes process the operation's process once it started. It reports false, and // stops the process, when the operation was stopped or replaced while the process started. func (a *App) attachProcess(p *project, op *buildOperation, process *buildprocess.Process) bool { - if op.cancelled || p.build.operation != op { + if op.cancelled || !p.build.owns(op) { process.Stop() return false } op.process = process op.ide.start() - p.build.status = a.text.Build.Running + op.session.processRunning = true + a.setOperationStatus(p, op, a.text.Build.Running) return true } @@ -1378,7 +1479,18 @@ func buildTargetRunEntries(instance *buildInstance, targetID string) []core.Buil // never older than the options. func (a *App) runBuildEntry(p *project, entryID string) { instance := p.selectedBuildInstance() - if instance == nil || p.build.operation != nil { + if instance == nil { + return + } + instanceID := instance.ID + a.startRun(p, "entry:"+instanceID+"/"+entryID, func(a *App, p *project) { a.startBuildEntry(p, instanceID, entryID) }) +} + +// startBuildEntry runs the command Run entry entryID of the instance instanceID, which is +// selected, once no run of it runs (runBuildEntry). +func (a *App) startBuildEntry(p *project, instanceID, entryID string) { + instance := p.selectedBuildInstance() + if instance == nil || instance.ID != instanceID { return } var entry *core.BuildRunEntry @@ -1400,7 +1512,7 @@ func (a *App) runBuildEntry(p *project, entryID string) { } captured := *instance messages := a.text.Build - op := a.beginBuildOperation(p, "run", entry.Name, "", restartWithInstance(instance.ID, func(a *App, p *project) { + op := a.beginRunOperation(p, entry.Name, "", "entry:"+instanceID+"/"+entryID, restartWithInstance(instance.ID, func(a *App, p *project) { a.runBuildEntry(p, entryID) })) a.background(p, 0, func(ctx context.Context) func(*App) { @@ -1437,9 +1549,25 @@ func (a *App) runBuildTarget(p *project, targetID, runID string) { // prepares the service suspended for its adapter. func (a *App) startBuildTarget(p *project, targetID string, run pluginservice.BuildRunDeclaration, debug *connectionDebug) { instance := p.selectedBuildInstance() - if instance == nil || p.build.operation != nil { + if instance == nil { return } + key, instanceID := targetRunKey(instance.ID, targetID, run.ID), instance.ID + a.startRun(p, key, func(a *App, p *project) { + if selected := p.selectedBuildInstance(); selected != nil && selected.ID == instanceID { + a.beginBuildTarget(p, key, targetID, run, debug) + } + }) +} + +// targetRunKey is the run key of target targetID of an instance run through run runID. +func targetRunKey(instanceID, targetID, runID string) string { + return "target:" + instanceID + "/" + targetID + "/" + runID +} + +// beginBuildTarget begins the run startBuildTarget asked for, once no run of key runs. +func (a *App) beginBuildTarget(p *project, key, targetID string, run pluginservice.BuildRunDeclaration, debug *connectionDebug) { + instance := p.selectedBuildInstance() target, ok := buildTargetByID(instance.Model, targetID) if !ok { a.operationRejected("build_run_target", "target_missing") @@ -1447,7 +1575,7 @@ func (a *App) startBuildTarget(p *project, targetID string, run pluginservice.Bu return } runID := run.ID - op := a.beginBuildOperation(p, "run", target.Name, "", restartWithInstance(instance.ID, func(a *App, p *project) { + op := a.beginRunOperation(p, target.Name, "", key, restartWithInstance(instance.ID, func(a *App, p *project) { if debug != nil { a.debugBuildTarget(p, targetID, runID) return @@ -1749,7 +1877,7 @@ func (a *App) runBuildTargetWith(p *project, op *buildOperation, instance *build // it. execution says the request is the execution itself, a task, rather than the plan of a // run's process. A request accepted after the operation was stopped or replaced is cancelled. func (a *App) attachRequest(p *project, op *buildOperation, client *buildprovider.Client, request *buildprovider.Operation, execution bool) { - if op.cancelled || p.build.operation != op { + if op.cancelled || !p.build.owns(op) { a.background(p, buildStopTimeout, func(ctx context.Context) func(*App) { _ = client.Cancel(ctx, request) return nil @@ -1807,8 +1935,8 @@ func (a *App) awaitProviderOperation(ctx context.Context, p *project, op *buildO } if progress.Message != "" { a.post(func(a *App) { - if p.build.operation == op && !op.cancelled { - p.build.status = progress.Message + if p.build.owns(op) && !op.cancelled { + a.setOperationStatus(p, op, progress.Message) } }) } @@ -1823,13 +1951,17 @@ func (a *App) awaitProviderOperation(ctx context.Context, p *project, op *buildO // no longer the window's operation: a closed project or a plugin change already detached and // settled it, and its late terminal event changes nothing. func (a *App) endBuildOperation(p *project, op *buildOperation, state string, exitCode *int, failure, status string) bool { - if a.project != p || p.build.operation != op { + if a.project != p || !p.build.owns(op) { return false } - p.build.operation = nil - p.build.status = status + p.build.release(op) + a.setOperationStatus(p, op, status) a.endBuildSession(op, state, status) op.ide.settle(state, exitCode, op.session.output.sequence, failure) + if then := op.then; then != nil { + op.then = nil + then(a, p) + } return true } @@ -1909,22 +2041,30 @@ func (a *App) finishBuildError(p *project, op *buildOperation, err error) { } } -// stopBuildOperation stops the current execution: its preparation ends, its process is asked -// to stop and the provider is asked to cancel its request. Stopping an execution that is already -// stopping kills its process at once instead of waiting out the stop time. The terminal event -// still clears the operation, so a replacement cannot start until the execution really ended. +// stopBuildOperation stops the execution a control without a tab of its own acts on: the Build +// window's operation, else the newest run (buildState.latest). func (a *App) stopBuildOperation(p *project) { - if p == nil || p.build.operation == nil { + if p == nil { + return + } + a.stopOperation(p, p.build.latest()) +} + +// stopOperation stops one execution: its preparation ends, its process is asked to stop and the +// provider is asked to cancel its request. Stopping an execution that is already stopping kills +// its process at once instead of waiting out the stop time. The terminal event still clears the +// operation, so a replacement cannot start until the execution really ended. +func (a *App) stopOperation(p *project, operation *buildOperation) { + if p == nil || !p.build.owns(operation) { return } - operation := p.build.operation if operation.cancelled { operation.stop() return } operation.stop() operation.ide.stopping() - p.build.status = a.text.Build.Stopping + a.setOperationStatus(p, operation, a.text.Build.Stopping) if operation.provider != nil && operation.request != nil { client, request := operation.provider, operation.request a.background(p, buildStopTimeout, func(ctx context.Context) func(*App) { @@ -1940,7 +2080,7 @@ func (a *App) stopBuild(p *project) { a.stopBuildSessions(p, true) } -// stopBuildSessions cancels the current operation and stops the sessions the project holds on a +// stopBuildSessions cancels every execution and stops the sessions the project holds on a // background task with a bounded wait. The sessions are detached from the project first, so the // task closes exactly them whatever the project starts next; with closing set the project starts no // session again. @@ -1948,10 +2088,15 @@ func (a *App) stopBuildSessions(p *project, closing bool) { if p == nil { return } - operation := p.build.operation - p.build.operation = nil - if operation != nil { - // Its terminal event finds the operation detached, so it settles here. + operations := slices.Clone(p.build.running) + if p.build.operation != nil { + operations = append(operations, p.build.operation) + } + p.build.operation, p.build.running = nil, nil + for _, operation := range operations { + // Its terminal event finds the operation detached, so it settles here; a run waiting to + // replace it is dropped with it. + operation.then = nil operation.stop() a.endBuildSession(operation, "cancelled", a.text.Build.Cancelled) operation.ide.settle("cancelled", nil, operation.session.output.sequence, "") @@ -1962,8 +2107,11 @@ func (a *App) stopBuildSessions(p *project, closing bool) { defer a.tasks.running.Done() ctx, cancel := context.WithTimeout(context.Background(), buildStopTimeout) defer cancel() - if operation != nil && operation.request != nil && operation.provider != nil { - _ = operation.provider.Cancel(ctx, operation.request) + for _, operation := range operations { + if operation.request != nil && operation.provider != nil { + // log-exempt: teardown:a provider that cannot cancel is closed right after. + _ = operation.provider.Cancel(ctx, operation.request) + } } for _, client := range clients { _ = client.Close(ctx) @@ -2001,7 +2149,7 @@ func (a *App) streamBuildOutput(p *project, op *buildOperation, text string) { // applyBuildOutput adds decoded output to op's console. Output of an operation the window no // longer runs is dropped, so it never lands in a later execution's console. func (a *App) applyBuildOutput(p *project, op *buildOperation, chunk outputChunk) { - if p == nil || a.project != p || p.build.operation != op { + if p == nil || a.project != p || !p.build.owns(op) { return } op.session.output.apply(chunk) diff --git a/desktop/internal/workbench/build_concurrent_runs_test.go b/desktop/internal/workbench/build_concurrent_runs_test.go new file mode 100644 index 0000000000..8d66396e64 --- /dev/null +++ b/desktop/internal/workbench/build_concurrent_runs_test.go @@ -0,0 +1,145 @@ +package workbench + +import ( + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" +) + +// Runs of different keys run beside each other and beside the Build window's task, and each +// stops on its own. The window used to hold one execution, so a second service could not start +// while the first ran. +func TestRunsOfDifferentKeysRunTogether(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(runConfigRoot(t)) + p := h.app.project + var first, second, task *buildOperation + h.app.post(func(a *App) { + first = a.beginRunOperation(p, "A", "a", configurationRunKey("a"), nil) + second = a.beginRunOperation(p, "B", "b", configurationRunKey("b"), nil) + task = a.beginBuildOperation(p, "build", "vet", "", nil) + }) + h.settle() + if !p.build.owns(first) || !p.build.owns(second) || !p.build.owns(task) { + t.Fatal("an execution was replaced by the next") + } + if p.build.runOf(configurationRunKey("a")) != first || p.build.runOf(configurationRunKey("b")) != second || p.build.latest() != task { + t.Fatalf("runOf a %p b %p latest %p", p.build.runOf(configurationRunKey("a")), p.build.runOf(configurationRunKey("b")), p.build.latest()) + } + + // A run begun while the task runs is what a start shows and the toolbar's Stop acts on. + var third *buildOperation + h.app.post(func(a *App) { + third = a.beginRunOperation(p, "C", "c", configurationRunKey("c"), nil) + a.showBuildConsole(p) + }) + h.settle() + if p.build.latest() != third || p.build.view != third.session.id { + t.Fatal("the run begun last is not the one shown while a task runs") + } + h.app.post(func(a *App) { a.endBuildOperation(p, third, "cancelled", nil, "", a.text.Build.Cancelled) }) + h.settle() + if p.build.latest() != task { + t.Fatal("the task is not the latest execution once the newer run ended") + } + + h.app.post(func(a *App) { a.stopOperation(p, first) }) + h.settle() + if !first.cancelled || second.cancelled || task.cancelled { + t.Fatalf("stopping one run stopped others: first %v second %v task %v", first.cancelled, second.cancelled, task.cancelled) + } + h.app.post(func(a *App) { + a.endBuildOperation(p, first, "cancelled", nil, "", a.text.Build.Cancelled) + }) + h.settle() + if p.build.owns(first) || !p.build.owns(second) || !p.build.owns(task) || first.session.running || !second.session.running { + t.Fatal("ending one run ended others") + } + if detail := runDetail(p, second.session); detail != h.app.text.Build.Preparing { + t.Fatalf("the second run's line is %q, want its own state, not the first run's", detail) + } + h.app.post(func(a *App) { + a.endBuildOperation(p, second, "cancelled", nil, "", a.text.Build.Cancelled) + a.endBuildOperation(p, task, "completed", nil, "", a.text.Build.Cancelled) + }) + h.settle() + if p.build.active() { + t.Fatal("executions remain after all ended") + } +} + +// Starting a run of a key that runs stops the one that runs and starts the new one only once it +// ended, as IDEA's Rerun does, so the two never hold the same port. +func TestStartRunReplacesTheRunOfItsKeyOnceItEnded(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(runConfigRoot(t)) + p := h.app.project + key := configurationRunKey("a") + var old, replacement *buildOperation + starts := 0 + start := func(a *App, p *project) { + starts++ + replacement = a.beginRunOperation(p, "A", "a", key, nil) + } + h.app.post(func(a *App) { + old = a.beginRunOperation(p, "A", "a", key, nil) + a.startRun(p, key, start) + // Asked again while the stop is pending, the start replaces the waiting one. + a.startRun(p, key, start) + }) + h.settle() + if !old.cancelled || starts != 0 { + t.Fatalf("old run cancelled %v, %d starts before it ended", old.cancelled, starts) + } + h.app.post(func(a *App) { a.endBuildOperation(p, old, "cancelled", nil, "", a.text.Build.Cancelled) }) + h.settle() + if starts != 1 || replacement == nil || p.build.runOf(key) != replacement { + t.Fatalf("%d starts after the old run ended, run of the key %p, want the replacement %p", starts, p.build.runOf(key), replacement) + } + // A project that closes drops a start that waits for its run to end. + h.app.post(func(a *App) { + a.startRun(p, key, start) + a.stopBuildSessions(p, false) + }) + h.settle() + if starts != 1 || p.build.active() { + t.Fatalf("%d starts, active %v after the sessions were stopped", starts, p.build.active()) + } +} + +// A service's session is marked running once its process starts, not only while it is +// prepared (#2071), and Run on the configuration that runs restarts it: the old process ends +// before the new one starts. +func TestServiceRunShowsRunningAndRestartsInPlace(t *testing.T) { + h := connectionDebugHarness(t, nil) + p, id := openServiceDebugProject(t, h) + var first *buildOperation + h.app.post(func(a *App) { + a.runConfiguration(p, id) + first = p.build.runOf(configurationRunKey(id)) + }) + h.settle() + if first == nil { + t.Fatal("Run started nothing") + } + awaitStateWithin(t, h, time.Minute, "the service process", func() bool { return first.session.processRunning || !first.session.running }) + if !first.session.running || runDetail(p, first.session) != h.app.text.Build.Running { + t.Fatalf("the service is not running: status %q, console:\n%s", p.build.status, first.session.output.all()) + } + + h.app.post(func(a *App) { a.runConfiguration(p, id) }) + awaitStateWithin(t, h, time.Minute, "the restarted service", func() bool { + next := p.build.runOf(configurationRunKey(id)) + return next != nil && next != first && next.session.processRunning + }) + if first.session.running || first.session.outcome != runStopped { + t.Fatalf("the first run still runs or did not end as stopped: running %v outcome %v", first.session.running, first.session.outcome) + } + if len(p.build.running) != 1 { + t.Fatalf("%d runs after the restart, want 1", len(p.build.running)) + } + next := p.build.runOf(configurationRunKey(id)) + h.app.post(func(a *App) { a.stopOperation(p, next) }) + awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool { return !p.build.active() }) +} diff --git a/desktop/internal/workbench/build_connection_debug.go b/desktop/internal/workbench/build_connection_debug.go index a12a845664..ef3db472f9 100644 --- a/desktop/internal/workbench/build_connection_debug.go +++ b/desktop/internal/workbench/build_connection_debug.go @@ -86,10 +86,6 @@ func (a *App) prepareConnectionDebug(p *project, configurationType string, start if p == nil { return } - if p.build.operation != nil { - a.notifyInfo(i18n.Shared(a.language(), "desktop.title.runBusy")) - return - } a.whenDebugAdaptersLoaded(p, func() { if p.debug.activeSession() != nil { a.operationRejected("build_debug_connection", "session_running") @@ -124,9 +120,11 @@ func (a *App) prepareConnectionDebug(p *project, configurationType string, start // selected adapter. func (a *App) debugRunConfiguration(p *project, id, configurationType string) { a.prepareConnectionDebug(p, configurationType, func(debug connectionDebug) { - if _, err := a.startRunConfigurationWith(p, id, &debug); errors.Is(err, errBuildBusy) { - a.notifyInfo(i18n.Shared(a.language(), "desktop.title.runBusy")) - } + // A run of the configuration that runs is stopped first and debugged once it ended. + a.startRun(p, configurationRunKey(id), func(a *App, p *project) { + // log-exempt: reported:startRunConfigurationWith reports why a start cannot happen. + _, _ = a.startRunConfigurationWith(p, id, &debug) + }) }) } @@ -144,7 +142,7 @@ func (a *App) debugServiceTarget(p *project, targetID string, run pluginservice. func (a *App) attachServiceDebugger(ctx context.Context, p *project, op *buildOperation, debug connectionDebug, ended <-chan struct{}) { err := pluginservice.WaitForDebugPort(ctx, debug.launch.Target.Port, ended, pluginservice.RunDebugConnectTimeout) a.post(func(a *App) { - if a.project != p || p.build.operation != op || op.cancelled { + if a.project != p || !p.build.owns(op) || op.cancelled { return } switch { @@ -152,7 +150,7 @@ func (a *App) attachServiceDebugger(ctx context.Context, p *project, op *buildOp // A plugin change since the selection is read first, so the adapter is checked // against the plugins as they are now. a.whenDebugAdaptersLoaded(p, func() { - if p.build.operation == op && !op.cancelled { + if p.build.owns(op) && !op.cancelled { a.attachServiceDebugSession(p, op, debug) } }) @@ -162,7 +160,7 @@ func (a *App) attachServiceDebugger(ctx context.Context, p *project, op *buildOp a.notifyError(i18n.SharedFormat(a.language(), "desktop.build.debugPortTimeout", map[string]string{ "seconds": strconv.Itoa(int(pluginservice.RunDebugConnectTimeout.Seconds())), })) - a.stopBuildOperation(p) + a.stopOperation(p, op) } }) } @@ -175,13 +173,13 @@ func (a *App) attachServiceDebugSession(p *project, op *buildOperation, debug co if index < 0 { a.operationFailed("build_debug_attach", errors.New("the selected debug adapter was disabled or replaced")) a.notifyError(i18n.SharedFormat(a.language(), "desktop.build.connectionDebugAdapterGone", map[string]string{"name": debug.adapter.Declaration.DisplayName})) - a.stopBuildOperation(p) + a.stopOperation(p, op) return } if p.debug.activeSession() != nil { a.operationRejected("build_debug_connection", "session_running") a.notifyInfo(i18n.Shared(a.language(), "desktop.build.debugSessionRunning")) - a.stopBuildOperation(p) + a.stopOperation(p, op) return } a.beginDebug(p, debugStart{ @@ -189,17 +187,13 @@ func (a *App) attachServiceDebugSession(p *project, op *buildOperation, debug co target: &core.DebugTargetFacts{Kind: "connection", Host: debug.launch.Target.Host, Port: debug.launch.Target.Port}, // Release calls stopRun off the window thread. stopRun: func() { - a.post(func(a *App) { - if p.build.operation == op { - a.stopBuildOperation(p) - } - }) + a.post(func(a *App) { a.stopOperation(p, op) }) }, }) session := p.debug.activeSession() if session == nil { // beginDebug reported why the session did not start; nothing debugs the suspended service. - a.stopBuildOperation(p) + a.stopOperation(p, op) return } op.debugSession = session diff --git a/desktop/internal/workbench/build_connection_debug_test.go b/desktop/internal/workbench/build_connection_debug_test.go index 97aade036e..12bd4731dc 100644 --- a/desktop/internal/workbench/build_connection_debug_test.go +++ b/desktop/internal/workbench/build_connection_debug_test.go @@ -236,13 +236,13 @@ func TestTitleDebugAttachesTheRegisteredAdapterToAServiceRun(t *testing.T) { if session == nil || session.adapter.PluginID != "dev.lithe.test.registry-attach" { t.Fatalf("debug session = %+v, want the registered adapter's", session) } - if p.build.operation == nil { + if !p.build.active() { t.Fatal("the service is not running while it is debugged") } // Stop in the Debug window ends the service it attached to. h.app.post(func(a *App) { a.stopDebugByUser(p) }) - awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool { return p.build.operation == nil && p.debug.activeSession() == nil }) + awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool { return !p.build.active() && p.debug.activeSession() == nil }) listener, err := net.Listen("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(debug.Target.Port))) if err != nil { t.Fatalf("the service still holds its debug port after Stop: %v", err) @@ -302,8 +302,8 @@ func TestServiceDebugRefusesAMissingOrAmbiguousAdapterBeforePreparing(t *testing t.Fatalf("the refusal has no message: %q", want) } awaitStateWithin(t, h, time.Minute, "the refusal", func() bool { return lastNotice(h) == want }) - if p.build.operation != nil || p.debug.activeSession() != nil { - t.Fatalf("a refused debug started something: operation %v, session %v", p.build.operation, p.debug.activeSession()) + if p.build.active() || p.debug.activeSession() != nil { + t.Fatalf("a refused debug started something: operation %v, session %v", p.build.latest(), p.debug.activeSession()) } if _, err := os.Stat(filepath.Join(p.root, "prepare-run.json")); !os.IsNotExist(err) { t.Fatalf("the provider prepared a run that nothing could debug: %v", err) @@ -373,9 +373,9 @@ func TestServiceRunOutlivesItsPreparationBound(t *testing.T) { if _, err := os.Stat(alive); err != nil { t.Fatalf("the service ended before it ran for %s: status %q, console:\n%s", fixtureServiceAliveAfter, p.build.status, op.session.output.all()) } - if p.build.operation != op { + if !p.build.owns(op) { t.Fatal("the service is not running after it outlived its preparation bound") } - h.app.post(func(a *App) { a.stopBuildOperation(p) }) - awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool { return p.build.operation == nil }) + h.app.post(func(a *App) { a.stopOperation(p, op) }) + awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool { return !p.build.active() }) } diff --git a/desktop/internal/workbench/build_connection_debug_visual_test.go b/desktop/internal/workbench/build_connection_debug_visual_test.go index d0a6caa30a..75868ac3e1 100644 --- a/desktop/internal/workbench/build_connection_debug_visual_test.go +++ b/desktop/internal/workbench/build_connection_debug_visual_test.go @@ -78,7 +78,7 @@ func TestVisualServiceDebugWithoutAnAdapter(t *testing.T) { if !h.shows(want) { t.Fatal("the notification history did not paint the whole notice") } - if p.build.operation != nil || p.debug.activeSession() != nil { + if p.build.active() || p.debug.activeSession() != nil { t.Fatal("a refused debug started something") } }) diff --git a/desktop/internal/workbench/build_menus.go b/desktop/internal/workbench/build_menus.go index 9d3bb260d0..d3ac186068 100644 --- a/desktop/internal/workbench/build_menus.go +++ b/desktop/internal/workbench/build_menus.go @@ -49,7 +49,7 @@ func (a *App) buildRowMenu(c ui.C, row ui.Box, p *project, instance *buildInstan continue } runID := run.ID - if menu.Item(a.text.Build.RunTarget(run.ActionName(spec.target.Name))).Disabled(b.operation != nil || instance.modelLoading).Clicked() { + if menu.Item(a.text.Build.RunTarget(run.ActionName(spec.target.Name))).Disabled(instance.modelLoading).Clicked() { c.After(func() { a.performed("build.target.run", surfaceContextMenu) choose() @@ -60,7 +60,7 @@ func (a *App) buildRowMenu(c ui.C, row ui.Box, p *project, instance *buildInstan // The same target under the debugger, when the run declares how: an adapter of its // own plugin starts the program the provider prepares, or the registered adapter of // its public type attaches to the service the provider starts. - if run.Debuggable() && menu.Item(i18n.Shared(lang, "desktop.build.debugTarget")).Disabled(b.operation != nil || instance.modelLoading || p.debug.preparing).Clicked() { + if run.Debuggable() && menu.Item(i18n.Shared(lang, "desktop.build.debugTarget")).Disabled(instance.modelLoading || p.debug.preparing).Clicked() { c.After(func() { a.performed("build.target.debug", surfaceContextMenu) choose() @@ -70,7 +70,7 @@ func (a *App) buildRowMenu(c ui.C, row ui.Box, p *project, instance *buildInstan } for _, entry := range buildTargetRunEntries(instance, targetID) { entryID := entry.ID - if menu.Item(a.text.Build.RunTarget(entry.Name)).Disabled(b.operation != nil || instance.modelLoading).Clicked() { + if menu.Item(a.text.Build.RunTarget(entry.Name)).Disabled(instance.modelLoading).Clicked() { c.After(func() { a.performed("build.target.run", surfaceContextMenu) choose() diff --git a/desktop/internal/workbench/build_panels_visual_test.go b/desktop/internal/workbench/build_panels_visual_test.go index bc3191f5d7..b805f4f8da 100644 --- a/desktop/internal/workbench/build_panels_visual_test.go +++ b/desktop/internal/workbench/build_panels_visual_test.go @@ -136,7 +136,7 @@ func TestVisualBuildPanels(t *testing.T) { t.Fatal(err) } for _, look := range []struct{ theme, language string }{{"dark", "zh-Hans"}, {"light", "en"}} { - for _, scene := range []string{"build-and-run", "build-sync", "build-filter", "build-go-targets"} { + for _, scene := range []string{"build-and-run", "concurrent-runs", "build-sync", "build-filter", "build-go-targets"} { t.Run(scene+"-"+look.theme, func(t *testing.T) { prefs := store.At(t.TempDir()) if err := prefs.Save(settingsFile, settings{Theme: themeChoice(look.theme), Language: look.language, DisableAutoSave: true}); err != nil { @@ -203,6 +203,23 @@ func TestVisualBuildPanels(t *testing.T) { a.finishBuildTask(p, op, json.RawMessage(`{"exitCode":0}`)) a.showBuildConsole(p) }) + case "concurrent-runs": + h.app.post(func(a *App) { + // Two services at once (#2071): one still prepared, with a spinner, and one + // whose process runs, with the static run mark and its address linked. + a.beginRunOperation(p, "ShopWorker", "worker", configurationRunKey("worker"), func(*App, *project) {}) + op := a.beginRunOperation(p, "ShopApplication", "web", configurationRunKey("web"), func(*App, *project) {}) + op.session.processRunning = true + a.setOperationStatus(p, op, a.text.Build.Running) + feedBuildOutput(a, p, op, strings.Join([]string{ + " . ____ _ __ _ _\n", + " :: Spring Boot :: (v3.3.4)\n", + "INFO o.s.b.w.e.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'\n", + "INFO demo.web.ShopApplication : Started ShopApplication in 1.912 seconds\n", + "INFO demo.web.ShopApplication : Open http://localhost:8080/swagger-ui/index.html.\n", + }, "")) + a.showBuildConsole(p) + }) case "build-sync": h.app.post(func(a *App) { // The Go module's model still loads, as go downloads the modules it needs. diff --git a/desktop/internal/workbench/build_tree_test.go b/desktop/internal/workbench/build_tree_test.go index 768ebc690a..f7a5573b67 100644 --- a/desktop/internal/workbench/build_tree_test.go +++ b/desktop/internal/workbench/build_tree_test.go @@ -801,12 +801,16 @@ func TestBuildTreeRunMarksRunTheirRowsAtOnce(t *testing.T) { } awaitStateWithin(t, h, 10*time.Second, "the refused plan", func() bool { return p.build.operation == nil }) - // While a build operation runs, no triangle takes a click. + // While a build operation runs, a task's triangle takes no click, since the Build window + // runs one task at a time; a target's run runs beside it, so its triangle still does. var operation *buildOperation h.app.post(func(a *App) { operation = a.beginBuildOperation(p, "build", "vet", "", nil) }) h.settle() - if len(controls(text.RunTarget("Vet verification"))) != 0 || len(controls(text.RunTarget("Run"))) != 0 { - t.Fatal("a triangle took clicks while a build operation ran") + if len(controls(text.RunTarget("Vet verification"))) != 0 { + t.Fatal("a task's triangle took clicks while a build operation ran") + } + if len(controls(text.RunTarget("Run"))) != 1 { + t.Fatal("a target's triangle took no click while a build operation ran") } h.app.post(func(a *App) { a.finishBuildTask(p, operation, json.RawMessage(`{"exitCode":0}`)) }) h.settle() diff --git a/desktop/internal/workbench/build_tree_view.go b/desktop/internal/workbench/build_tree_view.go index 5c0073941c..80ef252ff5 100644 --- a/desktop/internal/workbench/build_tree_view.go +++ b/desktop/internal/workbench/build_tree_view.go @@ -28,14 +28,14 @@ func (a *App) buildToolActions(c ui.C, p *project) { if !ok { label = t.ChooseTask } - if _, hit := a.toolIconButton(c.Part("run"), label, icons.Play, false, !ok || b.operation != nil); hit { + if _, hit := a.toolIconButton(c.Part("run"), label, icons.Play, false, !ok || b.taskID != "" && b.operation != nil); hit { c.After(func() { a.performed("build.runChosen", surfaceButton) run() a.showBuildConsole(p) }) } - if _, hit := a.toolIconButton(c.Part("stop"), runStopLabel(language, p), icons.Square, false, b.operation == nil); hit { + if _, hit := a.toolIconButton(c.Part("stop"), runStopLabel(language, b.latest()), icons.Square, false, !b.active()); hit { c.After(func() { a.performed("build.stop", surfaceButton) a.stopBuildOperation(p) @@ -516,7 +516,9 @@ func (a *App) buildItemRow(row ui.ListRow, p *project, instance *buildInstance, if tip := buildItemTip(spec); tip != "" { element = element.Tooltip(tip) } - busy := b.operation != nil || instance.modelLoading + // A task waits for the Build window's operation; a target's run runs beside it and the + // other runs. + busy := instance.modelLoading || spec.kind == buildRowTask && b.operation != nil index := spec.instance // choose makes the row the window's choice, the node's project, target and task as Core // placed it; run, when set, then starts what it runs. diff --git a/desktop/internal/workbench/ide_api_dispatch.go b/desktop/internal/workbench/ide_api_dispatch.go index 5862fbfb2a..a11064e8f7 100644 --- a/desktop/internal/workbench/ide_api_dispatch.go +++ b/desktop/internal/workbench/ide_api_dispatch.go @@ -438,19 +438,25 @@ func (a *App) ideAPIOperationOutput(ctx context.Context, conn *ideAPIConnection, // ideAPISnapshot marks an operation snapshot apart from a failure, which has the same map type. type ideAPISnapshot map[string]any -// ideAPIOperationStop asks the execution id names to stop. Only the window's current execution -// can be active, so a stop never reaches another one; an execution that already ended, or is -// already stopping, is answered with its state unchanged. +// ideAPIOperationStop asks the execution id names to stop: the Build window's operation or one +// of the runs. An execution that already ended, or is already stopping, is answered with its +// state unchanged. func (a *App) ideAPIOperationStop(p *project, id string) any { operation, failure := p.ideAPIOperationByID(id) if failure != nil { return failure } if !operation.terminal() && operation.State != "stopping" { - if p.build.operation == nil || p.build.operation.ide != operation { + live := p.build.latest() + for _, op := range append([]*buildOperation{p.build.operation}, p.build.running...) { + if op != nil && op.ide == operation { + live = op + } + } + if live == nil || live.ide != operation { return ideAPIFailure("OPERATION_EXPIRED", "The operation is no longer the window's execution") } - a.stopBuildOperation(p) + a.stopOperation(p, live) } return map[string]any{"operationID": operation.ID, "state": operation.State} } @@ -516,10 +522,7 @@ func ideAPIBuildInspect(p *project) any { if instance := p.selectedBuildInstance(); instance != nil { selected["instanceID"] = instance.ID } - running := false - if p.build.operation != nil { - running = true - } + running := p.build.active() return map[string]any{ "instances": instances, "selected": selected, diff --git a/desktop/internal/workbench/outputlinks.go b/desktop/internal/workbench/outputlinks.go index 69ffaf469c..2aefb242d8 100644 --- a/desktop/internal/workbench/outputlinks.go +++ b/desktop/internal/workbench/outputlinks.go @@ -5,9 +5,11 @@ import ( "encoding/json" "os" "sort" + "strings" "time" "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" ) const ( @@ -24,7 +26,8 @@ const ( ) // outputLinkState is one project's output link matchers and what Core answered -// for the console lines shown so far. Core decides what is a link; this only +// for the console lines shown so far. Core decides what is a link, the web +// addresses a line prints too, so lines are matched without any plugin; this only // remembers the answers so a line is matched once, not on every frame. type outputLinkState struct { sources []core.OutputLinkSource @@ -59,7 +62,9 @@ func (a *App) outputLinksFor(p *project, scope, line string) []core.OutputLink { } return nil } - if len(l.sources) == 0 || line == "" { + // Core links web addresses with no matcher, so a window without plugins asks too, + // but only for a line that could hold one. + if line == "" || len(l.sources) == 0 && !strings.Contains(line, "://") { return nil } key := outputLinkKey(scope, line) @@ -114,7 +119,12 @@ func (a *App) flushOutputLinks(p *project) { } l.wanted = nil l.inFlight = true + // A window without plugins still asks for the web addresses, with an empty list Core + // accepts rather than null. sources := l.sources + if sources == nil { + sources = []core.OutputLinkSource{} + } roots := []string{p.root} kernel := a.kernel a.background(p, outputLinkTimeout, func(ctx context.Context) func(*App) { @@ -166,13 +176,19 @@ func (a *App) flushOutputLinks(p *project) { }) } -// openOutputLink opens what a clicked link points at. A location names candidate -// files and opens the first that exists; a link that needs its plugin asks the -// plugin's backend first. Both run off the window thread, and a file that does -// not exist is a notice, not a navigation. +// openOutputLink opens what a clicked link points at. A web address opens in the +// browser. A location names candidate files and opens the first that exists; a +// link that needs its plugin asks the plugin's backend first. Both run off the +// window thread, and a file that does not exist is a notice, not a navigation. func (a *App) openOutputLink(p *project, link core.OutputLink) { messages := a.text.Run switch { + case link.URL != "": + a.performed("output.link.openURL", surfaceButton) + if err := openURL(link.URL); err != nil { + a.operationFailed("output_link_open_url", err) + a.notifyError(i18n.SharedFormat(a.language(), "desktop.editor.linkOpenFailed", map[string]string{"reason": err.Error()})) + } case link.Location != nil: location := *link.Location a.background(p, outputLinkTimeout, func(ctx context.Context) func(*App) { diff --git a/desktop/internal/workbench/outputlinks_test.go b/desktop/internal/workbench/outputlinks_test.go index e5c70a6baf..ca7afa8540 100644 --- a/desktop/internal/workbench/outputlinks_test.go +++ b/desktop/internal/workbench/outputlinks_test.go @@ -139,3 +139,33 @@ func TestOutputLinkToAMissingFileOnlyNotifies(t *testing.T) { t.Fatal("a link to a missing file opened a document") } } + +// A web address a run prints opens in the browser when clicked, with no plugin +// declaring a matcher (#1822): Core links addresses itself, so the window asks it +// even without plugins. The trailing period is not part of the address. +func TestRunOutputWebAddressOpensInTheBrowser(t *testing.T) { + var opened []string + previous := openURL + openURL = func(url string) error { + opened = append(opened, url) + return nil + } + t.Cleanup(func() { openURL = previous }) + h := newHarness(t, &testKernel{Client: core.NewClient()}) + root := t.TempDir() + h.open(root) + h.app.reduceChrome(core.ToggleChrome(itemRun)) + p := h.app.project + h.startRunConsole(root, "boot ok\nTomcat started on http://localhost:8080/.\n") + for range 6 { + h.settle() + } + if links := p.links.links[outputLinkKey(outputScopeRun, "boot ok")]; len(links) != 0 { + t.Fatalf("a line without an address has links %+v", links) + } + h.clickNamed("http://localhost:8080/") + h.settle() + if len(opened) != 1 || opened[0] != "http://localhost:8080/" { + t.Fatalf("opened %q, want the address", opened) + } +} diff --git a/desktop/internal/workbench/run_view.go b/desktop/internal/workbench/run_view.go index 8c8ed812b6..79c02f2a12 100644 --- a/desktop/internal/workbench/run_view.go +++ b/desktop/internal/workbench/run_view.go @@ -109,7 +109,9 @@ func (a *App) runSessionTabs(c ui.C, p *project) { // time; a stop asked of a host's execution already stopping forces it. func (a *App) runToolbar(c ui.C, p *project, run *runEntry) { ui.Column(c).FillHeight().Shrink(0).Gap(2).Pad(4).Children(func() { - rerunnable := run.restart != nil && p.build.operation == nil || run.restart == nil && run.rerun != nil + // A task reruns only while the Build window runs no other; a run reruns at any time, + // replacing a run of the same key (startRun). + rerunnable := run.restart != nil && (run.operation == nil || run.operation.key != "" || p.build.operation == nil) || run.restart == nil && run.rerun != nil if a.runToolButton(c.Part("rerun"), a.text.Run.Rerun, icons.RotateCcw, a.colors.Success, run.running || !rerunnable) { c.After(func() { a.rerunRun(p, run) }) } @@ -214,17 +216,23 @@ func runDetail(p *project, run *runEntry) string { if run.sync != nil && run.running { return run.sync.latest } - if run.operation != nil && p.build.operation == run.operation { - return p.build.status + if run.operation != nil && p.build.owns(run.operation) { + return run.operation.status } return "" } // runStatusMark declares the icon of where an execution stands, size pixels square, as IDEA marks -// one: a spinner while it runs, a green check once it succeeded, a red cross once it failed, and -// a grey slash once the user stopped it. +// one: a spinner while it is being prepared or a model loads, a green run mark once its process +// runs, a green check once it succeeded, a red cross once it failed, and a grey slash once the +// user stopped it. A service runs until it is stopped, so a spinner for as long as it runs would +// never say it started. func (a *App) runStatusMark(c ui.C, run *runEntry, size float32) { k := c.Part("status") + if run.running && run.processRunning { + ui.Icon(k, icons.Play).Size(size, size).Shrink(0).Color(a.colors.Success) + return + } if run.running { ui.Spinner(k).Size(size, size).Shrink(0) return @@ -296,7 +304,7 @@ func (a *App) runConsole(c ui.C, p *project, run *runEntry) { // there, on the host's execution that runs; a run a plugin starts selects its own tab when it // starts. func (a *App) showBuildConsole(p *project) { - if operation := p.build.operation; operation != nil && operation.session != nil { + if operation := p.build.latest(); operation != nil && operation.session != nil { p.build.view = operation.session.id } a.openToolWindow(itemRun) diff --git a/desktop/internal/workbench/runconfig.go b/desktop/internal/workbench/runconfig.go index 0e0d53a3bc..a390d0faf2 100644 --- a/desktop/internal/workbench/runconfig.go +++ b/desktop/internal/workbench/runconfig.go @@ -188,7 +188,7 @@ func (a *App) finishRunConfigurations(p *project, generation uint64, resolved co s.reveal = "" if start := s.start; start != "" { s.start = "" - if s.configuration(start) != nil && p.build.operation == nil { + if s.configuration(start) != nil { s.selected = start a.runConfiguration(p, start) } @@ -210,11 +210,17 @@ func (a *App) finishRunConfigurations(p *project, generation uint64, resolved co // button that is disabled; the IDE API reports it through startRunConfiguration, which // leaves the windows as they are. func (a *App) runConfiguration(p *project, id string) { - if _, err := a.startRunConfiguration(p, id); err == nil { - a.showBuildConsole(p) - } + // A configuration that runs is stopped first and started again once it ended (startRun). + a.startRun(p, configurationRunKey(id), func(a *App, p *project) { + if _, err := a.startRunConfiguration(p, id); err == nil { + a.showBuildConsole(p) + } + }) } +// configurationRunKey is the run key of run configuration id. +func configurationRunKey(id string) string { return "config:" + id } + // startRunConfiguration checks the request on the window thread, reserves the run as the // window's operation and starts it once unsaved documents are saved, so the run reads the files // on disk. The instance must be loaded, since the target is taken from its current model. A @@ -231,8 +237,8 @@ func (a *App) startRunConfigurationWith(p *project, id string, debug *connection if configuration == nil { return nil, refuseBuild(refusalNotFound, "unknown run configuration") } - if p.build.operation != nil { - return nil, errBuildBusy + if p.build.runOf(configurationRunKey(id)) != nil { + return nil, errRunRunning } if configuration.Unavailable() { message := a.runConfigUnavailableText(*configuration) @@ -260,7 +266,7 @@ func (a *App) startRunConfigurationWith(p *project, id string, debug *connection if debug != nil { configurationType = debug.launch.ConfigurationType } - op := a.beginBuildOperation(p, "run", configuration.Name, id, func(a *App, p *project) { + op := a.beginRunOperation(p, configuration.Name, id, configurationRunKey(id), func(a *App, p *project) { if debug != nil { a.debugRunConfiguration(p, id, configurationType) return @@ -289,7 +295,7 @@ func (a *App) startRunConfigurationWith(p *project, id string, debug *connection return func(a *App) { a.finishBuildError(p, op, err) } } return func(a *App) { - if op.cancelled || p.build.operation != op { + if op.cancelled || !p.build.owns(op) { a.finishBuildError(p, op, context.Canceled) return } diff --git a/desktop/internal/workbench/runconfig_browser.go b/desktop/internal/workbench/runconfig_browser.go index 613911b645..9f7549fda8 100644 --- a/desktop/internal/workbench/runconfig_browser.go +++ b/desktop/internal/workbench/runconfig_browser.go @@ -245,15 +245,6 @@ func (s *runConfigState) toggleRunConfigGroup(key string) { } } -// runningConfiguration is the run configuration the Build window's operation runs, "" when it -// runs none. -func (p *project) runningConfiguration() string { - if p.build.operation == nil { - return "" - } - return p.build.operation.configuration -} - // loadRunConfigPins reads the pinned configurations of the project the first time its // configurations resolve. A store that cannot be read leaves nothing pinned and says why. func (a *App) loadRunConfigPins(p *project) { diff --git a/desktop/internal/workbench/runconfig_browser_test.go b/desktop/internal/workbench/runconfig_browser_test.go index c4154ff66b..3adc09b0da 100644 --- a/desktop/internal/workbench/runconfig_browser_test.go +++ b/desktop/internal/workbench/runconfig_browser_test.go @@ -163,8 +163,8 @@ func TestRunConfigurationListScopesGroupsPinsAndRuns(t *testing.T) { h.settle() // The row of the configuration that runs shows it running, and its button stops it. - operation := &buildOperation{configuration: serve} - h.app.post(func(*App) { p.build.operation = operation }) + operation := &buildOperation{configuration: serve, key: configurationRunKey(serve)} + h.app.post(func(*App) { p.build.running = []*buildOperation{operation} }) h.settle() if !h.shows(i18n.Shared(lang, "native.running")) { t.Fatal("the running configuration's row does not say it runs") @@ -174,7 +174,7 @@ func TestRunConfigurationListScopesGroupsPinsAndRuns(t *testing.T) { if !operation.cancelled { t.Fatal("the row's stop button did not stop the run") } - h.app.post(func(*App) { p.build.operation = nil }) + h.app.post(func(*App) { p.build.running = nil }) h.settle() // Unpinning drops the project from the store. diff --git a/desktop/internal/workbench/runconfig_form_view.go b/desktop/internal/workbench/runconfig_form_view.go index 1bfcc13507..34b72e1459 100644 --- a/desktop/internal/workbench/runconfig_form_view.go +++ b/desktop/internal/workbench/runconfig_form_view.go @@ -212,7 +212,7 @@ func (a *App) drawRunConfigForm(c ui.C, p *project) { }) }, func() { ui.Row(c.Part("run-config-form-footer")).FillWidth().Items(ui.Center).Gap(8).Children(func() { - if ui.Button(c, i18n.Shared(language, "desktop.runConfig.run")).Icon(icons.Play).Outline().Disabled(!ready || p.build.operation != nil).Clicked() { + if ui.Button(c, i18n.Shared(language, "desktop.runConfig.run")).Icon(icons.Play).Outline().Disabled(!ready).Clicked() { c.After(func() { a.performed("run.configuration.form.run", surfaceButton) a.saveRunConfigForm(p, runConfigFormRun) diff --git a/desktop/internal/workbench/runconfig_process.go b/desktop/internal/workbench/runconfig_process.go index a3937ca358..dce23668f7 100644 --- a/desktop/internal/workbench/runconfig_process.go +++ b/desktop/internal/workbench/runconfig_process.go @@ -34,11 +34,12 @@ const inlineScriptDirectoryPattern = "lithe-run-script-" // errRunProgramNotFound is a planned command that no PATH directory holds. var errRunProgramNotFound = errors.New("run program not found") -// startProcessRun reserves the run as the window's operation and starts it once unsaved -// documents are saved, so the process reads the files on disk. Rerun starts it again. +// startProcessRun begins the configuration's run beside the window's other executions and +// starts it once unsaved documents are saved, so the process reads the files on disk. Rerun +// starts it again. func (a *App) startProcessRun(p *project, configuration core.RunConfiguration) *buildOperation { id := configuration.ID - op := a.beginBuildOperation(p, "run", configuration.Name, id, func(a *App, p *project) { + op := a.beginRunOperation(p, configuration.Name, id, configurationRunKey(id), func(a *App, p *project) { a.runConfiguration(p, id) }) a.saveProjectDocuments(p, func(ok bool) { diff --git a/desktop/internal/workbench/runconfig_process_test.go b/desktop/internal/workbench/runconfig_process_test.go index 50a9a743ed..d2208a32f9 100644 --- a/desktop/internal/workbench/runconfig_process_test.go +++ b/desktop/internal/workbench/runconfig_process_test.go @@ -249,7 +249,7 @@ func awaitProcessRun(t *testing.T, h *harness, p *project, label string, previou }() awaitStateWithin(t, h, 20*time.Second, "the run of "+label, func() bool { for _, entry := range p.build.runs { - if entry != previous && entry.label == label && !entry.running && p.build.operation == nil { + if entry != previous && entry.label == label && !entry.running && !p.build.active() { found = entry return true } diff --git a/desktop/internal/workbench/runconfig_view.go b/desktop/internal/workbench/runconfig_view.go index 1262af8c7d..3c599b8754 100644 --- a/desktop/internal/workbench/runconfig_view.go +++ b/desktop/internal/workbench/runconfig_view.go @@ -169,7 +169,7 @@ func (a *App) drawRunConfigRows(c ui.C, p *project, title string) { if row.configuration < 0 { key := b.groups[row.group].key c.After(func() { s.toggleRunConfigGroup(key) }) - } else if configuration := s.list[row.configuration]; p.build.operation == nil && p.runConfigurationReady(configuration) { + } else if configuration := s.list[row.configuration]; p.runConfigurationReady(configuration) { c.After(func() { a.performed("run.configuration.run", surfaceButton) a.runConfiguration(p, configuration.ID) @@ -201,7 +201,7 @@ func (a *App) drawRunConfigRow(p *project, row ui.ListRow, selected bool) { return } configuration := s.list[r.configuration] - running := p.runningConfiguration() == configuration.ID + running := p.build.runOf(configurationRunKey(configuration.ID)) a.runConfigMenu(c, box, p, configuration, running) unavailable := configuration.Unavailable() if unavailable { @@ -223,14 +223,14 @@ func (a *App) drawRunConfigRow(p *project, row ui.ListRow, selected bool) { } ui.Spacer(c) language := a.language() - if running { + if running != nil { ui.Text(c, i18n.Shared(language, "native.running")).FontSize(small).Color(a.colors.Subtle).Shrink(0) - if a.gitIconButton(c.Part("stop"), runStopLabel(language, p), icons.Square, false, false) { - c.After(func() { a.stopBuildOperation(p) }) + if a.gitIconButton(c.Part("stop"), runStopLabel(language, running), icons.Square, false, false) { + c.After(func() { a.stopOperation(p, running) }) } return } - disabled := p.build.operation != nil || !p.runConfigurationReady(configuration) + disabled := !p.runConfigurationReady(configuration) if a.gitIconButton(c.Part("run"), i18n.Shared(language, "desktop.runConfig.run"), icons.Play, false, disabled) { c.After(func() { a.performed("run.configuration.run", surfaceButton) @@ -240,10 +240,10 @@ func (a *App) drawRunConfigRow(p *project, row ui.ListRow, selected bool) { }) } -// runStopLabel names the stop of the project's running configuration: stopping one that is -// already stopping kills it at once. -func runStopLabel(language i18n.Language, p *project) string { - if p.build.operation != nil && p.build.operation.cancelled { +// runStopLabel names the stop of an execution: stopping one that is already stopping kills it +// at once. +func runStopLabel(language i18n.Language, op *buildOperation) string { + if op != nil && op.cancelled { return i18n.Shared(language, "desktop.process.forceStop") } return i18n.Shared(language, "native.stopRun.variant2") @@ -269,16 +269,17 @@ func (a *App) drawRunConfigGroupArrow(c ui.C, s *runConfigState, group runConfig } // runConfigMenu declares the context menu of a configuration's row: run it or stop its run, -// edit it, delete one the user created, and pin or unpin it. -func (a *App) runConfigMenu(c ui.C, row ui.Box, p *project, configuration core.RunConfiguration, running bool) { +// edit it, delete one the user created, and pin or unpin it. running is the configuration's run, +// nil when it runs none. +func (a *App) runConfigMenu(c ui.C, row ui.Box, p *project, configuration core.RunConfiguration, running *buildOperation) { ui.ContextMenu(c, row, func(menu *ui.MenuItems) { language, id := a.language(), configuration.ID menu.WidthRange(180, 280) - if running { - if menu.Item(runStopLabel(language, p)).Clicked() { - c.After(func() { a.stopBuildOperation(p) }) + if running != nil { + if menu.Item(runStopLabel(language, running)).Clicked() { + c.After(func() { a.stopOperation(p, running) }) } - } else if menu.Item(i18n.Shared(language, "desktop.runConfig.run")).Disabled(p.build.operation != nil || !p.runConfigurationReady(configuration)).Clicked() { + } else if menu.Item(i18n.Shared(language, "desktop.runConfig.run")).Disabled(!p.runConfigurationReady(configuration)).Clicked() { c.After(func() { a.performed("run.configuration.run", surfaceContextMenu) a.runConfiguration(p, id) @@ -292,7 +293,7 @@ func (a *App) runConfigMenu(c ui.C, row ui.Box, p *project, configuration core.R }) } if configuration.UserDefined() { - if menu.Item(i18n.Shared(language, "desktop.runConfig.delete")).Destructive().Disabled(running).Clicked() { + if menu.Item(i18n.Shared(language, "desktop.runConfig.delete")).Destructive().Disabled(running != nil).Clicked() { name := configuration.Name c.After(func() { a.performed("run.configuration.delete", surfaceContextMenu) diff --git a/desktop/internal/workbench/runs.go b/desktop/internal/workbench/runs.go index d76eaf5791..1fe8cf2eeb 100644 --- a/desktop/internal/workbench/runs.go +++ b/desktop/internal/workbench/runs.go @@ -59,7 +59,11 @@ type runEntry struct { // output is the console, decoded from the execution's ANSI escapes. output outputBuffer running bool - outcome runOutcome + // processRunning says the execution's process started: before it, the execution is still + // being prepared (planned, compiled, asked of a provider) and the Run window shows a + // spinner; after it, a static running mark, since a service may run for hours. + processRunning bool + outcome runOutcome // stopping is set when the user stopped a plugin's run, so its end reads as stopped. stopping bool started, ended time.Time @@ -219,7 +223,7 @@ func (a *App) applyRunEvent(event pluginservice.RunEvent) { p.links.loaded, p.links.sources = false, nil entry := &runEntry{ id: event.RunID, pluginID: event.PluginID, label: event.Label, rerun: event.Rerun, running: true, - started: a.now(), output: newOutputBuffer(runOutputMaxLines, runOutputBytes), + processRunning: true, started: a.now(), output: newOutputBuffer(runOutputMaxLines, runOutputBytes), } a.addRunSession(p, entry) if event.PID > 0 { @@ -366,9 +370,7 @@ func (a *App) stopRun(p *project, entry *runEntry) { return } if entry.pluginID == "" { - if entry.operation != nil && p.build.operation == entry.operation { - a.stopBuildOperation(p) - } + a.stopOperation(p, entry.operation) return } if a.plugins == nil { diff --git a/desktop/internal/workbench/tests_provider_test.go b/desktop/internal/workbench/tests_provider_test.go index b1bb8c0cf7..bc08954749 100644 --- a/desktop/internal/workbench/tests_provider_test.go +++ b/desktop/internal/workbench/tests_provider_test.go @@ -485,10 +485,10 @@ func TestProviderRunPreparationShowsItsBuildOutput(t *testing.T) { var op *buildOperation h.app.post(func(a *App) { a.runBuildTarget(p, targetID, "application") - op = p.build.operation + op = p.build.latest() }) awaitStateWithin(t, h, time.Minute, "the run operation", func() bool { return op != nil }) - awaitStateWithin(t, h, time.Minute, "the failed preparation", func() bool { return p.build.operation == nil }) + awaitStateWithin(t, h, time.Minute, "the failed preparation", func() bool { return !p.build.active() }) if console := op.session.output.all(); !strings.Contains(console, "class, interface, enum, or record expected") { t.Fatalf("the run console = %q, want the provider's build output", console) } diff --git a/desktop/internal/workbench/title_run.go b/desktop/internal/workbench/title_run.go index ef1a41bfdc..59c933c1b8 100644 --- a/desktop/internal/workbench/title_run.go +++ b/desktop/internal/workbench/title_run.go @@ -257,9 +257,7 @@ func (a *App) decideTitleAction(p *project, action titleAction, trigger string) a.operationFailed("title_run", errors.New(failure)) a.notifyError(failure) case "run": - if _, err := a.startRunConfiguration(p, configuration.ID); errors.Is(err, errBuildBusy) { - a.notifyInfo(i18n.Shared(a.language(), "desktop.title.runBusy")) - } + a.runConfiguration(p, configuration.ID) case "debug": // A run that names a public debug type debugs as a service the registered adapter of // that type attaches to; one that names its own plugin's adapter debugs a prepared program. diff --git a/docs/assets/concurrent-runs/concurrent-runs-dark.png b/docs/assets/concurrent-runs/concurrent-runs-dark.png new file mode 100644 index 0000000000..a3706f2248 Binary files /dev/null and b/docs/assets/concurrent-runs/concurrent-runs-dark.png differ diff --git a/docs/assets/concurrent-runs/concurrent-runs-light.png b/docs/assets/concurrent-runs/concurrent-runs-light.png new file mode 100644 index 0000000000..761a1cfabc Binary files /dev/null and b/docs/assets/concurrent-runs/concurrent-runs-light.png differ diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index 4c970e341b..4ae3ec8c38 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -8884,7 +8884,7 @@ }, { "id": "desktop.editor.linkOpenFailed", - "description": "Notification when the system cannot open a web or mail link from the editor; {reason} is the system's error", + "description": "Notification when the system cannot open a web or mail link from the editor or a web address in a Run or Test console; {reason} is the system's error", "platforms": [ "desktop" ], diff --git a/shared/platform-feature-matrix/features/run-concurrent-executions.json b/shared/platform-feature-matrix/features/run-concurrent-executions.json new file mode 100644 index 0000000000..17f2db42b7 --- /dev/null +++ b/shared/platform-feature-matrix/features/run-concurrent-executions.json @@ -0,0 +1,37 @@ +{ + "id": "run-concurrent-executions", + "area": "运行与调试", + "group": "运行输出", + "capability": "像 IntelliJ IDEA 一样同时运行多个服务:不同运行配置、不同构建目标的运行可以并行,每个运行有自己的 Run 标签、状态和停止按钮;再次运行一个正在运行的配置时先停止旧进程,结束后再启动新进程;Run 标签和执行树在准备阶段显示转圈,进程启动后显示静态的绿色运行图标", + "owner": "Run", + "notes": "Viva 共享实现。运行按键区分(运行配置 config:、构建目标 target:<实例>/<目标>/<运行>、命令入口 entry:<实例>/<入口>),存在 buildState.running;构建任务、模型加载和 IDE API 的构建仍然独占 buildState.operation,一次一个。调试仍是每个项目一个会话。IDE API 对正在运行的配置再次 start 返回 BUSY。内置进程运行(Shell、PowerShell、cmd、可执行程序)同样按配置键并行。插件经 lithe/host/run/start 发起的运行一开始就显示运行图标(进程已由插件服务启动)。", + "verification": "打开含两个服务运行配置的项目,先运行 A,再运行 B,确认两个 Run 标签同时为运行状态、两个进程都在;在运行配置列表里分别点停止,只停对应的那个。运行中再次运行 A,确认旧 A 先结束(状态为已停止)再启动新 A,端口不冲突。服务准备期间标签显示转圈,进程启动后变为静态绿色三角。构建任务运行时目标的运行按钮仍可用、任务按钮不可用。自动化:build_concurrent_runs_test.go 的 TestRunsOfDifferentKeysRunTogether、TestStartRunReplacesTheRunOfItsKeyOnceItEnded、TestServiceRunShowsRunningAndRestartsInPlace,build_tree_test.go 的 TestBuildTreeRunMarksRunTheirRowsAtOnce。", + "macos": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/workbench/build.go", + "desktop/internal/workbench/runconfig.go", + "desktop/internal/workbench/runconfig_process.go", + "desktop/internal/workbench/runconfig_view.go", + "desktop/internal/workbench/run_view.go", + "desktop/internal/workbench/runs.go", + "desktop/internal/workbench/build_tree_view.go", + "desktop/internal/workbench/build_concurrent_runs_test.go" + ] + }, + "windows": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/workbench/build.go", + "desktop/internal/workbench/runconfig.go", + "desktop/internal/workbench/runconfig_process.go", + "desktop/internal/workbench/runconfig_view.go", + "desktop/internal/workbench/run_view.go", + "desktop/internal/workbench/runs.go", + "desktop/internal/workbench/build_tree_view.go", + "desktop/internal/workbench/build_concurrent_runs_test.go" + ] + } +} diff --git a/shared/platform-feature-matrix/features/run-console-web-links.json b/shared/platform-feature-matrix/features/run-console-web-links.json new file mode 100644 index 0000000000..53696073c0 --- /dev/null +++ b/shared/platform-feature-matrix/features/run-console-web-links.json @@ -0,0 +1,29 @@ +{ + "id": "run-console-web-links", + "area": "运行与调试", + "group": "运行输出", + "capability": "运行和测试控制台里的 http/https 网址可点击,在系统浏览器中打开(例如 Spring Boot、Vite 启动后打印的访问地址),不需要任何插件声明匹配器", + "owner": "Run", + "notes": "Viva 共享实现。网址由 Core 的 outputLinks.match 在插件匹配器之后识别,返回不带插件的 url 链接;网址止于空白、引号、尖括号,不含句末标点和未配对的右括号,被插件链接覆盖的部分归插件链接。没有安装插件时只对含 :// 的行请求 Core。打开失败时提示 desktop.editor.linkOpenFailed。", + "verification": "运行一个打印“Tomcat started on http://localhost:8080/.”的服务,确认网址带下划线且句号不在链接内,点击后系统浏览器打开该地址;没有安装任何插件时同样可点。自动化:outputlinks_test.go 的 TestRunOutputWebAddressOpensInTheBrowser;Core 侧见 Lithe-core-rust#84 的 fixture。", + "macos": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/core/output_links.go", + "desktop/internal/workbench/outputlinks.go", + "desktop/internal/workbench/outputlinks_view.go", + "desktop/internal/workbench/outputlinks_test.go" + ] + }, + "windows": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/core/output_links.go", + "desktop/internal/workbench/outputlinks.go", + "desktop/internal/workbench/outputlinks_view.go", + "desktop/internal/workbench/outputlinks_test.go" + ] + } +}