feat: 翻译模式 + Codex 后审修复 + 胶囊翻译指示器#113
Conversation
翻译模式(issue #4) 按住录音键时随时按一下 Shift(任一侧)→ 录音结束后走"翻译输出"管线, 按"翻译"页中选定的目标语言翻译后插入到光标。 - hotkey.rs 三平台(CGEventTap / Win32 hook / rdev)都监听 Shift down 边沿, 通过新增的 HotkeyEvent::TranslationModifierPressed 上报 - coordinator.rs 加 translation_modifier_seen 标志位(begin_session 重置); end_session 路径根据它 + 非空 target_language 选 polish 或 translate - polish.rs 抽 chat_completion 共享通道;新增 translate_to + translate_system_prompt; working_languages 作为 system prompt 头部前提注入两条管线 - types.rs::UserPreferences 加 working_languages(默认 ["简体中文"])+ translation_target_language(默认空) - Settings.tsx 删除原来的录音 section 翻译配置;新建 Translation.tsx 一级页(在风格下面), 含工作语言多选 + 目标语言下拉 + 5 步使用指南 - 新增 capsule.tsx 翻译徽章:"● 正在翻译" 蓝色药丸,绝对定位在 pill 上方 8px, opacity + translateY transition 平滑出入;CapsulePayload 加 translation: bool - capsule 窗口高度 96 → 110 给 badge 让出空间 - 内置 SUPPORTED_LANGUAGES 列表(15 种自然语言原生名) Codex 后审修复(基于 4f45dee main 上跑的整体审查) - tauri.conf.json 主窗口 decorations 由 #108 设的 false 还原为 true, Windows-only 在 lib.rs::setup 里 set_decorations(false),让 macOS 拿回原生红黄绿 - coordinator.rs::SessionState 加 session_id;spawn_recorder_error_monitor 捕获当前 id,迟到的 cpal 错误若 id 不匹配直接 drop,不会误中止后续 session - volcengine.rs 把 spawn-per-chunk 模式改成单 mpsc worker 串行 send, 彻底消除跨 consume 调用的 writer 锁 race(之前的 fix 仅在 burst flush 内部有效) 附带修复 - insertion.rs Windows/Linux 粘贴后剪贴板恢复加用户开关 restore_clipboard_after_paste (issue #111),默认 true 保留现行行为;关掉后听写文本留剪贴板,paste 失败时可手动 Ctrl+V 找回 - SettingsModal 内容区改为 flex column + overflow:hidden,X 按钮 + 标题固定, 只 section 内容区滚动;Settings.tsx 嵌入模式右栏独立 scroll - Settings → 提供商:火山引擎 "App Key" 文案改为 "App ID" (keychain account name 不变,老用户凭据不丢) - i18n 增加 capsule.translating / nav.translation / translation.* 完整命名空间
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf335da697
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "title": "OpenLess Capsule", | ||
| "width": 220, | ||
| "height": 96, | ||
| "height": 110, |
There was a problem hiding this comment.
Keep capsule position in sync with new window height
After increasing the capsule window height to 110 in tauri.conf.json, the positioning logic still uses cap_h = 96.0 in position_capsule_bottom_center (src-tauri/src/lib.rs). On startup this computes y too low, so the capsule can sit ~14px lower than intended (partially clipped on smaller displays and inconsistent with the new layout). Please update the runtime position calculation to use the same height as config.
Useful? React with 👍 / 👎.
| elapsed_ms, | ||
| message, | ||
| inserted_chars, | ||
| translation: inner.translation_modifier_seen.load(Ordering::SeqCst), |
There was a problem hiding this comment.
Gate translation badge on enabled translation target
The capsule translation flag is emitted from translation_modifier_seen alone, but actual translation execution also requires a non-empty translation_target_language in end_session. This means when target is disabled (documented as “Shift does nothing”), pressing Shift still shows the blue “Translating” indicator even though the session will run normal polish. Please derive the emitted badge flag from the same predicate as the translation pipeline to avoid misleading status.
Useful? React with 👍 / 👎.
主要变更
翻译模式(issue #4)
录音过程中任意时刻按一下 Shift(任一侧)→ 录音结束走"翻译输出"管线,把转写翻译为用户在新「翻译」页选定的目标语言,再插入到光标位置。
前端
pages/Translation.tsx(在「风格」下方,图标是 stroke 翻译符号)opacity + translateYtransition 平滑出入;capsule 窗口高度 96 → 110后端
hotkey.rs三平台(CGEventTap / Win32 hook / rdev)监听 Shift down 边沿,新事件HotkeyEvent::TranslationModifierPressedcoordinator.rs::Inner加translation_modifier_seen: AtomicBool,begin_session重置;end_session据此 +translation_target_language选 polish 还是 translatepolish.rs抽chat_completion(system_prompt, user_prompt)共享方法;新translate_to走同通道;working_languages_premise把"用户的工作语言:…"拼到 system prompt 头部,影响 polish + translateUserPreferences加working_languages: Vec<String>(默认["简体中文"])+translation_target_language: StringCapsulePayload加translation: bool,emit_capsule自动带Codex 后审修复(基于 main = 4f45dee 的整体审查)
tauri.conf.json主窗口decorations设为 false,连带把 macOS 原生红黄绿按钮关掉。还原为 true,Windows-only 在lib.rs::setup里 runtimeset_decorations(false)SessionState加session_id: u64,begin_session自增;spawn_recorder_error_monitor捕获当前 id,处理时若 id 已变直接 drop(之前旧 session 的迟到 cpal 错误会误中止新 session)consume_pcm_chunk在 state 锁内分配 seq + 入队;open_sessionspawn 唯一 worker FIFO recv 后send_binary。session 结束时 take audio_tx,worker 自然退出附带修复
insertion.rsWindows/Linux 路径加restore_clipboard_after_paste: bool开关,默认 true 保现行;关掉则听写文本留剪贴板,simulate_paste 没生效时用户能手动 Ctrl+V 找回overflow:hidden + flex column,X 按钮 + section 标题固定不滚;嵌入 Settings 的右栏独立 overflow:autovolcengine.app_key保持不变,老用户凭据不丢)capsule.translating/nav.translation/ 完整translation.*命名空间,删settings.recording.workingLanguages*/translationTarget*Files
19 changed, +776 / -88
Test plan
error frame code=45000000日志,volcengine.log 无 seq mismatch