Repository navigation
fix(tree): 鼠标停留打开“打开于”时也查询应用,不再一直显示“正在查找应用…” - #2133
Merged
Merged
Conversation
项目树右键菜单里,把鼠标停在“打开于”上展开子菜单时,“打开方式”会一直停在 “正在查找应用…”。查询原来用 ui.C.After 推迟启动,而悬停展开的那一帧没有点击, Viva 会丢掉推迟的回调;这一帧之后菜单又被记为“已显示”,查询再也不会开始。 点击展开时回调会运行,所以原有的点击测试没有发现。 现在 askTreeApps 在声明子菜单的那一帧里直接调用 findTreeApps;后者只登记状态并在 后台查询,不阻塞绘制。新增回归测试用指针停留打开两级子菜单,修复前失败、修复后通过。 补充 bug-fix 笔记,并更正“打开方式”功能笔记里查询时机的描述。
xiaoyumuxi
marked this pull request as ready for review
November 18, 2026 04:26
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
项目树右键文件 → 把鼠标停在“打开于”上展开 → 移到“打开方式”,子菜单一直显示“正在查找应用…”,永远不列出系统应用(用户截图里的
.gitattributes就是这样)。点击“打开于”展开时则正常。鼠标停留展开是最常见的用法,所以用户看起来就是“一直卡着”。系统查询本身没有问题:LaunchServices 查询实测约 20 ms,进程采样也没有主线程卡死,日志里没有失败记录。问题在于查询从来没有开始。
改动 / Changes
desktop/internal/workbench/filetree_openin.go:askTreeApps在声明“打开于”子菜单的那一帧里直接调用findTreeApps,不再用c.After推迟;去掉不再需要的ui.C参数,调用处同步修改。findTreeApps只登记状态并用a.background在后台查询,不阻塞绘制(与debug_memory.go在绘制中发起后台读取的做法相同)。注释写明不能用ui.C.After的原因。desktop/internal/workbench/filetree_openin_test.go:新增测试辅助popupRest(把指针停在菜单项上超过子菜单展开延迟,不点击),以及回归测试TestProjectTreeOpenWithListsTheApplicationsWhenOpenedByHover:用指针停留打开两级子菜单,断言系统被询问一次,并列出“Editor.app(默认)”,不再显示“正在查找应用…”。.agents/notes/implemented/bug-fix/2026-11-18-open-with-lookup-on-hover.md:新增 bug-fix 笔记,记录ui.C.After在悬停展开的帧里会被丢弃,以及“打开即启动的后台工作不要交给c.After”的规则。.agents/notes/implemented/feature/2026-11-03-macos-open-with.md:更正查询时机。原文写“第一次展开‘打开方式’时开始、菜单关闭后丢弃结果”,与代码不符;现在写的是“打开于”一出现就查询(悬停或点击都算)、重新打开时先显示同一文件上一次的列表;验证一节补上悬停用例。shared/platform-feature-matrix/features/file-open-with.json:两个平台的证据加入 bug-fix 笔记;验证动作加入“只用鼠标停留展开也要列出应用”;自动化说明加入新回归测试。两端仍为pending。不在本 PR 范围内 / Out of scope
ui.Effect/keyedEffect重写“打开方式”的状态管理。它对同一个键只运行一次,而这里每次打开菜单都要重新查询,改写的范围比修复本身大。ui.C.After只在送达点击或指针事件的绘制后运行,这是 Viva 文档写明的约定(gfx.Canvas.AfterPaint),不是 Viva 的缺陷。类型专属:fix
复现与根因
askTreeApps在子菜单刚出现时调用c.After(func() { a.findTreeApps(file) })。Viva 的子菜单在指针停留 100 ms(submenuDelay)后,通过一次普通重绘展开,而gfx.Canvas.AfterPaint只在eventPass || hasPointer时登记回调,所以这一帧的回调被丢弃。帧结束时treeApps.endFrame已把子菜单记为“已显示”,之后的帧不再发起查询,于是“打开方式”一直等不到结果。点击展开时子菜单在事件处理阶段声明,回调能运行,所以原有的点击测试没有发现。检查项
desktop/internal/workbench/filetree_openin_test.go的TestProjectTreeOpenWithListsTheApplicationsWhenOpenedByHover,修复前输出filetree_openin_test.go:153: Open In opened by hover asked the system about [], want the file onceaskTreeApps只有openInMenu一处调用;treeApps状态只在filetree_openin.go和root.go的endPaint中使用c.After:都在Clicked()或选择变化分支里,只在送达点击的帧中执行,没有同类问题.agents/notes/implemented/bug-fix/记录:2026-11-18-open-with-lookup-on-hover.md范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/<id>.json:file-open-with的证据、验证动作已更新;两端没有运行原生验收,保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
TestProjectTreeOpen*(含新的悬停用例)在无头工作台里断言菜单项内容,见下方验证表docs/assets/project-tree-open-in/统一日志系统 / Structured logging
N/A:没有新增或改动日志事件;查询失败仍走原有的
project_tree_list_apps后台失败记录。界面文案 / i18n
node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
性能与内存 / Performance and memory
a.background的后台线程里执行,绘制中只登记状态设置 / Settings
N/A:没有修改设置。
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本、插件函数协议或宿主方法。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh(没有新增资源路径)无用代码与重构 / Dead code and refactoring
askTreeApps的ui.C参数已去掉refactor标签的 Issue:没有发现验证 / Verification
./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestProjectTreeOpen' -count=1(在desktop/下)asked the system about [], want the file once;其余 6 个通过-vTestProjectTreeOpen*全部通过./scripts/desktop/desktop-go.sh test ./... -count=1internal/localshell的TestClosingAnIntegratedShell*在全量并行时失败(关闭终端后子进程 5 秒内未退出),单独重跑./internal/localshell通过;该包不依赖 workbench,属于负载下的既有偶发失败./scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestProjectTree' -count=1./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh./scripts/agent-notes/verify-agent-notes.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/desktop/verify/verify-runtime-bundle-immutability.shgofmt -l(改动的两个 Go 文件)未能执行的检查和原因:
提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图