{"record":{"id":"7b9ac41a5f1ff489","repo":"cjpais/Handy","slug":"failed-to-initialize-model-manager","errorCode":null,"errorMessage":"Failed to initialize model manager","messagePattern":"Failed to initialize model manager","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/src/lib.rs","lineNumber":196,"sourceCode":"            );\n            return true;\n        }\n    }\n\n    false\n}\n\nfn initialize_core_logic(app_handle: &AppHandle) {\n    // Note: Enigo (keyboard/mouse simulation) is NOT initialized here.\n    // The frontend is responsible for calling the `initialize_enigo` command\n    // after onboarding completes. This avoids triggering permission dialogs\n    // on macOS before the user is ready.\n\n    // Initialize the managers. The audio recorder receives the streaming router\n    // explicitly, so always-on microphone startup can wire live-preview frames\n    // even before Tauri state is populated.\n    let model_manager =\n        Arc::new(ModelManager::new(app_handle).expect(\"Failed to initialize model manager\"));\n    let transcription_manager = Arc::new(\n        TranscriptionManager::new(app_handle, model_manager.clone())\n            .expect(\"Failed to initialize transcription manager\"),\n    );\n    let recording_manager = Arc::new(\n        AudioRecordingManager::new(app_handle, transcription_manager.stream_router())\n            .expect(\"Failed to initialize recording manager\"),\n    );\n    let history_manager =\n        Arc::new(HistoryManager::new(app_handle).expect(\"Failed to initialize history manager\"));\n\n    // Initialize the transcribe-cpp native backend (logging + backend module\n    // registration) once, before any whisper model is loaded.\n    managers::transcription::init_transcribe_backend();\n\n    // Apply accelerator preferences before any model loads\n    managers::transcription::apply_accelerator_settings(app_handle);\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/cjpais/Handy/blob/ba10ce1943ef34e93c09494027fc0b9ced2e8a44/src-tauri/src/lib.rs#L178-L214","documentation":"Startup panic when ModelManager::new returns Err. The constructor resolves the app data dir via portable::app_data_dir(app_handle) (mapped to 'Failed to get app data dir: {e}' on failure) and then fs::create_dir_all on <app_data>/models — so real-world failures are path-resolution errors or filesystem errors (permission denied, read-only volume, disk full).","triggerScenarios":"initialize_core_logic at every normal app launch: app_data_dir errors (paths plugin cannot produce a directory) or create_dir_all on the models dir fails.","commonSituations":"App data dir on a full or read-only disk; ownership/ACL damage after copying data between machines; portable mode pointing at an unwritable path; endpoint protection blocking creation of a models directory.","solutions":["Check free space and write permissions on the app data dir (~/Library/Application Support/Handy, %APPDATA%, ~/.local/share)","If portable mode is active, point its data dir at a writable location","Repair ownership/ACLs on the app data directory","Include the underlying error ({e:#}) in the panic message so logs name the failing path"],"exampleFix":"// before\nlet model_manager =\n    Arc::new(ModelManager::new(app_handle).expect(\"Failed to initialize model manager\"));\n\n// after — the panic still names the root cause chain\nlet model_manager = Arc::new(ModelManager::new(app_handle).unwrap_or_else(|e| {\n    panic!(\"Failed to initialize model manager: {e:#}\")\n}));","handlingStrategy":"validation","validationCode":"// Probe the app data dir before heavy init at startup\nlet models_dir = crate::portable::app_data_dir(app_handle)?.join(\"models\");\nstd::fs::create_dir_all(&models_dir)?;\nlet probe = models_dir.join(\".write-probe\");\nstd::fs::write(&probe, b\"\")?;\nstd::fs::remove_file(&probe)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Probe writability of the app data dir during onboarding and show a fix-it screen rather than crashing at next launch","Keep portable-mode data paths user-configurable and validate them before restarting","Log the resolved app data dir at startup so a crash report can be correlated with a concrete location"],"tags":["rust","tauri","startup","filesystem","app-data","models"],"backgroundTag":"app-data-dir-unavailable","analyzedSha":"ba10ce1943ef34e93c09494027fc0b9ced2e8a44","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}