Skip to content

[linux] Linux 平台契约缺口:UI 错配 / 选区永远 None / 仍用 rdev / 剪贴板延迟未升 #165

@appergb

Description

@appergb

现象

Linux 平台对外仍是一等公民(CI 出 deb/rpm/AppImage、Sparkle updater 走 linux-x86_64),但实际代码里多个 Linux 路径是占位 / 漂移到 Windows 分支:

  1. UI 走 Windows 分支detectOS() 只识别 mac/win,Linux 用户看到 Windows 自绘标题栏 + Windows hotkey preset 列表(Ctrl+Shift+;),但后端按 Linux 解析 modifier(cmd → SUPER)
  2. 划词追问选区永远 Noneselection.rs:79 Linux 直接 `return None`,但 SelectionAsk 设置页仍展示 hotkey 配置入口
  3. 主听写仍用 rdev:CLAUDE.md 明确 rdev 在 macOS 不可靠,项目记忆里 Wayland 下也有问题,但 Linux 仍 `hotkey.rs:653` 走 rdev
  4. Linux 剪贴板恢复延迟未升:Win 已升 750ms 修终端慢粘贴(fix(windows): 延后剪贴板恢复并补齐插入回归覆盖 #160),Linux 仍 150ms(gnome-terminal / wezterm 等同类问题)

复现

  1. UI 错配:在 Linux 跑 OpenLess → 看到 Windows 自绘标题栏(不该)
  2. 选区:选段文字 → 按 Cmd+Shift+; → Option 录音 → 提问 → LLM 收到的"选区"段是空
  3. rdev:在 Wayland session 里 OpenLess hotkey 完全不响应(rdev 在 Wayland 下没 input event)
  4. 剪贴板:在 Linux 终端听写,文本可能"被旧剪贴板覆盖"现象(同 [windows][insertion] 终端旧剪贴板粘贴风险已收敛,当前整链路回归稳定 #159 Win 那条)

根因

子问题 文件:行 解释
UI 错配 src/components/WindowChrome.tsx:19 detectOS() 仅 `navigator.userAgent.includes('Mac')` 二叉,Linux 落到 `'win'` 分支;连带 `App.tsx:37,59,98` + `SelectionAsk.tsx:43` 全部错配
QA 选区 selection.rs:79 `#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))] log::info!("platform unsupported, returning None");`
Linux hotkey hotkey.rs:653 `#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]` 仍 import rdev
Linux 剪贴板 delay insertion.rs:21 `#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))] const CLIPBOARD_RESTORE_DELAY: Duration = Duration::from_millis(150);`

影响

  • 平台:Linux 用户全部
  • 使用程度:划词追问在 Linux 完全不可用(选区永远空);主听写在 Wayland 下不工作;UI 错配体感不专业
  • CI / 分发:Linux 包仍在产出(deb/rpm/AppImage),但跑起来体验欠佳

建议 fix(拆分子任务)

可以拆三个子 PR 分别推进:

PR-A: UI / detectOS Linux 分支

  • `detectOS()` 加 `'linux'` 返回值
  • `App.tsx` 启动 gate 给 Linux 单独路径(无 hotkey-status 轮询,参考 macOS 走 a11y/mic 轻量检查或直接 ready)
  • `SelectionAsk.tsx` 加 `QA_HOTKEY_PRESETS_LINUX`(Super+Shift+; 系列,跟 GNOME / KDE 默认快捷键不撞)
  • `WindowChrome.tsx` Linux 不渲染 Windows 自绘 titlebar,走系统 chrome

PR-B: Linux 划词追问选区捕获 + hotkey

  • `selection.rs` 加 X11 / Wayland 选区抓取:xdotool / wl-clipboard 调用 / X11 `PRIMARY` selection / atspi for AX
  • `hotkey.rs` Linux 替换 rdev(用 X11 `XGrabKey` 或 Wayland `org.gnome.Shell.Extension` / `org.freedesktop.portal.GlobalShortcuts`)
  • 短期降级:UI 上明确"Linux 暂不支持划词追问",把 SelectionAsk 入口隐藏

PR-C: Linux 剪贴板延迟跟 Win 对齐

短期最快:先做 PR-A(前端纯改 UI),让 Linux 用户至少看到正确分支。Linux 后端补齐留长 sprint。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: highHigh priority

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions