From 8914dbd0737899daf9fe4c0176427d403c9579af Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 28 Feb 2023 23:25:19 -0600 Subject: [PATCH] Fix creating GUI panels for unconfigured search, processor types Repro: 1. Open khoj server with `khoj` on first run 2. Install/enable Khoj Obsidian plugin (to configure khoj server) 3. Restart khoj server with `khoj` Bug: - Unconfigured processor and search_types are instantiated as None in self.current_config - While creating the desktop GUI, these null configs are attempted to be accessed as valid dictionaries for creating their GUI panels - This results in the null ref errors Fix: Use default config to create their GUI elements for unconfigured search and processor types Resolves #167 --- src/khoj/interface/desktop/main_window.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/khoj/interface/desktop/main_window.py b/src/khoj/interface/desktop/main_window.py index a6379682..d2ea4f58 100644 --- a/src/khoj/interface/desktop/main_window.py +++ b/src/khoj/interface/desktop/main_window.py @@ -58,13 +58,18 @@ class MainWindow(QtWidgets.QMainWindow): # Add Settings Panels for each Search Type to Configure Window Layout self.search_settings_panels = [] for search_type in SearchType: - current_content_config = self.current_config["content-type"].get(search_type, {}) + current_content_config = self.current_config["content-type"][search_type] or self.get_default_config( + search_type=search_type + ) self.search_settings_panels += [self.add_settings_panel(current_content_config, search_type)] # Add Conversation Processor Panel to Configure Screen self.processor_settings_panels = [] conversation_type = ProcessorType.Conversation - current_conversation_config = self.current_config["processor"].get(conversation_type, {}) + if self.current_config["processor"] and conversation_type in self.current_config["processor"]: + current_conversation_config = self.current_config["processor"][conversation_type] + else: + current_conversation_config = self.get_default_config(processor_type=conversation_type) self.processor_settings_panels += [self.add_processor_panel(current_conversation_config, conversation_type)] # Add Action Buttons Panel