diff --git a/src/app_controller.py b/src/app_controller.py index 9d7b48d..8394119 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -986,6 +986,8 @@ class AppController: self.rag_config = models.RAGConfig() self.rag_engine = rag_engine.RAGEngine(self.rag_config, self.active_project_root) + if self.rag_config.enabled and self.rag_engine.is_empty(): + self._rebuild_rag_index() from src.personas import PersonaManager self.persona_manager = PersonaManager(Path(self.active_project_path).parent if self.active_project_path else None) diff --git a/src/gui_2.py b/src/gui_2.py index 34ca5e0..30313b2 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -483,7 +483,23 @@ class App: except Exception as e: self.ai_status = f"error: {e}" imgui.end_menu() - + + # RAG status indicator + if self.controller.rag_config and self.controller.rag_config.enabled: + imgui.same_line() + status = self.controller.rag_status + if status == "indexing...": + color = vec4(100, 255, 100) + elif status == "error": + color = vec4(255, 100, 100) + else: + color = vec4(180, 180, 180) + imgui.text_colored(color, f"[RAG: {status}]") + if imgui.is_item_hovered(): + imgui.set_tooltip(f"RAG is enabled. Status: {status}. Click to rebuild index.") + if imgui.is_item_clicked(): + self.controller._rebuild_rag_index() + # Draw right-aligned window controls directly in the menu bar (Win32 only) if sys.platform == "win32": try: diff --git a/src/rag_engine.py b/src/rag_engine.py index ab09a4b..924ef88 100644 --- a/src/rag_engine.py +++ b/src/rag_engine.py @@ -80,6 +80,15 @@ class RAGEngine: else: raise ValueError(f"Unknown vector store provider: {vs_config.provider}") + def is_empty(self) -> bool: + if not self.config.enabled: + return True + if self.config.vector_store.provider == 'mock' or self.collection == "mock": + return True + if self.collection is None: + return True + return self.collection.count() == 0 + def add_documents(self, ids: List[str], texts: List[str], metadatas: Optional[List[Dict[str, Any]]] = None): if not self.config.enabled or self.collection == "mock": return