feat(translation): add master 'Enable translation' preference toggle#365
feat(translation): add master 'Enable translation' preference toggle#365katanumahotori wants to merge 4 commits intoOpen-Less:betafrom
Conversation
Today translation is implicitly disabled by leaving translation_target_language empty. That's effective for the polish pipeline but it doesn't disable the translation hotkey nor the overlay, so a misfire on (e.g.) LeftOption still flashes the "translating" capsule. This PR adds an explicit master: - New UserPreferences.translate_enabled: bool (defaults to true for migration parity). - set_translate_enabled IPC command, persisted via existing preferences pipeline. - Capsule's translation overlay is gated on translation && !quiet && translateEnabled, so even if the translation hotkey misfires the user sees no overlay. - Settings -> Translation section: new toggle row with description. i18n strings added in 5 languages. Note: types.rs / commands.rs / lib.rs / lib/types.ts / lib/ipc.ts in this PR also include scaffolding for follow-up custom polish styles and per-app overrides PRs (CustomMode, AppModeOverride structs, PolishMode::Custom variant, related IPC commands). The UI consuming those fields is not present in this branch, so they are dormant on this branch alone. They are bundled here to avoid 3 follow-up schema-migration conflicts on the same files. If merged independently of this PR, the trailing PRs will rebase those types.
|
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 appergb#366 / appergb#367 land.
Capsule.tsx's quiet-mode gating depends on src/lib/quietMode.ts which is otherwise added in Open-Less#364. Including the file here keeps this PR buildable in isolation. The file is identical to Open-Less#364's; if both PRs land, the second merge is a no-op.
PR Reviewer Guide 🔍(Review updated until commit 7ac18a2)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 1b9f0f1 |
|
不符合要求: 将 @fontsource/noto-sans-jp 和 @fontsource/inter 打包到本地,而不是依赖 CDN。 |
|
Persistent review updated to latest commit 1b9f0f1 |
…n_target_language
|
Re: the previous comment — looks like content from PR #364 was pasted here. Treating this PR on its own: Original design added a new
No new pref field, no breaking changes for existing users — just a tighter integration of the existing one. |
|
Persistent review updated to latest commit 7ac18a2 |
User description
Why
Today translation is implicitly disabled by leaving
translation_target_languageempty. That's effective for the polish pipeline but it doesn't disable the translation hotkey nor the overlay, so a misfire on (e.g.) LeftOption still flashes the 'translating' capsule. Users who don't use translation at all want a hard kill switch.What
UserPreferences.translate_enabled: bool(defaults totruefor migration parity).set_translate_enabledIPC command, persisted via the existing preferences pipeline.Capsule's translation overlay is gated ontranslation && !quiet && translateEnabled, so even if the translation hotkey misfires the user sees no overlay.Note (scope leakage)
types.rs/commands.rs/lib.rs/lib/types.ts/lib/ipc.tsin this PR also include scaffolding for follow-up PRs (custom polish styles and per-app overrides): theCustomModeandAppModeOverridestructs, thePolishMode::Customvariant, and related IPC commands. The UI that consumes those fields is not present in this branch, so they are dormant code on this branch alone.They are bundled here to avoid 3 follow-up schema-migration conflicts on the same files. If this PR is merged independently of the trailing PRs, those PRs will rebase the type changes (which would then become no-ops). If reviewers prefer the schema split out to a prerequisite PR, happy to do that.
i18n keys for follow-up PRs are also included here for the same reason as #364.
PR Type
Enhancement
Description
Add master translation enable toggle (
translateEnabledpref, set_translate_enabled command, Capsule gating)Introduce custom polish styles (CustomMode) with full CRUD commands and custom system prompt override
Implement per‑app auto style switching via AppModeOverride rules and pick_mode_for_app logic
Provide quiet mode foundation (quietMode.ts) for suppressing transient capsule labels, consumed by Capsule
Extend i18n strings in 5 languages for the new settings, plus dormant UI font/quiet keys for parallel PRs
Diagram Walkthrough
File Walkthrough
15 files
Add translation toggle, custom mode CRUD, and app override commandsWire custom prompt, app overrides, and translation gating into polishpipelineRegister new Tauri commands for translation, custom modes, andoverridesSupport optional prompt override in system prompt compositionDefine CustomMode, AppModeOverride, PolishMode::Custom, and pick logicGate translation overlay on translateEnabled and quiet mode; add quietlabel suppressionAdd English labels for custom styles, app overrides, translationtoggle, and dormant UI keysAdd Japanese labels for new settings, polish mode names, and dormantUI keysAdd Korean labels for new settings, style names, and dormant UI keysAdd Simplified Chinese labels for custom modes, app overrides,translation toggle, and dormant UI keysAdd Traditional Chinese labels for new settings and dormant UI keysAdd frontend IPC wrappers for translation toggle, custom modes, andapp overridesNew helper for quiet mode state persisted in localStorageMirror CustomMode, AppModeOverride, and widen PolishMode type forcustom variantsAdd translation enable toggle row in Settings UI1 files
Update mock preferences with new fields to fix test compilation