feat(style): user-defined custom polish styles with editable system prompts#366
feat(style): user-defined custom polish styles with editable system prompts#366katanumahotori wants to merge 2 commits intoOpen-Less:betafrom
Conversation
…rompts
The four built-in PolishModes (Raw / Light / Structured / Formal) all
ship with hard-coded zh-CN system prompts. Users wanting a
"novel-writing", "email", or "casual chat" style had no way to register
one, and Ctrl+Shift+S only cycled the four built-ins.
This PR turns PolishMode into a Custom(String) extensible enum (serde
transparent via String, so the wire format stays compact) and adds a
CRUD surface for user styles:
- UserPreferences.custom_modes: Vec<CustomMode { id, name, prompt }>
- add_custom_mode / update_custom_mode / delete_custom_mode IPC
commands; delete falls back default_mode to Light if it was pointing
at the deleted custom id.
- prompts::system_prompt(mode, override_text) accepts an override
string used by Custom modes (built-ins still render the original
ROLE/RULES/OUTPUT scaffolding when override_text is None).
- Style page: existing 4-mode grid stays, each card gets a "view
default prompt" disclosure that hits the new
get_default_polish_prompt IPC. Below it, a new "Custom styles"
section with add / edit / delete UI; each custom mode participates
in enabled_modes and the master toggle, and Ctrl+Shift+S cycles
through them too.
Custom modes are picked by default_mode and the switch_style_hotkey
listener exactly like built-ins, so no other call site needs to learn
about them.
Note: coordinator.rs and Style.tsx in this PR also contain the
per-app override logic and UI (next PR's scope). They are bundled
because they're the same files; the new Style.tsx "Per-app override"
section requires the AppModeOverride type from this PR's types.rs
anyway. If reviewers prefer the override path stripped, that's a
follow-up.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…Mode::Custom Without these the PolishMode::Custom variant added to types.rs in this PR makes the existing match arms in polish.rs / coordinator.rs non-exhaustive and the crate fails to compile. Same scope-leakage caveat from the previous commit applies: these will be the canonical implementations once Open-Less#366 / Open-Less#367 land.
PR Reviewer Guide 🔍(Review updated until commit 3eab896)Here are some key observations to aid the review process:
|
|
@katanumahotori Deleting a custom style only removes it from |
…debounce on unmount
|
Thanks for the careful review. Both issues fixed:
Please re-review. |
|
Persistent review updated to latest commit 3eab896 |
User description
Why
The four built-in PolishModes (Raw / Light / Structured / Formal) all ship with hard-coded zh-CN system prompts. Users wanting a 'novel-writing', 'email', or 'casual chat' style had no way to register one, and Ctrl+Shift+S only cycled the four built-ins.
What
Turns
PolishModeinto aCustom(String)extensible enum (serde transparent via String, so the wire format stays compact) and adds a CRUD surface for user styles:UserPreferences.custom_modes: Vec<CustomMode { id, name, prompt }>add_custom_mode/update_custom_mode/delete_custom_modeIPC commands; delete falls backdefault_modeto Light if it was pointing at the deleted custom id.prompts::system_prompt(mode, override_text)accepts an override string used by Custom modes (built-ins still render the original ROLE/RULES/OUTPUT scaffolding whenoverride_textisNone).get_default_polish_promptIPC. Below it, a new 'Custom styles' section with add / edit / delete UI; each custom mode participates inenabled_modesand the master toggle, and Ctrl+Shift+S cycles through them too.Custom modes are picked by
default_modeand theswitch_style_hotkeylistener exactly like built-ins, so no other call site needs to learn about them.Note (scope leakage)
coordinator.rsandStyle.tsxin this PR also contain the per-app override logic and UI (next PR's scope). They're bundled because they're the same files; the newStyle.tsx'Per-app override' section needs theAppModeOverridetype from this PR'stypes.rsanyway. If reviewers prefer the override path stripped, that's a follow-up.Depends on schema in #365 (or this PR can land first and #365 rebases).
PR Type
Enhancement, Tests
Description
Add
translateEnabledpreference plumbingAdd custom styles and app overrides
Route custom prompts through polish flow
Expand style UI, locales, and tests
Diagram Walkthrough
File Walkthrough
13 files
Add custom modes and translate flagSupport custom prompts in polish flowAdd translation and custom mode commandsPick app overrides during dictationRegister new Tauri commandsAdd custom style and override UIAdd Japanese copy for new settingsAdd Korean copy for new settingsAdd Traditional Chinese copy for new settingsAdd Simplified Chinese copy for new settingsAdd English copy for new settingsMirror custom preferences and override typesAdd IPC wrappers for new settings1 files
Update mocked preferences for new fields