Skip to content

fix(windows): 补齐运行时反馈和平台化交互 - #23

Merged
appergb merged 4 commits into
Open-Less:mainfrom
Cooper-X-Oak:fix/windows-runtime-feedback
Apr 29, 2026
Merged

appergb merged 4 commits into
Open-Less:mainfrom
Cooper-X-Oak:fix/windows-runtime-feedback

Conversation

@Cooper-X-Oak

@Cooper-X-Oak Cooper-X-Oak commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

变更摘要

  • 增加全局快捷键安装状态查询 IPC,并在设置页展示监听安装中 / 已安装 / 失败状态。
  • Windows / 非 macOS 麦克风权限改为通过 cpal 探测真实输入设备可用性,系统设置按钮跳转到对应 Windows 设置页。
  • 将快捷键默认文案和选项按平台区分,Windows 使用右 Alt / Ctrl 系列文案,隐藏暂未支持的 macOS 快捷键。
  • 非 macOS 文本插入不再把 Ctrl+V 发送成功误报为已插入,而是显示已复制并提示用户 Ctrl+V。
  • 接入主界面和设置页的反馈、帮助、更新、全部记录等静态按钮。
  • 修正前端 repolish IPC 契约为 rawText/mode,匹配后端命令签名。

关联 Issue

Fixes #16
Fixes #17
Fixes #18
Fixes #19
Fixes #20
Fixes #21
Fixes #22

验证

备注

  • 原始仓库路径 openless -all 仍会触发已记录的 Windows GNU 空格路径问题,因此 Rust 门禁在 D:\Users\cooper\Practice-Project\202604\openless_all_app_copy 中执行。
  • 本 PR 不包含本地未跟踪的 .agents/、.codex/ 或 .github/workflows/ci.yml。

Summary by Sourcery

Improve Windows runtime behavior and platform-specific UX, including hotkey monitoring visibility, microphone permission detection, text insertion feedback, and entry points to help, feedback, and updates.

New Features:

  • Expose global hotkey installation status via IPC and display it in the settings UI.
  • Add Windows-specific handling for default hotkey labels and shortcut documentation, hiding unsupported macOS-only shortcuts.
  • Provide clickable links from the main UI and settings to documentation, feedback channels, and release notes.
  • Route overview page actions to open the full history view from recent records.

Bug Fixes:

  • Avoid reporting successful text insertion on non-macOS when only Ctrl+V was simulated, instead indicating copy-only behavior with appropriate prompts.
  • Align the repolish IPC contract to use rawText and mode to match the backend command signature.
  • Prevent misleading microphone permission status on Windows/Linux by probing actual input device availability via cpal.
  • Expose accurate insert status messaging in the capsule UI and history list, including OS-specific paste hints.

Enhancements:

  • Track and expose global hotkey listener lifecycle state in the backend and UI, including retry feedback and failure reasons on Windows.
  • Refine onboarding copy and behavior to distinguish between macOS accessibility permissions and Windows global hotkey setup.
  • Improve non-macOS global hotkey listener startup reporting by differentiating between immediate failures and successful listener activation.
  • Make keyboard shortcut hints in onboarding, overview, history, and shell footer dynamically reflect the current OS and default trigger key.

@sourcery-ai

sourcery-ai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implements Windows-focused runtime feedback and platform-specific behavior: adds a global hotkey installation status IPC and UI, differentiates hotkey labels/options per OS, improves microphone permission probing on non‑macOS, refines text insertion result reporting, wires up feedback/help/update/history entry points, and aligns the repolish IPC contract with the backend.

Sequence diagram for global hotkey installation status IPC flow

sequenceDiagram
    actor User
    participant SettingsPageTs as SettingsPage
    participant IpcTs as ipc_getHotkeyStatus
    participant Tauri as TauriRuntime
    participant CommandsRs as get_hotkey_status
    participant Coordinator as Coordinator

    User->>SettingsPageTs: Open Settings page
    activate SettingsPageTs
    SettingsPageTs->>IpcTs: getHotkeyStatus()
    activate IpcTs
    IpcTs->>Tauri: invoke get_hotkey_status
    activate Tauri
    Tauri->>CommandsRs: get_hotkey_status(coord)
    activate CommandsRs
    CommandsRs->>Coordinator: hotkey_status()
    activate Coordinator
    Coordinator-->>CommandsRs: HotkeyStatusRs
    deactivate Coordinator
    CommandsRs-->>Tauri: HotkeyStatusRs
    deactivate CommandsRs
    Tauri-->>IpcTs: HotkeyStatusRs (serialized)
    deactivate Tauri
    IpcTs-->>SettingsPageTs: Promise<HotkeyStatusTs>
    deactivate IpcTs
    SettingsPageTs->>SettingsPageTs: setHotkey(status)
    SettingsPageTs-->>User: Render HotkeyStatusPill
    deactivate SettingsPageTs
Loading

Sequence diagram for updated text insertion result and capsule feedback

sequenceDiagram
    actor User
    participant CapsuleTs as CapsuleComponent
    participant Backend as TauriBackend
    participant Inserter as TextInserter
    participant OS as OperatingSystem

    User->>CapsuleTs: Confirm insert
    activate CapsuleTs
    CapsuleTs->>Backend: end_session()
    activate Backend
    Backend->>Inserter: insert(text)
    activate Inserter
    Inserter->>Inserter: copy_to_clipboard(text)
    Inserter->>OS: simulate_paste()
    OS-->>Inserter: Result<(), String>
    alt simulate_paste error
        Inserter->>Inserter: log warn
        Inserter-->>Backend: InsertStatus::CopiedFallback
    else simulate_paste ok
        Inserter->>OS: insertion_success_status()
        OS-->>Inserter: InsertStatus (mac inserted, others copiedFallback)
        Inserter-->>Backend: InsertStatus
    end
    deactivate Inserter

    Backend->>Backend: map InsertStatus to done_message
    Backend-->>CapsuleTs: emit_capsule(state=Done, message, inserted_chars)
    deactivate Backend
    CapsuleTs->>CapsuleTs: render message or fallback
    CapsuleTs-->>User: Shows "已插入" or "已复制,请 Ctrl+V"
    deactivate CapsuleTs
Loading

Class diagram for updated hotkey status tracking across frontend and backend

classDiagram
    class HotkeyStatusRs {
      +HotkeyStatusState state
      +Option~String~ message
      +default() HotkeyStatusRs
    }

    class HotkeyStatusStateRs {
      <<enum>>
      +Starting
      +Installed
      +Failed
    }

    class Inner {
      +Mutex~Option~Arc~VolcengineStreamingASR~~~~ asr
      +Mutex~Option~Recorder~ recorder
      +Mutex~Option~HotkeyMonitor~ hotkey
      +Mutex~HotkeyStatusRs~ hotkey_status
    }

    class Coordinator {
      -Arc~Inner~ inner
      +new() Coordinator
      +hotkey_status() HotkeyStatusRs
      +start_dictation() Result
      +end_dictation() Result
    }

    class CommandsRs {
      +get_settings(coord CoordinatorState) UserPreferences
      +set_settings(coord CoordinatorState, prefs UserPreferences) Result
      +get_hotkey_status(coord CoordinatorState) HotkeyStatusRs
    }

    class HotkeyStatusTs {
      +HotkeyStatusStateTs state
      +string message
    }

    class HotkeyStatusStateTs {
      <<string-literal-union>>
      +'starting'
      +'installed'
      +'failed'
    }

    class IpcTs {
      +getHotkeyStatus() Promise~HotkeyStatusTs~
      +getSettings() Promise~UserPreferences~
      +setSettings(prefs UserPreferences) Promise~void~
      +repolish(rawText string, mode PolishMode) Promise~string~
      +openExternal(url string) Promise~void~
    }

    class SettingsPageTs {
      +RecordingSection()
      +PermissionsSection()
      +ShortcutsSection()
      +AboutSection()
    }

    class PermissionsSectionTs {
      -PermissionStatus accessibility
      -PermissionStatus microphone
      -HotkeyStatusTs hotkey
      +refresh()
      +render()
    }

    class HotkeyStatusPillTs {
      +status HotkeyStatusTs
      +render()
    }

    HotkeyStatusRs --> HotkeyStatusStateRs
    Inner o-- HotkeyStatusRs
    Coordinator *-- Inner
    Coordinator ..> HotkeyStatusRs : returns
    CommandsRs ..> Coordinator : uses
    CommandsRs ..> HotkeyStatusRs : returns

    HotkeyStatusTs --> HotkeyStatusStateTs
    IpcTs ..> HotkeyStatusTs : returns
    PermissionsSectionTs ..> IpcTs : calls getHotkeyStatus
    PermissionsSectionTs --> HotkeyStatusTs
    HotkeyStatusPillTs --> HotkeyStatusTs
    SettingsPageTs *-- PermissionsSectionTs
    SettingsPageTs ..> HotkeyStatusPillTs
Loading

File-Level Changes

Change Details Files
Add global hotkey installation status tracking, IPC, and settings UI display for Windows.
  • Introduce HotkeyStatus and HotkeyStatusState types with defaults on both Rust and TS sides.
  • Track hotkey installation lifecycle in Coordinator via a new hotkey_status field updated by the hotkey supervisor loop.
  • Expose a new get_hotkey_status Tauri command and IPC helper returning the current hotkey status.
  • Render a new PermissionsSection row showing hotkey status with a dedicated HotkeyStatusPill component in settings.
app/src-tauri/src/types.rs
app/src-tauri/src/coordinator.rs
app/src-tauri/src/commands.rs
app/src/lib/types.ts
app/src/lib/ipc.ts
app/src/pages/Settings.tsx
Improve non-macOS hotkey and insertion behavior and feedback, especially on Windows.
  • Differentiate macOS and Windows hotkey trigger options and user-facing shortcut labels across settings, overview, history, and floating shell.
  • Update rdev-based hotkey listener to report installation success or failure using a short readiness window instead of always assuming success.
  • Change text insertion flow so non-macOS treats simulated paste success as a copied fallback rather than guaranteed insertion, and propagate user-facing completion messages via Capsule.
  • Adjust history list insertion status labels to show platform-appropriate paste shortcuts (Ctrl+V vs ⌘V).
app/src/pages/Settings.tsx
app/src/components/FloatingShell.tsx
app/src/pages/Overview.tsx
app/src/pages/History.tsx
app/src/components/Capsule.tsx
app/src-tauri/src/insertion.rs
app/src-tauri/src/hotkey.rs
Probe microphone availability more accurately on Windows/non-macOS using cpal and route users to OS settings.
  • Replace optimistic microphone Granted status on non-macOS with a cpal-based default input device/config probe.
  • Classify cpal errors into Granted, Denied, or NotDetermined to avoid falsely reporting permission granted when devices or access are missing.
  • Reuse the same probe for request_microphone on non-macOS to reflect real availability.
app/src-tauri/src/permissions.rs
Wire up feedback, documentation, update, and history navigation entry points in the UI, plus OS-specific onboarding copy.
  • Add openExternal helper to open URLs via Tauri shell or window.open in web builds.
  • Hook settings About section buttons and floating shell footer icons to GitHub releases, README, and Issues URLs.
  • Allow Overview’s "全部记录" CTA to open the History tab via a callback.
  • Adjust onboarding copy and behavior to treat accessibility as a "global hotkey" confirmation step on Windows and use OS-specific labels and hints.
app/src/lib/ipc.ts
app/src/pages/Settings.tsx
app/src/components/FloatingShell.tsx
app/src/pages/Overview.tsx
app/src/components/Onboarding.tsx
Align front-end repolish IPC contract with backend signature.
  • Change repolish IPC wrapper to accept rawText and return the polished string instead of taking a history id and returning a DictationSession.
  • Update TypeScript typings accordingly and keep a mock implementation consistent with the new signature.
app/src/lib/ipc.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#16 On Windows (non-macOS), do not unconditionally return PermissionStatus::Granted for microphone permission checks/requests. ✅
#16 Implement a real microphone availability/permission probe on Windows (e.g., via default input device / cpal) that distinguishes between granted, denied, notDetermined or similar error states. ✅
#16 Ensure the onboarding and settings UI reflect the true microphone availability state on Windows and prevent/guard recording with clear feedback when microphone/permissions/devices are unavailable. ✅
#17 On Windows, implement open_system_settings so that calling open_system_settings('microphone') (and other used panes) actually opens the appropriate Windows settings page instead of being a silent no-op. ✅
#17 Ensure that on Windows the permissions-related UI (especially for accessibility / global hotkey) does not misleadingly present an unimplemented permission flow, instead either mapping to a real equivalent or clearly indicating that no authorization is needed. ✅
#17 Make unsupported or failing permission panes stop returning a silent Ok(()), and instead have an observable result (opening a settings page, showing a prompt, or at least logging/surfacing errors) when the user clicks the permission button. ✅
#18 Ensure the non-macOS global hotkey listener does not optimistically report success before rdev::listen has actually started, and instead reports a detectable failure when listen startup fails. ✅
#18 When rdev::listen fails on non-macOS (Windows), trigger retries and maintain an internal hotkey status that reflects Starting/Installed/Failed. ✅
#18 Expose the global hotkey listener status to the UI (especially on Windows) so that the settings/onboarding surfaces show installed/failed/starting states and users see a clear indication when global hotkeys are not working instead of silent failure. ✅
#19 In the Windows settings page, ensure the recording hotkey options include rightAlt and use Windows-friendly labels (e.g., '右 Alt'), while keeping a Mac-specific list for macOS. ✅
#19 Platformize hotkey-related UI copy so that overview, floating shell, history empty states, and shortcut cheat sheets show Windows-style labels on Windows (e.g., '右 Alt', 'Ctrl', 'Ctrl+V') and retain macOS-style labels on macOS (e.g., '右 Option', '⌘', '⌘V'). ✅
#19 On a fresh profile on Windows, the default recording hotkey should be visible in the UI and participate correctly in the settings flow (select shows the default, and it can be saved/restored). ✅
#20 Change Windows (non-macOS) insertion logic so that a successful Ctrl+V key simulation is not reported as inserted, but instead treated as an unconfirmed state (e.g., copiedFallback) when real insertion cannot be verified. ✅
#20 Update UI/UX (capsule and history) to show the real insertion status on Windows, e.g. messages like “已复制,请 Ctrl+V” instead of always claiming text was inserted. ✅
#20 Add logging for Windows insertion failure scenarios, including at least the failure reason from the paste simulation. ✅
#21 Overview 页中“最近识别”卡片的“全部记录 →”按钮应能导航到历史记录页。 ✅
#21 主窗口底部栏(FloatingShell)中的“账户”“反馈”“帮助”“检查更新”等入口应接入真实动作(导航到设置或打开外部链接),避免点击无响应。 ✅
#21 设置页关于区(Settings.AboutSection)中的“检查更新”“文档”“反馈渠道”按钮应接入真实动作:打开更新页面、文档(或 README)以及 GitHub Issues。 ✅
#22 Clarify the repolish IPC contract to use either history id to rerun and update a session, or rawText to return only polished text, and implement this choice consistently in the backend. ✅
#22 Align the frontend repolish IPC wrapper’s parameters and return type with the Rust Tauri command signature. ✅
#22 If history-based rerun is not supported, ensure the API surface does not mislead callers (e.g., by removing or correcting any history-based repolish wrapper and type declarations) and avoid adding a history UI entry for rerun. ✅

Possibly linked issues

  • #N/A: PR按平台区分快捷键选项和文案,在Windows中使用rightAlt并更新各页面提示文本。
  • #unknown: PR修正rdev监听的乐观成功汇报,增加失败信号与重试,并通过HotkeyStatus将全局快捷键状态暴露到UI。
  • #[windows] 权限设置按钮不应静默空操作: PR 为 Windows 实现 open_system_settings 深链与麦克风检测,并调整前端权限与提示逻辑,完全覆盖问题需求。

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The non-macOS branch of open_system_settings in commands.rs always shells out via cmd /C start and uses Windows ms-settings: URIs, which will break on Linux; consider gating this logic behind #[cfg(target_os = "windows")] and providing a no-op or Linux-appropriate behavior for other platforms.
  • In several React components (History, Overview, FloatingShellBody) you call detectOS() or derive the hotkey label multiple times inside render logic; it would be cleaner and slightly more efficient to compute os/hotkeyLabel once per component and reuse those values (e.g., also reuse hotkeyLabel in the history insert-status text instead of calling detectOS() again).
  • The clickable “检查更新” button in FloatingShell is styled with cursor: 'default', which makes it appear non-interactive; consider switching to cursor: 'pointer' to match its actual behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The non-macOS branch of `open_system_settings` in `commands.rs` always shells out via `cmd /C start` and uses Windows `ms-settings:` URIs, which will break on Linux; consider gating this logic behind `#[cfg(target_os = "windows")]` and providing a no-op or Linux-appropriate behavior for other platforms.
- In several React components (`History`, `Overview`, `FloatingShellBody`) you call `detectOS()` or derive the hotkey label multiple times inside render logic; it would be cleaner and slightly more efficient to compute `os`/`hotkeyLabel` once per component and reuse those values (e.g., also reuse `hotkeyLabel` in the history insert-status text instead of calling `detectOS()` again).
- The clickable “检查更新” button in `FloatingShell` is styled with `cursor: 'default'`, which makes it appear non-interactive; consider switching to `cursor: 'pointer'` to match its actual behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Cooper-X-Oak

Copy link
Copy Markdown
Contributor Author

Windows 真机回归已跑完,结论:构建和基本启动通过,但这版还不建议合并,需要继续改两处。

通过项:

  • npm run build 通过。
  • cargo check --target x86_64-pc-windows-gnu 通过(无空格路径副本)。
  • npm run tauri build -- --target x86_64-pc-windows-gnu 通过,生成 OpenLess_1.1.3_x64_en-US.msi 和 OpenLess_1.1.3_x64-setup.exe。
  • release openless.exe 可在 Windows 真机启动,进程 Responding=True,主窗口标题 OpenLess。
  • 日志确认 [coord] hotkey listener installed (after 1 attempt(s))。
  • ms-settings:privacy-microphone 可打开 Windows Settings。

需要修改:

  1. [windows] 麦克风权限状态不应无条件显示已授权 #16 还没有真正解决。check_microphone() 只调用 default_input_config(),这只能证明默认输入设备存在和格式可查询,不能证明 Windows 隐私权限允许当前桌面应用捕获音频。这样仍可能让 onboarding / 设置页显示“已授权”,实际到 Recorder::start 才失败。建议至少做一次短生命周期 input stream build/start 探测,或接入 Windows Runtime/registry/privacy capability 状态,不要把 format query 的 Ok 映射成 Granted。

  2. [windows] 快捷键默认值和界面文案需要平台化 #19 的 Windows 文案没有收口。Settings 里仍有“需要授予辅助功能权限”“所有快捷键全局生效,需要在权限设置中开启辅助功能”“授权后通常需要完全退出 App 重启一次才生效”“辅助功能”权限行。Windows 上 accessibility 是 notApplicable,这些文案会继续误导用户,把 hotkey/runtime 问题当成 macOS 辅助功能授权问题。

GitHub 不允许我对自己发起的 PR 提交 request changes review,所以这里用 PR comment 记录审阅结论。建议处理完上述两点后再合并。

@Cooper-X-Oak

Copy link
Copy Markdown
Contributor Author

已根据上一轮 Windows review findings 追加修复,提交:9efc634 fix(windows): 收口权限探测和平台文案。

修复项:

复验:

  • npm run build
  • cargo check --target x86_64-pc-windows-gnu(无空格路径副本)
  • git diff --check

@Cooper-X-Oak

Copy link
Copy Markdown
Contributor Author

已更新 PR head,补齐 fork/dev 中已经验证过的 Windows 构建交付,并回填 CI。

新增提交:

  • 9dbd0de docs(windows): 补齐构建预检和GNU打包流程
  • 141303d ci(windows): 回填Tauri检查流程

本次更新包含:

  • scripts/windows-preflight.ps1:检查 Node/npm、Rust、MSVC link.exe、Windows SDK kernel32.lib、WebView2、GNU/MinGW 工具链。
  • scripts/windows-build-gnu.ps1:当 app 路径包含空格时自动镜像到 %TEMP%\openless-windows-gnu,再执行 GNU build,规避 MinGW/dlltool 空格路径问题。
  • openless -all/README.md:补齐 Windows MSVC/GNU 构建、产物路径、空格路径限制、运行时权限说明。
  • .github/workflows/ci.yml:Windows runner 上执行 Tauri app 的 npm build、PowerShell 脚本语法检查、MSVC preflight、Rust backend cargo check。

本地复验:

  • npm run build
  • windows-preflight.ps1 -Toolchain gnu
  • PowerShell PSParser 检查两个 Windows 脚本
  • windows-build-gnu.ps1 已在 fork/dev 上从含空格路径完整验证过 MSI/NSIS 构建

@Cooper-X-Oak

Copy link
Copy Markdown
Contributor Author

fork/dev CI 已回填并通过。

当前 #23 仍为 mergeable,且没有失败 check。

@appergb
appergb merged commit 017569f into Open-Less:main Apr 29, 2026
2 checks passed
@Cooper-X-Oak

Copy link
Copy Markdown
Contributor Author

继续同步 fork/dev Windows 回归能力到 #23:

当前无人值守环境缺少真实 ASR/LLM 凭据,且 rdev 全局热键不能稳定用 SendInput 合成触发,所以真实“语音转写 + 前台粘贴 fallback”仍需要配置真实凭据后用物理按键做人工验收。脚本已把这些步骤列为 manual checks。

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

Labels

None yet

Projects

None yet

2 participants