feat(vocab): 增加词汇表场景预设#233
Merged
Merged
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
PR Reviewer Guide 🔍(Review updated until commit 647fc2d)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 2f7cd05 |
|
Persistent review updated to latest commit 044b2de |
|
Persistent review updated to latest commit b9a0b13 |
Issue Open-Less#224 requires scenario presets with multi-select apply and editable custom presets, while preparing for import/export. This revision moves built-in presets into a repository JSON file and stores user presets in the app data directory as JSON via Tauri commands, so preset persistence uses one JSON shape both in repo and user space. Constraint: Keep vocabulary entry backend and UI interaction model unchanged Rejected: Keep presets in localStorage/TS constants | does not satisfy unified JSON storage requirement Confidence: high Scope-risk: narrow Reversibility: clean Directive: Preserve vocab-presets JSON schema compatibility for future import/export Tested: cargo check (src-tauri) passed Not-tested: npm build currently fails on pre-existing Settings.tsx typing issues unrelated to this change
The frontend build failed because the autostart plugin import could not be resolved in the browser-targeted Vite bundle, and strict TS also flagged implicit any in the same flow. Switch the autostart integration to runtime lazy-loading behind the Tauri guard and type the callback parameters explicitly. Constraint: Keep autostart UX behavior unchanged on Tauri runtime Rejected: Add Vite external alias for plugin package | hides integration mismatch in app code Confidence: high Scope-risk: narrow Reversibility: clean Directive: Tauri-only plugin modules should stay runtime-gated to keep web build healthy Tested: npm run build (openless-all/app) passed Not-tested: End-to-end autostart toggle interaction on all desktop platforms
New preset previously persisted an empty entry immediately on click, so cancel or navigation left permanent junk rows without any delete path. Keep new preset as in-memory draft and persist only after explicit save. Also add a regression test for vocab preset JSON persistence roundtrip to cover the new preset storage workflow with automated verification. Constraint: Minimal UI change without introducing preset delete UX in this patch Rejected: Auto-delete blank presets on load | implicit cleanup can remove user-intended drafts Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep create flow non-persistent until user confirms save Tested: cargo test vocab_presets_roundtrip_json_file -- --nocapture; npm run build Not-tested: Manual UX walkthrough for preset draft cancel across app restart
Loading presets from app-data JSON previously replaced bundled defaults entirely, so adding any custom preset made shipped scenarios disappear on the next load. Merge user presets onto bundled defaults by id so built-ins always remain available while still allowing user overrides. Constraint: Minimal change in preset loading path without altering storage schema Rejected: Persist defaults into user file on first run | unnecessary write churn and migration complexity Confidence: high Scope-risk: narrow Reversibility: clean Directive: Preserve default+user merge behavior when adding future preset sources Tested: npm run build Not-tested: Manual Tauri UI check for merged list ordering
Saving presets previously wrote the merged list (including built-ins) into user storage, which froze old builtin copies and shadowed future app updates with the same preset ids. Switch preset persistence to a delta store: custom presets, overrides for edited built-ins, and disabled builtin ids. Constraint: Keep current preset UI and command names unchanged Rejected: Force builtin presets to always overwrite user file | would discard intentional user edits Confidence: high Scope-risk: moderate Reversibility: clean Directive: Never persist untouched builtin presets into user store Tested: cargo test vocab_presets_roundtrip_json_file -q; npm run build Not-tested: Manual end-to-end UX for builtin delete/restore (no delete UI yet)
|
Persistent review updated to latest commit aad7953 |
Preset edits were applied to local UI state before persistence finished, so storage failures could show a misleading saved state and then lose changes on reload. Also, batch apply aborted on first add_vocab error and skipped later selected presets. Make preset save await persistence before mutating UI/closing editor, and make batch apply continue across per-term failures while reporting aggregated errors. Constraint: Minimal behavior fix within existing Vocab page flow Rejected: Add transactional backend endpoint for batch apply | larger cross-layer change Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep UI success states aligned with durable persistence completion Tested: npm run build Not-tested: Manual readonly-disk simulation for persist failure
|
Persistent review updated to latest commit f2122dc |
Address review feedback by removing fragile runtime import of the autostart plugin package and invoking plugin commands via Tauri core bridge, so production bundles no longer depend on unresolved bare imports. Also update preset batch apply to re-enable existing disabled terms and continue processing remaining terms/presets when one add operation fails. Constraint: Minimal changes limited to existing Settings/Vocab flows Rejected: New backend batch endpoint for preset apply | broader cross-layer change Confidence: high Scope-risk: narrow Reversibility: clean Directive: Preset apply should be idempotent and restore disabled matching terms Tested: npm run build Not-tested: Manual autostart toggle check on packaged desktop build
|
Persistent review updated to latest commit 47069ce |
|
Persistent review updated to latest commit 647fc2d |
appergb
pushed a commit
that referenced
this pull request
May 4, 2026
包含自 1.2.13 以来的修复与新功能: - feat(autostart): 跨端开机自启 (#194) - feat(asr): SiliconFlow / GLM-ASR / Groq / OpenAI Whisper preset (#212) - fix(qa): Windows / Linux 划词追问浮窗 Esc + 拖拽 + 文案 (#205 / #206) - fix(settings): preset 切换 race + per-provider 凭据隔离 (#219 / #220) - fix(overview): 概览整屏适配 + 嵌套 scroller 细滚动条 (#243 / #248) - 一系列 Windows IME (TSF) 模块 (#233 / #240 等)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
摘要
Fixes #224。
本 PR 为词汇表增加场景预设能力,方便用户按使用场景批量启用常用词,而不是逐条手动输入。
当前实现支持内置场景预设、多选批量启用、编辑预设、新建自定义预设,并将用户预设保存到 app data 目录的 JSON 文件中。内置预设也改为仓库内 JSON 文件,保证内置预设和用户预设使用同一套
VocabPreset数据结构,为后续导入 / 导出功能保留兼容的 JSON 形状。修复 / 新增 / 改进
新增词汇表场景预设:
新增内置预设文件:
openless-all/app/src/lib/vocab-presets.json新增统一预设类型:
VocabPresetVocabPreset新增预设读写 Tauri command:
list_vocab_presetssave_vocab_presets用户自定义预设保存到 app data 目录:
vocab-presets.json词汇表页面新增场景预设区域:
批量启用预设时会复用现有词汇表入口:
addVocab()添加词条编辑预设时支持用逗号或换行分隔词条。
保存预设时会对词条做基础清洗:
补充中英文 i18n 文案:
兼容
不包含:
对现有用户 / 本地环境 / 构建流程的影响:
dictionary.json。vocab-presets.json。测试计划
命令:
cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml结果:通过
证据路径:本地 src-tauri 检查输出
命令:
npm run build结果:未完成
说明:当前
npm build受既有Settings.tsxtyping 问题阻塞,和本次词汇表预设改动无关。主要改动文件
openless-all/app/src-tauri/src/commands.rsopenless-all/app/src-tauri/src/lib.rsopenless-all/app/src-tauri/src/persistence.rsopenless-all/app/src-tauri/src/types.rsopenless-all/app/src/i18n/en.tsopenless-all/app/src/i18n/zh-CN.tsopenless-all/app/src/lib/ipc.tsopenless-all/app/src/lib/types.tsopenless-all/app/src/lib/vocab-presets.jsonopenless-all/app/src/lib/vocabPresets.tsopenless-all/app/src/pages/Vocab.tsx备注
本 PR 只实现词汇表预设的新增、编辑、保存和批量启用。导入 / 导出没有在本次实现中落地,但预设已经统一为 JSON 结构,后续可以直接基于当前 schema 扩展。
PR Type
Enhancement, Bug fix, Tests
Description
Add vocabulary scenario presets with multi‑select apply, create, and edit
Store built‑in presets in repo JSON and user presets via Tauri commands
Fix web build failure by lazy‑loading the autostart plugin in Settings
Add regression test for preset JSON persistence roundtrip
Diagram Walkthrough
File Walkthrough
10 files
Add list_vocab_presets and save_vocab_presets Tauri commandsRegister new vocab preset commands in the invoke handlerImplement vocab preset persistence with atomic write and roundtriptestDefine VocabPreset and VocabPresetStore Rust typesAdd English i18n strings for scenario presetsAdd Chinese i18n strings for scenario presetsAdd listVocabPresets and saveVocabPresets IPC wrappersAdd TypeScript interfaces for VocabPreset and VocabPresetStoreAdd vocab preset loading, merging, and persistence logicAdd scenario preset UI with multi-select, create, and edit2 files
Fix web build by lazy‑loading autostart plugin importsAdd type declaration for the autostart plugin1 files
Add built‑in vocab preset definitions in JSON