diff --git a/.agents/notes/implemented/architecture/2026-11-18-builtin-process-runs-and-run-file-formats.md b/.agents/notes/implemented/architecture/2026-11-18-builtin-process-runs-and-run-file-formats.md index c2743f0896..71fce0f138 100644 --- a/.agents/notes/implemented/architecture/2026-11-18-builtin-process-runs-and-run-file-formats.md +++ b/.agents/notes/implemented/architecture/2026-11-18-builtin-process-runs-and-run-file-formats.md @@ -4,7 +4,9 @@ ## 先说结论 -Shell 脚本、PowerShell 脚本、cmd 批处理(只在 Windows)和可执行程序四种运行由 Core 自己提供,叫“内置运行”(provider 为 `process.*`)。它们的表单、校验和启动计划都在 Core,宿主只负责画表单、写文件和起进程,不经过任何构建插件,所以 Java 等插件缺失或出错时这四种运行照常可用。 +Shell 脚本、PowerShell 脚本、cmd 批处理(只能在 Windows 上运行)和可执行程序四种运行由 Core 自己提供,叫“内置运行”(provider 为 `process.*`)。它们的表单、校验和启动计划都在 Core,宿主只负责画表单、写文件和起进程,不经过任何构建插件,所以 Java 等插件缺失或出错时这四种运行照常可用。 + +运行配置在 IDEA 式的“运行/调试配置”对话框里新建和编辑:左侧是按类型分组的配置树,右侧是选中配置的编辑器,几处改动在“应用”或“确定”时一起保存。 用户保存的运行配置换成两种格式:内置运行存 `.lithe/run/configurations.yaml`(团队共享)和 `.lithe/run/local.yaml`(本机);插件提供的运行按插件拆成 `.lithe/run/plugin/<插件 ID>.toml` 和 `<插件 ID>.local.toml`,文件头记录插件的作者、仓库和版本要求。Core 只计算文件改动,不写文件,宿主按哈希检查后一次性应用。 @@ -21,7 +23,9 @@ Shell 脚本、PowerShell 脚本、cmd 批处理(只在 Windows)和可执行 `process.shell`、`process.powershell`、`process.batch`、`process.executable` 的运行类型列表(`runConfig.configurationTypes`)、表单(`runConfig.editorForm`)、保存校验(`runConfig.saveConfiguration`)和启动计划(`runConfig.createLaunchPlan`)都在 Core 的 `execution/src/configuration/process.rs` 与 `form.rs`。默认解释器由 Core 决定:Shell 取脚本首行的 `#!`,没有时用 `/bin/sh`;PowerShell 用 `pwsh`(Windows 上 `powershell`)并默认带 `-ExecutionPolicy Bypass`,用户可以取消。 -Core 只在 Windows 上列出 `process.batch`。其他平台上读到已有的 batch 条目时丢弃,并给出 `unsupportedPlatform` 诊断,界面上不出现 cmd。 +四种类型在所有平台都列出,都能新建、编辑和保存。本机不能运行的类型(目前只有 Windows 以外的 `process.batch`)带 `availability`,code 为 `unsupportedPlatform`:`runConfig.configurationTypes` 的类型项、`runConfig.editorForm` 的表单和 `resolve` 列出的每条配置都带,`runConfig.createLaunchPlan` 拒绝启动。这样和 Windows 同事共享的项目在 macOS、Linux 上打开时,批处理配置不会消失,也能照常修改。 + +宿主按 `availability` 提示,不自己判断平台:对话框的“+”菜单和空白页在类型旁注明“仅 Windows”;编辑器顶部显示原因;配置树和标题栏下拉的这一行带警告图标(下拉里仍可选中,注明“仅 Windows”);对话框的“运行”和标题栏的运行按钮置灰;按下标题栏运行时只提示原因,不启动。 宿主(`desktop/internal/workbench/runconfig_process.go`)拿到启动计划后只做三件事:在 PATH 里找可执行文件,把“脚本文本”写到系统临时目录里的 `lithe-run-script-*` 目录、进程退出后删除,然后用 `buildprocess` 起进程,输出进 Run 窗口。宿主不判断脚本类型,也不拼解释器参数。 @@ -52,6 +56,15 @@ Core 只在 Windows 上列出 `process.batch`。其他平台上读到已有的 b `runConfig.editorForm` 返回字段列表(类型、是否必填、位置、自动值、可选项、`visibleWhen` 条件、说明)和当前值,`formVersion` 为 1。宿主(`runconfig_form.go`、`runconfig_form_view.go`)只画同时满足两个条件的字段:类型是它认识的,`shared/i18n` 里有这个字段 ID 的标题。其余字段跳过不画,值原样回传。Core 返回的 `formVersion` 比宿主新时,宿主不打开表单,提示升级。 +### 在“运行/调试配置”对话框里新建和编辑 + +对话框参照 IDEA 的同名窗口(`runconfig_dialog.go`、`runconfig_dialog_view.go`),在应用窗口内以模态层显示,不开系统窗口。入口有三个:标题栏运行下拉的“新建运行配置…”和“编辑运行配置…”,以及构建窗口配置列表表头的“+”。列表里的编辑按钮也打开它,并选中那一条。 + +- 左侧工具栏是“+”(按类型新建)、“−”(删除)和复制。配置树按类型分组,分组可以折叠,折叠状态在再次打开时保留。 +- 每条被选中过的配置都有自己的草稿。新建、修改和删除都先记在草稿里:“应用”先删除,再按配置树的顺序保存有改动的草稿,完成后留在对话框;“确定”保存后关闭;“取消”丢弃全部改动;“运行”保存后关闭,并运行选中的配置。 +- 新建的配置第一次保存后换成 Core 给的 `user:` ID;只有 `user:` 配置能删除。第一处失败就停下,选中出错的那条配置并在它的编辑器里显示原因,对话框不关闭;失败前已保存的部分照常生效。 +- 构建插件提供的运行也在这个对话框里编辑,用的是 `runconfig_edit.go` 的编辑器;内置运行用 Core 描述的表单。 + ### 从界面按下运行时打开 Run 窗口 从编辑对话框的“运行”、构建窗口的配置列表(按钮或双击)和 Run 窗口的再次运行启动时,都走 `runConfiguration`(`runconfig.go`)。它启动后打开 Run 窗口,并选中这次运行的控制台;构建插件提供的运行从列表启动时也一样。经 IDE API(`startRunConfiguration`)启动的运行不改变窗口布局,因为调用方不一定是用户。 @@ -75,6 +88,14 @@ Core 只在 Windows 上列出 `process.batch`。其他平台上读到已有的 b 和其他运行走同一条路,Core 不多一类提供者。没有采用:用户要求插件全坏时这几种运行也能用,放进插件就又依赖插件宿主、插件安装和插件版本。 +### 在非 Windows 平台隐藏批处理 + +和平台能力一致,界面也更少。没有采用:项目里的批处理配置常由 Windows 同事提交,隐藏后 macOS、Linux 用户既看不到也改不了它们(Core 之前保留文本、只是不列出)。现在照常列出和编辑,只是不能运行。 + +### 标题栏用“新建运行配置 >”子菜单,每条配置单独弹编辑框 + +实现简单,点两下就能新建。没有采用:用户要求参照 IDEA,在一个窗口里同时看到全部配置、切换着编辑,改完一起应用;子菜单也放不下“仅 Windows”这类说明和以后更多的类型。 + ### 全部配置都用 YAML,或都用 TOML 一种格式更简单。没有采用:内置配置只有通用字段,YAML 适合手写和代码评审;插件配置要带一个“依赖哪个插件、哪个版本”的头,TOML 的 `[plugin]` 表把元数据和配置分得清楚。按插件拆文件后,卸载插件或插件出错只影响一份文件。 @@ -100,8 +121,8 @@ Core 只在 Windows 上列出 `process.batch`。其他平台上读到已有的 b ## 验证 -- `scripts/desktop/desktop-go.sh test ./internal/core/... ./internal/buildprocess/... ./internal/workbench/...`:`runconfig_process_test.go` 用系统 shell 真实运行脚本,并断言 Run 窗口打开、输出进入控制台;`runconfig_browser_test.go`、`title_run_test.go`、`runconfig_edit_test.go` 覆盖列表、标题栏和保存。 -- `scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run '^TestVisualBuiltInProcessRuns$'`:设置 `LITHE_VISUAL_OUTPUT_DIR` 后生成 `docs/assets/builtin-process-runs/` 的截图。 +- `scripts/desktop/desktop-go.sh test ./internal/core/... ./internal/buildprocess/... ./internal/workbench/...`:`runconfig_process_test.go` 用系统 shell 真实运行脚本,并断言 Run 窗口打开、输出进入控制台;`runconfig_dialog_test.go` 覆盖对话框的应用、取消、删除、复制、分组折叠,以及批处理在非 Windows 上能编辑、能保存、不能运行;`runconfig_browser_test.go`、`title_run_test.go`、`runconfig_edit_test.go` 覆盖列表、标题栏和插件运行的编辑。 +- `scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run '^(TestVisualBuiltInProcessRuns|TestVisualTitleRunWithoutConfigurations)$'`:设置 `LITHE_VISUAL_OUTPUT_DIR` 后生成 `docs/assets/builtin-process-runs/` 和 `docs/assets/run-config-empty/` 的截图。 - Core 仓库的 `cargo test -p lithe-execution -p lithe-core`:覆盖表单、校验、启动计划、YAML/TOML 读写、旧 JSON 和插件可用性。 - `./scripts/desktop/verify/verify-runtime-bundle-immutability.sh`:确认运行不写发行目录。 @@ -111,6 +132,9 @@ Core 只在 Windows 上列出 `process.batch`。其他平台上读到已有的 b - `desktop/internal/workbench/runconfig_changes.go` - `desktop/internal/workbench/runconfig_form.go` - `desktop/internal/workbench/runconfig_form_view.go` +- `desktop/internal/workbench/runconfig_dialog.go` +- `desktop/internal/workbench/runconfig_dialog_view.go` +- `desktop/internal/workbench/title_run_view.go` - `desktop/internal/workbench/runconfig.go` - `desktop/internal/core/run_process.go` - `desktop/internal/buildprocess/` diff --git a/.agents/notes/implemented/feature/2026-11-18-run-configuration-before-launch-steps.md b/.agents/notes/implemented/feature/2026-11-18-run-configuration-before-launch-steps.md index 5e9b2584e3..e66ed8ebd5 100644 --- a/.agents/notes/implemented/feature/2026-11-18-run-configuration-before-launch-steps.md +++ b/.agents/notes/implemented/feature/2026-11-18-run-configuration-before-launch-steps.md @@ -12,6 +12,8 @@ - 只要展开过程中用到了项目文件写的列表,Core 就返回确认指纹:对列表和这些步骤启动的命令定义求 sha256。宿主第一次运行前弹框列出步骤和命令,用户点“运行步骤”后把指纹存进应用自己的存储 `run-before-launch-approvals.json`(按项目根目录,每个项目最多 64 个)。命令或列表一改,指纹就变,会再问一次。 - 步骤按顺序在被启动配置的 Run 控制台里运行,每一步前写一行暗色标题。某一步退出码不是 0,就写出步骤名和退出码,不启动配置。停止配置会结束正在运行的步骤。 - 内置运行编辑器(Core 描述的表单,字段类型 `beforeLaunch`,候选列表由 Core 给出)和构建提供者运行编辑器都可以添加、上移、下移、移除步骤。构建提供者编辑器只有列表改动时才发送 `beforeLaunch`,不会把解析后的列表抄进本地层。 +- 两种编辑器都在“运行/调试配置”窗口右侧(#2100)。步骤列表的改动和其他字段一样算作未保存的修改:内置运行表单经 `runConfigFormEdited` 标脏,构建提供者编辑器把列表纳入 `fingerprint`;“应用”“确定”“运行”会一并保存。 +- 本平台不能运行的配置(例如 macOS、Linux 上的 `process.batch`)照常列出、可以编辑,但 Core 不把它列为步骤候选;项目文件里引用它的列表在这些平台上被拒绝,原因码 `unavailable`(Lithe-core-rust#87)。 ## 问题 @@ -42,7 +44,7 @@ ## 验证 - Core:`cargo test -p lithe-core before_launch`(`core/src/tests/before_launch_steps.rs` 覆盖展开、确认指纹、拒绝原因、编辑校验和本地层清空)。 -- 宿主:`./scripts/desktop/desktop-go.sh test ./internal/workbench/ -run 'BeforeLaunch|TestRunConfigFormKeepsTheStepList' -count=1`,用真实 Core 和系统 shell/cmd 运行步骤,覆盖顺序、确认与记忆、改动后重新确认、取消、失败退出码和停止。 +- 宿主:`./scripts/desktop/desktop-go.sh test ./internal/workbench/ -run 'BeforeLaunch|TestRunConfigFormKeepsTheStepList|TestRunConfigDialogSavesAnAddedStep|TestRunConfigEditorSavesTheLocalLayer' -count=1`,用真实 Core 和系统 shell/cmd 运行步骤,覆盖顺序、确认与记忆、改动后重新确认、取消、失败退出码和停止,以及在“运行/调试配置”窗口里添加的步骤算作修改并由“应用”保存。 ## 适用范围 @@ -53,5 +55,6 @@ - `desktop/internal/workbench/runconfig_form_view.go` - `desktop/internal/workbench/runconfig_edit.go` - `desktop/internal/workbench/runconfig_view.go` +- `desktop/internal/workbench/runconfig_dialog.go` - `desktop/internal/core/run_before_launch.go` - Core:`rust/crates/execution/src/configuration/before_launch.rs` diff --git a/desktop/internal/core/run_config.go b/desktop/internal/core/run_config.go index 0eb815aeb6..a437999d85 100644 --- a/desktop/internal/core/run_config.go +++ b/desktop/internal/core/run_config.go @@ -72,7 +72,9 @@ type RunPluginDependency struct { // RunAvailability says why a saved configuration cannot run. Code is // pluginMissing, pluginRepositoryMismatch, pluginVersionUnsupported, -// invalidConfiguration or missingWorkingDirectory; Message is Core's English +// invalidConfiguration, unsupportedPlatform (a built-in kind this platform +// cannot run, such as a batch script outside Windows) or +// missingWorkingDirectory; Message is Core's English // description, which the host shows only as the detail of its own text. type RunAvailability struct { Status string `json:"status"` diff --git a/desktop/internal/core/run_process.go b/desktop/internal/core/run_process.go index 2659496ba7..2bf5fe3ffe 100644 --- a/desktop/internal/core/run_process.go +++ b/desktop/internal/core/run_process.go @@ -9,14 +9,22 @@ import ( // form is refused, since its fields may mean something this host cannot show. const RunFormVersion = 1 -// RunConfigurationType is one built-in run configuration kind a user can create -// on this platform, such as `process.shell`. +// RunConfigurationType is one built-in run configuration kind a user can create, +// such as `process.shell`. Availability is set when this platform cannot run the +// kind, such as a batch script outside Windows; its configurations are still +// created and edited. type RunConfigurationType struct { - Provider string `json:"provider"` + Provider string `json:"provider"` + Availability *RunAvailability `json:"availability,omitempty"` } -// RunConfigurationTypes lists the built-in kinds a user can create here, in -// display order. Batch scripts are listed only on Windows. +// Unavailable says this platform cannot run configurations of the kind. +func (t RunConfigurationType) Unavailable() bool { + return t.Availability != nil && t.Availability.Status == "unavailable" +} + +// RunConfigurationTypes lists the built-in kinds a user can create, in display +// order. Every platform lists every kind; one it cannot run says so. func (c *Client) RunConfigurationTypes(ctx context.Context) ([]RunConfigurationType, error) { var result struct { Types []RunConfigurationType `json:"types"` @@ -57,13 +65,15 @@ type RunFieldCondition struct { // RunEditorForm is what `runConfig.editorForm` returns: the fields in order and // the current value of each, by field ID. Values stay raw so keys this host -// does not show go back unchanged. +// does not show go back unchanged. Availability is set when this platform cannot +// run the kind; the form still edits and saves it. type RunEditorForm struct { FormVersion int `json:"formVersion"` Provider string `json:"provider"` ConfigurationID *string `json:"configurationId"` Values map[string]json.RawMessage `json:"values"` Fields []RunEditorField `json:"fields"` + Availability *RunAvailability `json:"availability,omitempty"` } // RunEditorFormRequest asks for the editor of a new configuration of Provider or diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 5c1b8f81f7..9219edd0ac 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1343,7 +1343,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.run.statusSucceeded": "Succeeded", "desktop.runConfig.apply": "Apply", "desktop.runConfig.arguments": "Program arguments", - "desktop.runConfig.argumentsPlaceholder": "Separate with spaces; quote values that contain spaces", + "desktop.runConfig.argumentsPlaceholder": "Arguments for the program, e.g. --port 8080; separate with spaces and quote one that contains spaces", "desktop.runConfig.automaticValue": "Automatic ({value})", "desktop.runConfig.beforeLaunch.confirmBody": "Before {name} starts, the project's run configuration file asks to run these commands. Run them only if you trust this project.", "desktop.runConfig.beforeLaunch.confirmRun": "Run Steps", @@ -1369,12 +1369,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.builtInGroup": "Scripts and Programs", "desktop.runConfig.chooseFailed": "Could not open the file chooser.", "desktop.runConfig.conflict": "The file changed on disk while saving. Close the editor, reopen it and try again.", + "desktop.runConfig.copyConfiguration": "Copy Configuration", + "desktop.runConfig.copyName": "{name} (Copy)", "desktop.runConfig.delete": "Delete", "desktop.runConfig.deleteBody": "Delete “{name}”? It is removed from the run configuration file it is saved in.", "desktop.runConfig.deleteFailed": "Could not delete the run configuration: {reason}", "desktop.runConfig.deleteTitle": "Delete Run Configuration", + "desktop.runConfig.dialogHint": "Select a run configuration on the left to edit it, or create one:", + "desktop.runConfig.dialogTitle": "Run/Debug Configurations", "desktop.runConfig.documentIgnored": "Not read: {file}", - "desktop.runConfig.editTitle": "Edit {name}", "desktop.runConfig.emptyHint": "No run configurations yet. Click + to add a script or program run.", "desktop.runConfig.entrypoint": "Entrypoint", "desktop.runConfig.entrypointPlaceholder": "Provider default", @@ -1405,15 +1408,21 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.fieldStoreAsProjectFile": "Store as project file", "desktop.runConfig.fieldText": "Script text", "desktop.runConfig.formTooNew": "Editing this run configuration needs a newer version of Lithe.", + "desktop.runConfig.interpreterArgumentsHelp": "Options placed before the script path and handled by the interpreter itself, such as bash's -x, which prints each command as it runs. The script does not see them. Left empty, the automatic options shown in brackets are used.", + "desktop.runConfig.interpreterArgumentsPlaceholder": "Options for the interpreter, e.g. -x", "desktop.runConfig.interpreterHelp": "Left empty, the automatic interpreter shown in brackets is used. You can also enter a command name, found on PATH, or the path of an executable.", "desktop.runConfig.loadFailed": "Run configurations are unavailable: {reason}", "desktop.runConfig.newConfiguration": "New Configuration", - "desktop.runConfig.newTitle": "New {type} Configuration", + "desktop.runConfig.newConfigurationEllipsis": "New Run Configuration…", + "desktop.runConfig.notEditable": "This run configuration can be edited once its plugin is available.", "desktop.runConfig.noteWindowsOnly": "Takes effect on Windows only; other systems ignore it.", "desktop.runConfig.ok": "OK", "desktop.runConfig.optionDefault": "Default", "desktop.runConfig.optionReadOnly": "Not editable here", + "desktop.runConfig.programArgumentsHelp": "Command-line arguments placed after the program path when it starts. Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.programArgumentsPlaceholder": "Arguments for the program, e.g. --port 8080", "desktop.runConfig.programNotFound": "“{program}” was not found on PATH. Enter the full path of the interpreter or program.", + "desktop.runConfig.removeConfiguration": "Remove Configuration", "desktop.runConfig.run": "Run", "desktop.runConfig.runtimeArguments": "Runtime arguments", "desktop.runConfig.runtimeArgumentsPlaceholder": "One argument per line", @@ -1421,6 +1430,10 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.scope": "Save to", "desktop.runConfig.scopeLocal": "This machine (.lithe/run/local.yaml)", "desktop.runConfig.scopeProject": "Project, shared (.lithe/run/configurations.yaml)", + "desktop.runConfig.scriptOptionsHelpBatch": "Arguments placed after the script path and passed to the script, which reads them as %1, %2… Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.scriptOptionsHelpPowerShell": "Arguments placed after the script path and passed to the script, which reads them through $args or param(). Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.scriptOptionsHelpShell": "Arguments placed after the script path and passed to the script, which reads them as $1, $2… Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.scriptOptionsPlaceholder": "Arguments for the script, e.g. --verbose input.txt", "desktop.runConfig.sourceFile": "Script file", "desktop.runConfig.sourceText": "Script text", "desktop.runConfig.storeAsProjectFileHelp": "Checked, the configuration is saved in .lithe/run/configurations.yaml and can be committed with the project; unchecked, it stays on this machine in .lithe/run/local.yaml.", @@ -1430,18 +1443,23 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.toolPickNone": "Choose an installation…", "desktop.runConfig.typeBatch": "Batch Script (cmd)", "desktop.runConfig.typeExecutable": "Program", + "desktop.runConfig.typeNotRunnableHere": "Cannot run on this computer", "desktop.runConfig.typePowerShell": "PowerShell Script", "desktop.runConfig.typeShell": "Shell Script", + "desktop.runConfig.unavailableBatchPlatform": "Batch scripts run only on Windows. You can edit and save this configuration here, but not run it.", "desktop.runConfig.unavailableInvalid": "The run configuration is invalid: {reason}", "desktop.runConfig.unavailableMissingDirectory": "The working directory “{directory}” no longer exists. Edit the configuration to change it.", "desktop.runConfig.unavailableOther": "This run configuration cannot run now: {reason}", + "desktop.runConfig.unavailablePlatform": "{type} cannot run on this system. You can edit and save this configuration, but not run it.", "desktop.runConfig.unavailablePluginMissing": "Needs the plugin “{plugin}”, which is not installed or not enabled.", "desktop.runConfig.unavailableRepositoryMismatch": "The installed “{plugin}” is not the plugin from {repository} the configuration records.", "desktop.runConfig.unavailableVersionUnsupported": "The installed “{plugin}” does not meet the version requirement {requirement}.", + "desktop.runConfig.unnamed": "Unnamed", "desktop.runConfig.variableAdd": "Add variable", "desktop.runConfig.variableName": "Name", "desktop.runConfig.variableRemove": "Remove variable", "desktop.runConfig.variableValue": "Value", + "desktop.runConfig.windowsOnlyType": "Windows only", "desktop.runConfig.workingDirectory": "Working directory", "desktop.runConfig.workingDirectoryPlaceholder": "Path inside the workspace; empty uses the default", "desktop.search.collapseFile": "Hide details", @@ -1883,8 +1901,6 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.title.noRecentProjects": "No recent projects", "desktop.title.noRunConfigurations": "No run configurations", "desktop.title.notDebuggable": "{name} cannot be debugged: its plugin declares no debug adapter for this run.", - "desktop.title.nothingToEdit": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project.", - "desktop.title.nothingToEditHidden": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project. {count} saved run configurations are hidden because no build plugin runs them, for example entries an earlier version of Lithe saved in .lithe/run.", "desktop.title.pluginsLater": "The plugins page comes later", "desktop.title.projectMenu": "Project menu", "desktop.title.runBusy": "The Run window is still running another operation. Wait for it to finish or stop it first.", @@ -4258,7 +4274,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.run.statusSucceeded": "成功", "desktop.runConfig.apply": "应用", "desktop.runConfig.arguments": "程序参数", - "desktop.runConfig.argumentsPlaceholder": "以空格分隔;含空格的值请加引号", + "desktop.runConfig.argumentsPlaceholder": "传给程序的参数,例如 --port 8080;多个参数用空格分隔,含空格的参数用引号括起来", "desktop.runConfig.automaticValue": "自动({value})", "desktop.runConfig.beforeLaunch.confirmBody": "启动 {name} 前,项目的运行配置文件要求先运行以下命令。只有信任此项目时才运行。", "desktop.runConfig.beforeLaunch.confirmRun": "运行步骤", @@ -4284,12 +4300,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.builtInGroup": "脚本与程序", "desktop.runConfig.chooseFailed": "无法打开文件选择器。", "desktop.runConfig.conflict": "保存期间文件已在磁盘上被修改,请关闭编辑器重新打开后再试。", + "desktop.runConfig.copyConfiguration": "复制配置", + "desktop.runConfig.copyName": "{name}(副本)", "desktop.runConfig.delete": "删除", "desktop.runConfig.deleteBody": "确定删除“{name}”吗?它会从保存它的运行配置文件中移除。", "desktop.runConfig.deleteFailed": "无法删除运行配置:{reason}", "desktop.runConfig.deleteTitle": "删除运行配置", + "desktop.runConfig.dialogHint": "在左侧选择一个运行配置进行编辑,或新建一个:", + "desktop.runConfig.dialogTitle": "运行/调试配置", "desktop.runConfig.documentIgnored": "未读取 {file} 中的运行配置", - "desktop.runConfig.editTitle": "编辑 {name}", "desktop.runConfig.emptyHint": "还没有运行配置,点 + 新建脚本或程序运行", "desktop.runConfig.entrypoint": "入口", "desktop.runConfig.entrypointPlaceholder": "提供方默认值", @@ -4320,15 +4339,21 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.fieldStoreAsProjectFile": "存为项目文件", "desktop.runConfig.fieldText": "脚本文本", "desktop.runConfig.formTooNew": "这个运行配置需要更新版本的 Lithe 才能编辑。", + "desktop.runConfig.interpreterArgumentsHelp": "写在脚本路径前面、交给解释器本身的选项,例如 bash 的 -x(逐行打印执行的命令);脚本读不到这些值。留空时使用括号里显示的自动选项。", + "desktop.runConfig.interpreterArgumentsPlaceholder": "传给解释器的选项,例如 -x", "desktop.runConfig.interpreterHelp": "留空时使用括号里显示的自动解释器;也可以填命令名(按 PATH 查找)或可执行文件路径。", "desktop.runConfig.loadFailed": "无法读取运行配置:{reason}", "desktop.runConfig.newConfiguration": "新建运行配置", - "desktop.runConfig.newTitle": "新建{type}运行配置", + "desktop.runConfig.newConfigurationEllipsis": "新建运行配置…", + "desktop.runConfig.notEditable": "插件可用后才能编辑这个运行配置。", "desktop.runConfig.noteWindowsOnly": "只在 Windows 上生效,其他系统会忽略。", "desktop.runConfig.ok": "确定", "desktop.runConfig.optionDefault": "默认", "desktop.runConfig.optionReadOnly": "此处无法编辑", + "desktop.runConfig.programArgumentsHelp": "启动程序时附在程序路径后面的命令行参数。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.programArgumentsPlaceholder": "传给程序的参数,例如 --port 8080", "desktop.runConfig.programNotFound": "在 PATH 中找不到“{program}”,请填写解释器或程序的完整路径。", + "desktop.runConfig.removeConfiguration": "删除配置", "desktop.runConfig.run": "运行", "desktop.runConfig.runtimeArguments": "运行时参数", "desktop.runConfig.runtimeArgumentsPlaceholder": "每行一个参数", @@ -4336,6 +4361,10 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.scope": "保存到", "desktop.runConfig.scopeLocal": "仅本机(.lithe/run/local.yaml)", "desktop.runConfig.scopeProject": "项目共享(.lithe/run/configurations.yaml)", + "desktop.runConfig.scriptOptionsHelpBatch": "写在脚本路径后面、传给脚本的参数,脚本里用 %1、%2… 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.scriptOptionsHelpPowerShell": "写在脚本路径后面、传给脚本的参数,脚本里用 $args 或 param() 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.scriptOptionsHelpShell": "写在脚本路径后面、传给脚本的参数,脚本里用 $1、$2… 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.scriptOptionsPlaceholder": "传给脚本的参数,例如 --verbose input.txt", "desktop.runConfig.sourceFile": "脚本文件", "desktop.runConfig.sourceText": "脚本文本", "desktop.runConfig.storeAsProjectFileHelp": "勾选后保存到 .lithe/run/configurations.yaml,可随项目提交共享;不勾选则只保存在本机的 .lithe/run/local.yaml。", @@ -4345,18 +4374,23 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.runConfig.toolPickNone": "选择安装…", "desktop.runConfig.typeBatch": "批处理脚本(cmd)", "desktop.runConfig.typeExecutable": "程序", + "desktop.runConfig.typeNotRunnableHere": "本机不能运行", "desktop.runConfig.typePowerShell": "PowerShell 脚本", "desktop.runConfig.typeShell": "Shell 脚本", + "desktop.runConfig.unavailableBatchPlatform": "批处理脚本只能在 Windows 上运行;在这台电脑上可以编辑和保存,但不能运行。", "desktop.runConfig.unavailableInvalid": "运行配置无效:{reason}", "desktop.runConfig.unavailableMissingDirectory": "工作目录“{directory}”不存在了,请编辑配置修改它。", "desktop.runConfig.unavailableOther": "此运行配置现在无法运行:{reason}", + "desktop.runConfig.unavailablePlatform": "{type}不能在当前系统上运行;可以编辑和保存,但不能运行。", "desktop.runConfig.unavailablePluginMissing": "需要插件“{plugin}”,但它没有安装或没有启用。", "desktop.runConfig.unavailableRepositoryMismatch": "已安装的“{plugin}”不是配置记录的仓库 {repository} 发布的插件。", "desktop.runConfig.unavailableVersionUnsupported": "已安装的“{plugin}”版本不满足要求 {requirement}。", + "desktop.runConfig.unnamed": "未命名", "desktop.runConfig.variableAdd": "添加变量", "desktop.runConfig.variableName": "变量名", "desktop.runConfig.variableRemove": "删除变量", "desktop.runConfig.variableValue": "值", + "desktop.runConfig.windowsOnlyType": "仅 Windows", "desktop.runConfig.workingDirectory": "工作目录", "desktop.runConfig.workingDirectoryPlaceholder": "工作区内的路径;留空使用默认目录", "desktop.search.collapseFile": "收起详情", @@ -4798,8 +4832,6 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.title.noRecentProjects": "无最近项目", "desktop.title.noRunConfigurations": "没有运行配置", "desktop.title.notDebuggable": "无法调试 {name}:它所属的插件没有为这个运行声明调试适配器。", - "desktop.title.nothingToEdit": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。", - "desktop.title.nothingToEditHidden": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。另有 {count} 条保存的运行配置没有构建插件负责运行,已隐藏,例如旧版 Lithe 保存在 .lithe/run 中的配置。", "desktop.title.pluginsLater": "插件页稍后提供", "desktop.title.projectMenu": "项目菜单", "desktop.title.runBusy": "运行窗口还在执行其他操作。请等它结束,或者先停止它。", diff --git a/desktop/internal/workbench/chrome_view.go b/desktop/internal/workbench/chrome_view.go index 82e86a55bc..f5110ed8ca 100644 --- a/desktop/internal/workbench/chrome_view.go +++ b/desktop/internal/workbench/chrome_view.go @@ -229,8 +229,14 @@ func (a *App) chromeTitleButton(c ui.C, i int) bool { } return false case itemTitleRun: - // Run is the one button that keeps its color at rest: green says what it does. - _, clicked := a.chromeGlyph(c, i, titleGlyph, a.colors.Success, a.colors.Success, false) + // Run is the one button that keeps its color at rest: green says what it does. It + // greys while the chosen configuration cannot run here, such as a batch script off + // Windows; a press still says why. + color := a.colors.Success + if configuration := a.project.titleConfiguration(); configuration != nil && configuration.Unavailable() { + color = a.colors.Subtle + } + _, clicked := a.chromeGlyph(c, i, titleGlyph, color, color, false) return clicked case itemTitleSettings: box, clicked := a.chromeGlyph(c, i, titleGlyph, a.colors.Text, a.colors.Text, a.title.gearOpen) diff --git a/desktop/internal/workbench/command_installers_test.go b/desktop/internal/workbench/command_installers_test.go index 565ba42b7d..166f795cff 100644 --- a/desktop/internal/workbench/command_installers_test.go +++ b/desktop/internal/workbench/command_installers_test.go @@ -287,6 +287,20 @@ func TestCommandInstallManagedRecordsWhereLaterLaunchesFindTheCommand(t *testing if err != nil { t.Fatal(err) } + // The tool's working directory is made under os.TempDir(), which other test runs on the + // machine share; a private one keeps their installs out of the check below. + private, err := os.MkdirTemp("", "lci-") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := os.RemoveAll(private); err != nil { + t.Error(err) + } + }) + for _, name := range []string{"TMPDIR", "TMP", "TEMP"} { + t.Setenv(name, private) + } var output commandOutput directory, err := installs.Install(ctx, commandInstallerPluginID, "fixture-ls", core.CommandInstallManaged, output.add) if err != nil { @@ -314,7 +328,7 @@ func TestCommandInstallManagedRecordsWhereLaterLaunchesFindTheCommand(t *testing if len(missing) != 1 || missing[0].Kind != settingswindow.CapabilityDebugger { t.Fatalf("still missing after the install: %+v", missing) } - entries, err := os.ReadDir(os.TempDir()) + entries, err := os.ReadDir(private) if err != nil { t.Fatal(err) } diff --git a/desktop/internal/workbench/root.go b/desktop/internal/workbench/root.go index c9a669bd91..9c7568dd47 100644 --- a/desktop/internal/workbench/root.go +++ b/desktop/internal/workbench/root.go @@ -310,8 +310,7 @@ func (a *App) overlays(c ui.C) { a.drawBranchDialog(c, p) a.drawSyncDialog(c, p) a.drawWorktreeDialog(c, p) - a.drawRunConfigEditor(c, p) - a.drawRunConfigForm(c, p) + a.drawRunConfigDialog(c, p) a.drawRunConfigDelete(c, p) a.drawBeforeLaunchConfirmation(c, p) a.buildOptionsDialog(c, p) diff --git a/desktop/internal/workbench/runconfig.go b/desktop/internal/workbench/runconfig.go index faffadf444..50928415a0 100644 --- a/desktop/internal/workbench/runconfig.go +++ b/desktop/internal/workbench/runconfig.go @@ -33,18 +33,16 @@ type runConfigState struct { // release's JSON document its YAML replacement wins over. The built-in configurations // still list; the run menu names each file so its configurations do not vanish silently. ignored []string - // types are the built-in kinds a user can create on this platform, in display order, - // read once per project; typesLoading is set while they are asked for. + // types are the built-in kinds a user can create, in display order, each with the reason + // this platform cannot run it, if any; read once per project; typesLoading is set while + // they are asked for. types []core.RunConfigurationType typesLoading bool - // editor is the dialog that edits one build provider run's saved options. - editor runConfigEditor - // form is the dialog that creates or edits a built-in process run (runconfig_form.go). - form runConfigForm + // dialog is the Run/Debug Configurations window that creates, edits and removes + // configurations (runconfig_dialog.go). + dialog runConfigDialog // reveal is the configuration a save just wrote, selected once the next refresh lists it. reveal string - // newMenu says the list header's menu of new configuration kinds is open. - newMenu bool // deleting is the user configuration whose delete waits for confirmation. deleting *runConfigDeletion // beforeLaunch is the start that waits for the user to allow the steps a project file @@ -386,6 +384,8 @@ func (a *App) runConfigUnavailableText(configuration core.RunConfiguration) stri return i18n.SharedFormat(language, "desktop.runConfig.unavailableMissingDirectory", map[string]string{"directory": configuration.Cwd}) case "invalidConfiguration": return i18n.SharedFormat(language, "desktop.runConfig.unavailableInvalid", map[string]string{"reason": availability.Message}) + case "unsupportedPlatform": + return a.runAvailabilityText(configuration.Provider, *availability) } return i18n.SharedFormat(language, "desktop.runConfig.unavailableOther", map[string]string{"reason": availability.Message}) } diff --git a/desktop/internal/workbench/runconfig_before_launch_test.go b/desktop/internal/workbench/runconfig_before_launch_test.go index fe41b7e299..104536765c 100644 --- a/desktop/internal/workbench/runconfig_before_launch_test.go +++ b/desktop/internal/workbench/runconfig_before_launch_test.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "runtime" + "slices" "strings" "testing" "time" @@ -226,3 +227,42 @@ func TestRunConfigFormKeepsTheStepList(t *testing.T) { t.Fatalf("candidates = %+v", candidates) } } + +// In the Run/Debug Configurations window a step added from the menu of Add step counts as a +// change, so Apply saves it with the configuration and the dialog shows nothing left to save. +func TestRunConfigDialogSavesAnAddedStep(t *testing.T) { + root := t.TempDir() + writeBeforeLaunchDocument(t, root, "local.yaml", + beforeLaunchEcho("user:generate", "step-generate"), + beforeLaunchEcho("user:app", "app-ran"), + ) + h, p := openBeforeLaunchProject(t, root) + d := &p.runConfigs.dialog + h.app.post(func(a *App) { a.openRunConfigDialog(p, "user:app") }) + var f *runConfigForm + awaitStateWithin(t, h, 10*time.Second, "the editor of app", func() bool { + if draft := d.drafts["user:app"]; draft != nil { + f = draft.form + } + return f != nil && f.ready() && f.beforeLaunch != nil + }) + h.settle() + if d.dirty() { + t.Fatal("the opened configuration shows as something to save") + } + h.clickNamed(i18n.Shared(h.app.language(), "desktop.runConfig.beforeLaunchAdd")) + h.clickNamed("generate") + h.settle() + if !slices.Equal(f.beforeLaunch, []string{"user:generate"}) || !d.dirty() { + t.Fatalf("steps %v, dirty %v after the menu added one", f.beforeLaunch, d.dirty()) + } + + applyDialog(t, h, p, runConfigDialogApply) + configuration := p.runConfigs.configuration("user:app") + if configuration == nil || len(configuration.BeforeLaunch) != 1 || configuration.BeforeLaunch[0].Configuration != "user:generate" { + t.Fatalf("configuration = %+v, failure %q / %q", configuration, d.failure, f.failure) + } + if !d.open || d.dirty() { + t.Fatalf("dialog open %v dirty %v after Apply", d.open, d.dirty()) + } +} diff --git a/desktop/internal/workbench/runconfig_before_launch_visual_test.go b/desktop/internal/workbench/runconfig_before_launch_visual_test.go index 615124d5e1..843ca238e1 100644 --- a/desktop/internal/workbench/runconfig_before_launch_visual_test.go +++ b/desktop/internal/workbench/runconfig_before_launch_visual_test.go @@ -14,10 +14,10 @@ import ( "github.com/vivaui/viva/headless" ) -// TestVisualBeforeLaunchSteps captures the steps before launch: the editor of a run with two -// steps, the question before the steps a project file names run, and the Run window after the -// steps and the run. It needs only LITHE_VISUAL_OUTPUT_DIR; the dark captures are in Chinese -// and the light ones in English. +// TestVisualBeforeLaunchSteps captures the steps before launch: the Run/Debug Configurations +// window editing a run with two steps, the question before the steps a project file names +// run, and the Run window after the steps and the run. It needs only LITHE_VISUAL_OUTPUT_DIR; +// the dark captures are in Chinese and the light ones in English. func TestVisualBeforeLaunchSteps(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -73,11 +73,14 @@ func TestVisualBeforeLaunchSteps(t *testing.T) { return s.generation > 0 && !s.loading && s.configuration("user:server") != nil }) - f := &p.runConfigs.form - h.app.post(func(a *App) { a.openRunConfigForm(p, "process.executable", "user:server") }) - awaitStateWithin(t, h, 10*time.Second, "the editor", func() bool { return f.open && !f.loading && f.beforeLaunch != nil }) + d := &p.runConfigs.dialog + h.app.post(func(a *App) { a.openRunConfigDialog(p, "user:server") }) + awaitStateWithin(t, h, 10*time.Second, "the editor", func() bool { + draft := d.drafts["user:server"] + return draft != nil && draft.form != nil && draft.form.open && !draft.form.loading && draft.form.beforeLaunch != nil + }) shot("editor") - h.app.post(func(a *App) { a.closeRunConfigForm(p) }) + h.app.post(func(a *App) { a.closeRunConfigDialog(p) }) h.app.post(func(a *App) { a.runConfiguration(p, "user:server") }) awaitStateWithin(t, h, 10*time.Second, "the confirmation", func() bool { return p.runConfigs.beforeLaunch != nil }) diff --git a/desktop/internal/workbench/runconfig_dialog.go b/desktop/internal/workbench/runconfig_dialog.go new file mode 100644 index 0000000000..862a50e470 --- /dev/null +++ b/desktop/internal/workbench/runconfig_dialog.go @@ -0,0 +1,658 @@ +package workbench + +import ( + "cmp" + "encoding/json" + "maps" + "slices" + "strconv" + "strings" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/icons" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui" +) + +// This file holds the Run/Debug Configurations dialog, after IDEA's: the configurations as a +// tree by kind on the left under the buttons that add, remove and copy one, the editor of the +// selected one on the right, and Run, Cancel, Apply and OK under them. Every configuration the +// user selects gets its own draft, so edits to several configurations, the configurations +// added and the ones removed all wait for Apply or OK, and Cancel drops them together. +// Drawing is in runconfig_dialog_view.go. + +// runConfigNewKey starts the draft key of a configuration created in the dialog and not saved +// yet. No configuration ID starts with it, since Core's IDs start with their layer. +const runConfigNewKey = "new:" + +// runConfigDialog is the state of the Run/Debug Configurations dialog. Only the window thread +// reads or writes it. +type runConfigDialog struct { + open bool + // generation rejects the answer of a save chain whose dialog was closed or reopened since. + generation uint64 + // selected is the draft key of the selected configuration, and group the key of the + // selected group row while a group rather than a configuration is selected. + selected, group string + // drafts are the editors of the configurations the user selected, by configuration ID, or + // by a runConfigNewKey key until a new configuration's first save names it. + drafts map[string]*runConfigDraft + // added are the keys of the configurations created in the dialog, in creation order. A + // saved one stays until the list shows it, so it does not vanish while the list refreshes. + added []string + // removed are the listed configurations to delete on Apply, and hidden the IDs a save + // replaced, such as by renaming, kept out of the tree until the list stops showing them. + removed, hidden map[string]bool + // next numbers the next new configuration's key. + next int + // newMenu says the menu of kinds the + button opens is showing. + newMenu bool + // saving says Apply, OK or Run is saving the drafts; failure is a removal that failed. + saving bool + failure string + // closed are the groups the user closed, by key. They stay closed across openings. + closed map[string]bool + // groups, rows and ids are the tree as it shows, collected on each paint; ids give every + // draft key a row key of its own for the list's state. + groups []runConfigDialogGroup + rows []runConfigDialogRow + ids map[string]int + view ui.ListState +} + +// runConfigDraft is the editor of one configuration in the dialog: the form of a built-in +// process run, or the options editor of a build provider run. A provider run whose plugin +// cannot resolve has neither, and the dialog says why it cannot be edited. +type runConfigDraft struct { + key string + form *runConfigForm + editor *runConfigEditor +} + +// runConfigDialogGroup is one kind of configuration in the tree: a built-in kind, or the build +// system that provides runs. +type runConfigDialogGroup struct { + key, title string + icon gfx.Icon + // order places the built-in kinds first, in the order Core lists them. + order int + keys []string +} + +// runConfigDialogRow is one row of the tree: a group's, with an empty key, or a configuration +// under it. +type runConfigDialogRow struct { + group int + key string +} + +// runConfigDialogStep is the button that saves the drafts. +type runConfigDialogStep int + +const ( + // runConfigDialogApply saves and keeps the dialog open. + runConfigDialogApply runConfigDialogStep = iota + // runConfigDialogOK saves and closes the dialog. + runConfigDialogOK + // runConfigDialogRun saves, closes the dialog and runs the selected configuration once the + // list shows what was saved. + runConfigDialogRun +) + +// runProcessKindKey is the group of the built-in runs of provider. +func runProcessKindKey(provider string) string { return runProcessGroupKey + ":" + provider } + +// openRunConfigDialog opens the dialog with configuration id selected, or nothing selected +// when id is empty or not listed. It asks for what the tree lists: the build models, whose +// runs it shows, and the built-in kinds. +func (a *App) openRunConfigDialog(p *project, id string) { + if p == nil { + return + } + d := &p.runConfigs.dialog + d.dropDrafts() + *d = runConfigDialog{ + open: true, generation: d.generation + 1, closed: d.closed, + drafts: map[string]*runConfigDraft{}, removed: map[string]bool{}, hidden: map[string]bool{}, ids: map[string]int{}, + } + a.title.runConfigOpen = false + a.loadTitleRunConfigs(p) + a.loadRunConfigTypes(p) + if configuration := p.runConfigs.configuration(id); configuration != nil { + a.selectRunConfigDraft(p, id) + delete(d.closed, p.runConfigDialogGroupKey(id)) + } +} + +// closeRunConfigDialog closes the dialog and drops every draft; answers still out are ignored. +func (a *App) closeRunConfigDialog(p *project) { + d := &p.runConfigs.dialog + d.dropDrafts() + d.generation++ + d.open, d.saving, d.newMenu = false, false, false +} + +// dropDrafts closes every draft's editor. +func (d *runConfigDialog) dropDrafts() { + for _, draft := range d.drafts { + draft.close() + } + d.drafts = nil +} + +// close closes the draft's editor. +func (draft *runConfigDraft) close() { + if draft.form != nil { + draft.form.close() + } + if draft.editor != nil { + draft.editor.close() + } +} + +// dirty says the draft holds something Apply would save: an edited configuration, or a new +// one not saved yet. +func (draft *runConfigDraft) dirty() bool { + switch { + case draft.form != nil: + return draft.form.open && (draft.form.dirty || draft.form.id == "") + case draft.editor != nil: + return draft.editor.dirty() + } + return false +} + +// busy says the draft is being read or saved, so Apply cannot save it yet. +func (draft *runConfigDraft) busy() bool { + switch { + case draft.form != nil: + return draft.form.loading || draft.form.saving + case draft.editor != nil: + return draft.editor.loading || draft.editor.saving + } + return false +} + +// selectRunConfigDraft selects configuration key and reads its editor the first time. +func (a *App) selectRunConfigDraft(p *project, key string) { + d := &p.runConfigs.dialog + d.selected, d.group, d.newMenu = key, "", false + if d.drafts[key] != nil { + return + } + configuration := p.runConfigs.configuration(key) + if configuration == nil { + return + } + draft := &runConfigDraft{key: key} + switch { + case configuration.IsProcess(): + draft.form = a.openRunConfigForm(p, configuration.Provider, key, nil) + case runConfigEditable(*configuration): + draft.editor = a.openRunConfigEditor(p, key) + } + d.drafts[key] = draft +} + +// addRunConfigDraft creates a new configuration of provider, seeded with values when they are +// set, opens its group and selects it. +func (a *App) addRunConfigDraft(p *project, provider string, values map[string]json.RawMessage) { + d := &p.runConfigs.dialog + d.next++ + key := runConfigNewKey + strconv.Itoa(d.next) + draft := &runConfigDraft{key: key, form: a.openRunConfigForm(p, provider, "", values)} + d.drafts[key] = draft + d.added = append(d.added, key) + delete(d.closed, runProcessKindKey(provider)) + d.selected, d.group, d.newMenu, d.failure = key, "", false, "" +} + +// copyRunConfigDraft creates a copy of the selected built-in run with the values its form shows, +// named as a copy. +func (a *App) copyRunConfigDraft(p *project) { + d := &p.runConfigs.dialog + draft := d.drafts[d.selected] + if draft == nil || draft.form == nil || !draft.form.ready() { + return + } + values := draft.form.collect() + name, _ := json.Marshal(i18n.SharedFormat(a.language(), "desktop.runConfig.copyName", map[string]string{"name": a.runConfigDraftLabel(p, d.selected)})) + values["name"] = name + a.addRunConfigDraft(p, draft.form.provider, values) +} + +// removeRunConfigDraft takes the selected configuration out of the tree: a new one is dropped, +// a saved one is deleted on Apply. The selection moves to the row that takes its place. +func (a *App) removeRunConfigDraft(p *project) { + d := &p.runConfigs.dialog + key := d.selected + if !p.runConfigRemovable(key) { + return + } + at := slices.IndexFunc(d.rows, func(row runConfigDialogRow) bool { return row.key == key }) + if draft := d.drafts[key]; draft != nil { + draft.close() + delete(d.drafts, key) + } + d.added = slices.DeleteFunc(d.added, func(added string) bool { return added == key }) + if !strings.HasPrefix(key, runConfigNewKey) { + d.removed[key] = true + } + d.selected, d.failure = "", "" + p.collectRunConfigDialogRows(a) + for index := min(at, len(d.rows)-1); index >= 0; index-- { + if index < len(d.rows) && d.rows[index].key != "" { + a.selectRunConfigDraft(p, d.rows[index].key) + return + } + } + for _, row := range d.rows { + if row.key != "" { + a.selectRunConfigDraft(p, row.key) + return + } + } +} + +// runConfigRemovable says − can take configuration key out: a new one, or a saved user +// configuration that does not run. Generated configurations come back on the next detection, +// so they are never removed. +func (p *project) runConfigRemovable(key string) bool { + d := &p.runConfigs.dialog + switch { + case key == "" || d.saving: + return false + case strings.HasPrefix(key, runConfigNewKey): + return true + case p.build.runOf(configurationRunKey(key)) != nil: + return false + } + if configuration := p.runConfigs.configuration(key); configuration != nil { + return configuration.UserDefined() + } + // A configuration saved in the dialog and not listed yet was created as a user one. + return slices.Contains(d.added, key) +} + +// runConfigDialogGroupKey is the tree group of configuration or draft key. +func (p *project) runConfigDialogGroupKey(key string) string { + if configuration := p.runConfigs.configuration(key); configuration != nil { + if configuration.IsProcess() { + return runProcessKindKey(configuration.Provider) + } + return runConfigGroupKey(configuration) + } + if draft := p.runConfigs.dialog.drafts[key]; draft != nil && draft.form != nil { + return runProcessKindKey(draft.form.provider) + } + return "" +} + +// collectRunConfigDialogRows lists the tree as it shows: the listed configurations the user did +// not remove and the ones created in the dialog, each under its kind, the built-in kinds first +// in Core's order and the build systems by title, the configurations of a kind by name. A +// closed group shows its row only. +func (p *project) collectRunConfigDialogRows(a *App) { + s := &p.runConfigs + d := &s.dialog + language := a.language() + d.groups, d.rows = d.groups[:0], d.rows[:0] + place := func(key, group, title string, icon gfx.Icon, order int) { + g := slices.IndexFunc(d.groups, func(existing runConfigDialogGroup) bool { return existing.key == group }) + if g < 0 { + g = len(d.groups) + d.groups = append(d.groups, runConfigDialogGroup{key: group, title: title, icon: icon, order: order}) + } + d.groups[g].keys = append(d.groups[g].keys, key) + } + processGroup := func(provider string) (string, string, gfx.Icon, int) { + title, ok := runConfigTypeLabel(language, provider) + if !ok { + title = i18n.Shared(language, "desktop.runConfig.builtInGroup") + } + order := slices.IndexFunc(s.types, func(kind core.RunConfigurationType) bool { return kind.Provider == provider }) + if order < 0 { + order = len(s.types) + } + return runProcessKindKey(provider), title, runConfigTypeIcon(provider), order + } + listed := map[string]bool{} + for index := range s.list { + configuration := &s.list[index] + listed[configuration.ID] = true + if d.removed[configuration.ID] || d.hidden[configuration.ID] { + continue + } + if configuration.IsProcess() { + group, title, icon, order := processGroup(configuration.Provider) + place(configuration.ID, group, title, icon, order) + continue + } + place(configuration.ID, runConfigGroupKey(configuration), p.runConfigGroupTitle(language, configuration), icons.Wrench, len(s.types)+1) + } + for _, key := range d.added { + draft := d.drafts[key] + if listed[key] || draft == nil || draft.form == nil { + continue + } + group, title, icon, order := processGroup(draft.form.provider) + place(key, group, title, icon, order) + } + slices.SortStableFunc(d.groups, func(x, y runConfigDialogGroup) int { + return cmp.Or(cmp.Compare(x.order, y.order), strings.Compare(strings.ToLower(x.title), strings.ToLower(y.title)), strings.Compare(x.key, y.key)) + }) + for g := range d.groups { + group := &d.groups[g] + labels := make(map[string]string, len(group.keys)) + for _, key := range group.keys { + labels[key] = strings.ToLower(a.runConfigDraftLabel(p, key)) + } + slices.SortStableFunc(group.keys, func(x, y string) int { + return cmp.Or(strings.Compare(labels[x], labels[y]), strings.Compare(x, y)) + }) + d.rows = append(d.rows, runConfigDialogRow{group: g}) + if d.closed[group.key] { + continue + } + for _, key := range group.keys { + d.rows = append(d.rows, runConfigDialogRow{group: g, key: key}) + } + } +} + +// runConfigDraftLabel is the name a configuration shows in the tree: the name its form holds, +// else the name it gets while the field is empty, else its saved name. +func (a *App) runConfigDraftLabel(p *project, key string) string { + if draft := p.runConfigs.dialog.drafts[key]; draft != nil && draft.form != nil { + f := draft.form + if name := f.texts["name"]; name != nil && strings.TrimSpace(*name) != "" { + return strings.TrimSpace(*name) + } + for _, field := range f.fields { + if field.ID == "name" && field.Automatic != nil && *field.Automatic != "" { + return *field.Automatic + } + } + if f.name != "" { + return f.name + } + } + if configuration := p.runConfigs.configuration(key); configuration != nil { + return configuration.Name + } + return i18n.Shared(a.language(), "desktop.runConfig.unnamed") +} + +// runConfigDraftUnavailable words why configuration key cannot run here, "" when it can. A +// form says what its kind needs, such as Windows for a batch script; a configuration whose +// form is edited is judged by its edits, so a listed failure such as a missing working +// directory no longer counts once the user changed it. +func (a *App) runConfigDraftUnavailable(p *project, key string) string { + draft := p.runConfigs.dialog.drafts[key] + if draft != nil && draft.form != nil { + if availability := draft.form.availability; availability != nil && availability.Status == "unavailable" { + return a.runAvailabilityText(draft.form.provider, *availability) + } + if draft.form.dirty { + return "" + } + } + if configuration := p.runConfigs.configuration(key); configuration != nil && configuration.Unavailable() { + return a.runConfigUnavailableText(*configuration) + } + return "" +} + +// runConfigDialogRunnable says Run can run the selected configuration once it is saved. +func (a *App) runConfigDialogRunnable(p *project) bool { + d := &p.runConfigs.dialog + draft := d.drafts[d.selected] + if draft == nil || a.runConfigDraftUnavailable(p, d.selected) != "" { + return false + } + if draft.form != nil { + return true + } + configuration := p.runConfigs.configuration(d.selected) + return configuration != nil && p.runConfigurationReady(*configuration) +} + +// runConfigDialogDirty says Apply has something to save. +func (d *runConfigDialog) dirty() bool { + if len(d.removed) > 0 { + return true + } + for _, draft := range d.drafts { + if draft.dirty() { + return true + } + } + return false +} + +// busy says a save runs, or a draft with something to save is still being read or saved. +func (d *runConfigDialog) busy() bool { + if d.saving { + return true + } + for _, draft := range d.drafts { + if draft.busy() { + return true + } + } + return false +} + +// runConfigDialogTask is one save of the chain Apply runs; done gets whether it succeeded. +type runConfigDialogTask func(done func(ok bool)) + +// applyRunConfigDialog saves what the dialog holds, one file change after another: the +// removals, then every draft with something to save. The first failure stops the chain and +// selects the configuration it belongs to, whose editor shows the reason. When every save +// succeeded, the selected configuration becomes the one the title bar runs; OK then closes the +// dialog, and Run closes it and runs the configuration once the list shows what was saved. The +// configurations are resolved again either way, so what was saved before a failure shows. +func (a *App) applyRunConfigDialog(p *project, step runConfigDialogStep) { + d := &p.runConfigs.dialog + if !d.open || d.busy() { + return + } + // The save order follows the tree, so a configuration added since the last paint saves too. + p.collectRunConfigDialogRows(a) + d.saving, d.failure = true, "" + generation := d.generation + var tasks []runConfigDialogTask + for _, id := range slices.Sorted(maps.Keys(d.removed)) { + tasks = append(tasks, func(done func(bool)) { + a.removeRunConfiguration(p, id, func(err error) { + if err != nil { + if d.generation == generation { + d.failure = i18n.SharedFormat(a.language(), "desktop.runConfig.deleteFailed", map[string]string{"reason": err.Error()}) + } + done(false) + return + } + delete(d.removed, id) + done(true) + }) + }) + } + for _, key := range p.runConfigDialogSaveOrder() { + draft := d.drafts[key] + tasks = append(tasks, func(done func(bool)) { + failed := func() { + if d.generation == generation { + d.selected, d.group = draft.key, "" + delete(d.closed, p.runConfigDialogGroupKey(draft.key)) + } + done(false) + } + if draft.form != nil { + a.saveRunConfigForm(p, draft.form, func(id string, ok bool) { + if !ok { + failed() + return + } + if d.generation == generation { + d.rekey(draft, id) + } + done(true) + }) + return + } + a.saveRunConfigEditor(p, draft.editor, func(ok bool) { + if !ok { + failed() + return + } + done(true) + }) + }) + } + finish := func(ok bool) { + if d.generation != generation { + a.refreshRunConfigurations(p) + return + } + d.saving = false + if ok { + s := &p.runConfigs + if id := d.selected; id != "" && !strings.HasPrefix(id, runConfigNewKey) { + s.reveal, s.currentFile = id, false + if step == runConfigDialogRun { + s.start = id + } + } + if step != runConfigDialogApply { + a.closeRunConfigDialog(p) + } + } + a.refreshRunConfigurations(p) + } + var next func(index int) + next = func(index int) { + if d.generation != generation { + finish(false) + return + } + if index == len(tasks) { + finish(true) + return + } + tasks[index](func(ok bool) { + if !ok { + finish(false) + return + } + next(index + 1) + }) + } + next(0) +} + +// runConfigDialogSaveOrder is the drafts with something to save, as the tree shows them, so a +// failure stops at the first one the user sees. +func (p *project) runConfigDialogSaveOrder() []string { + d := &p.runConfigs.dialog + var keys []string + seen := map[string]bool{} + for _, group := range d.groups { + for _, key := range group.keys { + if draft := d.drafts[key]; draft != nil && !seen[key] && draft.dirty() { + keys, seen[key] = append(keys, key), true + } + } + } + return keys +} + +// rekey files a draft under the ID its save returned, when that differs from its key: a new +// configuration's first save, or a rename that gave it another ID. The old ID stays out of the +// tree until the list stops showing it. +func (d *runConfigDialog) rekey(draft *runConfigDraft, id string) { + old := draft.key + if id == "" || id == old { + return + } + delete(d.drafts, old) + draft.key, d.drafts[id] = id, draft + if !strings.HasPrefix(old, runConfigNewKey) { + d.hidden[old] = true + } + if index := slices.Index(d.added, old); index >= 0 { + d.added[index] = id + } else { + d.added = append(d.added, id) + } + if d.selected == old { + d.selected = id + } + if row, ok := d.ids["c\x00"+old]; ok { + d.ids["c\x00"+id] = row + } +} + +// runConfigDialogRowID is the list key of a tree row, the same across paints: one per draft +// key and one per group key, numbered as they first show. +func (d *runConfigDialog) runConfigDialogRowID(row runConfigDialogRow) int { + key := "c\x00" + row.key + if row.key == "" { + key = "g\x00" + d.groups[row.group].key + } + id, ok := d.ids[key] + if !ok { + id = len(d.ids) + d.ids[key] = id + } + return id +} + +// runConfigDialogRowIndex is the index of the selected row among the rows as they show, -1 +// when nothing is selected or the selection is in a closed group. +func (d *runConfigDialog) runConfigDialogRowIndex() int { + for index, row := range d.rows { + if row.key == "" { + if d.selected == "" && d.group != "" && d.groups[row.group].key == d.group { + return index + } + } else if row.key == d.selected { + return index + } + } + return -1 +} + +// toggleRunConfigDialogGroup opens a closed group of the tree and closes an open one. +// Closing the group of the selected configuration leaves the selection on the group's row. +func (p *project) toggleRunConfigDialogGroup(key string) { + d := &p.runConfigs.dialog + if d.closed[key] { + delete(d.closed, key) + return + } + if d.closed == nil { + d.closed = map[string]bool{} + } + d.closed[key] = true + if d.selected != "" && p.runConfigDialogGroupKey(d.selected) == key { + d.selected, d.group = "", key + } +} + +// runAvailabilityText words why this platform cannot run a configuration of provider, from +// the availability Core gave its kind or its editor. +func (a *App) runAvailabilityText(provider string, availability core.RunAvailability) string { + language := a.language() + if availability.Code == "unsupportedPlatform" { + if provider == runProviderBatch { + return i18n.Shared(language, "desktop.runConfig.unavailableBatchPlatform") + } + kind, ok := runConfigTypeLabel(language, provider) + if !ok { + kind = provider + } + return i18n.SharedFormat(language, "desktop.runConfig.unavailablePlatform", map[string]string{"type": kind}) + } + return i18n.SharedFormat(language, "desktop.runConfig.unavailableOther", map[string]string{"reason": availability.Message}) +} diff --git a/desktop/internal/workbench/runconfig_dialog_test.go b/desktop/internal/workbench/runconfig_dialog_test.go new file mode 100644 index 0000000000..0e1d6b988b --- /dev/null +++ b/desktop/internal/workbench/runconfig_dialog_test.go @@ -0,0 +1,228 @@ +package workbench + +import ( + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" +) + +// emptyProcessRunHarness opens an empty project without any build plugin and waits until Core +// resolved its configurations and listed the built-in kinds. +func emptyProcessRunHarness(t *testing.T) (*harness, *project, string) { + t.Helper() + root := t.TempDir() + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(root) + p := h.app.project + h.app.post(func(a *App) { a.refreshRunConfigurations(p) }) + awaitStateWithin(t, h, 10*time.Second, "the empty configuration list", func() bool { + s := &p.runConfigs + return s.generation > 0 && !s.loading && s.types != nil + }) + if s := &p.runConfigs; s.failure != "" || len(s.list) != 0 { + t.Fatalf("configurations = %+v failure %q", s.list, s.failure) + } + return h, p, root +} + +// fillScriptText names form f, sets its script text and waits for the form that follows. +func fillScriptText(t *testing.T, h *harness, p *project, f *runConfigForm, name, text string) { + t.Helper() + h.app.post(func(a *App) { + *f.texts["name"] = name + *f.texts["source"] = "text" + a.runConfigFormEdited(p, f) + }) + awaitStateWithin(t, h, 10*time.Second, "the text field of "+name, func() bool { return !f.refreshing && f.texts["text"] != nil }) + h.app.post(func(*App) { *f.texts["text"] = text }) +} + +// applyDialog presses step once no draft is being read, as the buttons wait for, and waits until +// the save ended and the configurations resolved again. +func applyDialog(t *testing.T, h *harness, p *project, step runConfigDialogStep) { + t.Helper() + d := &p.runConfigs.dialog + awaitStateWithin(t, h, 10*time.Second, "the drafts to be read", func() bool { return !d.busy() }) + pressed := false + h.app.post(func(a *App) { + a.applyRunConfigDialog(p, step) + pressed = true + }) + awaitStateWithin(t, h, 10*time.Second, "the save", func() bool { + return pressed && !d.saving && !p.runConfigs.loading && p.runConfigs.pending == titleActionNone + }) +} + +// listedNames is the names of the listed configurations. +func listedNames(p *project) []string { + names := make([]string, 0, len(p.runConfigs.list)) + for _, configuration := range p.runConfigs.list { + names = append(names, configuration.Name) + } + return names +} + +// Apply saves every configuration created in the dialog in one press and keeps the dialog open +// on them under their saved IDs; Cancel drops what changed since; a removal waits for OK, and +// the selection moves to the configuration that takes the removed one's row. +func TestRunConfigDialogSavesWhatItHoldsTogether(t *testing.T) { + h, p, root := emptyProcessRunHarness(t) + d := &p.runConfigs.dialog + one := newRunConfigDraft(t, h, p, runProviderShell) + fillScriptText(t, h, p, one, "One", "echo one\n") + var two *runConfigForm + h.app.post(func(a *App) { + a.addRunConfigDraft(p, runProviderShell, nil) + two = d.drafts[d.selected].form + }) + awaitStateWithin(t, h, 10*time.Second, "the second form", func() bool { return two != nil && two.ready() }) + fillScriptText(t, h, p, two, "Two", "echo two\n") + h.settle() + if !d.dirty() { + t.Fatal("two new configurations show as nothing to save") + } + + applyDialog(t, h, p, runConfigDialogApply) + if names := listedNames(p); !d.open || len(names) != 2 { + t.Fatalf("dialog open %v, configurations %v, failure %q / %q / %q", d.open, names, d.failure, one.failure, two.failure) + } + for key, draft := range d.drafts { + if strings.HasPrefix(key, runConfigNewKey) || draft.key != key || draft.dirty() { + t.Fatalf("draft %q = key %q dirty %v after Apply", key, draft.key, draft.dirty()) + } + } + if !strings.HasPrefix(d.selected, "user:") || d.selected != two.id || p.runConfigs.selected != two.id || p.runConfigs.currentFile { + t.Fatalf("selected %q, title %q current file %v, want %q", d.selected, p.runConfigs.selected, p.runConfigs.currentFile, two.id) + } + if d.dirty() { + t.Fatal("the dialog shows something to save after Apply") + } + local := filepath.Join(root, ".lithe", "run", "local.yaml") + saved, err := os.ReadFile(local) + if err != nil || !strings.Contains(string(saved), "One") || !strings.Contains(string(saved), "Two") { + t.Fatalf("local.yaml = %s, %v", saved, err) + } + + // Cancel drops a removal and a new configuration together. + oneID := one.id + h.app.post(func(a *App) { + a.selectRunConfigDraft(p, oneID) + a.removeRunConfigDraft(p) + a.addRunConfigDraft(p, runProviderExecutable, nil) + a.closeRunConfigDialog(p) + }) + h.settle() + if data, _ := os.ReadFile(local); string(data) != string(saved) || len(p.runConfigs.list) != 2 { + t.Fatalf("Cancel wrote: %s, configurations %v", data, listedNames(p)) + } + + // A removal waits for OK; − moves the selection to the configuration below. + h.app.post(func(a *App) { + a.openRunConfigDialog(p, oneID) + a.removeRunConfigDraft(p) + }) + h.settle() + if !d.removed[oneID] || d.selected != two.id || h.shows("One") || len(p.runConfigs.list) != 2 { + t.Fatalf("removed %v selected %q, configurations %v", d.removed, d.selected, listedNames(p)) + } + applyDialog(t, h, p, runConfigDialogOK) + if names := listedNames(p); d.open || len(names) != 1 || names[0] != "Two" { + t.Fatalf("dialog open %v, configurations %v, failure %q", d.open, names, d.failure) + } +} + +// Copy creates a new configuration with the values the selected one's form shows, named as a +// copy; the copy saves as a configuration of its own. +func TestRunConfigDialogCopiesAConfiguration(t *testing.T) { + h, p, _ := emptyProcessRunHarness(t) + d := &p.runConfigs.dialog + original := newRunConfigDraft(t, h, p, runProviderShell) + fillScriptText(t, h, p, original, "Greet", "echo hello\n") + h.settle() + h.app.post(func(a *App) { a.copyRunConfigDraft(p) }) + var copied *runConfigForm + awaitStateWithin(t, h, 10*time.Second, "the copy's form", func() bool { + if draft := d.drafts[d.selected]; draft != nil && draft.form != original { + copied = draft.form + } + return copied != nil && copied.ready() + }) + want := i18n.SharedFormat(h.app.language(), "desktop.runConfig.copyName", map[string]string{"name": "Greet"}) + if *copied.texts["name"] != want || *copied.texts["text"] != "echo hello\n" || len(d.added) != 2 { + t.Fatalf("copy = name %q text %q, added %v", *copied.texts["name"], *copied.texts["text"], d.added) + } + applyDialog(t, h, p, runConfigDialogOK) + if names := listedNames(p); len(names) != 2 { + t.Fatalf("configurations %v, failure %q", names, d.failure) + } +} + +// Closing the group of the selected configuration leaves the selection on the group's row, and +// the group stays closed when the dialog opens again. +func TestRunConfigDialogGroupsClose(t *testing.T) { + h, p, _ := emptyProcessRunHarness(t) + d := &p.runConfigs.dialog + newRunConfigDraft(t, h, p, runProviderShell) + h.settle() + group := runProcessKindKey(runProviderShell) + if len(d.rows) != 2 || d.runConfigDialogRowIndex() != 1 { + t.Fatalf("rows %+v, selected row %d", d.rows, d.runConfigDialogRowIndex()) + } + h.app.post(func(*App) { p.toggleRunConfigDialogGroup(group) }) + h.settle() + if d.selected != "" || d.group != group || len(d.rows) != 1 || d.runConfigDialogRowIndex() != 0 { + t.Fatalf("selected %q group %q rows %+v", d.selected, d.group, d.rows) + } + h.app.post(func(a *App) { + a.closeRunConfigDialog(p) + a.openRunConfigDialog(p, "") + }) + if !d.closed[group] { + t.Fatal("the closed group opened again with the dialog") + } +} + +// Off Windows a batch script is created, edited and saved like any other run, under a warning +// that it cannot run here: the dialog's Run is off, the tree marks it, and the title bar's Run +// says why instead of starting it. +func TestBatchRunIsEditedButNotRunOffWindows(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Windows runs batch scripts") + } + h, p, root := emptyProcessRunHarness(t) + d := &p.runConfigs.dialog + f := newRunConfigDraft(t, h, p, runProviderBatch) + if f.availability == nil || f.availability.Code != "unsupportedPlatform" { + t.Fatalf("availability = %+v", f.availability) + } + fillScriptText(t, h, p, f, "Package", "@echo off\r\ncall build.cmd\r\n") + h.settle() + want := i18n.Shared(h.app.language(), "desktop.runConfig.unavailableBatchPlatform") + if !h.shows(want) || h.app.runConfigDialogRunnable(p) || h.app.runConfigDraftUnavailable(p, d.selected) != want { + t.Fatalf("warning shown %v, runnable %v", h.shows(want), h.app.runConfigDialogRunnable(p)) + } + + applyDialog(t, h, p, runConfigDialogOK) + configuration := p.titleConfiguration() + if d.open || configuration == nil || configuration.Name != "Package" || !configuration.Unavailable() { + t.Fatalf("dialog open %v, title configuration %+v, failure %q / %q", d.open, configuration, d.failure, f.failure) + } + if got := h.app.runConfigUnavailableText(*configuration); got != want { + t.Fatalf("unavailable text = %q, want %q", got, want) + } + if data, err := os.ReadFile(filepath.Join(root, ".lithe", "run", "local.yaml")); err != nil || !strings.Contains(string(data), "call build.cmd") { + t.Fatalf("local.yaml = %s, %v", data, err) + } + + h.app.post(func(a *App) { a.titleRun(p) }) + h.settle() + if got := lastNotice(h); got != want || len(p.build.runs) != 0 { + t.Fatalf("notice %q, want %q; runs %d", got, want, len(p.build.runs)) + } +} diff --git a/desktop/internal/workbench/runconfig_dialog_view.go b/desktop/internal/workbench/runconfig_dialog_view.go new file mode 100644 index 0000000000..a78f176b74 --- /dev/null +++ b/desktop/internal/workbench/runconfig_dialog_view.go @@ -0,0 +1,382 @@ +package workbench + +import ( + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/icons" + "github.com/1lck/Lithe-IDEA/desktop/internal/treelist" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui" +) + +// This file draws the Run/Debug Configurations dialog of runconfig_dialog.go. + +const ( + // runConfigDialogWidth and runConfigDialogHeight size the dialog: wide enough for the + // tree and a path with its options beside it, tall enough for a script's fields. + runConfigDialogWidth = 900 + runConfigDialogHeight = 620 + // runConfigDialogTreeWidth is the width of the tree and its toolbar. + runConfigDialogTreeWidth = 260 + // runConfigDialogIndent indents a configuration under its group's arrow. + runConfigDialogIndent = treelist.Disclosure + 6 +) + +// drawRunConfigDialog declares the dialog while it is open: the toolbar and tree on the left, +// the selected configuration's editor on the right, and Run, Cancel, Apply and OK below. +// Escape and the close button end it like Cancel. +func (a *App) drawRunConfigDialog(c ui.C, p *project) { + d := &p.runConfigs.dialog + if !d.open { + return + } + p.collectRunConfigDialogRows(a) + open := true + title := i18n.Shared(a.language(), "desktop.runConfig.dialogTitle") + ui.ModalWith(c, &open, title, ui.ModalSpec{Width: runConfigDialogWidth, Height: runConfigDialogHeight}, func() { + k := c.Part("run-config-dialog") + ui.Row(k).Fill().Children(func() { + a.drawRunConfigDialogTree(k, p) + ui.Column(k).Width(1).FillHeight().Shrink(0).Background(a.colors.Line) + a.drawRunConfigDialogPane(k, p) + }) + }, func() { + a.drawRunConfigDialogFooter(c.Part("run-config-dialog-footer"), p) + }) + if !open { + c.After(func() { a.closeRunConfigDialog(p) }) + } +} + +// drawRunConfigDialogTree declares the left column: the buttons that add, remove and copy a +// configuration over the tree of configurations by kind. +func (a *App) drawRunConfigDialogTree(c ui.C, p *project) { + s := &p.runConfigs + d := &s.dialog + language := a.language() + k := c.Part("tree") + ui.Column(k).Width(runConfigDialogTreeWidth).FillHeight().Shrink(0).Children(func() { + ui.Row(k.Part("toolbar")).FillWidth().Height(panelHeaderHeight).Shrink(0).Items(ui.Center).Gap(2).PadX(6).Children(func() { + label := i18n.Shared(language, "desktop.runConfig.newConfiguration") + add, clicked := a.gitToolButton(k.Part("add"), label, icons.Plus, d.newMenu, d.saving) + if clicked { + d.newMenu = !d.newMenu + } + ui.Menu(k.Part("add-menu"), add, &d.newMenu, func(menu *ui.MenuItems) { + menu.WidthRange(200, 300) + a.runConfigDialogTypeItems(k, menu, p) + }) + if a.gitIconButton(k.Part("remove"), i18n.Shared(language, "desktop.runConfig.removeConfiguration"), icons.Minus, false, !p.runConfigRemovable(d.selected)) { + c.After(func() { + a.performed("run.configuration.remove", surfaceButton) + a.removeRunConfigDraft(p) + }) + } + draft := d.drafts[d.selected] + copyable := !d.saving && draft != nil && draft.form != nil && draft.form.ready() + if a.gitIconButton(k.Part("copy"), i18n.Shared(language, "desktop.runConfig.copyConfiguration"), icons.Copy, false, !copyable) { + c.After(func() { + a.performed("run.configuration.copy", surfaceButton) + a.copyRunConfigDraft(p) + }) + } + }) + ui.Row(k).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) + ui.Column(k.Part("rows")).FillWidth().Grow(1).MinHeight(0).PadSides(4, 4, 4, 4).Children(func() { + a.drawRunConfigDialogRows(k, p) + }) + if s.hidden > 0 { + ui.Row(k).FillWidth().Height(1).Shrink(0).Background(a.colors.Line) + ui.Row(k.Part("hidden")).FillWidth().Shrink(0).Items(ui.Center).Gap(6).Pad(8).Children(func() { + ui.Icon(k, icons.Info).Size(12, 12).Shrink(0).Color(a.colors.Subtle) + ui.Paragraph(k, hiddenRunConfigurations(language, s.hidden), 2).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Grow(1).MinWidth(0) + }) + } + }) +} + +// runConfigDialogTypeItems adds an item per built-in kind to the + menu, each creating a new +// configuration of that kind. A kind this platform cannot run is still offered, saying so. +func (a *App) runConfigDialogTypeItems(c ui.C, menu *ui.MenuItems, p *project) { + language := a.language() + for _, kind := range p.runConfigs.types { + label, ok := runConfigTypeLabel(language, kind.Provider) + if !ok { + continue + } + provider := kind.Provider + item := menu.Item(label).Icon(runConfigTypeIcon(provider)) + if kind.Unavailable() { + item = item.Description(runConfigTypeNote(language, kind)) + } + if item.Clicked() { + c.After(func() { + a.performed("run.configuration.new", surfaceButton) + a.addRunConfigDraft(p, provider, nil) + }) + } + } + if len(p.runConfigs.types) == 0 { + menu.Item(i18n.Shared(language, "native.loading")).Disabled(true) + } +} + +// runConfigTypeNote is the short note of a kind this platform cannot run, beside its name. +func runConfigTypeNote(language i18n.Language, kind core.RunConfigurationType) string { + if kind.Provider == runProviderBatch && kind.Availability != nil && kind.Availability.Code == "unsupportedPlatform" { + return i18n.Shared(language, "desktop.runConfig.windowsOnlyType") + } + return i18n.Shared(language, "desktop.runConfig.typeNotRunnableHere") +} + +// drawRunConfigDialogRows declares the tree. Selecting a configuration shows its editor; +// Enter or a double click on a group opens or closes it. +func (a *App) drawRunConfigDialogRows(c ui.C, p *project) { + s := &p.runConfigs + d := &s.dialog + language := a.language() + if len(d.rows) == 0 { + message := i18n.Shared(language, "desktop.runConfig.emptyHint") + switch { + case s.failure != "": + message = i18n.SharedFormat(language, "desktop.runConfig.loadFailed", map[string]string{"reason": s.failure}) + case s.loading || s.generation == 0: + message = i18n.Shared(language, "native.loading") + } + // The message wraps inside the narrow column instead of centering one long line over it. + ui.Column(c.Part("empty")).Fill().Center().PadX(12).Children(func() { + ui.Paragraph(c, message, 4).TextCenter().FillWidth().Color(a.colors.Subtle) + }) + return + } + if d.view.Key == nil { + d.view.Key = func(i int) int { return d.runConfigDialogRowID(d.rows[i]) } + d.view.Label = func(i int) string { + if row := d.rows[i]; row.key != "" { + return a.runConfigDraftLabel(p, row.key) + } + return d.groups[d.rows[i].group].title + } + } + selected := d.runConfigDialogRowIndex() + if !d.view.Changed() && d.view.Selected() != selected { + d.view.Select(selected) + } + title := i18n.Shared(language, "desktop.runConfig.dialogTitle") + ui.List(c, &d.view, len(d.rows), func(row ui.ListRow) { a.drawRunConfigDialogRow(p, row, row.Index == selected) }). + Scrollbars().Label(title).Grow(1).FillWidth() + if d.view.Changed() { + if i := d.view.Selected(); i >= 0 && i < len(d.rows) { + row := d.rows[i] + if row.key != "" { + key := row.key + c.After(func() { a.selectRunConfigDraft(p, key) }) + } else { + key := d.groups[row.group].key + c.After(func() { d.selected, d.group, d.newMenu = "", key, false }) + } + } + } + if i, ok := d.view.Submitted(); ok && i >= 0 && i < len(d.rows) && d.rows[i].key == "" { + key := d.groups[d.rows[i].group].key + c.After(func() { p.toggleRunConfigDialogGroup(key) }) + } +} + +// drawRunConfigDialogRow declares one row of the tree: a group's arrow, icon and title, or a +// configuration's icon and name. A configuration this platform cannot run shows a warning +// icon and says why on hover. +func (a *App) drawRunConfigDialogRow(p *project, row ui.ListRow, selected bool) { + d := &p.runConfigs.dialog + c, r := row.C, d.rows[row.Index] + box := row.Element.Height(buildRowHeight).Items(ui.Center).Gap(6).PadX(6).Radius(a.theme.Metrics.RadiusItem()) + if selected { + box = box.Background(a.colors.Selection) + } else { + box = box.Hover(ui.Look{}.Background(a.colors.Hover)) + } + group := d.groups[r.group] + if r.key == "" { + box.Children(func() { + a.drawRunConfigDialogArrow(c, p, group) + ui.Icon(c, group.icon).Size(14, 14).Shrink(0).Color(a.colors.Subtle) + ui.Text(c, group.title).Ellipsis().Shrink(1).MinWidth(0) + }) + return + } + unavailable := a.runConfigDraftUnavailable(p, r.key) + if unavailable != "" { + box = box.Tooltip(unavailable) + } + box.Children(func() { + ui.Row(c.Part("indent")).Size(runConfigDialogIndent, treelist.Icon).Shrink(0) + icon, color := a.runConfigDraftIcon(p, r.key), a.colors.Subtle + if unavailable != "" { + icon, color = icons.CircleAlert, a.colors.Warning + } + ui.Icon(c, icon).Size(14, 14).Shrink(0).Color(color) + ui.Text(c, a.runConfigDraftLabel(p, r.key)).Ellipsis().Shrink(1).MinWidth(0) + }) +} + +// runConfigDraftIcon is the icon of configuration key in the tree: its kind's for a built-in +// run, its execution's for a build provider run. +func (a *App) runConfigDraftIcon(p *project, key string) gfx.Icon { + if configuration := p.runConfigs.configuration(key); configuration != nil { + if configuration.IsProcess() { + return runConfigTypeIcon(configuration.Provider) + } + return runExecutionIcon(configuration.Execution) + } + if draft := p.runConfigs.dialog.drafts[key]; draft != nil && draft.form != nil { + return runConfigTypeIcon(draft.form.provider) + } + return icons.FileCode +} + +// drawRunConfigDialogArrow declares the arrow that opens or closes a group of the tree. +func (a *App) drawRunConfigDialogArrow(c ui.C, p *project, group runConfigDialogGroup) { + open := !p.runConfigs.dialog.closed[group.key] + name, chevron := i18n.Shared(a.language(), "native.collapseSection"), icons.ChevronDown + if !open { + name, chevron = i18n.Shared(a.language(), "native.expandSection"), icons.ChevronRight + } + k := c.Part("arrow") + slot := ui.Row(k).Size(treelist.Disclosure, treelist.Icon).Shrink(0).Center(). + HitWith(ui.ID(k), name+" "+group.title, gfx.HitOptions{Role: gfx.RoleButton, Cursor: gfx.PointerCursorHand, Expandable: true, Expanded: open, SkipFocus: true}) + slot.Children(func() { + ui.Icon(k, chevron).Size(12, 12).Color(a.colors.Subtle) + }) + if slot.Clicked() { + key := group.key + c.After(func() { p.toggleRunConfigDialogGroup(key) }) + } +} + +// drawRunConfigDialogPane declares the right column: the editor of the selected +// configuration, under the reason this platform cannot run it, or, with nothing selected, the +// kinds a new configuration can take. +func (a *App) drawRunConfigDialogPane(c ui.C, p *project) { + d := &p.runConfigs.dialog + k := c.Part("pane") + ui.Column(k).Grow(1).FillHeight().MinWidth(0).Children(func() { + draft := d.drafts[d.selected] + ui.Scroll(k).Scrollbars().FillWidth().Grow(1).Children(func() { + ui.Column(k).FillWidth().Gap(10).PadSides(14, 20, 14, 16).Children(func() { + if draft == nil { + a.drawRunConfigDialogStart(k, p) + } else { + if text := a.runConfigDraftUnavailable(p, d.selected); text != "" { + a.drawRunConfigDialogBanner(k, text) + } + a.drawRunConfigDraft(k, p, draft) + } + if d.failure != "" { + ui.Paragraph(k, d.failure, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) + } + }) + }) + }) +} + +// drawRunConfigDraft declares the editor of one configuration: the form of a built-in run, the +// options of a build provider run, or why a run whose plugin cannot resolve has no editor. +func (a *App) drawRunConfigDraft(c ui.C, p *project, draft *runConfigDraft) { + d := &p.runConfigs.dialog + language := a.language() + switch { + case draft.form != nil: + f := draft.form + if f.loading && f.fields == nil { + ui.Text(c, i18n.Shared(language, "native.loading")).Color(a.colors.Subtle) + } + a.drawRunConfigFormFields(c, p, f, f.ready() && !d.saving) + if f.failure != "" { + ui.Paragraph(c, f.failure, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) + } + case draft.editor != nil: + ui.Text(c, draft.editor.name).Weight(gfx.WeightSemibold).Ellipsis().FillWidth() + if draft.editor.loading { + ui.Text(c, i18n.Shared(language, "native.loading")).Color(a.colors.Subtle) + } + a.drawRunConfigEditorPane(c, p, draft.editor) + default: + ui.Text(c, a.runConfigDraftLabel(p, draft.key)).Weight(gfx.WeightSemibold).Ellipsis().FillWidth() + ui.Paragraph(c, i18n.Shared(language, "desktop.runConfig.notEditable"), 3).Color(a.colors.Subtle) + } +} + +// drawRunConfigDialogStart declares the pane while nothing is selected: a hint and a button +// per built-in kind that creates a configuration of it. +func (a *App) drawRunConfigDialogStart(c ui.C, p *project) { + s := &p.runConfigs + d := &s.dialog + language, small := a.language(), a.theme.Metrics.FontSizeS + ui.Paragraph(c, i18n.Shared(language, "desktop.runConfig.dialogHint"), 3).Color(a.colors.Subtle) + if len(s.types) == 0 { + ui.Text(c, i18n.Shared(language, "native.loading")).Color(a.colors.Subtle) + return + } + for index, kind := range s.types { + label, ok := runConfigTypeLabel(language, kind.Provider) + if !ok { + continue + } + provider := kind.Provider + k := c.KeyInt(index) + ui.Row(k).FillWidth().Items(ui.Center).Gap(8).Children(func() { + if ui.Button(k, label).Icon(runConfigTypeIcon(provider)).Outline().Disabled(d.saving).Clicked() { + c.After(func() { + a.performed("run.configuration.new", surfaceButton) + a.addRunConfigDraft(p, provider, nil) + }) + } + if kind.Unavailable() { + ui.Text(k, runConfigTypeNote(language, kind)).FontSize(small).Color(a.colors.Subtle).Ellipsis().Shrink(1).MinWidth(0) + } + }) + } +} + +// drawRunConfigDialogBanner declares the warning over an editor whose configuration this +// platform cannot run, so the user sees why Run is off before editing. +func (a *App) drawRunConfigDialogBanner(c ui.C, text string) { + k := c.Part("banner") + ui.Row(k).FillWidth().Items(ui.Start).Gap(8).Pad(8).Radius(a.theme.Metrics.RadiusItem()).Border(1, a.colors.Warning).Children(func() { + ui.Icon(k, icons.CircleAlert).Size(14, 14).Shrink(0).Color(a.colors.Warning) + ui.Paragraph(k, text, 4).FontSize(a.theme.Metrics.FontSizeS).Grow(1).MinWidth(0) + }) +} + +// drawRunConfigDialogFooter declares Run on the left, and Cancel, Apply and OK on the right. +// Run saves first and is off while the selected configuration cannot run here; Apply is off +// while nothing changed. +func (a *App) drawRunConfigDialogFooter(c ui.C, p *project) { + d := &p.runConfigs.dialog + language := a.language() + busy := d.busy() + ui.Row(c).FillWidth().Items(ui.Center).Gap(8).Children(func() { + if ui.Button(c, i18n.Shared(language, "desktop.runConfig.run")).Icon(icons.Play).Outline().Disabled(busy || !a.runConfigDialogRunnable(p)).Clicked() { + c.After(func() { + a.performed("run.configuration.dialog.run", surfaceButton) + a.applyRunConfigDialog(p, runConfigDialogRun) + }) + } + ui.Spacer(c) + if ui.Button(c, i18n.Shared(language, "desktop.git.cancel")).Outline().Clicked() { + c.After(func() { a.closeRunConfigDialog(p) }) + } + if ui.Button(c, i18n.Shared(language, "desktop.runConfig.apply")).Outline().Disabled(busy || !d.dirty()).Clicked() { + c.After(func() { + a.performed("run.configuration.dialog.apply", surfaceButton) + a.applyRunConfigDialog(p, runConfigDialogApply) + }) + } + if ui.Button(c, i18n.Shared(language, "desktop.runConfig.ok")).Disabled(busy).Clicked() { + c.After(func() { + a.performed("run.configuration.dialog.save", surfaceButton) + a.applyRunConfigDialog(p, runConfigDialogOK) + }) + } + }) +} diff --git a/desktop/internal/workbench/runconfig_edit.go b/desktop/internal/workbench/runconfig_edit.go index 1fded14f6c..def928b195 100644 --- a/desktop/internal/workbench/runconfig_edit.go +++ b/desktop/internal/workbench/runconfig_edit.go @@ -14,14 +14,18 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" ) -// runConfigEditor is the open editor of one configuration's options. It starts from -// the effective values Core resolved, and saving writes them into the chosen layer -// file, so the next resolve shows what took effect. Every field is bound to a widget -// by address and lives here, not in a paint's locals. +// runConfigEditor is the editor of one build provider run's options in the Run/Debug +// Configurations dialog (runconfig_dialog.go). It starts from the effective values Core +// resolved, and saving writes them into the chosen layer file, so the next resolve shows what +// took effect. Every field is bound to a widget by address and lives here, not in a paint's +// locals. type runConfigEditor struct { + // open is cleared when the dialog drops the editor; answers still out are then ignored. open bool - // generation rejects the answer of an editor that was closed or reopened since. - generation uint64 + // generation rejects the answer of an editor that was dropped since. + generation uint64 + // baseline is the editor's fingerprint when it was read or last saved; see dirty. + baseline string id, name string arguments string directory string @@ -100,18 +104,15 @@ func providerRunEditorState(configuration core.RunConfiguration) (runConfigEdito return state, true } -// openRunConfigEditor opens the editor on configuration id. The argument field fills -// once Core formatted the saved vector as reversible editor text. -func (a *App) openRunConfigEditor(p *project, id string) { +// openRunConfigEditor reads the editor of configuration id, nil when it is not listed. The +// argument field fills once Core formatted the saved vector as reversible editor text. +func (a *App) openRunConfigEditor(p *project, id string) *runConfigEditor { configuration := p.runConfigs.configuration(id) if configuration == nil { - return + return nil } - e := &p.runConfigs.editor - e.generation++ - generation := e.generation - *e = runConfigEditor{ - open: true, generation: generation, id: id, name: configuration.Name, + e := &runConfigEditor{ + open: true, generation: 1, id: id, name: configuration.Name, directory: configuration.Cwd, environment: environmentText(configuration.Env), scope: "local", loading: true, } @@ -124,8 +125,9 @@ func (a *App) openRunConfigEditor(p *project, id string) { if reference, ok := configuration.BuildReference(); ok { e.optionFields = p.runOptionFields(reference, e.options) } - a.loadRunConfigInstalls(p, generation) + a.loadRunConfigInstalls(p, e, e.generation) } + generation := e.generation args, kernel := slices.Clone(configuration.Args), a.kernel a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { texts, err := kernel.RunArgumentText(ctx, [][]string{args}) @@ -133,49 +135,71 @@ func (a *App) openRunConfigEditor(p *project, id string) { err = errors.New("runConfig.argumentText returned no text") } return func(a *App) { - e := &p.runConfigs.editor if !e.open || e.generation != generation { return } e.loading = false - if err != nil { + if err == nil { + e.arguments = texts[0] + } else { e.failure = i18n.SharedFormat(a.language(), "desktop.runConfig.saveFailed", map[string]string{"reason": err.Error()}) - return } - e.arguments = texts[0] + e.baseline = e.fingerprint() } }) + return e } -func (a *App) closeRunConfigEditor(p *project) { - e := &p.runConfigs.editor +// close drops the editor; answers still out are ignored. +func (e *runConfigEditor) close() { e.generation++ e.open, e.loading, e.saving = false, false, false } -// saveRunConfigEditor has Core apply the edit to the chosen layer, applies the file changes it -// returns, then resolves the configurations again. -func (a *App) saveRunConfigEditor(p *project) { - e := &p.runConfigs.editor - if !e.open || e.loading || e.saving { +// ready says the editor is read and not being saved. +func (e *runConfigEditor) ready() bool { + return e.open && !e.loading && !e.saving +} + +// fingerprint is every value the editor saves, so a change shows as a different one. +func (e *runConfigEditor) fingerprint() string { + values := []any{e.arguments, e.directory, e.environment, e.scope, e.runtimeArguments, e.entrypoint, append([]string{}, e.beforeLaunch...)} + for _, tool := range e.tools { + values = append(values, tool.id, tool.kind, tool.path) + } + for _, field := range e.optionFields { + values = append(values, field.flag, field.text, field.picks) + } + raw, _ := json.Marshal(values) + return string(raw) +} + +// dirty says a value changed since the editor was read or last saved. +func (e *runConfigEditor) dirty() bool { + return e.ready() && e.fingerprint() != e.baseline +} + +// saveRunConfigEditor has Core apply the edit to the chosen layer and applies the file changes +// it returns; done gets whether it saved. A failure stays in the editor. The caller resolves +// the configurations again. +func (a *App) saveRunConfigEditor(p *project, e *runConfigEditor, done func(ok bool)) { + if !e.ready() { + done(false) return } environment, line := parseEnvironment(e.environment) if line > 0 { e.failure = i18n.SharedFormat(a.language(), "desktop.runConfig.environmentInvalid", map[string]string{"line": strconv.Itoa(line)}) + done(false) return } - e.saving, e.failure = true, "" - generation := e.generation edit := core.RunOptionsEdit{ Root: p.root, Scope: e.scope, ConfigurationID: e.id, WorkingDirectory: strings.TrimSpace(e.directory), Arguments: e.arguments, Environment: environment, } + steps := e.savedBeforeLaunch if !slices.Equal(e.beforeLaunch, e.savedBeforeLaunch) { - steps := slices.Clone(e.beforeLaunch) - if steps == nil { - steps = []string{} - } + steps = append([]string{}, e.beforeLaunch...) edit.BeforeLaunch = &steps } if e.provider { @@ -183,24 +207,31 @@ func (a *App) saveRunConfigEditor(p *project) { raw, err := providerRunOptionsJSON(e) if err != nil { e.failure = i18n.SharedFormat(a.language(), "desktop.runConfig.saveFailed", map[string]string{"reason": err.Error()}) + done(false) return } edit.ProviderRunOptions = raw } + e.saving, e.failure = true, "" + generation := e.generation a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { err := a.saveRunConfigOptions(ctx, edit) return func(a *App) { - e := &p.runConfigs.editor - if !e.open || e.generation != generation { - return + current := e.open && e.generation == generation + if current { + e.saving = false } - e.saving = false if err != nil { - e.failure = a.runConfigSaveFailure(err) + if current { + e.failure = a.runConfigSaveFailure(err) + } + done(false) return } - a.closeRunConfigEditor(p) - a.refreshRunConfigurations(p) + if current { + e.baseline, e.savedBeforeLaunch = e.fingerprint(), slices.Clone(steps) + } + done(true) } }) } @@ -293,7 +324,7 @@ func providerRunOptionsJSON(e *runConfigEditor) (json.RawMessage, error) { // loadRunConfigInstalls reads the toolchain discovery the settings page reads, so the editor can offer // the discovered installations. The answer is applied only while the same editor is open. -func (a *App) loadRunConfigInstalls(p *project, generation uint64) { +func (a *App) loadRunConfigInstalls(p *project, e *runConfigEditor, generation uint64) { a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { snapshot, err := settingsToolchains{app: a}.Load(ctx) var installs []runConfigInstall @@ -309,7 +340,6 @@ func (a *App) loadRunConfigInstalls(p *project, generation uint64) { } } return func(a *App) { - e := &p.runConfigs.editor if !e.open || e.generation != generation || err != nil { return } diff --git a/desktop/internal/workbench/runconfig_edit_test.go b/desktop/internal/workbench/runconfig_edit_test.go index 30aab4ab25..c34376173a 100644 --- a/desktop/internal/workbench/runconfig_edit_test.go +++ b/desktop/internal/workbench/runconfig_edit_test.go @@ -36,18 +36,30 @@ func loadedRunConfigs(t *testing.T, kernel Kernel, root string) (*harness, *proj return h, p } -// The editor opens on the resolved values, saving writes the local layer through Core -// and the configurations resolve again with the edit. +// The editor opens in the Run/Debug Configurations dialog on the resolved values, OK writes the +// local layer through Core and the configurations resolve again with the edit. func TestRunConfigEditorSavesTheLocalLayer(t *testing.T) { root := t.TempDir() h, p := loadedRunConfigs(t, &testKernel{Client: core.NewClient()}, root) id := p.runConfigs.selected - e := &p.runConfigs.editor - h.app.post(func(a *App) { a.openRunConfigEditor(p, id) }) - awaitStateWithin(t, h, 10*time.Second, "the editor's argument text", func() bool { return e.open && !e.loading }) + d := &p.runConfigs.dialog + // open opens the dialog on configuration id and waits for its editor. + open := func() *runConfigEditor { + t.Helper() + h.app.post(func(a *App) { a.editRunConfiguration(p, id) }) + var e *runConfigEditor + awaitStateWithin(t, h, 10*time.Second, "the editor's argument text", func() bool { + if draft := d.drafts[id]; d.open && draft != nil { + e = draft.editor + } + return e != nil && !e.loading + }) + return e + } + e := open() language := h.app.language() - if title := i18n.SharedFormat(language, "desktop.runConfig.editTitle", map[string]string{"name": "Run Main"}); !h.shows(title) { - t.Fatalf("the editor titled %q is not shown", title) + if !h.shows(i18n.Shared(language, "desktop.runConfig.dialogTitle")) || !h.shows("Run Main") { + t.Fatal("the dialog with the configuration's editor is not shown") } h.app.post(func(*App) { e.arguments = `--name "Alice Smith"` @@ -55,10 +67,13 @@ func TestRunConfigEditorSavesTheLocalLayer(t *testing.T) { e.environment = "MODE=prod\n\nTRACE=1" }) h.settle() - save := h.hitLabeled(i18n.Shared(language, "ui.save")) - h.click(gfx.Point{X: save.X + save.Width/2, Y: save.Y + save.Height/2}) + if !d.dirty() { + t.Fatal("the edit does not show as something to save") + } + ok := h.hitLabeled(i18n.Shared(language, "desktop.runConfig.ok")) + h.click(gfx.Point{X: ok.X + ok.Width/2, Y: ok.Y + ok.Height/2}) awaitStateWithin(t, h, 10*time.Second, "the saved configuration", func() bool { - return !e.open && !p.runConfigs.loading && len(p.runConfigs.list) == 1 && len(p.runConfigs.list[0].Args) == 2 + return !d.open && !p.runConfigs.loading && len(p.runConfigs.list) == 1 && len(p.runConfigs.list[0].Args) == 2 }) got := p.runConfigs.list[0] if !slices.Equal(got.Args, []string{"--name", "Alice Smith"}) || got.Cwd != "app/server" || got.Env["MODE"] != "prod" || got.Env["TRACE"] != "1" { @@ -74,22 +89,33 @@ func TestRunConfigEditorSavesTheLocalLayer(t *testing.T) { } } - // Reopening shows the saved values as editor text. - h.app.post(func(a *App) { a.openRunConfigEditor(p, id) }) - awaitStateWithin(t, h, 10*time.Second, "the reopened editor", func() bool { return e.open && !e.loading }) - if e.arguments != `--name "Alice Smith"` || e.environment != "MODE=prod\nTRACE=1" || e.directory != "app/server" { - t.Fatalf("editor = %+v", *e) + // Reopening shows the saved values as editor text, with nothing to save. + e = open() + if e.arguments != `--name "Alice Smith"` || e.environment != "MODE=prod\nTRACE=1" || e.directory != "app/server" || d.dirty() { + t.Fatalf("editor = %+v, dirty %v", *e, d.dirty()) + } + + // A changed step list counts as a change; one emptied again is the list the editor read. + h.app.post(func(*App) { e.beforeLaunch = []string{"user:prepare"} }) + h.settle() + if !d.dirty() { + t.Fatal("a changed step list does not show as something to save") + } + h.app.post(func(*App) { e.beforeLaunch = []string{} }) + h.settle() + if d.dirty() { + t.Fatal("an emptied step list shows as something to save") } - // A line without a name keeps the editor open with the line number, and writes nothing. + // A line without a name keeps the dialog open with the line number, and writes nothing. h.app.post(func(a *App) { e.environment = "MODE=prod\n=oops" - a.saveRunConfigEditor(p) + a.applyRunConfigDialog(p, runConfigDialogOK) }) h.settle() want := i18n.SharedFormat(language, "desktop.runConfig.environmentInvalid", map[string]string{"line": "2"}) - if !e.open || e.saving || e.failure != want { - t.Fatalf("editor = %+v, want failure %q", *e, want) + if !d.open || d.saving || e.saving || e.failure != want || d.selected != id { + t.Fatalf("dialog open %v saving %v, editor = %+v, want failure %q", d.open, d.saving, *e, want) } } diff --git a/desktop/internal/workbench/runconfig_form.go b/desktop/internal/workbench/runconfig_form.go index a68e946014..a1c5673341 100644 --- a/desktop/internal/workbench/runconfig_form.go +++ b/desktop/internal/workbench/runconfig_form.go @@ -13,8 +13,8 @@ import ( "github.com/vivaui/viva/app" ) -// This file holds the editor of built-in process runs: shell, PowerShell and batch scripts -// and programs. Core describes the editor as data (`runConfig.editorForm`): the fields in +// This file holds the editor of built-in process runs, shown in the Run/Debug Configurations +// dialog: shell, PowerShell and batch scripts and programs. Core describes the editor as data (`runConfig.editorForm`): the fields in // order, their kinds and current values, and the automatic value of each empty field. Core // also checks the values and returns the file changes that save them // (`runConfig.saveConfiguration`); the host draws the fields, applies the changes and @@ -23,19 +23,27 @@ import ( // later Core can add fields, options and buttons' inputs without breaking this host. A new // field shows here once it has a label in runConfigFieldLabel and a widget for its kind. -// runConfigForm is the open editor of a built-in process run. +// runConfigForm is the editor of one built-in process run in the Run/Debug Configurations +// dialog (runconfig_dialog.go). Each configuration the dialog shows has its own, so edits to +// several configurations wait together for Apply or OK. type runConfigForm struct { + // open is cleared when the dialog drops the form; answers still out are then ignored. open bool - // generation rejects the answer of an editor that was closed or reopened since. + // generation rejects the answer of a form that was dropped or reopened since. generation uint64 provider string // id is the saved configuration edited; empty for a new one until a save names it. id string - // name is the configuration's name as it was saved, for the dialog's title. + // name is the configuration's name as it was saved. name string loading, saving bool failure string - fields []core.RunEditorField + // dirty says a value changed since the form was read or last saved. + dirty bool + // availability says why this platform cannot run the kind, such as a batch script + // outside Windows; the form still edits and saves it. + availability *core.RunAvailability + fields []core.RunEditorField // values are the values by field ID as Core returned them. A save sends them with the // drawn fields' edits over them, so keys this host does not show go back unchanged. values map[string]json.RawMessage @@ -62,18 +70,6 @@ type runConfigVariable struct { name, value string } -// runConfigFormStep is what follows a save that succeeded. -type runConfigFormStep int - -const ( - // runConfigFormApply keeps the editor open on the saved configuration. - runConfigFormApply runConfigFormStep = iota - // runConfigFormClose closes the editor. - runConfigFormClose - // runConfigFormRun closes the editor and runs the configuration once it is listed. - runConfigFormRun -) - // Field kinds of `runConfig.editorForm` this host draws. const ( runFieldText = "text" @@ -97,8 +93,9 @@ func runFieldTextual(kind string) bool { return false } -// loadRunConfigTypes reads once per project which built-in kinds a user can create here. -// A failure leaves them unread, so the next refresh asks again. +// loadRunConfigTypes reads once per project which built-in kinds a user can create. Every +// platform lists every kind; one it cannot run carries the reason. A failure leaves them +// unread, so the next refresh asks again. func (a *App) loadRunConfigTypes(p *project) { s := &p.runConfigs if s.types != nil || s.typesLoading { @@ -126,39 +123,43 @@ func (a *App) loadRunConfigTypes(p *project) { }) } -// openRunConfigForm opens the editor on a new configuration of provider, or on the saved -// configuration id when it is set. -func (a *App) openRunConfigForm(p *project, provider, id string) { - f := &p.runConfigs.form - generation := f.generation + 1 - *f = runConfigForm{open: true, generation: generation, provider: provider, id: id, loading: true} +// openRunConfigForm reads the editor of a new configuration of provider, or of the saved +// configuration id when it is set. values seed a new configuration, such as a copy of +// another; nil starts from Core's defaults. +func (a *App) openRunConfigForm(p *project, provider, id string, values map[string]json.RawMessage) *runConfigForm { + f := &runConfigForm{open: true, generation: 1, provider: provider, id: id, loading: true} if configuration := p.runConfigs.configuration(id); configuration != nil { f.name = configuration.Name } - a.requestRunConfigForm(p, generation, core.RunEditorFormRequest{Root: p.root, Provider: provider, ConfigurationID: id}, true) + request := core.RunEditorFormRequest{Root: p.root, Provider: provider, ConfigurationID: id, Values: values} + a.requestRunConfigForm(p, f, f.generation, request, true) + return f } -// closeRunConfigForm closes the editor; answers still out are dropped. -func (a *App) closeRunConfigForm(p *project) { - f := &p.runConfigs.form +// close drops the form; answers still out are ignored. +func (f *runConfigForm) close() { f.generation++ f.open, f.loading, f.saving, f.refreshing, f.stale = false, false, false, false, false } +// ready says the form is read and not being saved, so its values can be edited and saved. +func (f *runConfigForm) ready() bool { + return f.open && !f.loading && !f.saving && f.fields != nil +} + // requestRunConfigForm asks Core for the editor. The first answer fills the fields and // values; a later one, for the values being edited, only replaces the field descriptions, // so the automatic values follow the edit and nothing the user typed since is lost. -func (a *App) requestRunConfigForm(p *project, generation uint64, request core.RunEditorFormRequest, initial bool) { +func (a *App) requestRunConfigForm(p *project, f *runConfigForm, generation uint64, request core.RunEditorFormRequest, initial bool) { kernel := a.kernel a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { form, err := kernel.RunEditorForm(ctx, request) return func(a *App) { - f := &p.runConfigs.form if !f.open || f.generation != generation { return } if !initial { - a.finishRunConfigFormRefresh(p, form, err) + a.finishRunConfigFormRefresh(p, f, form, err) return } f.loading = false @@ -173,7 +174,7 @@ func (a *App) requestRunConfigForm(p *project, generation uint64, request core.R f.failure = i18n.Shared(language, "desktop.runConfig.formTooNew") return } - f.provider, f.fields, f.values = form.Provider, form.Fields, form.Values + f.provider, f.fields, f.values, f.availability = form.Provider, form.Fields, form.Values, form.Availability if f.values == nil { f.values = map[string]json.RawMessage{} } @@ -185,8 +186,7 @@ func (a *App) requestRunConfigForm(p *project, generation uint64, request core.R // finishRunConfigFormRefresh takes the field descriptions for the edited values. A field // that appears only now takes its value from the answer. -func (a *App) finishRunConfigFormRefresh(p *project, form core.RunEditorForm, err error) { - f := &p.runConfigs.form +func (a *App) finishRunConfigFormRefresh(p *project, f *runConfigForm, form core.RunEditorForm, err error) { f.refreshing = false switch { case err != nil: @@ -195,11 +195,11 @@ func (a *App) finishRunConfigFormRefresh(p *project, form core.RunEditorForm, er case form.FormVersion > core.RunFormVersion || form.Provider != f.provider: a.operationRejected("run_config_form_refresh", "form_mismatch") default: - f.fields = form.Fields + f.fields, f.availability = form.Fields, form.Availability f.readValues(form.Fields, form.Values) } if f.stale { - a.runConfigFormEdited(p) + a.refreshRunConfigForm(p, f) } } @@ -289,11 +289,19 @@ func (f *runConfigForm) collect() map[string]json.RawMessage { return values } -// runConfigFormEdited asks for the editor of the edited values, so automatic values such as +// runConfigFormEdited marks the form changed and asks for the editor of the edited values. +func (a *App) runConfigFormEdited(p *project, f *runConfigForm) { + if !f.open || f.loading || f.fields == nil { + return + } + f.dirty = true + a.refreshRunConfigForm(p, f) +} + +// refreshRunConfigForm asks for the editor of the edited values, so automatic values such as // the interpreter a script's first line names follow the edit. One request is out at a // time; an edit made while it is out sends one more when it answers. -func (a *App) runConfigFormEdited(p *project) { - f := &p.runConfigs.form +func (a *App) refreshRunConfigForm(p *project, f *runConfigForm) { if !f.open || f.loading || f.fields == nil { return } @@ -303,15 +311,16 @@ func (a *App) runConfigFormEdited(p *project) { } f.refreshing, f.stale = true, false request := core.RunEditorFormRequest{Root: p.root, Provider: f.provider, ConfigurationID: f.id, Values: f.collect()} - a.requestRunConfigForm(p, f.generation, request, false) + a.requestRunConfigForm(p, f, f.generation, request, false) } -// saveRunConfigForm has Core check the values and compute the file changes, applies them as -// one transaction and resolves the configurations again. Wrong values stay in the editor -// with the reason beside each field. -func (a *App) saveRunConfigForm(p *project, step runConfigFormStep) { - f := &p.runConfigs.form - if !f.open || f.loading || f.saving || f.fields == nil { +// saveRunConfigForm has Core check the values and compute the file changes and applies them +// as one transaction; done gets the saved configuration's ID, or ok false. Wrong values stay +// in the form with the reason beside each field, and any other failure under the fields. +// The caller resolves the configurations again. +func (a *App) saveRunConfigForm(p *project, f *runConfigForm, done func(id string, ok bool)) { + if !f.ready() { + done("", false) return } f.saving, f.failure = true, "" @@ -327,7 +336,6 @@ func (a *App) saveRunConfigForm(p *project, step runConfigFormStep) { err = errors.New("runConfig.saveConfiguration returned an unknown status") } return func(a *App) { - f := &p.runConfigs.form current := f.open && f.generation == generation if current { f.saving = false @@ -337,6 +345,7 @@ func (a *App) saveRunConfigForm(p *project, step runConfigFormStep) { if current { f.failure = a.runConfigSaveFailure(err) } + done("", false) return } if saved.Status == "invalid" { @@ -349,29 +358,34 @@ func (a *App) saveRunConfigForm(p *project, step runConfigFormStep) { } } } + done("", false) return } - s := &p.runConfigs - s.reveal = saved.ID if current { - f.errors, f.id = nil, saved.ID + f.errors, f.id, f.dirty = nil, saved.ID, false if name := f.texts["name"]; name != nil && strings.TrimSpace(*name) != "" { f.name = strings.TrimSpace(*name) } - if step == runConfigFormRun { - s.start = saved.ID - } - if step != runConfigFormApply { - a.closeRunConfigForm(p) - } } - a.refreshRunConfigurations(p) + done(saved.ID, true) } }) } -// deleteRunConfiguration removes a saved `user:` configuration from every layer file. +// deleteRunConfiguration removes a saved `user:` configuration from every layer file, for +// the Build window's Delete, and resolves the configurations again. func (a *App) deleteRunConfiguration(p *project, id string) { + a.removeRunConfiguration(p, id, func(err error) { + if err != nil { + a.notifyError(i18n.SharedFormat(a.language(), "desktop.runConfig.deleteFailed", map[string]string{"reason": err.Error()})) + } + a.refreshRunConfigurations(p) + }) +} + +// removeRunConfiguration has Core compute the file changes that remove a saved `user:` +// configuration from every layer and applies them; done gets the failure, logged already. +func (a *App) removeRunConfiguration(p *project, id string, done func(error)) { root, kernel := p.root, a.kernel a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { changes, err := kernel.DeleteRunConfiguration(ctx, root, id, a.runConfigPlugins(ctx)) @@ -381,13 +395,8 @@ func (a *App) deleteRunConfiguration(p *project, id string) { return func(a *App) { if err != nil { a.operationFailed("run_config_delete", err) - a.notifyError(i18n.SharedFormat(a.language(), "desktop.runConfig.deleteFailed", map[string]string{"reason": err.Error()})) - return - } - if f := &p.runConfigs.form; f.open && f.id == id { - a.closeRunConfigForm(p) } - a.refreshRunConfigurations(p) + done(err) } }) } @@ -395,8 +404,8 @@ func (a *App) deleteRunConfiguration(p *project, id string) { // browseRunConfigField asks for a file or a directory and puts its path in the field. A // path inside the project is shown project-relative, as Core saves it; a program there // keeps a leading "./", so it does not read as a name looked up on PATH. -func (a *App) browseRunConfigField(p *project, field core.RunEditorField, title string) { - generation, root := p.runConfigs.form.generation, p.root +func (a *App) browseRunConfigField(p *project, f *runConfigForm, field core.RunEditorField, title string) { + generation, root := f.generation, p.root a.background(nil, 0, func(context.Context) func(*App) { var path string var err error @@ -422,13 +431,12 @@ func (a *App) browseRunConfigField(p *project, field core.RunEditorField, title a.notifyError(i18n.Shared(a.language(), "desktop.runConfig.chooseFailed")) return } - f := &p.runConfigs.form text := f.texts[field.ID] if !f.open || f.generation != generation || text == nil { return } *text = runConfigFieldPath(root, path, field.Kind) - a.runConfigFormEdited(p) + a.runConfigFormEdited(p, f) } }) } diff --git a/desktop/internal/workbench/runconfig_form_view.go b/desktop/internal/workbench/runconfig_form_view.go index a37ed95142..b08d3b2aa7 100644 --- a/desktop/internal/workbench/runconfig_form_view.go +++ b/desktop/internal/workbench/runconfig_form_view.go @@ -14,10 +14,6 @@ import ( ) const ( - // runConfigFormWidth is the editor dialog's width, wide enough for a path and its options. - runConfigFormWidth = 640 - // runConfigFormBodyMaxHeight bounds the fields, which scroll beyond it. - runConfigFormBodyMaxHeight = 520 // runConfigFormLabelWidth is the column of field titles. runConfigFormLabelWidth = 150 // runConfigFormTextHeight is the height of a script saved as text. @@ -93,8 +89,9 @@ func runConfigFieldLabel(language i18n.Language, id string) (string, bool) { return "", false } -// runConfigFieldHelp is the ⓘ tip of a field: what its note means, or what the field does. -func runConfigFieldHelp(language i18n.Language, field core.RunEditorField) string { +// runConfigFieldHelp is the ⓘ tip of a field of a provider's editor: what its note means, or +// what the field does. The script's arguments say how the script of that kind reads them. +func runConfigFieldHelp(language i18n.Language, provider string, field core.RunEditorField) string { switch { case field.Note == "windowsOnly": return i18n.Shared(language, "desktop.runConfig.noteWindowsOnly") @@ -104,6 +101,36 @@ func runConfigFieldHelp(language i18n.Language, field core.RunEditorField) strin return i18n.Shared(language, "desktop.runConfig.interpreterHelp") case field.ID == "beforeLaunch": return i18n.Shared(language, "desktop.runConfig.beforeLaunchHelp") + case field.ID == "interpreterArguments": + return i18n.Shared(language, "desktop.runConfig.interpreterArgumentsHelp") + case field.ID == "programArguments": + return i18n.Shared(language, "desktop.runConfig.programArgumentsHelp") + case field.ID == "scriptOptions" && provider == runProviderPowerShell: + return i18n.Shared(language, "desktop.runConfig.scriptOptionsHelpPowerShell") + case field.ID == "scriptOptions" && provider == runProviderBatch: + return i18n.Shared(language, "desktop.runConfig.scriptOptionsHelpBatch") + case field.ID == "scriptOptions": + return i18n.Shared(language, "desktop.runConfig.scriptOptionsHelpShell") + } + return "" +} + +// runConfigFieldPlaceholder is what an empty field shows: the automatic value that applies +// while it is empty, or an example of what goes into an argument field. +func runConfigFieldPlaceholder(language i18n.Language, field core.RunEditorField) string { + if field.Automatic != nil && *field.Automatic != "" { + return i18n.SharedFormat(language, "desktop.runConfig.automaticValue", map[string]string{"value": *field.Automatic}) + } + switch field.ID { + case "scriptOptions": + return i18n.Shared(language, "desktop.runConfig.scriptOptionsPlaceholder") + case "interpreterArguments": + return i18n.Shared(language, "desktop.runConfig.interpreterArgumentsPlaceholder") + case "programArguments": + return i18n.Shared(language, "desktop.runConfig.programArgumentsPlaceholder") + } + if field.Automatic != nil { + return i18n.SharedFormat(language, "desktop.runConfig.automaticValue", map[string]string{"value": *field.Automatic}) } return "" } @@ -186,71 +213,6 @@ func visibleRunConfigField(field core.RunEditorField, values map[string]json.Raw return reflect.DeepEqual(current, condition.Equals) } -// runConfigFormTitle is the dialog's title: the kind of a new configuration, or the name of -// the one edited. -func (a *App) runConfigFormTitle(f *runConfigForm) string { - language := a.language() - kind, _ := runConfigTypeLabel(language, f.provider) - if f.id == "" || f.name == "" { - return i18n.SharedFormat(language, "desktop.runConfig.newTitle", map[string]string{"type": kind}) - } - return i18n.SharedFormat(language, "desktop.runConfig.editTitle", map[string]string{"name": f.name}) -} - -// drawRunConfigForm declares the open editor of a built-in process run: the name and where it -// is stored on top, then the fields Core described in order, and Run, Cancel, Apply and OK. -func (a *App) drawRunConfigForm(c ui.C, p *project) { - f := &p.runConfigs.form - if !f.open { - return - } - language := a.language() - ready := !f.loading && !f.saving && f.fields != nil - open := true - closed := ui.ModalWith(c, &open, a.runConfigFormTitle(f), ui.ModalSpec{Width: runConfigFormWidth}, func() { - k := c.Part("run-config-form") - ui.Scroll(k).Scrollbars().FillWidth().MaxHeight(runConfigFormBodyMaxHeight).Children(func() { - ui.Column(k).FillWidth().Gap(10).PadSides(0, 12, 0, 0).Children(func() { - if f.loading { - ui.Text(k, i18n.Shared(language, "native.loading")).Color(a.colors.Subtle) - } - a.drawRunConfigFormFields(k, p, f, ready) - if f.failure != "" { - ui.Paragraph(k, f.failure, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) - } - }) - }) - }, 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).Clicked() { - c.After(func() { - a.performed("run.configuration.form.run", surfaceButton) - a.saveRunConfigForm(p, runConfigFormRun) - }) - } - ui.Spacer(c) - if ui.Button(c, i18n.Shared(language, "desktop.git.cancel")).Outline().Clicked() { - c.After(func() { a.closeRunConfigForm(p) }) - } - if ui.Button(c, i18n.Shared(language, "desktop.runConfig.apply")).Outline().Disabled(!ready).Clicked() { - c.After(func() { - a.performed("run.configuration.form.apply", surfaceButton) - a.saveRunConfigForm(p, runConfigFormApply) - }) - } - if ui.Button(c, i18n.Shared(language, "desktop.runConfig.ok")).Disabled(!ready).Clicked() { - c.After(func() { - a.performed("run.configuration.form.save", surfaceButton) - a.saveRunConfigForm(p, runConfigFormClose) - }) - } - }) - }) - if closed { - c.After(func() { a.closeRunConfigForm(p) }) - } -} - // drawRunConfigFormFields declares the header row, then every other field that shows for the // edited values. A wrong value's reason sits under its field; one for a field not drawn sits // at the end. @@ -302,9 +264,9 @@ func (a *App) drawRunConfigFormHeaderField(c ui.C, p *project, f *runConfigForm, if field.Kind == runFieldCheckbox { ui.Row(c).Shrink(0).Items(ui.Center).Gap(4).Children(func() { if ui.Checkbox(c, f.flags[field.ID], label).Disabled(!ready).Changed() { - c.After(func() { a.runConfigFormEdited(p) }) + c.After(func() { a.runConfigFormEdited(p, f) }) } - a.runConfigFormHelp(c, language, field) + a.runConfigFormHelp(c, language, f.provider, field) }) return } @@ -332,15 +294,15 @@ func (a *App) drawRunConfigFormField(c ui.C, p *project, f *runConfigForm, field ui.Row(c.Part("title")).Width(runConfigFormLabelWidth).MinHeight(28).Shrink(0).Items(ui.Center).Gap(4).Children(func() { if field.Kind != runFieldCheckbox { ui.Text(c, label).Ellipsis().Shrink(1).MinWidth(0) - a.runConfigFormHelp(c, language, field) + a.runConfigFormHelp(c, language, f.provider, field) } }) if field.Kind == runFieldCheckbox { ui.Row(c).Grow(1).Items(ui.Center).Gap(4).Children(func() { if ui.Checkbox(c, f.flags[field.ID], label).Disabled(!ready).Changed() { - c.After(func() { a.runConfigFormEdited(p) }) + c.After(func() { a.runConfigFormEdited(p, f) }) } - a.runConfigFormHelp(c, language, field) + a.runConfigFormHelp(c, language, f.provider, field) }) return } @@ -350,23 +312,17 @@ func (a *App) drawRunConfigFormField(c ui.C, p *project, f *runConfigForm, field }) } -// drawRunConfigFormControl declares the control of a field by its kind. A field whose -// automatic value applies while it is empty shows that value as its placeholder. +// drawRunConfigFormControl declares the control of a field by its kind, with the placeholder +// runConfigFieldPlaceholder gives it. func (a *App) drawRunConfigFormControl(c ui.C, p *project, f *runConfigForm, field core.RunEditorField, label string, ready bool) { language := a.language() - placeholder := "" - switch { - case field.Automatic != nil: - placeholder = i18n.SharedFormat(language, "desktop.runConfig.automaticValue", map[string]string{"value": *field.Automatic}) - case field.Kind == runFieldArguments: - placeholder = i18n.Shared(language, "desktop.runConfig.argumentsPlaceholder") - } - edited := func() { c.After(func() { a.runConfigFormEdited(p) }) } + placeholder := runConfigFieldPlaceholder(language, field) + edited := func() { c.After(func() { a.runConfigFormEdited(p, f) }) } switch field.Kind { case runFieldEnvironment: a.drawRunConfigVariables(c, p, f, ready) case runFieldBeforeLaunch: - a.drawRunConfigBeforeLaunch(c, &f.beforeLaunch, &f.beforeLaunchMenu, field.Candidates, ready) + a.drawRunConfigBeforeLaunch(c, &f.beforeLaunch, &f.beforeLaunchMenu, field.Candidates, ready, func() { a.runConfigFormEdited(p, f) }) case runFieldChoice: options := field.Options if ui.Choice(c, f.texts[field.ID], options, func(option string) string { @@ -386,7 +342,7 @@ func (a *App) drawRunConfigFormControl(c ui.C, p *project, f *runConfigForm, fie edited() } if box.ActionClicked() { - c.After(func() { a.browseRunConfigField(p, field, label) }) + c.After(func() { a.browseRunConfigField(p, f, field, label) }) } default: if ui.TextField(c, f.texts[field.ID], label, placeholder).Grow(1).MinWidth(0).Disabled(!ready).Changed() { @@ -405,21 +361,24 @@ func (a *App) drawRunConfigVariables(c ui.C, p *project, f *runConfigForm, ready k := c.KeyInt(index) ui.Row(k).FillWidth().Items(ui.Center).Gap(6).Children(func() { if ui.TextField(k.Part("name"), &variable.name, nameLabel, nameLabel).Width(runConfigFormVariableNameWidth).Shrink(0).Disabled(!ready).Changed() { - c.After(func() { a.runConfigFormEdited(p) }) + c.After(func() { a.runConfigFormEdited(p, f) }) } if ui.TextField(k.Part("value"), &variable.value, valueLabel, valueLabel).Grow(1).MinWidth(0).Disabled(!ready).Changed() { - c.After(func() { a.runConfigFormEdited(p) }) + c.After(func() { a.runConfigFormEdited(p, f) }) } if a.gitIconButton(k.Part("remove"), i18n.Shared(language, "desktop.runConfig.variableRemove"), icons.Trash2, false, !ready) { c.After(func() { f.environment = removeRunConfigVariable(f.environment, variable) - a.runConfigFormEdited(p) + a.runConfigFormEdited(p, f) }) } }) } if ui.Button(c.Part("add"), i18n.Shared(language, "desktop.runConfig.variableAdd")).Icon(icons.Plus).Ghost().Disabled(!ready).Clicked() { - c.After(func() { f.environment = append(f.environment, &runConfigVariable{}) }) + c.After(func() { + f.environment = append(f.environment, &runConfigVariable{}) + f.dirty = true + }) } }) } @@ -429,9 +388,18 @@ const runConfigBeforeLaunchLimit = 16 // drawRunConfigBeforeLaunch declares the steps that run before the configuration, each its name // with buttons that move it up or down or remove it, and the button whose menu adds one of the -// process runs not chosen yet. A step whose configuration is gone shows its ID. -func (a *App) drawRunConfigBeforeLaunch(c ui.C, chosen *[]string, menuOpen *bool, candidates []core.RunConfigurationName, ready bool) { +// process runs not chosen yet. A step whose configuration is gone shows its ID. edited, when +// set, runs after each change, so an editor that tracks its edits by flag sees it. +func (a *App) drawRunConfigBeforeLaunch(c ui.C, chosen *[]string, menuOpen *bool, candidates []core.RunConfigurationName, ready bool, edited func()) { language := a.language() + change := func(apply func()) { + c.After(func() { + apply() + if edited != nil { + edited() + } + }) + } steps := *chosen names := make(map[string]string, len(candidates)) for _, candidate := range candidates { @@ -455,13 +423,13 @@ func (a *App) drawRunConfigBeforeLaunch(c ui.C, chosen *[]string, menuOpen *bool } ui.Text(k, fmt.Sprintf("%d. %s", index+1, name)).Color(color).Ellipsis().Grow(1).MinWidth(0) if a.gitIconButton(k.Part("up"), i18n.Shared(language, "desktop.runConfig.beforeLaunchUp"), icons.ArrowUp, false, !ready || index == 0) { - c.After(func() { moveRunConfigStep(*chosen, index, index-1) }) + change(func() { moveRunConfigStep(*chosen, index, index-1) }) } if a.gitIconButton(k.Part("down"), i18n.Shared(language, "desktop.runConfig.beforeLaunchDown"), icons.ArrowDown, false, !ready || index == len(steps)-1) { - c.After(func() { moveRunConfigStep(*chosen, index, index+1) }) + change(func() { moveRunConfigStep(*chosen, index, index+1) }) } if a.gitIconButton(k.Part("remove"), i18n.Shared(language, "desktop.runConfig.beforeLaunchRemove"), icons.Trash2, false, !ready) { - c.After(func() { *chosen = slices.Delete(slices.Clone(*chosen), index, index+1) }) + change(func() { *chosen = slices.Delete(slices.Clone(*chosen), index, index+1) }) } }) } @@ -484,7 +452,7 @@ func (a *App) drawRunConfigBeforeLaunch(c ui.C, chosen *[]string, menuOpen *bool ui.Menu(c.Part("add-menu"), add, menuOpen, func(menu *ui.MenuItems) { for _, candidate := range left { if menu.Item(candidate.Name).Clicked() { - c.After(func() { + change(func() { a.performed("run.configuration.form.beforeLaunch.add", surfaceButton) *chosen = append(slices.Clone(*chosen), candidate.ID) }) @@ -515,8 +483,8 @@ func removeRunConfigVariable(rows []*runConfigVariable, row *runConfigVariable) } // runConfigFormHelp declares the ⓘ of a field that has a tip. -func (a *App) runConfigFormHelp(c ui.C, language i18n.Language, field core.RunEditorField) { - if help := runConfigFieldHelp(language, field); help != "" { +func (a *App) runConfigFormHelp(c ui.C, language i18n.Language, provider string, field core.RunEditorField) { + if help := runConfigFieldHelp(language, provider, field); help != "" { ui.Button(c.Part("help"), i18n.Shared(language, "native.moreInformation")).Icon(icons.Info).IconOnly().Ghost(). Size(18, 18).Shrink(0).Tooltip(help).TooltipOn(ui.TooltipRight) } diff --git a/desktop/internal/workbench/runconfig_process_test.go b/desktop/internal/workbench/runconfig_process_test.go index d2208a32f9..ce46832772 100644 --- a/desktop/internal/workbench/runconfig_process_test.go +++ b/desktop/internal/workbench/runconfig_process_test.go @@ -186,23 +186,22 @@ func TestBuiltInRunIsCreatedAndRunWithoutAnyPlugin(t *testing.T) { t.Fatalf("configurations = %+v failure %q", s.list, s.failure) } - f := &p.runConfigs.form - h.app.post(func(a *App) { a.openRunConfigForm(p, provider, "") }) - awaitStateWithin(t, h, 10*time.Second, "the new configuration's form", func() bool { return f.open && !f.loading && f.fields != nil }) + f := newRunConfigDraft(t, h, p, provider) h.app.post(func(a *App) { *f.texts["name"] = "Greet" *f.texts["source"] = "text" *f.flags["storeAsProjectFile"] = true - a.runConfigFormEdited(p) + a.runConfigFormEdited(p, f) }) awaitStateWithin(t, h, 10*time.Second, "the text field", func() bool { return !f.refreshing && f.texts["text"] != nil }) h.app.post(func(a *App) { *f.texts["text"] = text - a.saveRunConfigForm(p, runConfigFormRun) + a.applyRunConfigDialog(p, runConfigDialogRun) }) - awaitStateWithin(t, h, 10*time.Second, "the save", func() bool { return !f.open || len(f.errors) > 0 || f.failure != "" }) - if f.open { - t.Fatalf("the form stayed open: errors %v failure %q", f.errors, f.failure) + d := &p.runConfigs.dialog + awaitStateWithin(t, h, 10*time.Second, "the save", func() bool { return !d.open || len(f.errors) > 0 || f.failure != "" }) + if d.open { + t.Fatalf("the dialog stayed open: errors %v failure %q", f.errors, f.failure) } first := awaitProcessRun(t, h, p, "Greet", nil) if !strings.Contains(first.output.all(), "hello-from-lithe") { @@ -232,6 +231,25 @@ func TestBuiltInRunIsCreatedAndRunWithoutAnyPlugin(t *testing.T) { } } +// newRunConfigDraft opens the Run/Debug Configurations dialog, adds a configuration of +// provider as the + menu does and waits for its form. +func newRunConfigDraft(t *testing.T, h *harness, p *project, provider string) *runConfigForm { + t.Helper() + d := &p.runConfigs.dialog + h.app.post(func(a *App) { + a.openRunConfigDialog(p, "") + a.addRunConfigDraft(p, provider, nil) + }) + var f *runConfigForm + awaitStateWithin(t, h, 10*time.Second, "the new configuration's form", func() bool { + if draft := d.drafts[d.selected]; d.open && draft != nil && draft.form != nil { + f = draft.form + } + return f != nil && f.open && !f.loading && f.fields != nil + }) + return f +} + // awaitProcessRun waits for an ended run session labeled label other than previous and // requires it to have succeeded. A new run replaces the ended tab of the same label and the // harness clock does not advance by itself, so the session is told apart by identity, not by diff --git a/desktop/internal/workbench/runconfig_process_visual_test.go b/desktop/internal/workbench/runconfig_process_visual_test.go index fa8f7bdffa..0febd4d10f 100644 --- a/desktop/internal/workbench/runconfig_process_visual_test.go +++ b/desktop/internal/workbench/runconfig_process_visual_test.go @@ -9,17 +9,19 @@ import ( "time" "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/store" "github.com/vivaui/viva/app" "github.com/vivaui/viva/headless" ) -// TestVisualBuiltInProcessRuns captures the built-in runs of a project without any plugin: -// the editor of a shell script with a script file and with script text, the Run window after -// the script ran, the menu that creates a run of each kind this platform offers, the editors -// of a PowerShell script and of an executable, and the title bar's run menu naming a run -// configuration file that was not read. The script runs under the system's shell. It needs -// only LITHE_VISUAL_OUTPUT_DIR; the dark captures are in Chinese and the light ones in English. +// TestVisualBuiltInProcessRuns captures the built-in runs of a project without any plugin in +// the Run/Debug Configurations dialog: the dialog with nothing yet, the editor of a shell +// script with a script file and with script text, the Run window after the script ran, the + +// menu of every kind, the editors of a PowerShell script, an executable and a batch script +// this platform cannot run, the title bar with that batch script chosen, and the title bar's +// run menu marking that batch script and naming a run configuration file that was not read. The +// script runs under the system's shell. It needs only LITHE_VISUAL_OUTPUT_DIR; the dark captures are in Chinese and the light ones in English. func TestVisualBuiltInProcessRuns(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -41,6 +43,7 @@ func TestVisualBuiltInProcessRuns(t *testing.T) { "scripts/greet.sh": "#!/bin/bash\necho \"$GREETING from $1\"\n", "scripts/clean.ps1": "Remove-Item -Recurse build\n", "bin/README.md": "Tools built here.\n", + "bin/tool": "#!/bin/sh\n", } for name, text := range files { path := filepath.Join(root, filepath.FromSlash(name)) @@ -78,20 +81,18 @@ func TestVisualBuiltInProcessRuns(t *testing.T) { s := &p.runConfigs return s.generation > 0 && !s.loading && s.types != nil }) - f := &p.runConfigs.form - // edit opens the editor of a new run of provider, sets the texts and checkboxes - // given, and waits for the fields that follow the edit. - edit := func(provider string, texts map[string]string, flags map[string]bool, variables ...*runConfigVariable) { + d := &p.runConfigs.dialog + // edit adds a new run of provider to the open dialog as its + menu does, sets the + // texts and checkboxes given, and waits for the fields that follow the edit. + edit := func(provider string, texts map[string]string, flags map[string]bool, variables ...*runConfigVariable) *runConfigForm { t.Helper() - // The editor closed before keeps its fields, so the one waited for is told - // apart by its generation. - var generation uint64 + var f *runConfigForm h.app.post(func(a *App) { - a.openRunConfigForm(p, provider, "") - generation = f.generation + a.addRunConfigDraft(p, provider, nil) + f = d.drafts[d.selected].form }) awaitStateWithin(t, h, 10*time.Second, "the editor of "+provider, func() bool { - return generation != 0 && f.generation == generation && f.open && !f.loading && f.fields != nil + return f != nil && f.open && !f.loading && f.fields != nil }) h.app.post(func(a *App) { for id, value := range texts { @@ -105,44 +106,67 @@ func TestVisualBuiltInProcessRuns(t *testing.T) { } } f.environment = append(f.environment, variables...) - a.runConfigFormEdited(p) + a.runConfigFormEdited(p, f) }) awaitStateWithin(t, h, 10*time.Second, "the edited editor", func() bool { return !f.refreshing }) + return f } + // apply presses step and waits for the dialog to close. + apply := func(step runConfigDialogStep) { + t.Helper() + pressed := false + h.app.post(func(a *App) { + a.applyRunConfigDialog(p, step) + pressed = true + }) + awaitStateWithin(t, h, 10*time.Second, "the save", func() bool { return pressed && (!d.open || !d.saving) }) + if d.open { + t.Fatalf("the dialog stayed open: failure %q", d.failure) + } + } + + h.app.post(func(a *App) { a.openRunConfigDialog(p, "") }) + shot("dialog-empty") - edit(runProviderShell, map[string]string{"name": "Greet", "source": "file", "script": "scripts/greet.sh", "scriptOptions": "Lithe", "workingDirectory": "scripts"}, + f := edit(runProviderShell, map[string]string{"name": "Greet", "source": "file", "script": "scripts/greet.sh", "scriptOptions": "Lithe", "workingDirectory": "scripts"}, map[string]bool{"storeAsProjectFile": true}, &runConfigVariable{name: "GREETING", value: "Hello"}) shot("shell-file") h.app.post(func(a *App) { *f.texts["source"] = "text" - a.runConfigFormEdited(p) + a.runConfigFormEdited(p, f) }) awaitStateWithin(t, h, 10*time.Second, "the script text field", func() bool { return !f.refreshing && f.texts["text"] != nil }) h.app.post(func(a *App) { *f.texts["text"] = "echo \"$GREETING from $(pwd)\"\nuname -s\n" }) shot("shell-text") - h.app.post(func(a *App) { a.saveRunConfigForm(p, runConfigFormRun) }) - awaitStateWithin(t, h, 10*time.Second, "the save", func() bool { return !f.open || len(f.errors) > 0 || f.failure != "" }) - if f.open { - t.Fatalf("the editor stayed open: errors %v failure %q", f.errors, f.failure) - } + apply(runConfigDialogRun) awaitProcessRun(t, h, p, "Greet", nil) shot("run-output") - h.click(center(h.button(itemBuild))) - h.settleChain() - h.app.post(func(a *App) { p.runConfigs.newMenu = true }) + h.app.post(func(a *App) { + a.openRunConfigDialog(p, p.runConfigs.selected) + d.newMenu = true + }) shot("new-menu") - h.app.post(func(a *App) { p.runConfigs.newMenu = false }) + h.app.post(func(a *App) { d.newMenu = false }) edit(runProviderPowerShell, map[string]string{"name": "Clean", "source": "file", "script": "scripts/clean.ps1"}, nil) shot("powershell") - h.app.post(func(a *App) { a.closeRunConfigForm(p) }) edit(runProviderExecutable, map[string]string{"name": "Tool", "program": "bin/tool", "programArguments": "--verbose \"two words\"", "workingDirectory": "bin"}, nil) shot("executable") - h.app.post(func(a *App) { a.closeRunConfigForm(p) }) + + edit(runProviderBatch, map[string]string{"name": "Package", "source": "text"}, nil) + h.app.post(func(a *App) { *d.drafts[d.selected].form.texts["text"] = "@echo off\r\ncall build.cmd\r\n" }) + shot("batch") + + apply(runConfigDialogOK) + awaitStateWithin(t, h, 10*time.Second, "the saved configurations", func() bool { + c := p.titleConfiguration() + return !p.runConfigs.loading && len(p.runConfigs.list) == 4 && c != nil && c.Name == "Package" + }) + shot("title-unavailable") plugins := filepath.Join(root, ".lithe", "run", "plugin") if err := os.MkdirAll(plugins, 0o755); err != nil { @@ -158,6 +182,9 @@ func TestVisualBuiltInProcessRuns(t *testing.T) { return s.generation > generation && !s.loading && len(s.ignored) == 1 }) h.click(center(h.button(itemRunConfig))) + if note := i18n.Shared(h.app.language(), "desktop.runConfig.windowsOnlyType"); !h.shows(note) { + t.Fatalf("the run menu does not mark Package with %q", note) + } shot("run-menu") }) } diff --git a/desktop/internal/workbench/runconfig_view.go b/desktop/internal/workbench/runconfig_view.go index acc43de36a..dbdf044eba 100644 --- a/desktop/internal/workbench/runconfig_view.go +++ b/desktop/internal/workbench/runconfig_view.go @@ -58,7 +58,7 @@ func (a *App) runConfigList(c ui.C, p *project) { } // drawRunConfigHeader declares the list's header: its title, the scope picker when there are -// scopes to pick, and the button whose menu creates a built-in run of each kind. +// scopes to pick, and the button that opens the Run/Debug Configurations dialog to create one. func (a *App) drawRunConfigHeader(c ui.C, p *project, title string, scopes []string) { s := &p.runConfigs b := &s.browser @@ -70,51 +70,19 @@ func (a *App) drawRunConfigHeader(c ui.C, p *project, title string, scopes []str Label(title).Shrink(1).MinWidth(0).MaxWidth(240) } ui.Spacer(c) - label := i18n.Shared(language, "desktop.runConfig.newConfiguration") - add, clicked := a.toolIconButton(c.Part("new"), label, icons.Plus, s.newMenu, len(s.types) == 0) - if clicked { - s.newMenu = !s.newMenu - } - ui.Menu(c.Part("new-menu"), add, &s.newMenu, func(menu *ui.MenuItems) { - menu.WidthRange(180, 260) - a.runConfigTypeItems(c, menu, p, surfaceButton) - }) - }) -} - -// runConfigTypeItems adds an item per built-in kind this platform offers, each opening the -// editor of a new configuration of that kind. -func (a *App) runConfigTypeItems(c ui.C, menu *ui.MenuItems, p *project, surface actionSurface) { - language := a.language() - for _, kind := range p.runConfigs.types { - label, ok := runConfigTypeLabel(language, kind.Provider) - if !ok { - continue - } - provider := kind.Provider - if menu.Item(label).Icon(runConfigTypeIcon(provider)).Clicked() { + label := i18n.Shared(language, "desktop.runConfig.newConfigurationEllipsis") + if _, clicked := a.toolIconButton(c.Part("new"), label, icons.Plus, false, false); clicked { c.After(func() { - a.performed("run.configuration.new", surface) - a.openRunConfigForm(p, provider, "") + a.performed("run.configuration.dialog", surfaceButton) + a.openRunConfigDialog(p, "") }) } - } - if len(p.runConfigs.types) == 0 { - menu.Item(i18n.Shared(language, "native.loading")).Disabled(true) - } + }) } -// editRunConfiguration opens the editor that suits configuration id: the form of a built-in -// run, or the options of a build provider run. +// editRunConfiguration opens the Run/Debug Configurations dialog with configuration id selected. func (a *App) editRunConfiguration(p *project, id string) { - configuration := p.runConfigs.configuration(id) - switch { - case configuration == nil: - case configuration.IsProcess(): - a.openRunConfigForm(p, configuration.Provider, id) - default: - a.openRunConfigEditor(p, id) - } + a.openRunConfigDialog(p, id) } // runConfigEditable says whether the list offers an editor for configuration: every built-in @@ -314,78 +282,61 @@ func (a *App) runConfigMenu(c ui.C, row ui.Box, p *project, configuration core.R }) } -// drawRunConfigEditor declares the open run configuration editor: arguments, working -// directory, environment and the layer file the edit is saved into. -func (a *App) drawRunConfigEditor(c ui.C, p *project) { - e := &p.runConfigs.editor - if !e.open { - return - } +// drawRunConfigEditorPane declares the editor of a build provider run in the dialog: +// arguments, working directory, environment, the provider's choices, the process runs that +// start first and the layer file the edit is saved into. +func (a *App) drawRunConfigEditorPane(c ui.C, p *project, e *runConfigEditor) { language := a.language() - ready := !e.loading && !e.saving - open := true - title := i18n.SharedFormat(language, "desktop.runConfig.editTitle", map[string]string{"name": e.name}) - closed := ui.ModalWith(c, &open, title, ui.ModalSpec{Width: 460}, func() { - ui.Column(c.Part("run-config-editor")).FillWidth().Gap(10).Children(func() { - ui.TextField(c.Part("arguments"), &e.arguments, i18n.Shared(language, "desktop.runConfig.arguments"), i18n.Shared(language, "desktop.runConfig.argumentsPlaceholder")). - FillWidth().Disabled(!ready) - ui.TextField(c.Part("directory"), &e.directory, i18n.Shared(language, "desktop.runConfig.workingDirectory"), i18n.Shared(language, "desktop.runConfig.workingDirectoryPlaceholder")). + ready := e.ready() + ui.Column(c.Part("run-config-editor")).FillWidth().Gap(10).Children(func() { + ui.TextField(c.Part("arguments"), &e.arguments, i18n.Shared(language, "desktop.runConfig.arguments"), i18n.Shared(language, "desktop.runConfig.argumentsPlaceholder")). + FillWidth().Disabled(!ready) + ui.TextField(c.Part("directory"), &e.directory, i18n.Shared(language, "desktop.runConfig.workingDirectory"), i18n.Shared(language, "desktop.runConfig.workingDirectoryPlaceholder")). + FillWidth().Disabled(!ready) + ui.TextArea(c.Part("environment"), &e.environment, i18n.Shared(language, "desktop.runConfig.environment"), i18n.Shared(language, "desktop.runConfig.environmentPlaceholder")). + FillWidth().Height(96).Disabled(!ready) + if e.provider { + ui.TextArea(c.Part("runtime-arguments"), &e.runtimeArguments, i18n.Shared(language, "desktop.runConfig.runtimeArguments"), i18n.Shared(language, "desktop.runConfig.runtimeArgumentsPlaceholder")). + FillWidth().Height(72).Disabled(!ready) + ui.TextField(c.Part("entrypoint"), &e.entrypoint, i18n.Shared(language, "desktop.runConfig.entrypoint"), i18n.Shared(language, "desktop.runConfig.entrypointPlaceholder")). FillWidth().Disabled(!ready) - ui.TextArea(c.Part("environment"), &e.environment, i18n.Shared(language, "desktop.runConfig.environment"), i18n.Shared(language, "desktop.runConfig.environmentPlaceholder")). - FillWidth().Height(96).Disabled(!ready) - if e.provider { - ui.TextArea(c.Part("runtime-arguments"), &e.runtimeArguments, i18n.Shared(language, "desktop.runConfig.runtimeArguments"), i18n.Shared(language, "desktop.runConfig.runtimeArgumentsPlaceholder")). - FillWidth().Height(72).Disabled(!ready) - ui.TextField(c.Part("entrypoint"), &e.entrypoint, i18n.Shared(language, "desktop.runConfig.entrypoint"), i18n.Shared(language, "desktop.runConfig.entrypointPlaceholder")). - FillWidth().Disabled(!ready) - if len(e.installs) > 0 { - labels := []string{i18n.Shared(language, "desktop.runConfig.toolPickNone")} - for _, install := range e.installs { - labels = append(labels, install.toolName+": "+install.path+" "+install.version) - } - ui.Select(c.Part("tool-pick"), &e.pick, indexRange(len(labels)), func(index int) string { return labels[index] }). - Label(i18n.Shared(language, "desktop.runConfig.toolPick")).FillWidth().Disabled(!ready) - if e.pick > 0 && e.pick <= len(e.installs) { - e.pickRunConfigInstall(e.installs[e.pick-1]) - } - e.pick = 0 - } - for index := range e.tools { - tool := &e.tools[index] - label := i18n.SharedFormat(language, "desktop.runConfig.toolPath", map[string]string{"arg1": tool.id, "arg2": tool.kind}) - ui.TextField(c.Part("tool-"+strconv.Itoa(index)), &tool.path, label, i18n.Shared(language, "desktop.runConfig.toolPathPlaceholder")). - FillWidth().Disabled(!ready) + if len(e.installs) > 0 { + labels := []string{i18n.Shared(language, "desktop.runConfig.toolPickNone")} + for _, install := range e.installs { + labels = append(labels, install.toolName+": "+install.path+" "+install.version) } - for index := range e.optionFields { - a.drawRunOptionField(c.Part("option-"+strconv.Itoa(index)), language, &e.optionFields[index], ready) + ui.Select(c.Part("tool-pick"), &e.pick, indexRange(len(labels)), func(index int) string { return labels[index] }). + Label(i18n.Shared(language, "desktop.runConfig.toolPick")).FillWidth().Disabled(!ready) + if e.pick > 0 && e.pick <= len(e.installs) { + e.pickRunConfigInstall(e.installs[e.pick-1]) } + e.pick = 0 } - ui.Column(c.Part("before-launch-field")).FillWidth().Gap(4).Children(func() { - ui.Row(c).FillWidth().Items(ui.Center).Gap(4).Children(func() { - ui.Text(c, i18n.Shared(language, "desktop.runConfig.fieldBeforeLaunch")).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) - ui.Button(c.Part("help"), i18n.Shared(language, "native.moreInformation")).Icon(icons.Info).IconOnly().Ghost(). - Size(18, 18).Shrink(0).Tooltip(i18n.Shared(language, "desktop.runConfig.beforeLaunchHelp")).TooltipOn(ui.TooltipRight) - }) - a.drawRunConfigBeforeLaunch(c, &e.beforeLaunch, &e.beforeLaunchMenu, p.runConfigs.beforeLaunchCandidates(e.id), ready) - }) - labels := map[string]string{"local": i18n.Shared(language, "desktop.runConfig.scopeLocal"), "project": i18n.Shared(language, "desktop.runConfig.scopeProject")} - ui.Select(c.Part("scope"), &e.scope, []string{"local", "project"}, func(scope string) string { return labels[scope] }). - Label(i18n.Shared(language, "desktop.runConfig.scope")).FillWidth() - if e.failure != "" { - ui.Paragraph(c, e.failure, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) + for index := range e.tools { + tool := &e.tools[index] + label := i18n.SharedFormat(language, "desktop.runConfig.toolPath", map[string]string{"arg1": tool.id, "arg2": tool.kind}) + ui.TextField(c.Part("tool-"+strconv.Itoa(index)), &tool.path, label, i18n.Shared(language, "desktop.runConfig.toolPathPlaceholder")). + FillWidth().Disabled(!ready) + } + for index := range e.optionFields { + a.drawRunOptionField(c.Part("option-"+strconv.Itoa(index)), language, &e.optionFields[index], ready) } - }) - }, func() { - if ui.Button(c, i18n.Shared(language, "desktop.git.cancel")).Outline().Clicked() { - c.After(func() { a.closeRunConfigEditor(p) }) } - if ui.Button(c, i18n.Shared(language, "ui.save")).Disabled(!ready).Clicked() { - c.After(func() { a.saveRunConfigEditor(p) }) + ui.Column(c.Part("before-launch-field")).FillWidth().Gap(4).Children(func() { + ui.Row(c).FillWidth().Items(ui.Center).Gap(4).Children(func() { + ui.Text(c, i18n.Shared(language, "desktop.runConfig.fieldBeforeLaunch")).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) + ui.Button(c.Part("help"), i18n.Shared(language, "native.moreInformation")).Icon(icons.Info).IconOnly().Ghost(). + Size(18, 18).Shrink(0).Tooltip(i18n.Shared(language, "desktop.runConfig.beforeLaunchHelp")).TooltipOn(ui.TooltipRight) + }) + a.drawRunConfigBeforeLaunch(c, &e.beforeLaunch, &e.beforeLaunchMenu, p.runConfigs.beforeLaunchCandidates(e.id), ready, nil) + }) + labels := map[string]string{"local": i18n.Shared(language, "desktop.runConfig.scopeLocal"), "project": i18n.Shared(language, "desktop.runConfig.scopeProject")} + ui.Select(c.Part("scope"), &e.scope, []string{"local", "project"}, func(scope string) string { return labels[scope] }). + Label(i18n.Shared(language, "desktop.runConfig.scope")).FillWidth().Disabled(!ready) + if e.failure != "" { + ui.Paragraph(c, e.failure, 4).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) } }) - if closed { - c.After(func() { a.closeRunConfigEditor(p) }) - } } // indexRange is the list 0..n-1, the options of an index picker. diff --git a/desktop/internal/workbench/title_run.go b/desktop/internal/workbench/title_run.go index 59672bfd5b..06d3ff1062 100644 --- a/desktop/internal/workbench/title_run.go +++ b/desktop/internal/workbench/title_run.go @@ -52,23 +52,6 @@ func (p *project) runConfigsSettled() bool { return true } -// noRunConfigurationsNotice explains an empty run configuration list once it is final, and -// is empty while there is something to edit, the list is still read, or reading it failed -// (the menu and the Run window show that failure). -func (p *project) noRunConfigurationsNotice(language i18n.Language) string { - s := &p.runConfigs - if !p.runConfigsSettled() || s.failure != "" || len(s.list) > 0 { - return "" - } - if p.build.failed != "" { - return p.build.failed - } - if s.hidden > 0 { - return i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": strconv.Itoa(s.hidden)}) - } - return i18n.Shared(language, "desktop.title.nothingToEdit") -} - // hiddenRunConfigurations says how many saved configurations the list leaves out because no // build plugin starts them. func hiddenRunConfigurations(language i18n.Language, count int) string { @@ -120,29 +103,18 @@ func (a *App) chooseTitleConfiguration(p *project, id string) { p.runConfigs.selected = id } -// editRunConfigurations opens the Run window, which lists the configurations, and the editor -// of the one the title bar runs. With none chosen it opens the editor of a new built-in run; -// before the built-in kinds are read it says why there is nothing to edit instead, so the -// press never looks like it did nothing. +// editRunConfigurations opens the Run/Debug Configurations dialog with the configuration the +// title bar runs selected, or nothing selected when it runs Current File, so the user can +// create one there. func (a *App) editRunConfigurations(p *project) { if p == nil { return } - configuration := p.titleConfiguration() - if configuration == nil && len(p.runConfigs.types) > 0 { - // Nothing to edit yet: the editor opens on a new configuration of the platform's - // first built-in kind, whose kind the user can still pick from New Configuration. - a.openRunConfigForm(p, p.runConfigs.types[0].Provider, "") - return - } - if notice := p.noRunConfigurationsNotice(a.language()); notice != "" { - a.notifyInfo(notice) - return - } - a.openToolWindow(itemRun) - if configuration != nil && runConfigEditable(*configuration) { - a.editRunConfiguration(p, configuration.ID) + id := "" + if configuration := p.titleConfiguration(); configuration != nil { + id = configuration.ID } + a.openRunConfigDialog(p, id) } // openToolWindow shows tool window id, leaving it open when it already is. diff --git a/desktop/internal/workbench/title_run_empty_visual_test.go b/desktop/internal/workbench/title_run_empty_visual_test.go index 9773990d82..7b667d3c36 100644 --- a/desktop/internal/workbench/title_run_empty_visual_test.go +++ b/desktop/internal/workbench/title_run_empty_visual_test.go @@ -17,8 +17,8 @@ import ( ) // TestVisualTitleRunWithoutConfigurations captures the run configuration menu of a project -// whose build plugin declares no run while two saved configurations are hidden, and the notice -// Edit Configuration… shows there (#2028). +// whose build plugin declares no run while two saved configurations are hidden, and the +// Run/Debug Configurations dialog Edit Configuration… opens there, counting them (#2028). func TestVisualTitleRunWithoutConfigurations(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -83,10 +83,10 @@ func TestVisualTitleRunWithoutConfigurations(t *testing.T) { if err := session.Screenshot(filepath.Join(out, "title-run-empty-edit-"+name+".png")); err != nil { t.Fatal(err) } - want := i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": "2"}) - if got := lastNotice(h); got != want { - t.Fatalf("notice = %q, want %q", got, want) + if !p.runConfigs.dialog.open || !h.showsWrapped(hiddenRunConfigurations(language, 2)) { + t.Fatal("Edit Configuration did not open the dialog counting the hidden configurations") } + h.app.post(func(a *App) { a.closeRunConfigDialog(p) }) }) } } diff --git a/desktop/internal/workbench/title_run_test.go b/desktop/internal/workbench/title_run_test.go index c7fb1dbb2c..3d49b6452b 100644 --- a/desktop/internal/workbench/title_run_test.go +++ b/desktop/internal/workbench/title_run_test.go @@ -234,40 +234,26 @@ func emptyRunConfigHarness(t *testing.T, root string) (*harness, *project) { } // Edit Configuration on a project without configurations used to open a Run window that showed -// nothing, which looked like no reaction (#2028). It now opens the editor on a new -// configuration of the platform's first built-in kind; only while no kind is known does it -// say why the list is empty. -func TestEditRunConfigurationsWithoutAnyOpensANewConfiguration(t *testing.T) { +// nothing, which looked like no reaction (#2028). It now opens the Run/Debug Configurations +// dialog with nothing selected, whose pane offers a button per built-in kind. +func TestEditRunConfigurationsWithoutAnyOpensTheDialog(t *testing.T) { h, p := emptyRunConfigHarness(t, runConfigRoot(t)) + h.app.post(func(a *App) { a.editRunConfigurations(p) }) awaitStateWithin(t, h, 10*time.Second, "the built-in kinds", func() bool { return p.runConfigs.types != nil }) - kinds := p.runConfigs.types - h.app.post(func(a *App) { - p.runConfigs.types = []core.RunConfigurationType{} - a.editRunConfigurations(p) - }) h.settle() - want := i18n.Shared(h.app.language(), "desktop.title.nothingToEdit") - if got := lastNotice(h); got != want { - t.Fatalf("notice = %q, want %q", got, want) - } - if p.runConfigs.editor.open || p.runConfigs.form.open { - t.Fatal("an editor opened without a kind") - } - - h.app.post(func(a *App) { - p.runConfigs.types = kinds - a.editRunConfigurations(p) - }) - awaitStateWithin(t, h, 10*time.Second, "the new configuration's form", func() bool { - f := &p.runConfigs.form - return f.open && !f.loading && len(f.fields) > 0 - }) - if f := &p.runConfigs.form; f.provider != runProviderShell || f.id != "" { - t.Fatalf("form = provider %q id %q, want a new %s", f.provider, f.id, runProviderShell) + d := &p.runConfigs.dialog + if !d.open || d.selected != "" || len(d.drafts) != 0 || lastNotice(h) != "" { + t.Fatalf("dialog open %v selected %q drafts %d, notice %q", d.open, d.selected, len(d.drafts), lastNotice(h)) } - title := i18n.SharedFormat(h.app.language(), "desktop.runConfig.newTitle", map[string]string{"type": i18n.Shared(h.app.language(), "desktop.runConfig.typeShell")}) - if !h.shows(title) { - t.Fatalf("the form titled %q is not shown", title) + language := h.app.language() + for _, text := range []string{ + i18n.Shared(language, "desktop.runConfig.dialogTitle"), + i18n.Shared(language, "desktop.runConfig.dialogHint"), + i18n.Shared(language, "desktop.runConfig.typeShell"), + } { + if !h.shows(text) { + t.Fatalf("%q is not shown", text) + } } } @@ -296,25 +282,26 @@ func TestEditRunConfigurationsCountsTheConfigurationsNoBuildPluginStarts(t *test if p.runConfigs.hidden != 2 { t.Fatalf("hidden = %d, want 2", p.runConfigs.hidden) } - h.app.post(func(a *App) { - p.runConfigs.types = []core.RunConfigurationType{} - a.editRunConfigurations(p) - }) + h.app.post(func(a *App) { a.editRunConfigurations(p) }) h.settle() - language := h.app.language() - want := i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": "2"}) - if got := lastNotice(h); got != want { - t.Fatalf("notice = %q, want %q", got, want) + want := hiddenRunConfigurations(h.app.language(), 2) + if !p.runConfigs.dialog.open || !h.shows(want) { + t.Fatalf("dialog open %v, %q shown %v", p.runConfigs.dialog.open, want, h.shows(want)) } } -// With configurations to show, Edit Configuration keeps opening the Run window and the editor -// of the chosen one. +// With configurations to show, Edit Configuration opens the dialog with the chosen one selected +// and its editor read. func TestEditRunConfigurationsOpensTheChosenOnesEditor(t *testing.T) { h, p := titleRunHarness(t, &testKernel{Client: core.NewClient()}, pluginservice.BuildRunDeclaration{ID: "application", Name: "Run", Tags: []string{"app"}}) + id := p.titleConfiguration().ID h.app.post(func(a *App) { a.editRunConfigurations(p) }) - awaitStateWithin(t, h, 10*time.Second, "the editor", func() bool { return p.runConfigs.editor.open }) - if !h.app.chrome.isOpen(catalogIndex[itemRun]) || lastNotice(h) != "" { - t.Fatalf("Run window open %v, notice %q", h.app.chrome.isOpen(catalogIndex[itemRun]), lastNotice(h)) + d := &p.runConfigs.dialog + awaitStateWithin(t, h, 10*time.Second, "the editor", func() bool { + draft := d.drafts[id] + return d.open && draft != nil && draft.editor != nil && !draft.editor.loading + }) + if d.selected != id || lastNotice(h) != "" { + t.Fatalf("selected %q, want %q; notice %q", d.selected, id, lastNotice(h)) } } diff --git a/desktop/internal/workbench/title_run_view.go b/desktop/internal/workbench/title_run_view.go index db9edf99a5..594b1a2bcf 100644 --- a/desktop/internal/workbench/title_run_view.go +++ b/desktop/internal/workbench/title_run_view.go @@ -4,6 +4,7 @@ import ( "path" "path/filepath" + "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/icons" "github.com/vivaui/viva/ui" @@ -39,7 +40,13 @@ func (a *App) titleRunConfigMenu(c ui.C, anchor ui.Box) { for index := range s.list { configuration := &s.list[index] id := configuration.ID - if menu.Item(configuration.Name).Icon(icons.Play).Chosen(chosen != nil && chosen.ID == id).Clicked() { + item := menu.Item(configuration.Name).Icon(icons.Play).Chosen(chosen != nil && chosen.ID == id) + // A configuration that cannot run here stays choosable, so it can be edited from the + // title bar, and says why Run will not start it. + if configuration.Unavailable() { + item.Icon(icons.CircleAlert).Description(a.runConfigMenuNote(*configuration)) + } + if item.Clicked() { c.After(func() { a.chooseTitleConfiguration(p, id) }) } } @@ -69,10 +76,12 @@ func (a *App) titleRunConfigMenu(c ui.C, anchor ui.Box) { } } menu.Separator() - menu.Sub(i18n.Shared(lang, "desktop.runConfig.newConfiguration"), func(sub *ui.MenuItems) { - sub.WidthRange(runConfigMenuMin, runConfigMenuMax) - a.runConfigTypeItems(c, sub, p, surfaceToolbar) - }).Icon(icons.Plus) + if menu.Item(i18n.Shared(lang, "desktop.runConfig.newConfigurationEllipsis")).Icon(icons.Plus).Clicked() { + c.After(func() { + a.performed("run.configuration.dialog", surfaceToolbar) + a.openRunConfigDialog(p, "") + }) + } if menu.Item(i18n.Shared(lang, "native.editConfiguration")).Icon(icons.Pencil).Clicked() { c.After(func() { a.editRunConfigurations(p) }) } @@ -81,3 +90,13 @@ func (a *App) titleRunConfigMenu(c ui.C, anchor ui.Box) { a.title.runConfigOpen = false } } + +// runConfigMenuNote is the line under a configuration the menu cannot run: the short platform +// note of the dialog's + menu when this system cannot run its kind, which fits the menu's +// width, or the reason Run would give. +func (a *App) runConfigMenuNote(configuration core.RunConfiguration) string { + if availability := configuration.Availability; availability != nil && availability.Code == "unsupportedPlatform" { + return runConfigTypeNote(a.language(), core.RunConfigurationType{Provider: configuration.Provider, Availability: availability}) + } + return a.runConfigUnavailableText(configuration) +} diff --git a/docs/assets/before-launch/before-launch-confirm-dark.png b/docs/assets/before-launch/before-launch-confirm-dark.png index 01d5c01398..390e7b0a86 100644 Binary files a/docs/assets/before-launch/before-launch-confirm-dark.png and b/docs/assets/before-launch/before-launch-confirm-dark.png differ diff --git a/docs/assets/before-launch/before-launch-confirm-light.png b/docs/assets/before-launch/before-launch-confirm-light.png index 4b7fc1d960..5f9ee7b664 100644 Binary files a/docs/assets/before-launch/before-launch-confirm-light.png and b/docs/assets/before-launch/before-launch-confirm-light.png differ diff --git a/docs/assets/before-launch/before-launch-editor-dark.png b/docs/assets/before-launch/before-launch-editor-dark.png index 19920f8133..5b8dabfe39 100644 Binary files a/docs/assets/before-launch/before-launch-editor-dark.png and b/docs/assets/before-launch/before-launch-editor-dark.png differ diff --git a/docs/assets/before-launch/before-launch-editor-light.png b/docs/assets/before-launch/before-launch-editor-light.png index 1c6ded7b48..b00a596466 100644 Binary files a/docs/assets/before-launch/before-launch-editor-light.png and b/docs/assets/before-launch/before-launch-editor-light.png differ diff --git a/docs/assets/before-launch/before-launch-run-output-dark.png b/docs/assets/before-launch/before-launch-run-output-dark.png index 2b5f1d153d..43d34d1d23 100644 Binary files a/docs/assets/before-launch/before-launch-run-output-dark.png and b/docs/assets/before-launch/before-launch-run-output-dark.png differ diff --git a/docs/assets/before-launch/before-launch-run-output-light.png b/docs/assets/before-launch/before-launch-run-output-light.png index c33f4f2623..e1a53cdc3c 100644 Binary files a/docs/assets/before-launch/before-launch-run-output-light.png and b/docs/assets/before-launch/before-launch-run-output-light.png differ diff --git a/docs/assets/builtin-process-runs/README.md b/docs/assets/builtin-process-runs/README.md index 87394a9cc4..d2db72da35 100644 --- a/docs/assets/builtin-process-runs/README.md +++ b/docs/assets/builtin-process-runs/README.md @@ -1,22 +1,35 @@ # 内置脚本与程序运行测试截图 -这些截图是生产 Viva Page 的无头渲染,跑在 macOS 上,使用隔离的临时项目 ScriptDemo 和临时配置,没有安装任何插件。 +这些截图是生产 Viva Page 的无头渲染,在 macOS 上生成。项目是隔离的临时项目 ScriptDemo,配置也是临时的,没有装任何插件。 深色界面用中文,浅色界面用英文,窗口 1200×760。 -测试内核不带插件宿主,所以构建窗口和运行下拉会显示“此窗口无法使用构建插件。”; -截图同时说明,插件不可用时内置运行照常列出、照常运行。 +测试内核不带插件宿主,所以运行下拉会显示“此窗口无法使用构建插件。”。 +这也说明插件不可用时,内置运行照常列出、照常运行。 Shell 脚本在系统 shell 里真实运行,控制台内容是真实输出,日期来自测试的虚拟时钟。 无头截图不代表 macOS/Windows 原生窗口验收。 +运行配置在“运行/调试配置”对话框里新建和编辑。标题栏运行下拉的“新建运行配置…”和“编辑运行配置…”都打开这个对话框。 +对话框左侧是工具栏(+ 新建、− 删除、复制)和按类型分组的配置树,右侧是选中配置的编辑器。 +底部左边是“运行”,右边是“取消 / 应用 / 确定”。 + | 场景 | 深色中文 | 浅色英文 | | --- | --- | --- | -| 新建 Shell 脚本,执行方式为脚本文件。勾选了“存为项目文件”,填了脚本路径、脚本选项、项目内的工作目录和一个环境变量。解释器路径没填,显示的自动值取自脚本首行的 `#!/bin/bash` | [截图](builtin-run-shell-file-dark.png) | [截图](builtin-run-shell-file-light.png) | +| 还没有配置时打开对话框:左侧提示点 + 新建,右侧列出 macOS 提供的四类内置运行。批处理脚本(cmd)标“仅 Windows”,但也能新建 | [截图](builtin-run-dialog-empty-dark.png) | [截图](builtin-run-dialog-empty-light.png) | +| 新建 Shell 脚本,执行方式为脚本文件:勾选了“存为项目文件”,填了脚本路径、脚本选项、项目内的工作目录和一个环境变量。解释器路径没填,自动值取自脚本首行的 `#!/bin/bash`。脚本选项、解释器路径和解释器选项旁的 ⓘ 说明各自传给谁 | [截图](builtin-run-shell-file-dark.png) | [截图](builtin-run-shell-file-light.png) | | 同一配置换成脚本文本,出现多行文本框。文本没有首行 `#!`,解释器自动值变为 `/bin/sh` | [截图](builtin-run-shell-text-dark.png) | [截图](builtin-run-shell-text-light.png) | -| 点击对话框的运行后,配置写入 `.lithe/run/configurations.yaml`,Run 窗口自动打开并选中这次运行。控制台打印脚本输出,执行树以“进程已结束,退出码 0。”结束;标题栏改选 Greet | [截图](builtin-run-run-output-dark.png) | [截图](builtin-run-run-output-light.png) | -| 构建窗口的运行配置列表:Greet 在“脚本与程序”组下,“+”菜单列出 macOS 提供的三类内置运行,没有 cmd 批处理 | [截图](builtin-run-new-menu-dark.png) | [截图](builtin-run-new-menu-light.png) | +| 点击对话框的“运行”后:配置写入 `.lithe/run/configurations.yaml`,对话框关闭,Run 窗口打开并选中这次运行。控制台打印脚本输出,执行树以“进程已结束,退出码 0。”结束;标题栏改选 Greet | [截图](builtin-run-run-output-dark.png) | [截图](builtin-run-run-output-light.png) | +| 再次打开对话框并展开“+”菜单:列出四类内置运行,批处理脚本下注明“仅 Windows” | [截图](builtin-run-new-menu-dark.png) | [截图](builtin-run-new-menu-light.png) | | 新建 PowerShell 脚本:macOS 上的解释器自动值是 pwsh,解释器选项自动值是 `-NoLogo -NoProfile`。“绕过执行策略(-ExecutionPolicy Bypass)”默认勾选,ⓘ 说明只在 Windows 生效 | [截图](builtin-run-powershell-dark.png) | [截图](builtin-run-powershell-light.png) | -| 新建可执行程序:程序路径、程序参数(含带引号的空格参数)、工作目录和环境变量 | [截图](builtin-run-executable-dark.png) | [截图](builtin-run-executable-light.png) | -| 一个插件的运行配置文件 `.lithe/run/plugin/dev.example.engine.toml` 写坏后,标题栏运行下拉仍列出 Greet,并多出一项“未读取 dev.example.engine.toml 中的运行配置”,点击在编辑器中打开该文件 | [截图](builtin-run-run-menu-dark.png) | [截图](builtin-run-run-menu-light.png) | +| 新建可执行程序:程序路径、程序参数(含带引号的空格参数)和工作目录 | [截图](builtin-run-executable-dark.png) | [截图](builtin-run-executable-light.png) | +| 在 macOS 上新建批处理脚本:能编辑、能保存,编辑器顶部提示“批处理脚本只能在 Windows 上运行;在这台电脑上可以编辑和保存,但不能运行。”。配置树里这一行带警告图标,对话框的“运行”置灰 | [截图](builtin-run-batch-dark.png) | [截图](builtin-run-batch-light.png) | +| 点“确定”保存全部四个配置后,标题栏选中 Package:运行按钮置灰;按下时只提示原因,不会启动 | [截图](builtin-run-title-unavailable-dark.png) | [截图](builtin-run-title-unavailable-light.png) | +| 标题栏运行下拉:Package 带警告图标,下方注明“仅 Windows”,仍可选中。插件运行配置文件 `.lithe/run/plugin/dev.example.engine.toml` 写坏后,下拉多出一项“未读取 dev.example.engine.toml 中的运行配置”,点击后在编辑器中打开该文件 | [截图](builtin-run-run-menu-dark.png) | [截图](builtin-run-run-menu-light.png) | + +`docs/assets/run-config-empty/` 是另一组截图,展示项目没有可用运行配置时的标题栏下拉和对话框。 +它们由 `TestVisualTitleRunWithoutConfigurations` 生成。 + +复验:设置 `LITHE_VISUAL_OUTPUT_DIR` 后运行下面的命令,两组截图都会生成。 -复验:设置 `LITHE_VISUAL_OUTPUT_DIR`,运行 `scripts/desktop/desktop-go.sh test --tags 'vivahead lithevisual' ./internal/workbench -run '^TestVisualBuiltInProcessRuns$' --count=1 -timeout 180s` 生成。 +```sh +scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench \ + -run '^(TestVisualBuiltInProcessRuns|TestVisualTitleRunWithoutConfigurations)$' -count=1 -timeout 300s +``` diff --git a/docs/assets/builtin-process-runs/builtin-run-batch-dark.png b/docs/assets/builtin-process-runs/builtin-run-batch-dark.png new file mode 100644 index 0000000000..f4f4d44b34 Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-batch-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-batch-light.png b/docs/assets/builtin-process-runs/builtin-run-batch-light.png new file mode 100644 index 0000000000..983cb7c620 Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-batch-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-dialog-empty-dark.png b/docs/assets/builtin-process-runs/builtin-run-dialog-empty-dark.png new file mode 100644 index 0000000000..3b723f01d8 Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-dialog-empty-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-dialog-empty-light.png b/docs/assets/builtin-process-runs/builtin-run-dialog-empty-light.png new file mode 100644 index 0000000000..817235c727 Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-dialog-empty-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-executable-dark.png b/docs/assets/builtin-process-runs/builtin-run-executable-dark.png index 5310edc923..ca0e4b036d 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-executable-dark.png and b/docs/assets/builtin-process-runs/builtin-run-executable-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-executable-light.png b/docs/assets/builtin-process-runs/builtin-run-executable-light.png index 0da09b79c5..be66b733e2 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-executable-light.png and b/docs/assets/builtin-process-runs/builtin-run-executable-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-new-menu-dark.png b/docs/assets/builtin-process-runs/builtin-run-new-menu-dark.png index b8ec008491..8cb3528914 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-new-menu-dark.png and b/docs/assets/builtin-process-runs/builtin-run-new-menu-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-new-menu-light.png b/docs/assets/builtin-process-runs/builtin-run-new-menu-light.png index 900bbc4acb..f7efce4885 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-new-menu-light.png and b/docs/assets/builtin-process-runs/builtin-run-new-menu-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-powershell-dark.png b/docs/assets/builtin-process-runs/builtin-run-powershell-dark.png index 84d0468e9a..4ae34aeb70 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-powershell-dark.png and b/docs/assets/builtin-process-runs/builtin-run-powershell-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-powershell-light.png b/docs/assets/builtin-process-runs/builtin-run-powershell-light.png index 15c87abf6d..48f09c55e0 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-powershell-light.png and b/docs/assets/builtin-process-runs/builtin-run-powershell-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-run-menu-dark.png b/docs/assets/builtin-process-runs/builtin-run-run-menu-dark.png index 434bd89af2..33552a59a0 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-run-menu-dark.png and b/docs/assets/builtin-process-runs/builtin-run-run-menu-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-run-menu-light.png b/docs/assets/builtin-process-runs/builtin-run-run-menu-light.png index 2264824df0..976f707e68 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-run-menu-light.png and b/docs/assets/builtin-process-runs/builtin-run-run-menu-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-run-output-dark.png b/docs/assets/builtin-process-runs/builtin-run-run-output-dark.png index bc5dd59523..f01aff37f4 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-run-output-dark.png and b/docs/assets/builtin-process-runs/builtin-run-run-output-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-run-output-light.png b/docs/assets/builtin-process-runs/builtin-run-run-output-light.png index 0b695eaaa1..67d2f983c6 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-run-output-light.png and b/docs/assets/builtin-process-runs/builtin-run-run-output-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-shell-file-dark.png b/docs/assets/builtin-process-runs/builtin-run-shell-file-dark.png index 5435eec5ad..7f78cf30ea 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-shell-file-dark.png and b/docs/assets/builtin-process-runs/builtin-run-shell-file-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-shell-file-light.png b/docs/assets/builtin-process-runs/builtin-run-shell-file-light.png index 923d33e8e7..e17e3cdce5 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-shell-file-light.png and b/docs/assets/builtin-process-runs/builtin-run-shell-file-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-shell-text-dark.png b/docs/assets/builtin-process-runs/builtin-run-shell-text-dark.png index c93a0f4340..0562566266 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-shell-text-dark.png and b/docs/assets/builtin-process-runs/builtin-run-shell-text-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-shell-text-light.png b/docs/assets/builtin-process-runs/builtin-run-shell-text-light.png index 7bb122f286..e3ef47afb6 100644 Binary files a/docs/assets/builtin-process-runs/builtin-run-shell-text-light.png and b/docs/assets/builtin-process-runs/builtin-run-shell-text-light.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-title-unavailable-dark.png b/docs/assets/builtin-process-runs/builtin-run-title-unavailable-dark.png new file mode 100644 index 0000000000..5f087ab7a4 Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-title-unavailable-dark.png differ diff --git a/docs/assets/builtin-process-runs/builtin-run-title-unavailable-light.png b/docs/assets/builtin-process-runs/builtin-run-title-unavailable-light.png new file mode 100644 index 0000000000..cd4b310cdf Binary files /dev/null and b/docs/assets/builtin-process-runs/builtin-run-title-unavailable-light.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png b/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png index 715501cb84..f044ed9bd6 100644 Binary files a/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png and b/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png b/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png index 6705391f4d..10193cbf32 100644 Binary files a/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png and b/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png b/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png index f555d42503..46b5c7ae62 100644 Binary files a/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png and b/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png b/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png index 71441e8b71..9594063837 100644 Binary files a/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png and b/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png differ diff --git a/docs/assets/run-current-file/run-current-file-menu-dark.png b/docs/assets/run-current-file/run-current-file-menu-dark.png index 3eaa0962f6..af1bd439d1 100644 Binary files a/docs/assets/run-current-file/run-current-file-menu-dark.png and b/docs/assets/run-current-file/run-current-file-menu-dark.png differ diff --git a/docs/assets/run-current-file/run-current-file-menu-light.png b/docs/assets/run-current-file/run-current-file-menu-light.png index adf0bf46b5..5030b08eb5 100644 Binary files a/docs/assets/run-current-file/run-current-file-menu-light.png and b/docs/assets/run-current-file/run-current-file-menu-light.png differ diff --git a/docs/assets/run-current-file/run-current-file-run-dark.png b/docs/assets/run-current-file/run-current-file-run-dark.png index 1ee680d64d..398da9d505 100644 Binary files a/docs/assets/run-current-file/run-current-file-run-dark.png and b/docs/assets/run-current-file/run-current-file-run-dark.png differ diff --git a/docs/assets/run-current-file/run-current-file-run-light.png b/docs/assets/run-current-file/run-current-file-run-light.png index 0944c8d776..3b4d52c4d6 100644 Binary files a/docs/assets/run-current-file/run-current-file-run-light.png and b/docs/assets/run-current-file/run-current-file-run-light.png differ diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 121ee16874..bc228223bc 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -36,7 +36,13 @@ native_path() { # back; and git.graphProjection checkedOutHeads marks the commits of every repository's # checked-out branch, refusing currentBranch beside it (#2013). Switch to main's commit once #75 # is squash-merged. -# Lithe-core-rust main at d833d6a, #89 squash-merged (on top of bb4832e, #88): buildProviders 1 +# #87, squash-merged into main as 6f5fbcc (on top of d8094c6, #90): runConfig.configurationTypes +# lists every built-in kind on every platform, one this platform cannot run with an unsupportedPlatform +# availability, and runConfig.editorForm, runConfig.saveConfiguration and runConfig.resolve treat a cmd +# run off Windows the same way, so it can be created and edited there while runConfig.createLaunchPlan +# still refuses to start it and runConfig.beforeLaunch refuses it as a step (#2100). #90, squash-merged +# into main as d8094c6 (on top of d833d6a): the chrome layout catalog takes alsoOnToolStripes. +# #89, squash-merged into main as d833d6a (on top of bb4832e, #88): buildProviders 1 # adds runs with entrypoints: true; build.runEntrypointsPlan and build.decodeRunEntrypoints ask a # provider for the entrypoints of one source file, prepareRunPlan takes an entrypoint run without a # target, and runConfig.createUserConfiguration saves the entrypoint as part of the entry (#2104). diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index 880f3ff2e2..45b701271a 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -1400,9 +1400,8 @@ "desktop.run.rerun": "Run again", "desktop.run.signalled": "Process stopped by signal {signal}.", "desktop.runConfig.arguments": "Program arguments", - "desktop.runConfig.argumentsPlaceholder": "Separate with spaces; quote values that contain spaces", + "desktop.runConfig.argumentsPlaceholder": "Arguments for the program, e.g. --port 8080; separate with spaces and quote one that contains spaces", "desktop.runConfig.conflict": "The file changed on disk while saving. Close the editor, reopen it and try again.", - "desktop.runConfig.editTitle": "Edit {name}", "desktop.runConfig.environment": "Environment variables", "desktop.runConfig.environmentInvalid": "Line {line} is not KEY=VALUE.", "desktop.runConfig.environmentPlaceholder": "One KEY=VALUE per line", @@ -11295,8 +11294,6 @@ "desktop.title.configurationNotStartable": "{name} cannot be started: no build plugin runs it.", "desktop.title.currentFileNotRunnable": "The current file has no entrypoint to run, such as a class with a main method. Open such a file, or choose a run configuration from the run configuration menu.", "desktop.title.hiddenRunConfigurations": "{count} saved configurations hidden (not runnable)", - "desktop.title.nothingToEdit": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project.", - "desktop.title.nothingToEditHidden": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project. {count} saved run configurations are hidden because no build plugin runs them, for example entries an earlier version of Lithe saved in .lithe/run.", "desktop.title.noRunConfigurations": "No run configurations", "desktop.title.notDebuggable": "{name} cannot be debugged: its plugin declares no debug adapter for this run.", "desktop.title.runBusy": "The Run window is still running another operation. Wait for it to finish or stop it first.", @@ -11464,7 +11461,6 @@ "desktop.runConfig.builtInGroup": "Scripts and Programs", "desktop.runConfig.newConfiguration": "New Configuration", "desktop.runConfig.emptyHint": "No run configurations yet. Click + to add a script or program run.", - "desktop.runConfig.newTitle": "New {type} Configuration", "desktop.runConfig.fieldName": "Name", "desktop.runConfig.fieldStoreAsProjectFile": "Store as project file", "desktop.runConfig.storeAsProjectFileHelp": "Checked, the configuration is saved in .lithe/run/configurations.yaml and can be committed with the project; unchecked, it stays on this machine in .lithe/run/local.yaml.", @@ -11534,7 +11530,27 @@ "desktop.runConfig.unavailableVersionUnsupported": "The installed “{plugin}” does not meet the version requirement {requirement}.", "desktop.runConfig.unavailableMissingDirectory": "The working directory “{directory}” no longer exists. Edit the configuration to change it.", "desktop.runConfig.unavailableInvalid": "The run configuration is invalid: {reason}", - "desktop.runConfig.unavailableOther": "This run configuration cannot run now: {reason}" + "desktop.runConfig.unavailableOther": "This run configuration cannot run now: {reason}", + "desktop.runConfig.dialogTitle": "Run/Debug Configurations", + "desktop.runConfig.dialogHint": "Select a run configuration on the left to edit it, or create one:", + "desktop.runConfig.newConfigurationEllipsis": "New Run Configuration…", + "desktop.runConfig.removeConfiguration": "Remove Configuration", + "desktop.runConfig.copyConfiguration": "Copy Configuration", + "desktop.runConfig.copyName": "{name} (Copy)", + "desktop.runConfig.unnamed": "Unnamed", + "desktop.runConfig.windowsOnlyType": "Windows only", + "desktop.runConfig.typeNotRunnableHere": "Cannot run on this computer", + "desktop.runConfig.unavailableBatchPlatform": "Batch scripts run only on Windows. You can edit and save this configuration here, but not run it.", + "desktop.runConfig.unavailablePlatform": "{type} cannot run on this system. You can edit and save this configuration, but not run it.", + "desktop.runConfig.notEditable": "This run configuration can be edited once its plugin is available.", + "desktop.runConfig.scriptOptionsPlaceholder": "Arguments for the script, e.g. --verbose input.txt", + "desktop.runConfig.interpreterArgumentsPlaceholder": "Options for the interpreter, e.g. -x", + "desktop.runConfig.programArgumentsPlaceholder": "Arguments for the program, e.g. --port 8080", + "desktop.runConfig.scriptOptionsHelpShell": "Arguments placed after the script path and passed to the script, which reads them as $1, $2… Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.scriptOptionsHelpPowerShell": "Arguments placed after the script path and passed to the script, which reads them through $args or param(). Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.scriptOptionsHelpBatch": "Arguments placed after the script path and passed to the script, which reads them as %1, %2… Separate them with spaces; quote an argument that contains spaces.", + "desktop.runConfig.interpreterArgumentsHelp": "Options placed before the script path and handled by the interpreter itself, such as bash's -x, which prints each command as it runs. The script does not see them. Left empty, the automatic options shown in brackets are used.", + "desktop.runConfig.programArgumentsHelp": "Command-line arguments placed after the program path when it starts. Separate them with spaces; quote an argument that contains spaces." }, "overrides": { "windows": { diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index 9e5198f4b8..291b5d55d4 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -1400,9 +1400,8 @@ "desktop.run.rerun": "再次运行", "desktop.run.signalled": "进程被信号 {signal} 终止。", "desktop.runConfig.arguments": "程序参数", - "desktop.runConfig.argumentsPlaceholder": "以空格分隔;含空格的值请加引号", + "desktop.runConfig.argumentsPlaceholder": "传给程序的参数,例如 --port 8080;多个参数用空格分隔,含空格的参数用引号括起来", "desktop.runConfig.conflict": "保存期间文件已在磁盘上被修改,请关闭编辑器重新打开后再试。", - "desktop.runConfig.editTitle": "编辑 {name}", "desktop.runConfig.environment": "环境变量", "desktop.runConfig.environmentInvalid": "第 {line} 行不是 KEY=VALUE 格式。", "desktop.runConfig.environmentPlaceholder": "每行一个 KEY=VALUE", @@ -11295,8 +11294,6 @@ "desktop.title.configurationNotStartable": "无法启动 {name}:没有构建插件负责运行它。", "desktop.title.currentFileNotRunnable": "当前文件没有可运行的入口(例如带 main 方法的类)。请打开这样的文件,或在运行配置菜单里选择一个运行配置。", "desktop.title.hiddenRunConfigurations": "已隐藏 {count} 条无法运行的已保存配置", - "desktop.title.nothingToEdit": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。", - "desktop.title.nothingToEditHidden": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。另有 {count} 条保存的运行配置没有构建插件负责运行,已隐藏,例如旧版 Lithe 保存在 .lithe/run 中的配置。", "desktop.title.noRunConfigurations": "没有运行配置", "desktop.title.notDebuggable": "无法调试 {name}:它所属的插件没有为这个运行声明调试适配器。", "desktop.title.runBusy": "运行窗口还在执行其他操作。请等它结束,或者先停止它。", @@ -11464,7 +11461,6 @@ "desktop.runConfig.builtInGroup": "脚本与程序", "desktop.runConfig.newConfiguration": "新建运行配置", "desktop.runConfig.emptyHint": "还没有运行配置,点 + 新建脚本或程序运行", - "desktop.runConfig.newTitle": "新建{type}运行配置", "desktop.runConfig.fieldName": "名称", "desktop.runConfig.fieldStoreAsProjectFile": "存为项目文件", "desktop.runConfig.storeAsProjectFileHelp": "勾选后保存到 .lithe/run/configurations.yaml,可随项目提交共享;不勾选则只保存在本机的 .lithe/run/local.yaml。", @@ -11534,7 +11530,27 @@ "desktop.runConfig.unavailableVersionUnsupported": "已安装的“{plugin}”版本不满足要求 {requirement}。", "desktop.runConfig.unavailableMissingDirectory": "工作目录“{directory}”不存在了,请编辑配置修改它。", "desktop.runConfig.unavailableInvalid": "运行配置无效:{reason}", - "desktop.runConfig.unavailableOther": "此运行配置现在无法运行:{reason}" + "desktop.runConfig.unavailableOther": "此运行配置现在无法运行:{reason}", + "desktop.runConfig.dialogTitle": "运行/调试配置", + "desktop.runConfig.dialogHint": "在左侧选择一个运行配置进行编辑,或新建一个:", + "desktop.runConfig.newConfigurationEllipsis": "新建运行配置…", + "desktop.runConfig.removeConfiguration": "删除配置", + "desktop.runConfig.copyConfiguration": "复制配置", + "desktop.runConfig.copyName": "{name}(副本)", + "desktop.runConfig.unnamed": "未命名", + "desktop.runConfig.windowsOnlyType": "仅 Windows", + "desktop.runConfig.typeNotRunnableHere": "本机不能运行", + "desktop.runConfig.unavailableBatchPlatform": "批处理脚本只能在 Windows 上运行;在这台电脑上可以编辑和保存,但不能运行。", + "desktop.runConfig.unavailablePlatform": "{type}不能在当前系统上运行;可以编辑和保存,但不能运行。", + "desktop.runConfig.notEditable": "插件可用后才能编辑这个运行配置。", + "desktop.runConfig.scriptOptionsPlaceholder": "传给脚本的参数,例如 --verbose input.txt", + "desktop.runConfig.interpreterArgumentsPlaceholder": "传给解释器的选项,例如 -x", + "desktop.runConfig.programArgumentsPlaceholder": "传给程序的参数,例如 --port 8080", + "desktop.runConfig.scriptOptionsHelpShell": "写在脚本路径后面、传给脚本的参数,脚本里用 $1、$2… 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.scriptOptionsHelpPowerShell": "写在脚本路径后面、传给脚本的参数,脚本里用 $args 或 param() 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.scriptOptionsHelpBatch": "写在脚本路径后面、传给脚本的参数,脚本里用 %1、%2… 读取。多个参数用空格分隔,含空格的参数用引号括起来。", + "desktop.runConfig.interpreterArgumentsHelp": "写在脚本路径前面、交给解释器本身的选项,例如 bash 的 -x(逐行打印执行的命令);脚本读不到这些值。留空时使用括号里显示的自动选项。", + "desktop.runConfig.programArgumentsHelp": "启动程序时附在程序路径后面的命令行参数。多个参数用空格分隔,含空格的参数用引号括起来。" }, "overrides": { "macos": { diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index c21db48a12..fb436d172a 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -15457,16 +15457,6 @@ "desktop" ] }, - { - "id": "desktop.runConfig.editTitle", - "description": "Title of the run configuration editor dialog; {name} is the configuration's name.", - "platforms": [ - "desktop" - ], - "parameters": { - "name": "string" - } - }, { "id": "desktop.runConfig.entrypoint", "description": "Label of the provider entrypoint field of a build provider run", @@ -15676,16 +15666,6 @@ "desktop" ] }, - { - "id": "desktop.runConfig.newTitle", - "description": "Title of the editor dialog of a new built-in run configuration; type is the kind's name.", - "platforms": [ - "desktop" - ], - "parameters": { - "type": "string" - } - }, { "id": "desktop.runConfig.fieldName", "description": "Label of the name field of a built-in run configuration.", @@ -16251,6 +16231,152 @@ "reason": "string" } }, + { + "id": "desktop.runConfig.dialogTitle", + "description": "Title of the Run/Debug Configurations dialog, which lists the run configurations by kind and edits the selected one.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.dialogHint", + "description": "Run/Debug Configurations dialog: hint shown while no configuration is selected, above a button per built-in kind.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.newConfigurationEllipsis", + "description": "Menu item and button that open the Run/Debug Configurations dialog to create a run configuration.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.removeConfiguration", + "description": "Run/Debug Configurations dialog: toolbar button that removes the selected configuration when Apply or OK is pressed.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.copyConfiguration", + "description": "Run/Debug Configurations dialog: toolbar button that creates a copy of the selected built-in configuration.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.copyName", + "description": "Run/Debug Configurations dialog: name of a copied configuration; {name} is the original's name.", + "platforms": [ + "desktop" + ], + "parameters": { + "name": "string" + } + }, + { + "id": "desktop.runConfig.unnamed", + "description": "Run/Debug Configurations dialog: tree label of a configuration without a name.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.windowsOnlyType", + "description": "Run/Debug Configurations dialog: note beside the batch script kind on macOS and Linux, which can create and edit it but not run it.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.typeNotRunnableHere", + "description": "Run/Debug Configurations dialog: note beside a built-in kind this platform cannot run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.unavailableBatchPlatform", + "description": "Why a batch script run configuration cannot run on macOS or Linux, shown over its editor, on its row and when Run is pressed.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.unavailablePlatform", + "description": "Why a built-in run configuration cannot run on this platform; {type} is the kind's name.", + "platforms": [ + "desktop" + ], + "parameters": { + "type": "string" + } + }, + { + "id": "desktop.runConfig.notEditable", + "description": "Run/Debug Configurations dialog: shown for a plugin run configuration whose plugin is missing, disabled or the wrong version.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.scriptOptionsPlaceholder", + "description": "Placeholder of the script options field of a built-in script run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.interpreterArgumentsPlaceholder", + "description": "Placeholder of the interpreter options field of a built-in script run while it has no automatic value.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.programArgumentsPlaceholder", + "description": "Placeholder of the program arguments field of a built-in executable run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.scriptOptionsHelpShell", + "description": "Help tip of the script options field of a shell script run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.scriptOptionsHelpPowerShell", + "description": "Help tip of the script options field of a PowerShell script run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.scriptOptionsHelpBatch", + "description": "Help tip of the script options field of a batch script run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.interpreterArgumentsHelp", + "description": "Help tip of the interpreter options field of a built-in script run.", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.runConfig.programArgumentsHelp", + "description": "Help tip of the program arguments field of a built-in executable run.", + "platforms": [ + "desktop" + ] + }, { "id": "desktop.search.collapseFile", "description": "Find in Files result: collapse an expanded file row", @@ -19481,23 +19607,6 @@ "desktop" ] }, - { - "id": "desktop.title.nothingToEdit", - "description": "Desktop title bar: Edit Configuration chosen when the project has no run configuration; build plugins generate them from the project model and none declared a runnable entry", - "platforms": [ - "desktop" - ] - }, - { - "id": "desktop.title.nothingToEditHidden", - "description": "Desktop title bar: Edit Configuration chosen when the project has no run configuration that a build plugin starts, while count saved ones are hidden because no build plugin runs them", - "platforms": [ - "desktop" - ], - "parameters": { - "count": "unsignedInteger" - } - }, { "id": "desktop.title.notDebuggable", "description": "Desktop title bar: Debug pressed on a run configuration whose plugin declares no debug adapter for its run", diff --git a/shared/platform-feature-matrix/features/builtin-process-runs.json b/shared/platform-feature-matrix/features/builtin-process-runs.json index 00e0aa6e9c..26ed180baf 100644 --- a/shared/platform-feature-matrix/features/builtin-process-runs.json +++ b/shared/platform-feature-matrix/features/builtin-process-runs.json @@ -2,7 +2,7 @@ "id": "builtin-process-runs", "area": "运行与调试", "group": "运行配置", - "capability": "内置脚本与程序运行:不装任何插件也能新建、编辑、删除并运行 Shell 脚本、PowerShell 脚本、cmd 批处理(只在 Windows 列出)和可执行程序四类运行配置;编辑对话框参照 IDEA 的 Shell Script 配置,有名称、“存为项目文件”、脚本文件或脚本文本、脚本选项、工作目录、环境变量、解释器路径、解释器选项(留空时显示自动值:Shell 按脚本首行 #! 选解释器,没有时 macOS/Linux 用 /bin/sh、Windows 用 bash;PowerShell 用 Windows 的 powershell 或 pwsh;cmd 用 cmd /d),PowerShell 的“绕过执行策略”默认勾选、只在 Windows 生效;底部有运行、取消、应用、确定;可执行程序有程序路径、参数、工作目录和环境变量。字段、默认值、显示条件和校验错误全部来自 Core(runConfig.configurationTypes、runConfig.editorForm),新增字段不改宿主绘制代码。存为项目文件时写 .lithe/run/configurations.yaml,否则写 .lithe/run/local.yaml;插件运行另存 .lithe/run/plugin/<插件>.toml 与 <插件>.local.toml,并记下插件的作者/仓库、版本、版本要求、插件 API 版本和所需能力;旧版 configurations.json、local.json 在没有对应 YAML 时仍读取,第一次编辑该层时改写为 YAML 并删除 JSON。编辑对话框的“运行”、构建窗口的运行配置列表、标题栏的运行按钮和 Run 窗口的再次运行都能启动,启动时 Run 窗口自动打开并选中这次运行,输出进入它的控制台,以“进程已结束,退出码 N。”结束;脚本文本写到系统临时目录(不写安装目录),运行结束后删除。插件出错、未装或项目尚未加载构建模型时,内置运行照常列出和运行;某个运行配置文件没有读取(插件 TOML 写坏、同一配置存了两次、旧版 JSON 已被 YAML 取代)时,标题栏运行下拉按文件名列出它,点击在编辑器中打开", + "capability": "内置脚本与程序运行:不装任何插件也能新建、编辑、删除并运行 Shell 脚本、PowerShell 脚本、cmd 批处理和可执行程序四类运行配置。新建和编辑都在参照 IDEA 的“运行/调试配置”对话框里:标题栏运行下拉的“新建运行配置…”“编辑运行配置…”和构建窗口配置列表的“+”打开它,左侧是“+”“−”、复制和按类型分组、可折叠的配置树,右侧是选中配置的编辑器,底部有运行、取消、应用、确定;几条配置的新建、修改和删除在“应用”或“确定”时一起保存,“取消”全部丢弃。批处理只能在 Windows 上运行:macOS/Linux 上仍可新建、编辑和保存(和 Windows 同事共享的配置不会消失),类型旁注明“仅 Windows”,编辑器顶部说明原因,配置树和标题栏下拉的这一行带警告图标,对话框的“运行”和标题栏运行按钮置灰,按下时只提示原因。内置运行的编辑器参照 IDEA 的 Shell Script 配置,有名称、“存为项目文件”、脚本文件或脚本文本、脚本选项、工作目录、环境变量、解释器路径、解释器选项(留空时显示自动值:Shell 按脚本首行 #! 选解释器,没有时 macOS/Linux 用 /bin/sh、Windows 用 bash;PowerShell 用 Windows 的 powershell 或 pwsh;cmd 用 cmd /d),脚本选项、解释器路径和解释器选项旁的 ⓘ 说明各自传给谁;PowerShell 的“绕过执行策略”默认勾选、只在 Windows 生效;可执行程序有程序路径、参数、工作目录和环境变量。字段、默认值、显示条件和校验错误全部来自 Core(runConfig.configurationTypes、runConfig.editorForm),新增字段不改宿主绘制代码。存为项目文件时写 .lithe/run/configurations.yaml,否则写 .lithe/run/local.yaml;插件运行另存 .lithe/run/plugin/<插件>.toml 与 <插件>.local.toml,并记下插件的作者/仓库、版本、版本要求、插件 API 版本和所需能力;旧版 configurations.json、local.json 在没有对应 YAML 时仍读取,第一次编辑该层时改写为 YAML 并删除 JSON。编辑对话框的“运行”、构建窗口的运行配置列表、标题栏的运行按钮和 Run 窗口的再次运行都能启动,启动时 Run 窗口自动打开并选中这次运行,输出进入它的控制台,以“进程已结束,退出码 N。”结束;脚本文本写到系统临时目录(不写安装目录),运行结束后删除。插件出错、未装或项目尚未加载构建模型时,内置运行照常列出和运行;某个运行配置文件没有读取(插件 TOML 写坏、同一配置存了两次、旧版 JSON 已被 YAML 取代)时,标题栏运行下拉按文件名列出它,点击在编辑器中打开", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -16,14 +16,18 @@ "desktop/internal/workbench/runconfig.go", "desktop/internal/workbench/runconfig_browser.go", "desktop/internal/workbench/runconfig_changes.go", + "desktop/internal/workbench/runconfig_dialog.go", + "desktop/internal/workbench/runconfig_dialog_view.go", "desktop/internal/workbench/runconfig_edit.go", "desktop/internal/workbench/runconfig_form.go", "desktop/internal/workbench/runconfig_form_view.go", "desktop/internal/workbench/runconfig_process.go", "desktop/internal/workbench/runconfig_process_test.go", "desktop/internal/workbench/runconfig_edit_test.go", + "desktop/internal/workbench/runconfig_dialog_test.go", "desktop/internal/workbench/runconfig_process_visual_test.go", "desktop/internal/workbench/title_run.go", + "desktop/internal/workbench/title_run_view.go", "desktop/internal/workbench/title_run_test.go", "docs/assets/builtin-process-runs/README.md" ] @@ -41,17 +45,21 @@ "desktop/internal/workbench/runconfig.go", "desktop/internal/workbench/runconfig_browser.go", "desktop/internal/workbench/runconfig_changes.go", + "desktop/internal/workbench/runconfig_dialog.go", + "desktop/internal/workbench/runconfig_dialog_view.go", "desktop/internal/workbench/runconfig_edit.go", "desktop/internal/workbench/runconfig_form.go", "desktop/internal/workbench/runconfig_form_view.go", "desktop/internal/workbench/runconfig_process.go", "desktop/internal/workbench/runconfig_process_test.go", "desktop/internal/workbench/runconfig_edit_test.go", + "desktop/internal/workbench/runconfig_dialog_test.go", "desktop/internal/workbench/title_run.go", + "desktop/internal/workbench/title_run_view.go", "desktop/internal/workbench/title_run_test.go" ] }, "owner": "Run", - "verification": "不装任何插件打开一个空文件夹:标题栏“编辑运行配置…”直接打开新建表单;新建 Shell 脚本,选“脚本文本”写 echo hello,勾选“存为项目文件”后点运行,确认 .lithe/run/configurations.yaml 出现该配置、Run 窗口控制台输出 hello 并以“进程已结束,退出码 0。”结束、系统临时目录没有残留的 lithe-run-script-*;标题栏运行按钮再次运行同一配置。改为脚本文件(项目内的 .sh,带与不带 #! 首行各一次)、填脚本选项、工作目录和环境变量,确认解释器自动值随首行变化,保存后重开回显一致;取消勾选“存为项目文件”后配置移到 .lithe/run/local.yaml。新建可执行程序运行项目内程序与 PATH 上的程序;程序不存在、工作目录出项目或不存在时运行前提示原因。macOS/Linux 的类型列表没有 cmd;Windows 上分别运行 .ps1(默认带 -ExecutionPolicy Bypass,取消勾选后不带)、.cmd/.bat(含空格与引号参数)和 .exe。放一份旧版 .lithe/run/configurations.json,确认仍列出,编辑一次后改写为 YAML 并删除 JSON。让一个插件的 TOML 文件写坏,确认内置运行仍列出可运行,运行下拉出现“未读取 <文件名> 中的运行配置”,点击后在编辑器打开该文件。自动化覆盖:runconfig_process_test.go 的端到端测试用真实 Core 和系统 shell(Windows 为 cmd)新建、保存、运行(确认 Run 窗口打开并选中这次运行)并从标题栏再运行;runconfig_process_visual_test.go 生成 docs/assets/builtin-process-runs 的无头截图;单元测试覆盖 PATH 查找跳过相对目录、临时脚本只写在本次目录、工作目录不出项目、浏览路径转为项目相对、字段显示条件和保留未绘制字段的值;TestUnreadablePluginRunDocumentKeepsBuiltInRunsListed 覆盖写坏的插件文件不影响内置运行、下拉列出并打开该文件;buildprocess 测试覆盖批处理参数转义。", - "notes": "Issue #2100。只内置平台自带的脚本和二进制程序,Python、Node 等其他运行交给插件注入。Windows 上未指定解释器的 Shell 脚本按 PATH 找 bash,可能找到 WSL 的 bash;cmd 参数转义不处理 %(cmd 会展开环境变量)。macOS 原生窗口验收、Windows 与 Linux 实机验证待做。" + "verification": "不装任何插件打开一个空文件夹:标题栏“编辑运行配置…”打开“运行/调试配置”对话框,空白页列出四类内置运行;点“+”新建 Shell 脚本,选“脚本文本”写 echo hello,勾选“存为项目文件”后点对话框的“运行”,确认 .lithe/run/configurations.yaml 出现该配置、Run 窗口控制台输出 hello 并以“进程已结束,退出码 0。”结束、系统临时目录没有残留的 lithe-run-script-*;标题栏运行按钮再次运行同一配置。改为脚本文件(项目内的 .sh,带与不带 #! 首行各一次)、填脚本选项、工作目录和环境变量,确认解释器自动值随首行变化,保存后重开回显一致;取消勾选“存为项目文件”后配置移到 .lithe/run/local.yaml。新建可执行程序运行项目内程序与 PATH 上的程序;程序不存在、工作目录出项目或不存在时运行前提示原因。在对话框里连续新建两条配置后点“应用”,确认两条一起保存、对话框不关;选中一条点“−”再点“取消”,确认没有删除,点“确定”后才删除;复制一条配置,确认副本名为“<原名>(副本)”且字段一致。macOS/Linux 上新建批处理:类型旁标“仅 Windows”,可编辑保存,编辑器顶部有原因,对话框“运行”和标题栏运行按钮置灰,下拉里该行带警告图标并注明“仅 Windows”,按标题栏运行只提示原因;Windows 上分别运行 .ps1(默认带 -ExecutionPolicy Bypass,取消勾选后不带)、.cmd/.bat(含空格与引号参数)和 .exe。放一份旧版 .lithe/run/configurations.json,确认仍列出,编辑一次后改写为 YAML 并删除 JSON。让一个插件的 TOML 文件写坏,确认内置运行仍列出可运行,运行下拉出现“未读取 <文件名> 中的运行配置”,点击后在编辑器打开该文件。自动化覆盖:runconfig_process_test.go 的端到端测试用真实 Core 和系统 shell(Windows 为 cmd)新建、保存、运行(确认 Run 窗口打开并选中这次运行)并从标题栏再运行;runconfig_dialog_test.go 覆盖对话框的应用、取消、删除、复制、分组折叠,以及批处理在非 Windows 上能编辑保存、不能运行;runconfig_process_visual_test.go 生成 docs/assets/builtin-process-runs 的无头截图;单元测试覆盖 PATH 查找跳过相对目录、临时脚本只写在本次目录、工作目录不出项目、浏览路径转为项目相对、字段显示条件和保留未绘制字段的值;TestUnreadablePluginRunDocumentKeepsBuiltInRunsListed 覆盖写坏的插件文件不影响内置运行、下拉列出并打开该文件;buildprocess 测试覆盖批处理参数转义。", + "notes": "Issue #2100。只内置平台自带的脚本和二进制程序,Python、Node 等其他运行交给插件注入。Windows 上未指定解释器的 Shell 脚本按 PATH 找 bash,可能找到 WSL 的 bash;cmd 参数转义不处理 %(cmd 会展开环境变量);Core 拆分脚本选项、程序参数和解释器选项时把反斜杠当转义符(只在单引号内按原样保留),Windows 路径要用单引号括起来或把 \\ 写成 \\\\。对话框在应用窗口内以模态层显示,暂不支持 IDEA 的文件夹分组和拖动排序。macOS 原生窗口验收、Windows 与 Linux 实机验证待做。" } diff --git a/shared/platform-feature-matrix/features/run-before-launch-steps.json b/shared/platform-feature-matrix/features/run-before-launch-steps.json index 6cdc58ab80..b4af761d1d 100644 --- a/shared/platform-feature-matrix/features/run-before-launch-steps.json +++ b/shared/platform-feature-matrix/features/run-before-launch-steps.json @@ -4,8 +4,8 @@ "group": "运行配置", "capability": "像 IntelliJ IDEA 的 Before launch: Run Another Configuration 一样,运行配置可以列出启动前步骤:每一步是一个内置进程运行(Shell、PowerShell、批处理、可执行程序),按顺序在同一个 Run 控制台里运行,全部以退出码 0 结束后才启动配置;某一步失败时报出步骤名和退出码并不启动配置,停止配置会停止正在运行的步骤。项目文件(.lithe/run/configurations.yaml)列出的步骤第一次运行前要确认,确认结果按步骤列表与命令的指纹记在应用自己的存储里", "owner": "Run", - "notes": "Viva 共享实现。步骤只能引用内置进程运行,嵌套步骤先展开、最多 32 步,引用不存在、不可用、成环的配置时由 Core 拒绝。内置运行编辑器和构建提供者运行编辑器都有步骤列表,可添加、上移、下移、移除。调试(Debug)同样先运行步骤。插件可注入的 runOptions 扩展点不在本项范围。", - "verification": "在项目里创建两个 Shell 运行 A、B,并让应用运行配置的启动前步骤依次为 A、B;运行应用配置,确认弹出确认框列出 A、B,点“运行步骤”后控制台依次出现 A、B 的输出和应用输出;再次运行不再询问。把 B 改成以 3 退出,确认控制台写出“启动前步骤 B 以退出码 3 结束”,应用未启动。把 A 改成长时间运行,运行中点停止,确认 A 被结束、应用未启动。自动化:runconfig_before_launch_test.go 的 TestBeforeLaunchStepsRunInOrderAfterTheProjectListIsAllowed、TestFailingBeforeLaunchStepStopsTheStart、TestStoppingDuringABeforeLaunchStepEndsIt、TestRunConfigFormKeepsTheStepList。", + "notes": "Viva 共享实现。步骤只能引用内置进程运行,嵌套步骤先展开、最多 32 步,引用不存在、不可用、成环的配置时由 Core 拒绝。“运行/调试配置”窗口里的内置运行编辑器和构建提供者运行编辑器都有步骤列表,可添加、上移、下移、移除;本平台不能运行的配置不作为步骤候选。调试(Debug)同样先运行步骤。插件可注入的 runOptions 扩展点不在本项范围。", + "verification": "在项目里创建两个 Shell 运行 A、B,并让应用运行配置的启动前步骤依次为 A、B;运行应用配置,确认弹出确认框列出 A、B,点“运行步骤”后控制台依次出现 A、B 的输出和应用输出;再次运行不再询问。把 B 改成以 3 退出,确认控制台写出“启动前步骤 B 以退出码 3 结束”,应用未启动。把 A 改成长时间运行,运行中点停止,确认 A 被结束、应用未启动。自动化:runconfig_before_launch_test.go 的 TestBeforeLaunchStepsRunInOrderAfterTheProjectListIsAllowed、TestFailingBeforeLaunchStepStopsTheStart、TestStoppingDuringABeforeLaunchStepEndsIt、TestRunConfigFormKeepsTheStepList、TestRunConfigDialogSavesAnAddedStep。", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending",