Doubao-powered voice input for Linux, Wayland and Omarchy
fix(macos): 修复系统语言、网页输入和 Esc 取消,准备 1.8.2 (#92)
Leyang6112ad9c463c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a670b51..b136d29 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,13 @@# Changelog+## 1.8.2++- Follow the system language by default on macOS while preserving explicit choices.+- Use clipboard paste for web editors in automatic mode, avoiding successful accessibility calls that do not insert text.+- Cancel recording, transcription, polishing and pending input with Escape; allow immediate restart and ignore stale callbacks.+- Deliver at the current cursor after shortcut release and retain actionable recognition-service errors in the overlay.+- Improve contextual polishing corrections and Qwen response latency.+- macOS: turn Setup into a four-step guided flow with completion gates, Back navigation and automatic saving.- macOS: place recognition at the bottom of the active screen, recover one startup audio reconfiguration, and keep microphone/recognition failure messages visible.diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex 788fac7..9396727 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -30,7 +30,7 @@ read this file, [CONTRIBUTING.md](CONTRIBUTING.md), and- Overlays must not steal focus. Input-delivery changes must account for targetwindows, shortcut release timing, focus changes, and original-text recovery,avoiding duplicate delivery or input into the wrong window.-- English is the default UI language. Provide Chinese translations alongside new+- The macOS UI follows system language preferences by default; Linux defaults to English. Provide Chinese translations alongside newEnglish strings. Check both languages, long text, truncation, state transitions,and reduced-motion behavior when changing animations.- Do not expose real transcripts, cookies, tokens, API keys, or device/accountdiff --git a/README.md b/README.mdindex b788f09..767ac25 100644--- a/README.md+++ b/README.md@@ -19,6 +19,10 @@ Seed ASR 2.0 API or Deepgram Nova-3 for English dictation. English by default. Suses Simplified Chinese for Chinese locales, and falls back to English otherwise.Optional Omarchy integration manages the **same application**, not another engine.+## Mac input behavior++The interface follows the system language by default, preserving existing explicit choices. Automatic input uses clipboard paste for web editors (including Electron), and direct accessibility input for supported native fields. Escape cancels recording, transcription, polishing or pending input and dismisses the overlay; you can record again immediately. Text already entered is not undone.+## Get startedUse the application or Omarchy plugin archive in `dist/`. Archives include andiff --git a/README.zh-CN.md b/README.zh-CN.mdindex 0a5fae1..0119878 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -14,6 +14,10 @@ macOS 在快捷键释放后向当前光标输入文字。剪贴板粘贴不要System 读取桌面会话的语言偏好,中文区域使用简体中文,其他不支持的语言回退为英文。可选的 Omarchy 集成管理的是**同一个应用**,不是另一套语音引擎。+## Mac 输入行为++界面默认跟随系统语言,保留已有的手动选择。自动输入对网页编辑器(含 Electron)使用剪贴板粘贴,对支持的原生输入框使用辅助功能直接写入。Esc 取消录音、转写、润色或待输入任务并关闭浮窗,随后可立即重新录制;已输入的文字不会撤回。+## 安装和首次使用使用 `dist/` 中的应用或 Omarchy 插件安装包,内含离线安装器及 Python 依赖 wheel,diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 9da5b22..c847fe8 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -1,15 +1,21 @@-# Doubao Say 1.8.1+# Doubao Say 1.8.2-## Dictation and setup+## macOS dictation-On macOS, final polishing starts while recognition finishes. Revised recognition text invalidates stale polishing, and delivery still waits for the final recognition result. Returning users open General settings after completing onboarding; restarting or upgrading preserves that completion.+- Follow the system language by default. Existing explicit language choices remain in effect.+- Paste into web editors, including Electron applications such as Vibelet, in automatic input mode. This fixes text disappearing when an accessibility write reports success without changing the field. Supported native fields can still use direct input.+- Press Escape to cancel recording, transcription, polishing or pending input and close the overlay. Start a new recording immediately; late results from the cancelled session cannot enter text. Text already entered is not undone.+- Resolve the input destination at the current cursor after shortcut release, with clipboard fallback for custom editors.+- Keep recognition-service errors visible with actionable feedback, including capacity and rate-limit errors.-On Linux, the polishing page keeps model and API settings beside the endpoint test and its feedback. Detailed model guidance is expandable. Disabling polishing collapses API and ChatGPT service controls without discarding their configuration. Arch and Omarchy source installation now includes the required JWT and cryptography packages.+## Polishing++Improve contextual action-word corrections and reduce unnecessary Qwen thinking latency.## Downloads and verification-Developer ID signed, Apple-notarized DMGs are provided for Apple Silicon and Intel. Linux app and plugin archives support Python 3.11–3.14. SHA256SUMS and update.json cover the release packages.+Developer ID signed, Apple-notarized DMGs are provided for Apple Silicon and Intel. Linux application and plugin archives support Python 3.11–3.14. SHA256SUMS and update.json cover the release packages.-Native desktop regression suites cover settings, shortcuts, microphone-check gating, synthetic dictation delivery and cancellation. CI Summary tables include a screenshot and an exact report-step link for each case. Synthetic checks do not establish real microphone/ASR quality, physical-hotkey behavior, accessibility permission retention, clipboard behavior in every receiving application or Intel hardware acceptance.+Regression coverage includes language defaults, native/web input routing, Escape key repeats and releases, cancellation in five active phases, immediate restart, and stale-callback isolation. The web-editor fix was reproduced and checked in Vibelet on Apple Silicon. Automated checks do not establish microphone/ASR quality, compatibility with every editor, or Intel hardware acceptance.-[Full changes](https://github.com/quanru/doubao-say/compare/v1.8.0...v1.8.1)+[Full changes](https://github.com/quanru/doubao-say/compare/v1.8.1...v1.8.2)diff --git a/debian/changelog b/debian/changelogindex 197fe4f..a0f20ed 100644--- a/debian/changelog+++ b/debian/changelog@@ -1,3 +1,10 @@+doubao-say (1.8.2-1) noble; urgency=medium++ * Improve macOS language defaults, web-editor delivery and Escape cancellation.+ * Improve recognition error feedback and contextual polishing.++ -- quanru <[email protected]> Sat, 31 Oct 2026 21:00:00 +0800+doubao-say (1.8.1-1) noble; urgency=medium* Fix Arch source dependencies and simplify polishing settings.diff --git a/macos/README.zh-CN.md b/macos/README.zh-CN.mdindex 9976dc4..c337fc2 100644--- a/macos/README.zh-CN.md+++ b/macos/README.zh-CN.md@@ -1,6 +1,6 @@# 豆包说 macOS-独立的 Swift 菜单栏应用,要求 macOS 13 及以上。界面默认英文,可选择简体中文或跟随系统。Mac 版提供与 Linux 版对应的识别服务、润色、录音手势、设置与文字恢复功能;权限、设备和输入接口使用 macOS 原生实现。逐项范围与验收边界见 [功能对照](PARITY.zh-CN.md)。已提供 Developer ID 签名、Apple 公证的发行安装包。+独立的 Swift 菜单栏应用,要求 macOS 13 及以上。界面默认跟随系统语言,也可手动选择简体中文或英文;已有的语言选择保持不变。Mac 版提供与 Linux 版对应的识别服务、润色、录音手势、设置与文字恢复功能;权限、设备和输入接口使用 macOS 原生实现。逐项范围与验收边界见 [功能对照](PARITY.zh-CN.md)。已提供 Developer ID 签名、Apple 公证的发行安装包。## 构建与运行@@ -45,11 +45,11 @@ ChatGPT 凭据使用本应用独立的 macOS 钥匙串条目,不借用 Codex## 文字恢复与隐私-“最近文字”只保留一条内存文字,可编辑、复制、清除,或点击“三秒后重试”并切换到目标输入框。倒计时和输入完成前不能重复重试,也不响应新的听写或独立回车;重试倒计时可按 `Esc` 取消,输入操作可从菜单选择“取消输入”。重试不发送回车。关闭“自动粘贴”后每次手动复制。识别或音频中断时保留部分文字,不自动输入。+“最近文字”只保留一条内存文字,可编辑、复制、清除,或点击“三秒后重试”并切换到目标输入框。倒计时和输入完成前不能重复重试,也不响应新的听写或独立回车;重试倒计时和待输入操作均可按 `Esc` 或从菜单选择“取消输入”。重试不发送回车。关闭“自动粘贴”后每次手动复制。识别或音频中断时保留部分文字,不自动输入。-输入前核对前台进程和原辅助功能输入元素,并等待快捷键修饰键松开。模拟快捷键在松开时释放修饰键标记,避免粘贴后系统继续报告 Command 被按住。密码框不自动输入。输入目标变化或直接输入不可用时,文字保留在软件内。剪贴板方式会用识别结果替换剪贴板内容,并在发送粘贴后保留这段文字,避免目标应用延迟读取时拿到旧内容;也可手动再次粘贴。粘贴发出前中止时,仅在剪贴板尚未被其他操作改写的情况下恢复原内容。输入和回车前分别检查目标,但系统事件仍存在短暂竞争窗口,需要完全手动控制时关闭自动粘贴。+输入前等待快捷键修饰键松开,再读取当前光标所在的输入目标。模拟快捷键在松开时释放修饰键标记,避免粘贴后系统继续报告 Command 被按住。密码框不自动输入。直接输入不可用时,文字保留在软件内。剪贴板方式会用识别结果替换剪贴板内容,并在发送粘贴后保留这段文字,避免目标应用延迟读取时拿到旧内容;也可手动再次粘贴。粘贴发出前中止时,仅在剪贴板尚未被其他操作改写的情况下恢复原内容。粘贴跟随当前光标,额外发送回车前会核对目标;需要完全手动控制时关闭自动粘贴。-新配置默认使用“自动选择”:根据目标输入框的能力选择方式,支持辅助功能文字插入时直接写入,否则使用剪贴板;不按应用名称区别处理。已有配置保留原来的选择,手动选择剪贴板或直接输入时严格使用该方式。直接写入失败后保留文字,不自动再次粘贴,以免重复输入。输入前等待录音快捷键释放(包括 Fn),并检查目标输入框是否仍一致。输入失败时浮窗保留文字和具体原因,可从菜单选择“三秒后重试输入”;成功后清除失败提示。+新配置默认使用“自动选择”:根据目标输入框的能力选择方式,原生输入框支持辅助功能文字插入时直接写入;网页输入框(包括 Electron 编辑器)及无法确认类型的输入框使用剪贴板,确保触发正常的粘贴事件。不按应用名称区别处理。已有配置保留原来的选择,手动选择剪贴板或直接输入时严格使用该方式。直接写入失败后保留文字,不自动再次粘贴,以免重复输入。输入前等待录音快捷键释放(包括 Fn),再选择当前输入目标。输入失败时浮窗保留文字和具体原因,可从菜单选择“三秒后重试输入”;成功后清除失败提示。刚切换应用时,若系统暂时无法提供输入框焦点,或只返回窗口本身,但已能确定前台应用和窗口,会在 500 毫秒内每隔 50 毫秒重新读取焦点。期间切换应用、窗口或取消录音会终止恢复;已取得的输入框不会被替换。明确聚焦在非输入控件上或无法确定原窗口时不重试。“复制诊断信息”会记录焦点是否恢复、超时或发生变化,不包含输入文字。diff --git a/macos/Sources/DoubaoSayApp.swift b/macos/Sources/DoubaoSayApp.swiftindex 4d80f2d..5d104d4 100644--- a/macos/Sources/DoubaoSayApp.swift+++ b/macos/Sources/DoubaoSayApp.swift@@ -132,7 +132,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {let value = language.rawValuelet item = NSMenuItem(title: language.name, action: #selector(setLanguage(_:)), keyEquivalent: "")item.target = self; item.representedObject = value- item.state = (UserDefaults.standard.string(forKey: "language") ?? "en") == value ? .on : .off+ item.state = (UserDefaults.standard.string(forKey: "language") ?? "system") == value ? .on : .offsubmenu.addItem(item)}language.submenu = submenu@@ -326,8 +326,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {Configure your recognition service, then enable the microphone and global shortcut.Focus an input field before recording.Your configured shortcut: tap to start, hold to talk; double-tap sends Enter while idle.- During voice input, any key stops and inputs text; the key itself is blocked, including Escape and Enter.- Outside voice input, Escape dismisses kept text or cancels retry. Maximum recording: 60 seconds.+ Escape cancels recording, transcription, polishing or pending input and closes the overlay without submitting text.+ Other keys finish voice input; the key itself is blocked. Escape also dismisses kept text or cancels retry. Maximum recording: 60 seconds.If the input target changes, use Copy last result from this menu.Dictation audio is sent to your selected service without saving local audio files.Speech evaluation recordings are saved locally until you delete them; running a comparison uploads them.@@ -337,8 +337,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {配置识别服务,并启用麦克风和全局快捷键权限。录音前将光标放到输入框。使用你配置的快捷键:短按开始录音,长按说话;空闲时双击发送回车。- 语音输入期间,任意按键都结束并上屏,按键本身被拦截,包括 Esc 和回车。- 非语音输入状态下,Esc 可关闭保留文字或取消重试。单次最多录音 60 秒。+ Esc 取消录音、转写、润色或待输入任务,关闭浮窗,不提交文字。+ 其他按键结束并上屏,按键本身被拦截。Esc 也可关闭保留文字或取消重试。单次最多录音 60 秒。输入目标变化时,请从菜单复制最近结果。普通听写音频发送至所选识别服务,不保存本地录音文件。语音评测录音会保存在本机,直到手动删除;开始对比时才上传。diff --git a/macos/Sources/HotkeyManager.swift b/macos/Sources/HotkeyManager.swiftindex 620947f..9f33568 100644--- a/macos/Sources/HotkeyManager.swift+++ b/macos/Sources/HotkeyManager.swift@@ -145,21 +145,21 @@ final class HotkeyManager {}let physicalCode = UInt16(event.getIntegerValueField(.keyboardEventKeycode))let modifierPressed = type == .flagsChanged && Self.modifierPressed(physicalCode, flags: event.flags)+ // Escape always cancels before the generic finish-on-key path, even+ // while another swallowed key is waiting for release.+ if code == 53 && type == .keyDown && (active || interceptingInput || shortcutDown || gesture.isPending || blockedKeys.contains(physicalCode)) {+ if blockedKeys.insert(physicalCode).inserted {+ resetGesture()+ onHotkeyEvent?(.cancel)+ }+ return nil+ }if type == .flagsChanged && !modifierPressed, withheldTriggerModifiers.remove(physicalCode) != nil {if shortcutDown { shortcutDown = false; emit(gesture.up(at: ProcessInfo.processInfo.systemUptime)) }return nil}if type == .keyUp, blockedKeys.remove(physicalCode) != nil { return nil }if type == .flagsChanged && !modifierPressed, blockedModifiers.remove(physicalCode) != nil { return nil }- // Cancellation takes priority over the generic finish-on-any-key rule,- // including while ASR or polishing is still pending. Retain the key until- // release so neither repeats nor key-up escape into the target app.- if code == 53 && type == .keyDown && (active || shortcutDown || gesture.isPending) {- if blockedKeys.insert(physicalCode).inserted {- resetGesture(); onHotkeyEvent?(.cancel)- }- return nil- }let draining = !blockedKeys.isEmpty || !blockedModifiers.isEmptyif type.rawValue == 14, let media = NSEvent(cgEvent: event), media.subtype.rawValue == 8 {let mediaCode = UInt16(0x8000 | ((media.data1 >> 16) & 0x7fff))diff --git a/macos/Sources/PasteHelper.swift b/macos/Sources/PasteHelper.swiftindex 7bcc7dc..ab2a933 100644--- a/macos/Sources/PasteHelper.swift+++ b/macos/Sources/PasteHelper.swift@@ -64,6 +64,22 @@ struct InputTarget {guard subrole as? String != kAXSecureTextFieldSubrole else { return nil }return InputTarget(pid: app.processIdentifier, element: element, cursorOnly: true, cursorScope: scope())}+ // Web editors can advertise writable AXSelectedText yet ignore the write or+ // fail to update their application state. Use a real paste event for them.+ var supportsAutomaticDirectInput: Bool {+ var current = element+ for _ in 0..<64 {+ var role: CFTypeRef?+ guard AXUIElementCopyAttributeValue(current, kAXRoleAttribute as CFString, &role) == .success else { return false }+ if role as? String == "AXWebArea" { return false }+ if role as? String == kAXApplicationRole { return true }+ var parent: CFTypeRef?+ guard AXUIElementCopyAttributeValue(current, kAXParentAttribute as CFString, &parent) == .success,+ let parent, CFGetTypeID(parent) == AXUIElementGetTypeID() else { return false }+ current = unsafeBitCast(parent, to: AXUIElement.self)+ }+ return false+ }func isCurrent() -> Bool {if cursorOnly {guard let current = Self.captureCursor() else { return false }@@ -99,9 +115,9 @@ final class PasteHelper {init(modifierFlags: @escaping () -> CGEventFlags = { CGEventSource.flagsState(.combinedSessionState) }) {self.modifierFlags = modifierFlags}- static func useAccessibilityInput(method: String, selectedTextWritable: Bool) -> Bool {+ static func useAccessibilityInput(method: String, selectedTextWritable: Bool, nativeField: Bool = true) -> Bool {if method == "direct" { return true }- return method == "auto" && selectedTextWritable+ return method == "auto" && selectedTextWritable && nativeField}func cancel() { generation = UUID() }func deliver(_ text: String, target _: InputTarget?, method: String = "auto", sendEnter: Bool = false, completion: @escaping (Bool) -> Void) {@@ -133,7 +149,8 @@ final class PasteHelper {var writable = DarwinBoolean(false)let writableStatus = AXUIElementIsAttributeSettable(target.element, kAXSelectedTextAttribute as CFString, &writable)if !target.cursorOnly && Self.useAccessibilityInput(method: method,- selectedTextWritable: writableStatus == .success && writable.boolValue) {+ selectedTextWritable: writableStatus == .success && writable.boolValue,+ nativeField: method == "auto" ? target.supportsAutomaticDirectInput : true) {let status = AXUIElementSetAttributeValue(target.element, kAXSelectedTextAttribute as CFString, text as CFString)self.diagnostic = "method=\(method); route=accessibility; AXStatus=\(status.rawValue)"guard status == .success else { fail(.directUnavailable); return }diff --git a/macos/Sources/SettingsWindow.swift b/macos/Sources/SettingsWindow.swiftindex b54dce3..0aa606b 100644--- a/macos/Sources/SettingsWindow.swift+++ b/macos/Sources/SettingsWindow.swift@@ -7,7 +7,7 @@ struct SettingsView: View {@ObservedObject var state: AppState@State private var showingAppearance = false@FocusState private var sidebarFocus: String?- @AppStorage("language") private var language = "en"+ @AppStorage("language") private var language = "system"private var pages: [(String, String, String)] { [("setup", L("Setup", "使用准备"), "checkmark.circle"),("recognition", L("Recognition", "识别服务"), "waveform"),@@ -197,7 +197,7 @@ struct SettingsView: View {HStack { Text(model.draft.shortcut.label); Button(L("Choose shortcut", "选择快捷键")) { model.chooseShortcut() } }.disabled(model.setupBusy)Label(model.shortcutAvailable ? L("Shortcut ready", "快捷键已就绪") : L("Shortcut permission required", "请启用快捷键权限"), systemImage: model.shortcutAvailable ? "checkmark.circle.fill" : "circle").foregroundColor(model.shortcutAvailable ? .green : .secondary)- Text(L("Tap to start; hold to talk. During voice input, any key stops and inputs text.", "短按开始,长按说话;语音输入期间,任意按键都结束并上屏。"))+ Text(L("Tap to start; hold to talk. Escape cancels without input; other keys finish and input text.", "短按开始,长按说话;Esc 取消且不上屏,其他按键结束并上屏。"))}.formStyle(.grouped).padding(8)default:Form {@@ -254,7 +254,7 @@ struct SettingsView: View {ScrollView {VStack(alignment: .leading, spacing: 14) {HStack { Text(L("Dictation: ", "听写:") + model.draft.shortcut.label); Button(L("Choose shortcut", "选择快捷键")) { model.chooseShortcut() } }- Text(L("Tap to start; hold to talk. Any key finishes voice input without its original action. Double-tap sends Enter while idle.", "短按开始录音,长按说话。语音输入期间任意按键都结束上屏,不执行原按键动作;空闲时双击发送回车。"))+ Text(L("Tap to start; hold to talk. Escape cancels and closes the overlay; other keys finish voice input. Double-tap sends Enter while idle.", "短按开始录音,长按说话。Esc 取消并关闭浮窗,其他按键结束上屏;空闲时双击发送回车。"))Toggle(L("Double-tap sends Enter when idle", "空闲时双击发送回车"), isOn: $model.draft.doubleEnter)Stepper(L("Hold threshold: ", "长按阈值:") + "\(model.draft.holdMilliseconds) ms", value: $model.draft.holdMilliseconds, in: 200...1500, step: 50)Stepper(L("Double-tap interval: ", "双击间隔:") + "\(model.draft.doubleMilliseconds) ms", value: $model.draft.doubleMilliseconds, in: 150...600, step: 50)diff --git a/macos/Sources/Strings.swift b/macos/Sources/Strings.swiftindex 76d9d56..5cc3966 100644--- a/macos/Sources/Strings.swift+++ b/macos/Sources/Strings.swift@@ -9,20 +9,20 @@ enum UILanguage: String, CaseIterable {case .zh: return "简体中文"}}- static func resolve(_ selected: String, preferred: [String]) -> UILanguage {- if selected == "system" {+ static func resolve(_ selected: String?, preferred: [String]) -> UILanguage {+ if selected == nil || selected == "system" {for language in preferred {if language.hasPrefix("zh") { return .zh }if language.hasPrefix("en") { return .en }}return .en}- if selected.hasPrefix("zh") { return .zh }+ if selected?.hasPrefix("zh") == true { return .zh }return .en}}func L(_ english: String, _ chinese: String) -> String {- let language = UserDefaults.standard.string(forKey: "language") ?? "en"+ let language = UserDefaults.standard.string(forKey: "language")return UILanguage.resolve(language, preferred: Locale.preferredLanguages) == .zh ? chinese : english}diff --git a/macos/Tests/CoreTests.swift b/macos/Tests/CoreTests.swiftindex 4856af3..90e2094 100644--- a/macos/Tests/CoreTests.swift+++ b/macos/Tests/CoreTests.swift@@ -47,6 +47,14 @@ final class CoreTests: XCTestCase {}final class LanguageTests: XCTestCase {+ func testMissingLanguageFollowsSystemPreferences() {+ XCTAssertEqual(UILanguage.resolve(nil, preferred: ["zh-Hans-CN", "en-US"]), .zh)+ XCTAssertEqual(UILanguage.resolve(nil, preferred: ["fr-FR", "zh-Hant-TW"]), .zh)+ XCTAssertEqual(UILanguage.resolve(nil, preferred: ["en-US", "zh-CN"]), .en)+ XCTAssertEqual(UILanguage.resolve(nil, preferred: ["fr-FR"]), .en)+ XCTAssertEqual(UILanguage.resolve(nil, preferred: []), .en)+ }+func testSystemLanguageUsesFirstSupportedPreference() {XCTAssertEqual(UILanguage.resolve("system", preferred: ["fr-FR", "zh-Hans-CN", "en-US"]), .zh)XCTAssertEqual(UILanguage.resolve("system", preferred: ["en-GB", "zh-CN"]), .en)diff --git a/macos/Tests/Input/DeliveryCheck.swift b/macos/Tests/Input/DeliveryCheck.swiftindex 156c0ab..748130f 100644--- a/macos/Tests/Input/DeliveryCheck.swift+++ b/macos/Tests/Input/DeliveryCheck.swift@@ -4,6 +4,7 @@ import ApplicationServices// Test the production delivery implementation with inert platform boundaries.enum Fixture {static var trusted = true, current = true, writable = true, cursorAvailable = true, fieldAvailable = true+ static var nativeField = truestatic var writeStatus = AXError.successstatic var writes: [String] = []}@@ -21,6 +22,7 @@ struct InputTarget {var cursorOnly = falsestatic func capture() -> InputTarget? { Fixture.fieldAvailable ? InputTarget() : nil }static func captureCursor() -> InputTarget? { Fixture.cursorAvailable ? InputTarget(cursorOnly: true) : nil }+ var supportsAutomaticDirectInput: Bool { Fixture.nativeField }func isCurrent() -> Bool { Fixture.current }}final class NSPasteboard {@@ -125,6 +127,17 @@ enum HotkeyManager {Fixture.current = truesend(nil); helper.cancel(); wait(0.4)precondition(result == nil && CGEvent.posted == posted + 4)+ Fixture.fieldAvailable = true+ Fixture.nativeField = false; Fixture.writes = []; result = nil+ let postedBeforeWeb = CGEvent.posted+ helper.deliver("web editor text", target: target, method: "auto") { result = $0 }+ wait(0.3)+ precondition(result == true && Fixture.writes.isEmpty && CGEvent.posted == postedBeforeWeb + 2,+ "Web editors must receive paste even when AXSelectedText claims to be writable")+ precondition(NSPasteboard.general.pastedTexts.last == "web editor text")+ result = nil+ helper.deliver("explicit direct", target: target, method: "direct") { result = $0 }+ precondition(result == true && Fixture.writes == ["explicit direct"], "Explicit direct choice must be preserved")print("PASS: capability-based delivery, explicit clipboard choice, permission/focus failures, Fn release, held-key timeout and cancellation; all platform effects are inert")}}diff --git a/macos/Tests/Input/KeyInterceptionCheck.swift b/macos/Tests/Input/KeyInterceptionCheck.swiftindex c1e1100..639dabf 100644--- a/macos/Tests/Input/KeyInterceptionCheck.swift+++ b/macos/Tests/Input/KeyInterceptionCheck.swift@@ -97,6 +97,34 @@ import AppKitmanager.setEscapeHandlingEnabled(false)precondition(manager.handle(mediaUp.type, mediaUp) == nil)precondition(manager.handle(mediaDown.type, mediaDown) != nil, "Media keys must resume when idle")+ for recording in [true, false] {+ let escape = HotkeyManager()+ var cancels = 0, finishes = 0, primes = 0+ escape.onHotkeyEvent = {+ switch $0 {+ case .cancel: cancels += 1; escape.setEscapeHandlingEnabled(false)+ case .stop, .enter: finishes += 1+ case .prime: primes += 1+ default: break+ }+ }+ escape.setEscapeHandlingEnabled(true, recording: recording, interceptKeys: true)+ precondition(escape.handle(.keyDown, key(53, true)) == nil)+ precondition(cancels == 1 && finishes == 0, "Escape must cancel recording or finishing, never submit text")+ precondition(escape.handle(.keyDown, key(53, true)) == nil && cancels == 1, "Held Escape must not repeat cancellation")+ precondition(escape.handle(.keyUp, key(53, false)) == nil)+ precondition(escape.handle(.keyDown, key(49, true, flags: [.maskControl, .maskAlternate])) == nil && primes == 1,+ "The next recording shortcut must work immediately after Escape is released")+ precondition(escape.handle(.keyDown, key(53, true)) == nil && cancels == 2,+ "Escape must also cancel a pending trigger gesture")+ }+ let draining = HotkeyManager()+ var cancelsDuringDrain = 0+ draining.onHotkeyEvent = { if case .cancel = $0 { cancelsDuringDrain += 1 } }+ draining.setEscapeHandlingEnabled(true, recording: true)+ _ = draining.handle(.keyDown, key(0, true))+ _ = draining.handle(.keyDown, key(53, true))+ precondition(cancelsDuringDrain == 1, "Escape must cancel even while a finishing key is still held")print("PASS: recording keys, Escape/Enter, modifiers, shortcut chords, media keys, repeats, post-delivery releases and synthetic-output bypass; no event tap or real key posting")}}diff --git a/macos/Tests/Input/RetryCheck.swift b/macos/Tests/Input/RetryCheck.swiftindex f617f58..f4c3446 100644--- a/macos/Tests/Input/RetryCheck.swift+++ b/macos/Tests/Input/RetryCheck.swift@@ -58,7 +58,11 @@ final class HotkeyManager {func prepareFinal(text: String) {}func useOriginal() {}func cancel() {}- func finish(text: String, completion: @escaping (String, Bool) -> Void) { completion(text, false) }+ static var holdFinal = false+ static var pending: ((String, Bool) -> Void)?+ func finish(text: String, completion: @escaping (String, Bool) -> Void) {+ if Self.holdFinal { Self.pending = completion } else { completion(text, false) }+ }}protocol ASRTransport: AnyObject {var onOpen: (() -> Void)? { get set }; var onResult: ((String) -> Void)? { get set }@@ -68,11 +72,12 @@ protocol ASRTransport: AnyObject {}class DoubaoASRClient: ASRTransport {static var latest: DoubaoASRClient?+ static var openImmediately = trueinit() { Self.latest = self }var onOpen: (() -> Void)?; var onResult: ((String) -> Void)?; var onFinish: (() -> Void)?var onAudioDrained: (() -> Void)?; var onError: (() -> Void)?; var onAuthError: (() -> Void)?func sendAudio(_ data: Data) {}; func finishSending() {}; func disconnect() {}- func connect(params: Int) { onOpen?() }+ func connect(params: Int) { if Self.openImmediately { onOpen?() } }}final class APIASRClient: DoubaoASRClient {init(provider: RecognitionProvider) {}@@ -208,5 +213,34 @@ final class PersonalDataStore {precondition(recoveredState.inputDiagnostic.contains("capture=recovered"))recoveredManager.cancel()print("PASS: actual transcription controller preserves focus recovery across prime/start and reports its capture diagnostic; no real input")+ func pump() { RunLoop.current.run(until: Date().addingTimeInterval(0.08)) }+ for phase in ["starting", "recording", "stopping", "polishing", "delivery"] {+ DoubaoASRClient.openImmediately = phase != "starting"+ PolishCoordinator.holdFinal = phase == "polishing"+ PolishCoordinator.pending = nil+ let state = AppState(), overlay = OverlayPanel(), hotkey = HotkeyManager()+ let controller = TranscriptionManager(appState: state, overlayPanel: overlay, hotkeyManager: hotkey)+ controller.start(); hotkey.onHotkeyEvent?(.start); pump()+ let oldClient = DoubaoASRClient.latest!+ if phase != "starting" { oldClient.onResult?("cancelled utterance"); pump() }+ if ["stopping", "polishing", "delivery"].contains(phase) { hotkey.onHotkeyEvent?(.stop); pump() }+ if ["polishing", "delivery"].contains(phase) { oldClient.onFinish?(); pump() }+ precondition(phase == "delivery" ? state.inputPending : state.recordingState != .idle)+ let lateResult = oldClient.onResult, lateFinish = oldClient.onFinish+ let latePolish = PolishCoordinator.pending, lateDelivery = PasteHelper.pending+ let attempts = PasteHelper.events.count+ hotkey.onHotkeyEvent?(.cancel); pump()+ precondition(state.recordingState == .idle && !state.inputPending && !overlay.isVisible && state.transcriptionText.isEmpty,+ "Escape cancellation must reset every active phase and dismiss the overlay: \(phase)")+ DoubaoASRClient.openImmediately = true+ hotkey.onHotkeyEvent?(.start); pump()+ precondition(state.isRecording, "A fresh recording must start immediately after cancellation")+ lateResult?("stale text"); lateFinish?(); latePolish?("stale polish", true); lateDelivery?(false); pump()+ precondition(state.isRecording && state.transcriptionText.isEmpty && PasteHelper.events.count == attempts,+ "Cancelled callbacks must not deliver text or disturb the new recording: \(phase)")+ controller.cancel()+ }+ print("PASS: cancel during starting, recording, stopping, polishing and delivery; immediate restart and stale callback isolation")+}}diff --git a/macos/Tests/Settings/AutoSaveCheck.swift b/macos/Tests/Settings/AutoSaveCheck.swiftindex 53249d3..341400c 100644--- a/macos/Tests/Settings/AutoSaveCheck.swift+++ b/macos/Tests/Settings/AutoSaveCheck.swift@@ -5,6 +5,8 @@ struct AutoSaveCheck {@MainActor static func main() {precondition(PasteHelper.useAccessibilityInput(method: "auto", selectedTextWritable: true))precondition(!PasteHelper.useAccessibilityInput(method: "auto", selectedTextWritable: false))+ precondition(!PasteHelper.useAccessibilityInput(method: "auto", selectedTextWritable: true, nativeField: false))+ precondition(PasteHelper.useAccessibilityInput(method: "direct", selectedTextWritable: true, nativeField: false))precondition(!PasteHelper.useAccessibilityInput(method: "clipboard", selectedTextWritable: true),"Explicit clipboard selection must be respected even for writable fields")precondition(PasteHelper.useAccessibilityInput(method: "direct", selectedTextWritable: false))diff --git a/manifest.json b/manifest.jsonindex 7908fd8..b45b78a 100644--- a/manifest.json+++ b/manifest.json@@ -2,7 +2,7 @@"schemaVersion": 1,"id": "md.lifeos.doubao-say","name": "Doubao Say",- "version": "1.8.1",+ "version": "1.8.2","author": "quanru and contributors","description": "Doubao Say turns speech into polished text with live captions and configurable tap or hold triggers on Wayland.","kinds": [diff --git a/packaging/INSTALL.md b/packaging/INSTALL.mdindex c00f9f7..50730f8 100644--- a/packaging/INSTALL.md+++ b/packaging/INSTALL.md@@ -1,4 +1,4 @@-# Doubao Say 1.8.1+# Doubao Say 1.8.2[Website](https://doubao-say.lifeos.md/) · [简体中文安装指南](https://doubao-say.lifeos.md/zh/guide/install)diff --git a/packaging/runtime-requirements.txt b/packaging/runtime-requirements.txtindex 83ef9a9..bb67945 100644--- a/packaging/runtime-requirements.txt+++ b/packaging/runtime-requirements.txt@@ -1,4 +1,4 @@-# Complete Python dependency set for the 1.8.1 release.+# Complete Python dependency set for the 1.8.2 release.PyJWT[crypto]==2.15.1cryptography==50.0.2websockets==17.1diff --git a/pyproject.toml b/pyproject.tomlindex d8944a6..21c3b83 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "doubao-say"-version = "1.8.1"+version = "1.8.2"description = "Global push-to-hold voice input for Linux/Wayland, backed by Doubao ASR"readme = "README.md"requires-python = ">=3.11"diff --git a/src/doubao_input/product.py b/src/doubao_input/product.pyindex c5cabac..f2f9616 100644--- a/src/doubao_input/product.py+++ b/src/doubao_input/product.py@@ -1,6 +1,6 @@"""Single runtime source for Doubao Say release identity."""-VERSION = "1.8.1"+VERSION = "1.8.2"REPOSITORY_URL = "https://github.com/quanru/doubao-say"LATEST_RELEASE_API = "https://api.github.com/repos/quanru/doubao-say/releases/latest"LATEST_RELEASE_FEED = REPOSITORY_URL + "/releases/latest/download/update.json"diff --git a/tests/contracts/test_release.py b/tests/contracts/test_release.pyindex dab45a4..b158eb3 100644--- a/tests/contracts/test_release.py+++ b/tests/contracts/test_release.py@@ -50,7 +50,7 @@ class ReleaseTest(unittest.TestCase):notes = (ROOT / "RELEASE_NOTES.md").read_text()self.assertIn("--notes-file RELEASE_NOTES.md", workflow)self.assertNotIn("--generate-notes", workflow)- for expected in ("Doubao Say 1.8.1", "ChatGPT", "accessibility", "clipboard", "microphone"):+ for expected in ("Doubao Say 1.8.2", "Escape", "accessibility", "clipboard", "microphone"):self.assertIn(expected, " ".join(notes.split()))def test_both_archives_exclude_ignored_source_files(self):diff --git a/tests/contracts/test_version_check.py b/tests/contracts/test_version_check.pyindex b9051ce..5f7adac 100644--- a/tests/contracts/test_version_check.py+++ b/tests/contracts/test_version_check.py@@ -11,13 +11,13 @@ SPEC.loader.exec_module(VERSION_CHECK)class VersionCheckTests(unittest.TestCase):def test_sources_are_aligned_at_current_release(self):- self.assertEqual(VERSION_CHECK.validate(root=ROOT), "1.8.1")+ self.assertEqual(VERSION_CHECK.validate(root=ROOT), "1.8.2")def test_exact_release_tag_is_accepted(self):- self.assertEqual(VERSION_CHECK.validate("v1.8.1", ROOT), "1.8.1")+ self.assertEqual(VERSION_CHECK.validate("v1.8.2", ROOT), "1.8.2")def test_wrong_release_tag_is_rejected(self):- with self.assertRaisesRegex(ValueError, "must be 'v1.8.1'"):+ with self.assertRaisesRegex(ValueError, "must be 'v1.8.2'"):VERSION_CHECK.validate("v1.1.0", ROOT)diff --git a/tests/unit/test_product.py b/tests/unit/test_product.pyindex 6f287a8..1409359 100644--- a/tests/unit/test_product.py+++ b/tests/unit/test_product.py@@ -51,7 +51,7 @@ class ProductTest(TestCase):self.assertNotIn("private-device-identifier", data)self.assertNotIn("cookies", data)self.assertNotIn("transcript", data)- self.assertEqual(json.loads(data)["product_version"], "1.8.1")+ self.assertEqual(json.loads(data)["product_version"], "1.8.2")self.assertEqual(json.loads(data)["recognition_provider"], "volcengine")self.assertEqual(json.loads(data)["recent_stages"], [{"stage": "first_result", "after_ms": 125}])