Skip to content

[Bug] Windows 下每次启动 ZCode 都会清空系统全局"最近打开的文件"(app.clearRecentDocuments 波及整个 Recent 列表) #858

Open

Description

@zhoushimiaov

问题描述

每次启动 ZCode 桌面端(冷启动或退出后重新打开),Windows 的系统级"最近打开的文件"会被整批清空:

  • %APPDATA%\Microsoft\Windows\Recent\*.lnk 全部被删除
  • 注册表 HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs 及其子键被清除

表现为:文件资源管理器主页的"最近"、开始菜单的最近文件列表每次都被清零。用户会误以为是"重启导致记录丢失",实际触发时机是 ZCode 启动——这些记录可以安然活过系统重启,死在打开 ZCode 的 3 秒后。

复现步骤

  1. 在资源管理器中正常打开几个文件,确认 %APPDATA%\Microsoft\Windows\Recent\ 里有多条 .lnk 记录
  2. 完全退出 ZCode,重新启动 ZCode
  3. Recent 目录被清空、RecentDocs 注册表键被清除

证据(Windows 对象访问审计:SACL + 事件 4659/4663)

  • ZCode.exe 启动 3 秒后,以 DELETE 权限(AccessMask 0x10000)批量删除 Recent 目录下全部 .lnk(Event 4659 ×17,ProcessId 对应 ZCode.exe,其进程启动时间与用户点击启动的时刻一致)

  • 同一秒内对 Explorer\RecentDocs 键的 Delete 访问(Event 4663)

  • app.asar 主进程包中的唯一调用点:

    (process.platform==="darwin"||process.platform==="win32") && Z.clearRecentDocuments()
  • Electron 的 app.clearRecentDocuments() 在 Windows 上清空的是系统全局 Recent 列表(底层为 SHAddToRecentDocs 的清空语义),并不只是应用自身的最近文档列表。

影响

  • 用户系统级最近文件记录丢失(包括与 ZCode 无关、由其它程序打开的文件),每次启动必触发
  • 无设置项可关闭(主进程无条件调用)

修复建议

  • 去掉 win32 分支,仅 macOS 保留(darwin 下该调用只影响 Dock 最近文档,语义正确)
  • 或改用只管理应用自身跳转列表的 API(app.setUserTasks / app.setJumpList),不要触碰系统 Recent

环境

  • ZCode 3.14.3.7762(Windows x64)
  • Windows 11 Pro 26200

Activity

  1. github-actions commented on Sep 28, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
  2. zhoushimiaov commented on Sep 30, 2026

    @zhoushimiaov
    Author

    Update / 补充验证:用 Windows 对象访问审计(SACL + 事件 4659/4663)确认了清空动作的精确指纹——ZCode.exe 启动后约 3 秒以 DELETE 权限批量删除 %APPDATA%\Microsoft\Windows\Recent\*.lnk(单次 17~29 个),同一秒清除注册表 HKCU\...\Explorer\RecentDocs。三次独立捕获(进程 PID + 进程启动时间完全吻合)。

    本地临时方案已验证可行:对 app.asar 做等长字节补丁,把该调用点的 process.platform==="win32" 改为恒假条件,补丁后应用启动不再清空系统 Recent。期待官方在 win32 分支上去掉这个调用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions