Skip to content

feat: add style pack store v1#429

Merged
H-Chris233 merged 16 commits into
Open-Less:betafrom
Cooper-X-Oak:cooper/style-pack-store-v1-beta
May 14, 2026
Merged

feat: add style pack store v1#429
H-Chris233 merged 16 commits into
Open-Less:betafrom
Cooper-X-Oak:cooper/style-pack-store-v1-beta

Conversation

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor

@Cooper-X-Oak Cooper-X-Oak commented May 13, 2026

User description

Summary

  • add the v1 Style Pack runtime, persistence, import/export, and runtime prompt selection flow
  • add the store-style Style management UI and updated example presentation
  • align the branch with current beta settings structure so the feature lands cleanly on the active development base

Verification

  • npm run build
  • cargo check --manifest-path src-tauri/Cargo.toml
  • npx tsx src/lib/stylePrefs.test.ts

PR Type

Enhancement, Bug fix, Tests


Description

  • Add persistent style pack store

    • Import/export, reset, enable, migrate packs
  • Drive polish prompts from active packs

  • Add style manager UI and IPC

  • Update translations and regression tests


Diagram Walkthrough

flowchart LR
  T["types.rs style pack defaults"] -- "persisted by" --> P["persistence.rs style pack store"]
  U["Style and settings UI"] -- "invokes" --> C["commands.rs and IPC"]
  C -- "updates" --> P
  P -- "syncs" --> R["preferences and active pack"]
  R -- "feeds" --> M["polish.rs prompt assembly"]
  M -- "used by" --> L["LLM providers"]
Loading

File Walkthrough

Relevant files
Enhancement
17 files
types.rs
Define style pack models and defaults                                       
+605/-0 
polish.rs
Assemble prompts from style pack content                                 
+148/-210
persistence.rs
Persist style packs and migration state                                   
+805/-3 
llm_gemini.rs
Thread style prompts into Gemini requests                               
+2/-0     
dictation.rs
Select active style pack during dictation                               
+173/-101
commands.rs
Add style pack command handlers                                                   
+267/-28
coordinator.rs
Wire style pack state into coordinator                                     
+129/-19
lib.rs
Export style pack modules to Tauri                                             
+18/-7   
Style.tsx
Build style pack management screen                                             
+1084/-223
ipc.ts
Extend IPC types for style packs                                                 
+447/-6 
ja.ts
Translate style pack settings copy                                             
+17/-0   
zh-TW.ts
Translate style pack settings copy                                             
+17/-0   
ko.ts
Translate style pack settings copy                                             
+17/-0   
zh-CN.ts
Translate style pack settings copy                                             
+17/-0   
en.ts
Translate style pack settings copy                                             
+17/-0   
Settings.tsx
Surface style pack controls in settings                                   
+28/-1   
types.ts
Mirror style pack frontend data types                                       
+69/-0   
Bug fix
1 files
_atoms.tsx
Restore clickable button cursor affordance                             
+1/-1     
Tests
1 files
stylePrefs.test.ts
Update style preference fixture coverage                                 
+8/-0     

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

PR Reviewer Guide 🔍

(Review updated until commit 426bd8f)

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

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

Cooper-X-Oak commented May 13, 2026

先别动我的PR 别动 别动 别动,等github的review,等我自己的review,等测试

@Cooper-X-Oak Cooper-X-Oak marked this pull request as draft May 13, 2026 06:20
@Cooper-X-Oak Cooper-X-Oak changed the title feat: add style pack store v1 feat: add style pack store v1 DRAFT! 别动我PR May 13, 2026
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 7616ef0

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit c77d9f4

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 0a19ad3

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 0c6cc8b

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 16dd99c

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

补充一轮 review fix:

  • 修了 tray 样式切换只改 default_mode、没有同步 active_style_pack_id 的问题。现在托盘、set_default_polish_modeset_active_style_pack 复用同一套激活 helper,切换内置样式会统一启用目标 pack、写 active id、同步持久化并刷新 tray。
  • 修了流式插入路径在字符已经打到光标后又继续做简繁/纠错后处理的问题。现在 already_streamed=true 时直接以已流式输出的文本作为最终结果,避免 screen / clipboard / history 分叉。
  • 顺手补了两个低成本修复:legacy custom prompt 迁移避免重复追加,get_or_default_active fallback 到 builtin light 时也要求该 pack 处于 enabled。

本地验证:

  • npm run build 通过
  • npx tsx src/lib/stylePrefs.test.ts 通过
  • cargo check --manifest-path src-tauri/Cargo.toml 通过
  • cargo fmt --manifest-path src-tauri/Cargo.toml --check 通过
  • 本机 cargo test --manifest-path src-tauri/Cargo.toml --lib 当前在启动 test harness 时直接异常退出,返回 0xc0000139 STATUS_ENTRYPOINT_NOT_FOUND--no-run 可通过,说明编译层面正常,这个看起来是当前 Windows 本地测试运行环境问题,不是新增断言失败。CI 已重新触发,等线上结果补充。

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit a4c4cc2

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit ae2c7e4

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit c77e235

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor Author

Final merge-ready review summary

这一轮我按 origin/beta...HEAD 做了面向真实本地使用链路的最终复核,目标是判断 Style Store / Style Pack v1 及其后续 review fix 是否已经达到可合并质量,而不是继续扩功能。

复核范围

  • diff review:覆盖 origin/beta...HEAD 及其直接受影响链路
  • 本地产品验收:Style Store / Style Pack、导入导出、持久化、tray 切换、streaming insertion、一致性/回归风险
  • 工程门禁:前端构建、TS 校验、Rust 编译检查、可运行后端测试、PR CI

过程中的关键问题与修复

1. 导出未保存 draft 时导出的是旧持久化内容

  • 复现:编辑 builtin style pack,修改名称/Prompt 但不保存,直接点“导出 ZIP”
  • 预期:阻止导出,要求先保存当前 draft
  • 实际:UI 提示导出成功,但导出的仍是旧的 persisted pack
  • 修复:ae2c7e4
  • 结果:现在会明确提示“请先保存当前风格包,再导出 ZIP。”,不再导出旧内容

2. tray / 热键切换 style 后 UI 与 prefs 不同步

  • 复现:通过 switch-style 热键切换当前 style
  • 预期:prefs、tray、前端状态同步更新
  • 实际:prefs 写了,但 prefs:changed / tray refresh 不完整,UI 可能滞后
  • 修复:ae2c7e4
  • 结果:切换后会补发 prefs:changed,并在主线程刷新 tray

3. builtin style pack 保存/重置后,store 与 prefs 兼容字段可能重新分叉

  • 复现路径:builtin style pack 保存/重置只更新 store,不同步 prefs.style_system_prompts;后续任意 Settings 保存可能把旧 prefs 再写回
  • 预期:store / prefs / 后续 set_settings 持久化保持同一事实源
  • 实际:存在“新 style pack store + 旧 prefs 兼容字段”的持久化不一致风险
  • 修复:c77e235
  • 修复内容:
    • set_settings 先按当前 style pack store 归一化 style prefs
    • builtin pack 的保存/重置后立即同步 prefs 并广播
    • sync_style_pack_preferences 现在会把 builtin prompts 回填到 prefs,并清空遗留 custom_style_prompts
  • 结果:style pack store 重新成为单一事实源,避免后续设置保存把旧 prompt 回写覆盖

本地验证结果

  • npm run build:通过
  • cargo check --manifest-path src-tauri/Cargo.toml:通过
  • npx tsx src/lib/stylePrefs.test.ts:此前通过
  • cargo test --manifest-path openless-all/app/src-tauri/backend-tests/Cargo.toml --test backend_rust -- --nocapture:47/47 通过

CI 结果

当前 PR head 已更新为 c77e235,本轮 CI 全绿:

  • Linux checks: pass
  • Windows checks: pass
  • macOS checks: pass
  • pr_agent_job: pass

最终结论

这一轮复核里发现过真实阻塞项,但都已经用最小必要改动修复并完成本地回归 + CI 回归。以当前 PR head 来看,我这边的结论是:已达到 merge-ready,可继续正常评审/合并。

唯一保留说明:主 crate 的 cargo test --lib 在这台 Windows 环境里仍受既有 STATUS_ENTRYPOINT_NOT_FOUND 测试运行时问题影响,所以新增的持久化回归测试目前主要依赖代码审查 + cargo check + 现有 backend harness + CI 交叉覆盖;这不构成当前 PR 的 merge blocker。

@Cooper-X-Oak Cooper-X-Oak changed the title feat: add style pack store v1 DRAFT! 别动我PR feat: add style pack store v1 May 14, 2026
@Cooper-X-Oak Cooper-X-Oak marked this pull request as ready for review May 14, 2026 01:48
@github-actions github-actions Bot changed the title feat: add style pack store v1 feat: add style pack store v1 May 14, 2026
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit c77e235

Constraint: types.rs must remain the shared value layer and must not depend on polish.rs
Rejected: keeping polish::prompts as the source of defaults | preserves the reverse dependency and backend test shim
Confidence: high
Scope-risk: narrow
Directive: keep built-in Style Pack defaults owned by types.rs unless the value-layer boundary changes explicitly
Tested: npm run build; npx tsx src/lib/stylePrefs.test.ts; cargo check --manifest-path src-tauri/Cargo.toml; cargo test --manifest-path src-tauri/Cargo.toml --lib
Not-tested: desktop runtime smoke on macOS/Windows
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 3563c8e

Constraint: type_unicode_chunk returns the actual count of inserted characters, including partial failures
Rejected: appending the full delta after every successful call | hides short writes and makes typed_text diverge from the screen
Confidence: high
Scope-risk: narrow
Directive: preserve typed_text as the source of truth for what actually reached the focused field during streaming insertion
Tested: cargo fmt --manifest-path src-tauri/Cargo.toml; git diff --check; cargo check --manifest-path src-tauri/Cargo.toml; cargo test --manifest-path src-tauri/Cargo.toml --lib
Not-tested: desktop runtime smoke on macOS/Windows
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 97e91ec

Constraint: hotword wording appears in both effective system prompts and preview diagnostics
Rejected: keeping the slash form | less natural and leaves preview wording harder to read
Confidence: high
Scope-risk: narrow
Directive: keep hotword preview wording aligned with the system prompt wording
Tested: cargo fmt --manifest-path src-tauri/Cargo.toml; git diff --check; cargo test --manifest-path src-tauri/Cargo.toml --lib polish::tests::
Not-tested: full app build; desktop runtime smoke on macOS/Windows
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit b3a2bc3

Constraint: legacy preferences may have defaultMode without activeStylePackId, and Raw style packs may still use the LLM path
Rejected: defaulting missing activeStylePackId to builtin.light | silently changes Raw, Structured, and Formal users during upgrade
Rejected: skipping script normalization for Raw LLM output | lets Simplified/Traditional preferences be bypassed by raw style packs
Confidence: high
Scope-risk: narrow
Directive: treat missing activeStylePackId as a migration case derived from defaultMode, not as the new-user default
Tested: cargo fmt --manifest-path src-tauri/Cargo.toml; git diff --check; cargo test --manifest-path src-tauri/Cargo.toml --lib types::tests::missing_active_style_pack_id_uses_legacy_default_mode; cargo test --manifest-path src-tauri/Cargo.toml --lib types::tests::explicit_active_style_pack_id_is_preserved; cargo test --manifest-path src-tauri/Cargo.toml --lib coordinator::dictation::tests::raw_llm_output_still_applies_script_preference; cargo test --manifest-path src-tauri/Cargo.toml --lib
Not-tested: full app build; desktop runtime smoke on macOS/Windows
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 426bd8f

@H-Chris233 H-Chris233 merged commit 4f64450 into Open-Less:beta May 14, 2026
5 checks passed
appergb added a commit that referenced this pull request May 14, 2026
feat(style-pack): rework UI + 模板新建 + 清理 PR #429 遗留死代码
pull Bot pushed a commit to yimmy23/openless that referenced this pull request May 14, 2026
UI:
- 「原文」改成标题旁的 pill 切换器,与 builtin 卡分离
- builtin 卡片按 light → structured → formal 排序,followed by imported 包
- 「+ 新建风格包」tile 固定在网格末位
- imported 卡片右上角换成红色 trash 删除按钮(builtin 显示装饰 sparkle 图标,无 delete)
- builtin 卡片背景做灰底处理;编辑按钮 disabled,"只读"
- 编辑按钮挪到底部,紧接「导出」右边

后端:
- 新增 IPC create_style_pack_from_template / persistence.create_from_template,「+」走这条路径直接落盘
- 编辑面板出场加 modal-backdrop-out / modal-drawer-out 两个 keyframe

清理:
- 删除 Settings.tsx 里 PR Open-Less#429 留下的"润色 System Prompt 已迁移"死告示卡
- 删除 11 个相关 i18n key 跨 5 种语言
- 删除卡片上的「轮换 ON/OFF」按钮 + 编辑面板里同款 + metaStatus item
- BusyAction 移除 'toggling' 变体
- 删除 BUILTIN 选中态与 active 共用 highlight 的 bug
- SavedToast 统一替换 inline notice/error banner
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.

2 participants