{"record":{"id":"7adf534543b72b20","repo":"flxzt/rnote","slug":"no-active-tab-to-import-into","errorCode":null,"errorMessage":"No active tab to import into","messagePattern":"No active tab to import into","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/rnote-ui/src/appwindow/mod.rs","lineNumber":645,"sourceCode":"                            (false, Some(active_wrapper)) => (false, active_wrapper),\n                        };\n\n                    let (bytes, _) = input_file.load_bytes_future().await?;\n                    let widget_flags = wrapper\n                        .canvas()\n                        .load_in_rnote_bytes(bytes.to_vec(), input_file.path())\n                        .await?;\n                    if rnote_file_new_tab {\n                        self.append_wrapper_new_tab(&wrapper);\n                    }\n                    self.handle_widget_flags(widget_flags, &wrapper.canvas());\n                    true\n                }\n            }\n            FileType::VectorImageFile => {\n                let canvas = self\n                    .active_tab_wrapper()\n                    .ok_or_else(|| anyhow::anyhow!(\"No active tab to import into\"))?\n                    .canvas();\n                let (bytes, _) = input_file.load_bytes_future().await?;\n                canvas\n                    .load_in_vectorimage_bytes(bytes.to_vec(), target_pos, self.respect_borders())\n                    .await?;\n                true\n            }\n            FileType::BitmapImageFile => {\n                let canvas = self\n                    .active_tab_wrapper()\n                    .ok_or_else(|| anyhow::anyhow!(\"No active tab to import into\"))?\n                    .canvas();\n                let (bytes, _) = input_file.load_bytes_future().await?;\n                canvas\n                    .load_in_bitmapimage_bytes(bytes.to_vec(), target_pos, self.respect_borders())\n                    .await?;\n                true\n            }","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/appwindow/mod.rs#L627-L663","documentation":"Importing a vector image requires a canvas to load the bytes into. try_open_file fetches the currently active tab wrapper; when there is no active tab (no open document), active_tab_wrapper() is None and the error is thrown instead of importing.","triggerScenarios":"open_file_w_dialogs -> try_open_file with FileType::VectorImageFile while the appwindow has zero open tabs (all documents closed), so active_tab_wrapper() returns None.","commonSituations":"Double-clicking an SVG in a file manager when rnote opens with no document; dragging an image into the window after closing all tabs; scripted/CLI opens of images before any tab is created.","solutions":["Create a new empty tab/document when no tab exists before attempting the import (open a blank canvas then retry).","In the caller (open_file_w_dialogs), check active_tab_wrapper() first and open a new tab for the file instead of erroring.","Disable/route file-open actions when tabs list is empty, or show a dialog telling the user to open a document first."],"exampleFix":"// before\nlet canvas = self\n    .active_tab_wrapper()\n    .ok_or_else(|| anyhow::anyhow!(\"No active tab to import into\"))?\n    .canvas();\n// after\nif self.active_tab_wrapper().is_none() {\n    self.tabs_add_tab_default_pos(None); // open a fresh document\n}\nlet canvas = self.active_tab_wrapper().unwrap().canvas();","handlingStrategy":"fallback","validationCode":"// rust\nif appwindow.active_tab_wrapper().is_none() {\n    appwindow.tabs_add_tab_default_pos(None); // create a document before importing\n}","typeGuard":"fn has_active_tab(w: &RnAppWindow) -> bool { w.active_tab_wrapper().is_some() }","tryCatchPattern":"if let Err(e) = appwindow.try_open_file(&file, pos, new_tab).await {\n    if e.to_string().contains(\"No active tab\") {\n        appwindow.tabs_add_tab_default_pos(None);\n        appwindow.try_open_file(&file, pos, new_tab).await?;\n    } else { return Err(e); }\n}","preventionTips":["Open a default blank document at startup so a tab always exists","Disable import/open actions while the tabs model is empty","Before scripted imports, assert active_tab_wrapper().is_some()","Centralize 'ensure active tab' logic in one helper used by all import branches"],"tags":["gtk","ui-state","import"],"backgroundTag":"missing-required-argument","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}