Skip to content

[windows] aerospace 工作区不合理跳转 #452

Closed

Description

@peguri26

现象

  • 触发条件: 使用aerospace,openless窗口与工作窗口不在一个workspace时
  • 当前现象: 按下转文字会导致界面跳回openless的workspace

影响

  • 使用体验割裂

建议接受标准

  • 当二者在不同工作区时,转文字不会导致工作区切换

TODO / 不确定项

No response

Activity

  1. added
    bug
    on May 15, 2026
  2. H-Chris233 commented on May 16, 2026

    @H-Chris233
    Collaborator

    我们已经收到你的反馈并会尽快跟进,感谢使用并反馈!

  3. self-assigned this
    on May 16, 2026
  4. appergb commented on May 17, 2026

    @appergb
    Collaborator

    @claude 在新版本中,请你审查以下两点:

    1. 这个问题是否已经修复。
    2. 如果已修复,请 @ 我,让我去关闭这个 issue。
  5. claude commented on May 17, 2026

    @claude

    Claude finished @appergb's task in 2m 35s —— View job


    审查结果

    • 读取仓库结构和 CLAUDE.md
    • 检查与窗口激活/焦点相关的代码
    • 查看 git 历史记录,寻找与此问题相关的修复
    • 报告调查结果

    调查结论

    此问题在当前代码库中已有针对性修复。

    根本原因

    原始问题在于:当按下转文字快捷键时,录音胶囊(capsule)窗口通过 window.show() 显示,这会触发 macOS 的窗口激活,导致 AeroSpace 将工作区切换回 OpenLess 所在的空间。

    已实现的修复

    在 coordinator.rs 中,代码引入了 CapsuleShowStrategy::NoActivate 策略,对 macOS 和 Windows 均作为主路径:

    coordinator.rs:82-91 — 平台策略判断:

    fn capsule_show_strategy_for_platform() -> CapsuleShowStrategy {
        #[cfg(any(target_os = "macos", target_os = "windows"))]
        { CapsuleShowStrategy::NoActivate }
        // ...
    }

    coordinator.rs:4105-4127 — macOS 路径使用 orderFrontRegardless 而非 show():

    // 不能调用 window.show()/set_focus()/NSApp.activate,
    // 否则 AeroSpace 会把 workspace 切回 OpenLess 主窗口所在空间。
    // orderFrontRegardless 只让胶囊可见,不成为 key window。
    let _: () = msg_send![ns_window, orderFrontRegardless];

    coordinator.rs:1976 — 听写流程中也明确注释说明不再调 show_main_window:

    // 听写路径不抢前台焦点:缺 mic 权限时直接请求系统授权,不再先 show_main_window。
    

    残余风险(极小概率)

    若 show_capsule_window_no_activate 失败(ns_window 指针为空),代码会降级到 window.show()(coordinator.rs:111),并打印警告日志。该路径理论上仍会触发工作区跳转,但属于极少见的降级情况,代码也有单次告警限制(CAPSULE_NO_ACTIVATE_FALLBACK_WARNED)。

    结论

    核心的 AeroSpace workspace 跳转问题已被修复,通过 orderFrontRegardless(macOS)/ SW_SHOWNOACTIVATE(Windows)显示胶囊窗口而不激活应用程序。

    @appergb 建议可以关闭此 issue,若有条件,可先让原始反馈用户 @littlepenguin66 在最新版本中验证一下。

  6. H-Chris233 commented on May 17, 2026

    @H-Chris233
    Collaborator

    我已尝试修复该问题,修复将在下一个版本生效,届时请继续跟进并提供相关信息,谢谢您对项目的支持!

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions