fix: allow recording outside protected fields

This commit is contained in:
Зарубин Филипп
2026-09-14 05:10:38 +03:00
parent 07aa70b379
commit 0fceb1ebbf
13 changed files with 5277 additions and 4808 deletions
+14 -4
View File
@@ -171,8 +171,8 @@ let dictationWarmUpWaitLimitSeconds: Double = 180
// MARK: - Отказ старта записи
/// Почему запись не стартует. `secureInputActive` — новый класс отказа:
/// в поле пароля синтетический ⌘V не дойдёт всё равно, честнее сказать сразу.
/// Почему запись не стартует. Защита относится к текущему полю, а не к
/// наличию фонового процесса с защищённым вводом клавиатуры.
enum DictationStartRefusal: String, Equatable {
case secureInputActive
case modelNotReady
@@ -180,6 +180,12 @@ enum DictationStartRefusal: String, Equatable {
case transcriptionInFlight
}
/// Неизвестное поле при активной системной защите не считается обычным.
func dictationInputIsProtected(secureInputActive: Bool,
focusedInputProtected: Bool?) -> Bool {
focusedInputProtected ?? secureInputActive
}
/// Отказать ли старту.
///
/// `modelWarming` отделяет «модель ещё грузится» от «модели нет». Разница
@@ -195,8 +201,12 @@ func dictationStartRefusal(modelReady: Bool,
isRecording: Bool,
isBusy: Bool,
secureInputActive: Bool,
modelWarming: Bool = false) -> DictationStartRefusal? {
if secureInputActive { return .secureInputActive }
modelWarming: Bool = false,
focusedInputProtected: Bool? = nil) -> DictationStartRefusal? {
if dictationInputIsProtected(secureInputActive: secureInputActive,
focusedInputProtected: focusedInputProtected) {
return .secureInputActive
}
if !modelReady, !modelWarming { return .modelNotReady }
if isRecording { return .alreadyRecording }
if isBusy { return .transcriptionInFlight }