Commit Graph
6 Commits
Author SHA1 Message Date
TRIPandbaiqing ecf2b0f6c2 feat: style pack i18n + 差量缓存 + 内置三包升级到 v2 (#460)
* docs(windows): 记录独占全屏游戏下 capsule overlay / hotkey 的 OS 级限制 (#457)

- coordinator.rs: 在 show_capsule_window_no_activate (Windows 路径) 上方加注释,
  说明 SetWindowPos(HWND_TOPMOST) 在独占全屏 DirectX/OpenGL 应用之上失效,以及
  UIPI 阻挡 hotkey 的同源现象,避免后续维护者再次尝试用户空间 workaround。
- USAGE.md: 给最终用户加 FAQ —— Minecraft 等全屏游戏下应切换到 borderless
  windowed fullscreen,对齐管理员权限,预先打开游戏聊天框。

此次仅文档与注释改动,不修改运行时行为。修复独占全屏 overlay 需要 DirectX
overlay 注入(Discord / MSI Afterburner 路线),工程量与风险都不在 surgical
修复范围。

* feat: style pack i18n + 差量缓存 + 内置三包升级到 v2

i18n(5 个 locale 全覆盖)
- 新增 style.pack.* 命名空间(~70 keys)覆盖 Style 页面所有 UI 文案。
- 扩展 marketplace.* 命名空间(~50 keys,含 myPacks/upload/oauth/state/modal/derivativeBadge/sortLiked/likedEmpty 等)。
- ja.ts / ko.ts 原本完全缺失 marketplace.* —— JP/KR 用户进风格市场会 fallback 看见中文,本次补齐。
- Style.tsx 删除 100+ 行 `isEnglish ? '...' : '...'` 三元 copy 对象,全走 t()。
- Marketplace.tsx + MarketplaceModal.tsx 把硬编码 '我赞过的'/'我的发布'/'确定上传'/'已下架'/'撤回发布'
  /'审核中'/'已上架'/'未通过'/'未登录'/'衍生自' 等 30+ 处全走 t(),含 statusLabel(state, t) 重构。

差量缓存(src/lib/ipc.ts + Marketplace.tsx)
- list cache 从 sessionStorage 升到 localStorage,跨重启秒呈现,TTL 24h。
- 新增 detail cache:按 (id, version, updatedAt) 三元组缓存 marketplace_detail;
  三元组等价于内容版本签名,version/updatedAt 任一变化即失效重拉。命中 = 0 请求。
- 自动驱逐:写入 list cache 时根据当前三元组集合 prune 不在列表里的 detail 条目
  —— 满足「云端哈希被移除时本机也移除」的语义。
- 安全审计:
  - 包 ID 必须匹配 UUID v4 正则(防 key 注入)。
  - detail.id 必须等于请求 packId(防服务端返回错位内容)。
  - 单条 prompt 长度上限 200KB(防 OOM)。
  - detail 条目上限 64,LRU 淘汰(防 localStorage 配额耗尽)。
- openDetail 先查本机三元组缓存,命中即渲染 + 跳过网络;未命中再走 IPC + 校验回写。

内置 style pack 升级到 v2.0(types.rs + polish.rs tests)
- 「轻度润色」「清晰结构」「正式表达」三个 builtin pack 整体替换为社区维护的 PRO v2 prompt
  (含独立角色 + {{HOTWORDS}} + 七/八节中文序号骨架 + 高密度示例 + ASR 纠错词表)。
- default_style_system_prompt_for_mode 对这三个 mode 早返回各自的 BUILTIN_PROMPT,
  跳过标准 ROLE_BLOCK + COMMON_RULES + OUTPUT_BLOCK wrapper,避免与 v2 内同名段落重复。
- StylePack literal 同步:name 保留中文短名(去掉 PRO 后缀),version → 2.0.0,
  description/examples/tags 同步 manifest。
- 老用户磁盘已有的 builtin pack 不会被自动覆盖(persistence migration 只填空字段,
  保护用户对内置包的编辑);要应用 v2 需在「风格」页面点一次「重置」;新装用户直接拿 v2。
- polish.rs 的 4 处依赖旧 heading 的断言更新为 v2 实际锚点;
  common_rules_include_auto_correction_and_natural_organization 拆为
  Raw(走 wrapper)+ Light/Structured/Formal(走 v2 PRO 自带 ASR 纠错段)两组。

后端服务(apic.openless.top)这次没动。

* feat: 英文翻译注入 EN 专用指引 + 修「我的发布」加载/计数/驱逐

英文翻译加专用补丁
- translate_system_prompt 检测 target_language == English(含 '美式英文' / '英文' / 'english'
  / 'British English' 等别名)时,在基础 prompt 末尾拼一段 EN 专用指引:
    · ASR 纠错优先策略(高/中/低置信度分级)
    · 中→英技术词规范化表(令牌→Token / 密钥→Secret Key / 应用ID→App ID /
      鉴权失败→authentication failure / 调用接口→call the API …)
    · 模型名 / 产品名还原(克劳德→Claude、双子座→Gemini、卡布奇诺→Cappuccino …)
    · 自然英文要求(idiomatic、avoid Chinglish、code/URL/版本号原样保留)
- 其它语言行为不变。
- 来源:社区贡献的「重写为英文」prompt,精简后避免与 base 重复。
- 新增 translate_prompt_appends_en_extras_only_for_english 单测覆盖 happy path + 别名 + 非英文。

修「我的发布」三个 bug
1. 数据拉取态:新增 myPacksLoading / myPacksError 状态机。
   原行为:拉取中显示「你还没有发布过风格包」,失败只弹 toast;用户分不清"empty"和"loading"。
   现行为:四态优先级 loading → error → empty → list;loading 显示「正在拉取,请稍后…」;
   error 单独成块带「重试」按钮(inline 比 toast 更稳定可达)。
2. 计数错位:visibleMyPacks 立即过滤 withdrawn / superseded(移除原 5 分钟可见窗口)。
   原 bug:发布 1 个删 1 个后,刚下架的那个还在 5 分钟窗口内 → 计数显示 2,跟实际不符。
   下架的反馈走 actionMsg toast 即可,不需要在列表里继续占位。
3. 计数源切换:'已发布 N 个'里的 N 改用 visibleMyPacks.length(active 包),
   跟列表里实际看到的卡片数对得上。pending 计数同样基于 visible。
4. 顺手清理:刷新按钮在 myPacksLoading=true 时 disabled,避免并发请求;
   删掉只为旧 5 分钟窗口存在的 nowTick / setInterval 状态与 effect。

i18n(5 个 locale):marketplace.myPacks 新增 loadingTitle / loadingHint /
loadErrorTitle / loadErrorRetry 四个 key。

* refactor(translate): EN 目标整段切到专用 prompt(不再走 append)

上一版是「通用 base + 末尾追加 EN 专用补丁」,两段重复 / 注意力被稀释。这版改为:
- target_language 命中 English 时(含 '美式英文' / '英文' / 'english' / 'British English' 别名)
  → translate_system_prompt 直接 return 新增的 EN_TRANSLATE_SYSTEM_PROMPT 整段,不再拼通用 base。
- 其它语言行为不变(继续走原通用 # 任务(翻译输出) base)。

新 EN_TRANSLATE_SYSTEM_PROMPT 自包含、~60 行精简版(来源:社区「重写为英文」prompt):
  · 角色 + 输入是 ASR 不可靠 + 任务定义(先纠错再翻译,结果直插光标)
  · 工作流程 6 步(不可换顺序)
  · ASR 纠错按高/中/低置信度分级
  · 中→英技术术语规范化表(Token / Secret Key / App ID / Access Token / Endpoint /
    Webhook / authentication failure / call the API / quota / front-end / back-end /
    Claude / Gemini / Cappuccino / Coder / LongCat …)
  · 翻译要求:自然 idiomatic、不要 Chinglish、保持原语气、英语写法的日期数字
  · 原样保留:代码标识符 / 命令 / 路径 / env vars / 布尔值 / 完整版本号 /
    大写缩略语(API SDK JWT OAuth …)/ 人名地名品牌名
  · 边界 case + 5 条禁止 + 输出约束

替换 translate_prompt_appends_en_extras_only_for_english 单测为
translate_prompt_swaps_to_en_dedicated_when_target_is_english:断言
- 英文目标命中 EN 专用 prompt("# 任务(中文转写 → 英文翻译)"),不再含通用 base 标题
- 非英文目标仍走通用 base
- 别名 '美式英文' / '英文' / 'english' / 'British English' 都解析为英文

cargo test 269 / 0 / 0;tsc clean。

---------

Co-authored-by: baiqing <lbx12309@icloud.com>
2026-05-17 09:45:28 +08:00
Cooper-X-Oak b8e43c8a0c docs: link Volcengine guide from README and usage 2026-05-01 17:35:23 +08:00
baiqing 7f83bca5b6 docs: 更新 README / USAGE / CLAUDE.md 至 Tauri v1.1 现状
- 两个 README 改为描述 Tauri 2 + Rust + React/TS,macOS 12+ 和 Windows
- Badges:去掉 Swift/macOS15+,加 Tauri/Rust/Windows/macOS12+
- 状态章节:v1.0 Swift → v1.1 Tauri
- 构建说明:Tauri 优先,Swift 降为 legacy
- 架构章节:更新为 Tauri 模块表
- Roadmap:删除已完成项(Developer ID + Sparkle)
- 下载说明:更新为 DMG/MSI 安装流程
- 发布检查:更新为 tag CI 流程
- 新增 USAGE.md(快速上手指南,中文)
- QQ 群号 1078960553 加入显眼位置(README 标题区 + USAGE)
- CLAUDE.md:补充 whisper ASR、HotkeySettingsContext、cargo check
2026-04-30 09:12:31 +08:00
baiqing 34d2823961 chore: remove deprecated Swift implementation
项目已全面转型为 Tauri 跨平台版本(openless -all/),
Swift 端(Sources/、Tests/、scripts/、Package.swift、appcast.xml)
已废弃,一并清理。
2026-04-29 22:17:59 +08:00
TRIPandbaiqing 56c3e09983 feat: hold-to-talk + UX fixes + structured prompt overhaul
* feat: add hold-to-talk hotkey mode (closes #1)

OpenLessHotkey now emits explicit .pressed / .released edge events on
the modifier-key trigger; the coordinator interprets them per the new
HotkeyMode preference (toggle stays the default, hold = press-and-hold).

Hold mode rules: .pressed on idle starts the session; .released stops
it from .listening; releasing during .starting cancels (no audio
useful was captured yet). Esc-cancel sets a one-shot suppress flag so
the trailing .released after a cancel does not re-trigger end.

Settings hub gets a "录音方式" segmented picker and a one-line hint
explaining the tradeoff. Bump version to 1.1.0; update README roadmap
and USAGE walkthrough to document the new mode.

* test: update HotkeyEventTests for pressed/released split

* chore: tag hold-to-talk build as 1.0.01 / A1003

* fix: stop window-background drag eating text selection; add eye toggle on secret fields

Settings window had isMovableByWindowBackground = true, so any drag
inside the content view dragged the whole window — making it
impossible to select words inside a TextField. Disable it; the native
title-bar strip (with the traffic lights) still drags the window.

PasteableCredentialField now exposes an eye / eye.slash toggle when
secure: true, so users can verify pasted API keys before saving.

* fix: stop pretending polish ran when it was skipped or errored

When the user removes the Ark API key (or the Ark call errors out),
DictationCoordinator was still showing the green "已插入" capsule and
recording the session in history under the originally-selected polish
mode. From the user's side it looked like polish had succeeded, even
though only the raw transcript reached the cursor.

Track a PolishOutcome (ok / skippedNoCredentials / failed) through
insertText. Capsule now uses a new CapsuleState.warning (orange) state
to surface honest messages — "已插入原文 · 未润色" / "润色失败 · 已用原文" —
and history saves the session as PolishMode.raw whenever polish
didn't actually run. The error capsule + 1.5s artificial sleep that
preceded a fake "success" insert is gone; warning state stays for the
normal 2.5s.

* feat(polish): make Structured mode prompt force a 1./1)/a. hierarchy

Some weaker chat models would emit a single flat list when the user
asked for Structured polish, even when the dictation clearly covered
multiple topics. The mode is meant to produce something pasteable as
an AI prompt or a working doc, not a wall of bullets.

Rewrite the .structured system prompt to be prescriptive: when the
input contains ≥2 themes, emit three explicit levels — top "1./2./3."
sections, "1)/2)/3)" sub-points indented 3 spaces, and "a./b./c."
detail items indented another 3 — and to fall back to a plain
paragraph when the input is short / single-topic. Add a concrete
format example so weaker models have a pattern to copy.

---------

Co-authored-by: baiqing <lbx12309@icloud.com>
2026-04-27 18:57:41 +08:00
baiqing c78bb44c23 chore: cut 1.0.0 release with usage docs and MIT license
Bump APP_VERSION to 1.0.0 / BUILD_NUMBER to 1; refresh README to clarify
project direction and add quarantine-removal guidance for the unsigned
release artifact; add USAGE.md as the end-user walkthrough; add MIT LICENSE.
2026-04-27 15:25:28 +08:00