{"record":{"id":"7372de49dea92470","repo":"tonhowtf/omniget","slug":"digitar","errorCode":null,"errorMessage":"digitar: {}","messagePattern":"digitar: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/dictation.rs","lineNumber":367,"sourceCode":"                Some(e.to_string()),\n            );\n            Err(e)\n        }\n    }\n}\n\npub fn is_recording() -> bool {\n    REC.lock().unwrap_or_else(|e| e.into_inner()).is_some()\n}\n\n/// Digita o texto onde o cursor estiver.\npub fn type_text(text: &str) -> anyhow::Result<()> {\n    use enigo::{Enigo, Keyboard, Settings};\n    let mut enigo = Enigo::new(&Settings::default())\n        .map_err(|e| anyhow!(\"teclado: {} (macOS: permissao de Acessibilidade)\", e))?;\n    // Um instante para o usuário soltar o atalho antes de digitar.\n    std::thread::sleep(std::time::Duration::from_millis(150));\n    enigo.text(text).map_err(|e| anyhow!(\"digitar: {}\", e))?;\n    Ok(())\n}\n\n/// Cmd+V / Ctrl+V (o app coloca o texto na área de transferência antes).\npub fn press_paste() -> anyhow::Result<()> {\n    use enigo::{Direction, Enigo, Key, Keyboard, Settings};\n    let mut enigo = Enigo::new(&Settings::default()).map_err(|e| anyhow!(\"teclado: {}\", e))?;\n    std::thread::sleep(std::time::Duration::from_millis(150));\n    let modifier = if cfg!(target_os = \"macos\") {\n        Key::Meta\n    } else {\n        Key::Control\n    };\n    enigo\n        .key(modifier, Direction::Press)\n        .map_err(|e| anyhow!(\"{}\", e))?;\n    enigo\n        .key(Key::Unicode('v'), Direction::Click)","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/dictation.rs#L349-L385","documentation":"Wrapper error in type_text: an enigo text-typing step failed — commonly because the OS denied synthetic keyboard input (missing Accessibility permission on macOS) or the keyboard device could not be opened on this session.","triggerScenarios":"enigo.text() returns Err when synthesizing keystrokes for the given string — unsupported characters/layout issues or the injection backend failing at runtime after successful construction.","commonSituations":"Text contains characters the platform layout cannot produce; keyboard focus moved to a secure/privileged window that swallows synthetic input; macOS permission revoked mid-session; Wayland compositor rejects synthetic key events.","solutions":["Retry the typing once — transient backend failures often resolve on a second attempt.","Fall back to press_paste() (clipboard + Cmd/Ctrl+V), which avoids per-character synthesis.","Check that macOS Accessibility permission is still granted and the target window accepts synthetic input.","Sanitize or strip unsupported characters from the text before typing."],"exampleFix":"// before\nenigo.text(text).map_err(|e| anyhow!(\"digitar: {}\", e))?;\n// after\nif let Err(e) = enigo.text(text) {\n    clipboard::set_text(text)?;\n    press_paste()?; // fallback path\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// fall back to clipboard paste when typing fails\nif let Err(e) = dictation::type_text(text) {\n    clipboard::set_text(text)?;\n    dictation::press_paste()?;\n}","preventionTips":["Implement clipboard+paste as a built-in retry path for typing failures.","Strip characters not producible by the target keyboard layout.","Keep a short delay after hotkey release (the library already sleeps 150ms — keep it)."],"tags":["keyboard","enigo","dictation","input-injection"],"backgroundTag":"invalid-state-transition","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}