feat(windows): add selected-text polish workflow - #851
Conversation
PR Reviewer Guide 🔍(Review updated until commit a27023c)Here are some key observations to aid the review process:
|
274a73f to
e53af2e
Compare
|
Persistent review updated to latest commit e53af2e |
|
不是,哥们,你改啥了?新增 2000 行,减 300 行。 |
我看这个不错啊,选区润色非常好的功能。你不要,我要了这个功能。 |
|
这个PR由我接手 |
PR Open-Less#851 新增的 coordinator/selection_polish 模块无条件编译,但 selection 模块在 mobile 走 mobile_stubs/selection.rs stub,缺少 SelectionInsertionTarget 等桌面 API,导致 CI 的 Android cargo check 失败(E0432/E0425)。 选区润色是桌面(Windows-first)工作流,mobile 不注册全局热键、不做跨应用 替换。将相关代码统一加 #[cfg(not(mobile))] 门控: - coordinator.rs: selection_polish 模块、Inner 字段、热键绑定方法 - hotkey_loops.rs: 选区润色热键 supervisor/bridge 函数与事件分支 - mobile_stubs/hotkey.rs: 移除桌面专属事件变体 - commands: set_selection_polish_hotkey 与 SettingsWriter 实现 本地验证:cargo check (Windows) 与 cargo check --target aarch64-linux-android 均通过。
e53af2e to
30ff274
Compare
|
Persistent review updated to latest commit 30ff274 |
按 review 反馈清理 PR diff 噪音,不改变任何行为: - .gitignore: 移除作者本机诊断产物(/.codegraph/、/artifacts/、/baseline-*.log、 /cargo-*.log、/docs/notes/、+/),恢复 beta 原样 - package.json / scripts/tauri-dev-visible.mjs: 移除开发验收专用 npm script 与脚本 - 恢复被重排的既有代码格式(import 分组、match arm、函数签名、空行、 测试断言排版、serde 属性、mod 声明顺序等),仅保留功能改动 本地验证:cargo check (Windows) 与 --target aarch64-linux-android 通过, cargo test --lib 885 passed(1 个环境相关的符号链接权限测试除外)。
|
Persistent review updated to latest commit 3008b70 |
- types.rs: selection_polish_hotkey 注释从「默认右 Control」改为实际默认 Right Alt(与 default_selection_polish_hotkey 及前端保持一致) - coordinator.rs: inject_hotkey_click_for_dev 修正 beta 遗留的多余缩进
|
Persistent review updated to latest commit 695b30e |
macOS/Linux 尚未实现等效的前台窗口/焦点控件校验,无法保证云端等待 期间结果不会落到用户切换后的应用或控件上。此前非 Windows 分支的 selection_insertion_target_is_captured 直接返回 true,用户一旦在 macOS 手动启用该功能,会执行无校验替换,与「安全替换」的承诺相悖。 - selection.rs: 非 Windows 一律返回 false,阻止选区文本发给 provider - SelectionPolishSection: 设置入口仅 Windows 显示(macOS/Linux 隐藏)
is_non_asr_selection_prompt / is_asr_style_prompt / is_generic_selection_prompt 是为从未合入 beta 的中间构建写的字符串匹配恢复逻辑('short-lived pre-separation build'),属于 YAGNI 违反且匹配脆弱。删除恢复逻辑与 三个 helper,保留 v1 风格包 selection_prompt 为空的默认值填充; 对应测试同步为 migration_fills_empty_selection_prompts_with_style_defaults。
|
Persistent review updated to latest commit e30afaf |
新增 settings.selectionPolish / style.pack.selection* / capsule.selectionPolish / selectionPolishPreview 四组 key,覆盖 en/ja/ko/zh-CN/zh-TW。SelectionPolishSection、 SelectionPolishPreview、Capsule 提示、Style 工作流切换等 UI 文案全部改用 t(), 消除新组件与项目其余部分的 i18n 混用。风格包模板默认值(数据)保留中文。
PR 原改动把内置包的编辑按钮从禁用改为可编辑(行为变更未在描述中声明)。 按接手 review 意见恢复 beta 原样:内置包仅可查看/重置,不进入编辑器。
审查发现的收尾问题(子代理复核): - 内联编辑器提示改用已存在的 selectionPromptHint / dictationPromptHint - 编辑器头部改用独立 dictationPromptEditorDesc / selectionPromptEditorDesc (保留「当前编辑…输入对象是…」原意,避免与内联提示同屏重复) - 风格卡片「当前」徽章改用 style.pack.current - ja: selectionPromptHint 语感修正(ASRは通らず → ASRは経由せず)
|
Persistent review updated to latest commit b0f5635 |
|
Persistent review updated to latest commit a27023c |
Resolve conflicts with latest beta: - credentials.rs: keep PR's async spawn_blocking refactor, fold in beta's LLM_TEMPERATURE_ACCOUNT branch and new Volcengine auth-mode accounts - CodingAgentSection.tsx: keep PR's OpenCode model discovery UI, port to beta's SelectLite component - SelectionPolishSection.tsx: drop undefined ShortcutRecorder props (alignRecordButton/modifierPresets) from #851 so frontend tsc passes
User description
Summary
OpenLess voice input is very convenient, but speaking is not always practical in meetings, shared offices, or public places.
This PR adds a Windows-first selected-text polish workflow:
The goal is to provide a small, practical keyboard-based complement to voice input, not a new chat workflow.
What changed
Added a global shortcut and settings section for selected-text polish.
Right Ctrl.Right Alt.Added a safe selected-text workflow.
Added separate prompts for the two workflows.
Added shortcut conflict checks and lightweight capsule feedback.
Platform scope
This feature was developed and tested on Windows through real desktop use.
OpenLess itself remains cross-platform, but this selected-text workflow currently relies on Windows-specific desktop integration for global shortcuts, foreground-window checks, and safe cross-application replacement. macOS and Linux support has not yet been implemented or validated.
Privacy and configuration
Validation
npm test— passed (23 frontend checks)cargo test --manifest-path src-tauri/Cargo.toml --lib— passed (788 tests)Disclosure
This contribution was implemented and tested with assistance from an AI coding agent. The contributor reviewed the design, performed real-use testing, and is responsible for the final submission.
Note
A full Windows NSIS installer smoke test should still be completed through the project's existing IME packaging workflow before a release build is published.
PR Type
Enhancement, Bug fix
Description
Add Windows selected-text polish workflow with global shortcut.
Support direct replacement and editable preview modes.
Introduce selection-specific prompts and separate history source.
Gate to desktop and fix mobile compile.
Diagram Walkthrough
flowchart LR A["Select text in any app"] --> B["Global shortcut (Right Alt)"] B --> C["Capture selection and insertion target"] C --> D{"Output mode?"} D -- "DirectReplace" --> E["Validate target and selection"] D -- "PreviewConfirm" --> G["Show editable preview"] G --> H["User confirms"] H --> E E --> F["Insert polished text"] E --> I["Record history with source"]File Walkthrough
18 files
Implement selected-text polish workflow with safe insertionAdd selection polish types, prefs, and prompt dispatchCapture and validate Windows insertion target safelyAdd selection polish capsule feedback with epoch guardingAdd selection polish shortcut event and monitor supportWire selection polish hotkey supervisor and bridgeAdd selection polish hotkey command with collision checksExpose selection polish workflow as Tauri commandAdd preview confirmation and cancel commandsIntegrate selection polish coordinator state and listenersRegister selection polish preview window and IPC handlersPersist and migrate selection prompt in style packsTag dictation history with voice sourceRefresh selection polish hotkey on settings saveHarden prompt against question-like source textBuild editable preview window for polished textAdd settings UI for selection polish optionsAdd IPC helpers for preview confirmation flow1 files
Remove desktop-only event from mobile stub1 files
Test selection prompt migration and sync24 files