{"record":{"id":"8cd45bb1bec188dc","repo":"cjpais/Handy","slug":"failed-to-create-version-item","errorCode":null,"errorMessage":"failed to create version item","messagePattern":"failed to create version item","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/tray.rs","lineNumber":214,"sourceCode":"            // Linux never sets the warning flag (Secure Input is macOS-only),\n            // but fall back to the normal icon just in case.\n            AppTheme::Colored => \"resources/handy.png\",\n        };\n    }\n    match (theme, state) {\n        // Dark theme uses light icons\n        (AppTheme::Dark, TrayIconState::Idle) => \"resources/tray_idle.png\",\n        (AppTheme::Dark, TrayIconState::Recording) => \"resources/tray_recording.png\",\n        (AppTheme::Dark, TrayIconState::Transcribing) => \"resources/tray_transcribing.png\",\n        // Light theme uses dark icons\n        (AppTheme::Light, TrayIconState::Idle) => \"resources/tray_idle_dark.png\",\n        (AppTheme::Light, TrayIconState::Recording) => \"resources/tray_recording_dark.png\",\n        (AppTheme::Light, TrayIconState::Transcribing) => \"resources/tray_transcribing_dark.png\",\n        // Colored theme uses pink icons (for Linux)\n        (AppTheme::Colored, TrayIconState::Idle) => \"resources/handy.png\",\n        (AppTheme::Colored, TrayIconState::Recording) => \"resources/recording.png\",\n        (AppTheme::Colored, TrayIconState::Transcribing) => \"resources/transcribing.png\",\n    }\n}\n\n/// Sets the recording state shown by the tray (icon + Cancel/model menu).\npub fn set_tray_state(app: &AppHandle, state: TrayIconState) {\n    sync_tray_with(app, |inner| inner.icon_state = state);\n}\n\n/// Re-syncs the tray after something other than the recording state changed\n/// (theme, Secure Input warning). The recording state itself is preserved.\npub fn refresh_tray_icon(app: &AppHandle) {\n    sync_tray(app);\n}\n\n/// Re-syncs the tray after something the menu depends on changed (model\n/// list/selection/loaded state, language, settings).\npub fn update_tray_menu(app: &AppHandle) {\n    sync_tray(app);\n}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/cjpais/Handy/blob/fbd4e15fa14a721c66c57006ae110428b9e255b3/src-tauri/src/tray.rs#L196-L232","documentation":"Panic when MenuItem::with_id fails to create the disabled 'version' information item for the tray menu. muda item creation is fallible; for this item (no accelerator, disabled) failure means the menu subsystem could not allocate the item — duplicated id, or tray rebuild racing app teardown so the app handle cannot service the request.","triggerScenarios":"Tray creation/refresh where MenuItem::with_id(app, \"version\", version_label, false, None) errors — id collision within the same menu, or rebuild during shutdown.","commonSituations":"Theme-change tray rebuilds racing quit; forks reusing the 'version' id for another item; running on a system where the tray/status-item host is going away mid-build.","solutions":["Keep 'version' unique within each menu build and centralize tray ids in one module","Debounce or skip tray rebuilds once shutdown has started","Convert expect to logged degradation (build the menu without the version line) if the item is non-essential"],"exampleFix":"// before\nlet version_i = MenuItem::with_id(app, \"version\", &version_label, false, None::<&str>)\n    .expect(\"failed to create version item\");\n\n// after — include ids in diagnostics when tray creation fails\nlet version_i = MenuItem::with_id(app, \"version\", &version_label, false, None::<&str>)\n    .unwrap_or_else(|e| panic!(\"failed to create version item (id='version'): {e}\"));","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let version_i = match MenuItem::with_id(app, \"version\", &version_label, false, None::<&str>) {\n    Ok(item) => Some(item),\n    Err(e) => {\n        log::warn!(\"version tray item skipped: {e}\");\n        None\n    }\n};","preventionTips":["Keep tray ids unique per menu build and define them in one place","Cancel pending tray rebuilds at shutdown","Degrade to a menu without informational items rather than aborting"],"tags":["rust","tauri","tray","muda","menu"],"backgroundTag":"tray-menu-item-creation-failed","analyzedSha":"fbd4e15fa14a721c66c57006ae110428b9e255b3","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}