diff --git a/desktop/internal/workbench/filetree_openin_test.go b/desktop/internal/workbench/filetree_openin_test.go index 534b11c55e..7c18befd89 100644 --- a/desktop/internal/workbench/filetree_openin_test.go +++ b/desktop/internal/workbench/filetree_openin_test.go @@ -83,10 +83,13 @@ func TestProjectTreeOpenWithListsTheSystemsApplications(t *testing.T) { writeTreeFiles(t, root, "notes.txt") h := newHarness(t, &testKernel{Client: core.NewClient()}) h.openTree(t, root) + appsDir := filepath.Join(root, "Apps") + otherDir := filepath.Join(root, "Other") + otherViewer := filepath.Join(otherDir, "Viewer.app") stub := stubTreeApps(t, []fileapps.App{ - {ID: "/Apps/Editor.app", Name: "Editor.app", Default: true}, - {ID: "/Apps/Viewer.app", Name: "Viewer.app"}, - {ID: "/Other/Viewer.app", Name: "Viewer.app"}, + {ID: filepath.Join(appsDir, "Editor.app"), Name: "Editor.app", Default: true}, + {ID: filepath.Join(appsDir, "Viewer.app"), Name: "Viewer.app"}, + {ID: otherViewer, Name: "Viewer.app"}, }, nil) language := h.app.language() file := filepath.Join(root, "notes.txt") @@ -104,10 +107,10 @@ func TestProjectTreeOpenWithListsTheSystemsApplications(t *testing.T) { } } h.popupClick(h.shared("desktop.files.openWith")) - other := i18n.SharedFormat(language, "desktop.files.openWithAppPath", map[string]string{"name": "Viewer.app", "path": "/Other"}) + other := i18n.SharedFormat(language, "desktop.files.openWithAppPath", map[string]string{"name": "Viewer.app", "path": otherDir}) for _, item := range []string{ i18n.SharedFormat(language, "desktop.files.openWithDefault", map[string]string{"name": "Editor.app"}), - i18n.SharedFormat(language, "desktop.files.openWithAppPath", map[string]string{"name": "Viewer.app", "path": "/Apps"}), + i18n.SharedFormat(language, "desktop.files.openWithAppPath", map[string]string{"name": "Viewer.app", "path": appsDir}), other, h.shared("desktop.files.openWithOther"), } { @@ -127,7 +130,7 @@ func TestProjectTreeOpenWithListsTheSystemsApplications(t *testing.T) { if want := []string{file}; !slices.Equal(asked, want) { t.Fatalf("asked the system about %q, want %q once", asked, want) } - if want := []string{file + " with /Other/Viewer.app"}; !slices.Equal(opened, want) { + if want := []string{file + " with " + otherViewer}; !slices.Equal(opened, want) { t.Fatalf("opened %q, want %q", opened, want) } if h.app.notice != "" { diff --git a/desktop/internal/workbench/runconfig_shell_test.go b/desktop/internal/workbench/runconfig_shell_test.go index ee57a0326c..01dfe3e94f 100644 --- a/desktop/internal/workbench/runconfig_shell_test.go +++ b/desktop/internal/workbench/runconfig_shell_test.go @@ -1,6 +1,8 @@ package workbench import ( + "context" + "encoding/json" "os" "path/filepath" "slices" @@ -8,6 +10,7 @@ import ( "testing" "time" + "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" "github.com/1lck/Lithe-IDEA/desktop/internal/localshell" "github.com/1lck/Lithe-IDEA/desktop/internal/shellkind" @@ -76,10 +79,20 @@ func TestRunConfigShellChoicesListTheFamilyAndCustom(t *testing.T) { // the field again. func TestRunConfigInterpreterListsTheTerminalShells(t *testing.T) { h, p, root := emptyProcessRunHarness(t) - h.app.listShells = testTerminalShells + // Saving exercises Core's native path validation. Keep the WSL identifier and + // give the file-backed shell choices absolute paths on the test host. + shellDir := t.TempDir() + writeTreeFiles(t, shellDir, "bash") + shells := testTerminalShells() + for i, shell := range shells { + if !strings.HasPrefix(shell.Path, "wsl:") { + shells[i].Path = filepath.Join(shellDir, shell.Name) + } + } + h.app.listShells = func() []localshell.Choice { return slices.Clone(shells) } f := newRunConfigDraft(t, h, p, runProviderShell) fillScriptText(t, h, p, f, "Greet", "echo hi\n") - awaitStateWithin(t, h, 10*time.Second, "the terminal's shells", func() bool { return len(h.app.term.shells.list) == len(testTerminalShells()) }) + awaitStateWithin(t, h, 10*time.Second, "the terminal's shells", func() bool { return len(h.app.term.shells.list) == len(shells) }) h.settle() interpreter := f.texts["interpreter"] if interpreter == nil { @@ -100,19 +113,20 @@ func TestRunConfigInterpreterListsTheTerminalShells(t *testing.T) { choose := func(entry string) { t.Helper() h.click(center(h.hitLabeled(label))) - if h.hasPopupItem(shell("pwsh", "/usr/local/bin/pwsh")) || h.hasPopupItem(shell("fish", "/opt/homebrew/bin/fish")) { + if h.hasPopupItem(shell("pwsh", filepath.Join(shellDir, "pwsh"))) || h.hasPopupItem(shell("fish", filepath.Join(shellDir, "fish"))) { t.Fatal("the list offers a shell of another family") } h.click(center(h.popupHit(entry))) } - choose(shell("bash", "/bin/bash")) - if *interpreter != "/bin/bash" || h.hasPopupItem(custom) { + bashPath := filepath.Join(shellDir, "bash") + choose(shell("bash", bashPath)) + if *interpreter != bashPath || h.hasPopupItem(custom) { t.Fatalf("interpreter %q, custom field shown %v", *interpreter, h.hasPopupItem(custom)) } choose(i18n.Shared(language, "desktop.runConfig.interpreterCustom")) - if *interpreter != "/bin/bash" || !h.hasPopupItem(custom) { + if *interpreter != bashPath || !h.hasPopupItem(custom) { t.Fatalf("Custom…: interpreter %q, custom field shown %v", *interpreter, h.hasPopupItem(custom)) } h.typeInto(custom, func() { *interpreter = "" }, "tools/sh") @@ -120,17 +134,28 @@ func TestRunConfigInterpreterListsTheTerminalShells(t *testing.T) { t.Fatalf("typed interpreter %q, custom field shown %v", *interpreter, h.hasPopupItem(custom)) } - choose(shell("bash", "/bin/bash")) - if *interpreter != "/bin/bash" || h.hasPopupItem(custom) { + choose(shell("bash", bashPath)) + if *interpreter != bashPath || h.hasPopupItem(custom) { t.Fatalf("back to bash: interpreter %q, custom field shown %v", *interpreter, h.hasPopupItem(custom)) } applyDialog(t, h, p, runConfigDialogApply) - saved, err := os.ReadFile(filepath.Join(root, ".lithe", "run", "local.yaml")) - if err != nil || !strings.Contains(string(saved), "/bin/bash") { - t.Fatalf("local.yaml = %s, %v", saved, err) + if _, err := os.Stat(filepath.Join(root, ".lithe", "run", "local.yaml")); err != nil { + t.Fatalf("save local.yaml: %v, dialog failure %q, form failure %q, field errors %v", err, p.runConfigs.dialog.failure, f.failure, f.errors) + } + + id := p.runConfigs.dialog.selected + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + saved, err := h.app.kernel.RunEditorForm(ctx, core.RunEditorFormRequest{Root: root, Provider: runProviderShell, ConfigurationID: id}) + if err != nil { + t.Fatalf("load configuration %q: %v", id, err) + } + var savedInterpreter string + if err := json.Unmarshal(saved.Values["interpreter"], &savedInterpreter); err != nil || savedInterpreter != bashPath { + t.Fatalf("saved interpreter = %q, want %q: %v", savedInterpreter, bashPath, err) } - f = p.runConfigs.dialog.drafts[p.runConfigs.dialog.selected].form + f = p.runConfigs.dialog.drafts[id].form awaitStateWithin(t, h, 10*time.Second, "the saved configuration's form", func() bool { return f != nil && f.ready() }) interpreter = f.texts["interpreter"] choose(i18n.SharedFormat(language, "desktop.runConfig.automaticValue", map[string]string{"value": automaticInterpreter(t, f)})) diff --git a/shared/platform-feature-matrix/features/builtin-process-runs.json b/shared/platform-feature-matrix/features/builtin-process-runs.json index 0a8eb1d3db..7627200ac9 100644 --- a/shared/platform-feature-matrix/features/builtin-process-runs.json +++ b/shared/platform-feature-matrix/features/builtin-process-runs.json @@ -66,6 +66,6 @@ ] }, "owner": "Run", - "verification": "不装任何插件打开一个空文件夹:标题栏“编辑运行配置…”打开“运行/调试配置”对话框,空白页列出四类内置运行;点“+”新建 Shell 脚本,选“脚本文本”写 echo hello,勾选“存为项目文件”后点对话框的“运行”,确认 .lithe/run/configurations.yaml 出现该配置、Run 窗口控制台输出 hello 并以“进程已结束,退出码 0。”结束、系统临时目录没有残留的 lithe-run-script-*;标题栏运行按钮再次运行同一配置。改为脚本文件(项目内的 .sh,带与不带 #! 首行各一次)、填脚本选项、工作目录和环境变量,确认解释器自动值随首行变化,保存后重开回显一致;展开解释器路径下拉,确认列出终端新建菜单里的同类 shell,选中一个后保存写入其路径,选“自定义…”填 PATH 上的命令名或用浏览选文件后能运行,改回“自动”后字段清空;取消勾选“存为项目文件”后配置移到 .lithe/run/local.yaml。新建可执行程序运行项目内程序与 PATH 上的程序;程序不存在、工作目录出项目或不存在时运行前提示原因。在对话框里连续新建两条配置后点“应用”,确认两条一起保存、对话框不关;选中一条点“−”再点“取消”,确认没有删除,点“确定”后才删除;复制一条配置,确认副本名为“<原名>(副本)”且字段一致;有构建插件生成的运行时复制它,点“应用”后确认 .lithe/run/plugin/<插件>.local.toml 出现副本、原配置仍在。删掉全部配置后重开对话框,确认左右两侧的 IDEA 式空白页,点两个链接和按 ⌃N(Windows 为 Alt+Insert)都弹出类型菜单。选中配置按 ⌫(Windows 为 Delete)删除,“取消”后恢复。选中配置点“新建文件夹”,在右侧把它改名(空名、重名、含 Tab 时提示原因),“应用”后确认配置文件里写入 folder;把另一条配置拖进这个文件夹;选中文件夹点“−”解散。关掉“按字母顺序排序”后拖动调整顺序,“应用”后确认只有 .lithe/run/local.yaml 的 arrangement 变化、标题栏下拉顺序一致,重新打开排序后恢复按名称。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 覆盖对话框的应用、取消、删除(含 ⌫/Delete 键)、复制(含插件运行复制进 <插件>.local.toml)、文件夹新建/重命名/解散、手动顺序与排序开关、IDEA 式空白页与 ⌃N/Alt+Insert、分组折叠,以及批处理在非 Windows 上能编辑保存、不能运行;runconfig_shell_test.go 覆盖解释器下拉只列同类 shell、选中 shell、自定义输入、改回自动和保存;runconfig_process_visual_test.go 生成 docs/assets/builtin-process-runs 的无头截图;单元测试覆盖 PATH 查找跳过相对目录、临时脚本只写在本次目录、工作目录不出项目、浏览路径转为项目相对、字段显示条件和保留未绘制字段的值;TestUnreadablePluginRunDocumentKeepsBuiltInRunsListed 覆盖写坏的插件文件不影响内置运行、下拉列出并打开该文件;buildprocess 测试覆盖批处理参数转义。", + "verification": "不装任何插件打开一个空文件夹:标题栏“编辑运行配置…”打开“运行/调试配置”对话框,空白页列出四类内置运行;点“+”新建 Shell 脚本,选“脚本文本”写 echo hello,勾选“存为项目文件”后点对话框的“运行”,确认 .lithe/run/configurations.yaml 出现该配置、Run 窗口控制台输出 hello 并以“进程已结束,退出码 0。”结束、系统临时目录没有残留的 lithe-run-script-*;标题栏运行按钮再次运行同一配置。改为脚本文件(项目内的 .sh,带与不带 #! 首行各一次)、填脚本选项、工作目录和环境变量,确认解释器自动值随首行变化,保存后重开回显一致;展开解释器路径下拉,确认列出终端新建菜单里的同类 shell,选中一个后保存写入其路径,选“自定义…”填 PATH 上的命令名或用浏览选文件后能运行,改回“自动”后字段清空;取消勾选“存为项目文件”后配置移到 .lithe/run/local.yaml。新建可执行程序运行项目内程序与 PATH 上的程序;程序不存在、工作目录出项目或不存在时运行前提示原因。在对话框里连续新建两条配置后点“应用”,确认两条一起保存、对话框不关;选中一条点“−”再点“取消”,确认没有删除,点“确定”后才删除;复制一条配置,确认副本名为“<原名>(副本)”且字段一致;有构建插件生成的运行时复制它,点“应用”后确认 .lithe/run/plugin/<插件>.local.toml 出现副本、原配置仍在。删掉全部配置后重开对话框,确认左右两侧的 IDEA 式空白页,点两个链接和按 ⌃N(Windows 为 Alt+Insert)都弹出类型菜单。选中配置按 ⌫(Windows 为 Delete)删除,“取消”后恢复。选中配置点“新建文件夹”,在右侧把它改名(空名、重名、含 Tab 时提示原因),“应用”后确认配置文件里写入 folder;把另一条配置拖进这个文件夹;选中文件夹点“−”解散。关掉“按字母顺序排序”后拖动调整顺序,“应用”后确认只有 .lithe/run/local.yaml 的 arrangement 变化、标题栏下拉顺序一致,重新打开排序后恢复按名称。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 覆盖对话框的应用、取消、删除(含 ⌫/Delete 键)、复制(含插件运行复制进 <插件>.local.toml)、文件夹新建/重命名/解散、手动顺序与排序开关、IDEA 式空白页与 ⌃N/Alt+Insert、分组折叠,以及批处理在非 Windows 上能编辑保存、不能运行;runconfig_shell_test.go 覆盖解释器下拉只列同类 shell、选中 shell、自定义输入、改回自动,并用本机绝对路径的文件替身验证保存后从磁盘读取的解释器路径;runconfig_process_visual_test.go 生成 docs/assets/builtin-process-runs 的无头截图;单元测试覆盖 PATH 查找跳过相对目录、临时脚本只写在本次目录、工作目录不出项目、浏览路径转为项目相对、字段显示条件和保留未绘制字段的值;TestUnreadablePluginRunDocumentKeepsBuiltInRunsListed 覆盖写坏的插件文件不影响内置运行、下拉列出并打开该文件;buildprocess 测试覆盖批处理参数转义。", "notes": "Issue #2100。只内置平台自带的脚本和二进制程序,Python、Node 等其他运行交给插件注入。Windows 上未指定解释器的 Shell 脚本按 PATH 找 bash,可能找到 WSL 的 bash,需要 Git Bash 时从解释器下拉选终端检测到的 Git Bash 或自定义完整路径;cmd 参数转义不处理 %(cmd 会展开环境变量);Core 拆分脚本选项、程序参数和解释器选项时把反斜杠当转义符(只在单引号内按原样保留),Windows 路径要用单引号括起来或把 \\ 写成 \\\\。对话框在应用窗口内以模态层显示。空文件夹只在对话框打开期间存在,不会保存(和 IDEA 一样,文件夹记在配置上)。配置树的行不显示悬停提示(Viva 的树行没有标识),不可运行的原因写在编辑器顶部和无障碍标签里。macOS 原生窗口验收、Windows 与 Linux 实机验证待做。" } diff --git a/shared/platform-feature-matrix/features/file-open-with.json b/shared/platform-feature-matrix/features/file-open-with.json index 268301a52b..fd2fa390cc 100644 --- a/shared/platform-feature-matrix/features/file-open-with.json +++ b/shared/platform-feature-matrix/features/file-open-with.json @@ -37,7 +37,7 @@ ] }, "owner": "Workspace", - "verification": "Viva(2026-11-18):项目树文件行右键“打开于 › 打开方式”,确认默认应用在最前并标“(默认)”,其后是系统列出的其他应用,同名应用后带所在文件夹,最后是“其他…”;选一个应用打开确切的磁盘文件,“其他…”弹出应用选择器,取消不打开;应用不再能打开该类文件或启动失败时显示错误;查询期间显示“正在查找应用…”;只把鼠标停在“打开于”和“打开方式”上展开(不点击)时,也要列出应用,不能一直停在“正在查找应用…”;文件夹和项目根行没有“打开方式”。分别对 DOCX、图片、Markdown、无扩展名文件检查,中英文、深浅主题各一次。macOS 用 LaunchServices(NSWorkspace URLsForApplicationsToOpenURL)列出应用,与 Finder 的“打开方式”对照;Windows 用 SHAssocEnumHandlers 推荐列表并经 IAssocHandler::Invoke 打开,与资源管理器的“打开方式”对照,“其他…”在 Windows 仍是选择 exe。自动化:fileapps 包测试查询本机真实数据库并记录列表;workbench 的 TestProjectTreeOpen* 用替换的应用列表覆盖菜单结构、选择、失败提示和文件夹行,TestProjectTreeOpenWithListsTheApplicationsWhenOpenedByHover 覆盖鼠标停留展开子菜单时也会查询(2026-11-18 修复:查询曾经由 ui.C.After 推迟,悬停展开的那一帧会丢掉它);Windows 的默认项排序由 TestMarkDefaultMovesTheDefaultFirstAndKeepsTheShellsOrder 覆盖;截图见 docs/assets/project-tree-open-in。原生窗口和 Windows 实机验收未做,两端保持 pending。 以下为旧 Swift 客户端记录:2026-11-03 本机 Swift 6.3.3/macOS 26.5 SDK 定向七项测试通过:六项 ExternalFileApplicationsTests 及菜单源码边界覆盖;共 1.023 秒,新增真实菜单关闭和会话标识回归分别为 0.090/0.001 秒,HTML/JUnit 已生成。独立工作树首次构建达到 15 分钟上限;随后临时只编译两个相关测试源并移除无关测试 target,Package.swift 已恢复。补齐菜单测试对最新 preview 日志配置参数的调用适配;完整菜单套件其余用例未执行。完整产品仍需对本地 DOCX、图片、未知扩展名右键,检查原生子菜单中应用、图标、默认项置顶与分隔线,中英文及深浅主题随系统显示;选择应用打开确切磁盘文件,其他…选择/取消正确,缺失文件或应用显示错误;App Store 仅按扩展名搜索;打开应用选择面板后切换项目或关闭窗口不得启动旧请求;SSH 项目无该入口。确认原有打开、复制/粘贴、Agent 子菜单与 Git 动作保留。完成产品运行验收前保持 pending;Windows 需要独立实现。 PR #1674 审查修复补充:系统菜单由共享 presenter 持有并响应 dismiss/替换,嵌套跟踪结束不能清理新会话;Agent 同名会话保留可见 ID(14.4+ 原生副标题,旧系统本地化标题格式)。ExternalFileApplicationsTests 增加真实菜单跟踪的一次性关闭回归和会话标识显示检查。", + "verification": "Viva(2026-11-18):项目树文件行右键“打开于 › 打开方式”,确认默认应用在最前并标“(默认)”,其后是系统列出的其他应用,同名应用后带所在文件夹,最后是“其他…”;选一个应用打开确切的磁盘文件,“其他…”弹出应用选择器,取消不打开;应用不再能打开该类文件或启动失败时显示错误;查询期间显示“正在查找应用…”;只把鼠标停在“打开于”和“打开方式”上展开(不点击)时,也要列出应用,不能一直停在“正在查找应用…”;文件夹和项目根行没有“打开方式”。分别对 DOCX、图片、Markdown、无扩展名文件检查,中英文、深浅主题各一次。macOS 用 LaunchServices(NSWorkspace URLsForApplicationsToOpenURL)列出应用,与 Finder 的“打开方式”对照;Windows 用 SHAssocEnumHandlers 推荐列表并经 IAssocHandler::Invoke 打开,与资源管理器的“打开方式”对照,“其他…”在 Windows 仍是选择 exe。自动化:fileapps 包测试查询本机真实数据库并记录列表;workbench 的 TestProjectTreeOpen* 用替换的应用列表覆盖菜单结构、选择、失败提示和文件夹行,TestProjectTreeOpenWithListsTheSystemsApplications 用测试平台的绝对路径验证同名应用显示父目录并传回对应应用,TestProjectTreeOpenWithListsTheApplicationsWhenOpenedByHover 覆盖鼠标停留展开子菜单时也会查询(2026-11-18 修复:查询曾经由 ui.C.After 推迟,悬停展开的那一帧会丢掉它);Windows 的默认项排序由 TestMarkDefaultMovesTheDefaultFirstAndKeepsTheShellsOrder 覆盖;截图见 docs/assets/project-tree-open-in。原生窗口和 Windows 实机验收未做,两端保持 pending。 以下为旧 Swift 客户端记录:2026-11-03 本机 Swift 6.3.3/macOS 26.5 SDK 定向七项测试通过:六项 ExternalFileApplicationsTests 及菜单源码边界覆盖;共 1.023 秒,新增真实菜单关闭和会话标识回归分别为 0.090/0.001 秒,HTML/JUnit 已生成。独立工作树首次构建达到 15 分钟上限;随后临时只编译两个相关测试源并移除无关测试 target,Package.swift 已恢复。补齐菜单测试对最新 preview 日志配置参数的调用适配;完整菜单套件其余用例未执行。完整产品仍需对本地 DOCX、图片、未知扩展名右键,检查原生子菜单中应用、图标、默认项置顶与分隔线,中英文及深浅主题随系统显示;选择应用打开确切磁盘文件,其他…选择/取消正确,缺失文件或应用显示错误;App Store 仅按扩展名搜索;打开应用选择面板后切换项目或关闭窗口不得启动旧请求;SSH 项目无该入口。确认原有打开、复制/粘贴、Agent 子菜单与 Git 动作保留。完成产品运行验收前保持 pending;Windows 需要独立实现。 PR #1674 审查修复补充:系统菜单由共享 presenter 持有并响应 dismiss/替换,嵌套跟踪结束不能清理新会话;Agent 同名会话保留可见 ID(14.4+ 原生副标题,旧系统本地化标题格式)。ExternalFileApplicationsTests 增加真实菜单跟踪的一次性关闭回归和会话标识显示检查。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": {