Skip to content

feat(windows): add selected-text polish workflow#851

Open
SeanZhang226 wants to merge 1 commit into
Open-Less:betafrom
SeanZhang226:feat/selection-polish-core
Open

feat(windows): add selected-text polish workflow#851
SeanZhang226 wants to merge 1 commit into
Open-Less:betafrom
SeanZhang226:feat/selection-polish-core

Conversation

@SeanZhang226

@SeanZhang226 SeanZhang226 commented Jul 21, 2026

Copy link
Copy Markdown

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:

  1. Select text in any application.
  2. Trigger OpenLess with a global shortcut.
  3. OpenLess sends the selected text to the configured LLM and applies the selected style.
  4. The result either replaces the original selection directly or opens in an editable preview before pasting.

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.

    • Dictation keeps the existing default: Right Ctrl.
    • Selected-text polish defaults to Right Alt.
    • Users can record and use any shortcut they prefer.
  • Added a safe selected-text workflow.

    • Captures selected text through the clipboard.
    • Verifies the original target before replacing text.
    • Supports direct replacement and editable preview modes.
    • Stores selected-text results in history separately from voice sessions.
  • Added separate prompts for the two workflows.

    • Dictation / ASR uses the existing style-pack prompt.
    • Selected written text uses a dedicated selection prompt.
    • Built-in Light, Structured, and Formal styles now have editable and restorable selection prompts.
  • 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

  • This change does not modify users' existing ASR or LLM provider settings, models, endpoints, or credentials.
  • No user configuration, history, style-pack data, or API keys are included in this PR.

Validation

  • npm test — passed (23 frontend checks)
  • cargo test --manifest-path src-tauri/Cargo.toml --lib — passed (788 tests)
  • Tested manually in real Windows desktop workflows.

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


Description

  • Add configurable global shortcut for selected-text polish (default RightAlt on Windows)

  • Implement safe clipboard-based capture and target verification before inserting

  • Introduce dedicated selection prompts per style pack, separate from ASR prompts

  • Support direct replacement and preview-confirm modes with history tracking


Diagram Walkthrough

flowchart LR
  User["User selects text and presses shortcut"] -- "HotkeyEvent" --> SelectionPolish["selection_polish module"]
  SelectionPolish -- "capture_selection_with_status" --> Selection["selection.rs: capture + target snapshot"]
  Selection -- "polish_text with selection prompt" --> LLM["LLM provider"]
  LLM -- "result" --> Insertion["Inserter (direct or preview)"]
  Insertion -- "capsule feedback" --> Capsule["capsule_focus.rs: epoch-guarded capsule"]
  Insertion -- "history entry" --> History["History with source=SelectionPolish"]
Loading

File Walkthrough

Relevant files
Enhancement
16 files
selection_polish.rs
New selection polish workflow module                                         
+556/-0 
types.rs
Add HistorySource, SelectionPolishOutputMode, selection prompts
+215/-7 
selection.rs
Add safe target capture and validation for Windows             
+286/-0 
capsule_focus.rs
Add epoch-guarded capsule for selection polish                     
+118/-6 
hotkey_loops.rs
Add selection polish hotkey bridge and supervisor loops   
+184/-14
hotkey.rs
Add SelectionPolishShortcutPressed event and routing         
+137/-32
coordinator.rs
Integrate selection polish module and capsule epoch fields
+158/-54
lib.rs
Register new commands and preview window factory                 
+97/-41 
selection_polish.rs
Tauri commands for triggering selection polish                     
+7/-0     
selection_polish_preview.rs
Commands for preview confirm/cancel and get payload           
+22/-0   
hotkeys.rs
Add set_selection_polish_hotkey command                                   
+135/-0 
settings.rs
Include selection polish preferences in settings read/write
+38/-7   
SelectionPolishPreview.tsx
Selection polish preview UI component                                       
+74/-0   
SelectionPolishSection.tsx
Settings UI for selection polish hotkey and mode                 
+94/-0   
selection-polish-preview.ts
IPC bindings for preview window                                                   
+20/-0   
Capsule.tsx
Support selection_polish flag in capsule state                     
+130/-1 
Bug fix
1 files
qa.rs
Add conflict check with selection polish hotkey                   
+1/-0     
Documentation
3 files
selection_light.md
Light style selection polish prompt                                           
+16/-0   
selection_structured.md
Structured style selection polish prompt                                 
+18/-0   
selection_formal.md
Formal style selection polish prompt                                         
+19/-0   
Additional files
21 files
package.json +1/-0     
tauri-dev-visible.mjs +12/-0   
history.rs +2/-1     
mod.rs +14/-0   
dictation.rs +11/-2   
qa_session.rs +1/-0     
hotkey.rs +2/-0     
style_pack.rs +67/-1   
style_pack_archive.rs +2/-0     
style_pack_tests.rs +102/-2 
polish.rs +25/-1   
App.tsx +6/-1     
hotkey.ts +5/-0     
hotkeys.ts +15/-1   
index.ts +7/-0     
mock-data.ts +12/-0   
stylePrefs.test.ts +3/-0     
types.ts +16/-0   
main.tsx +2/-0     
Style.tsx +116/-31
tabs.tsx +2/-0     

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit e53af2e)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@SeanZhang226
SeanZhang226 force-pushed the feat/selection-polish-core branch from 274a73f to e53af2e Compare July 21, 2026 16:35
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit e53af2e

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant