OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
unify config
phactafe9a59bafa0
diff --git a/src/tui/cli.py b/src/tui/cli.pyindex baccc4f8c..a2e4ea773 100644--- a/src/tui/cli.py+++ b/src/tui/cli.py@@ -2,6 +2,7 @@import asyncioimport getpass+import osimport signalimport sysimport webbrowser@@ -12,18 +13,11 @@ from rich.rule import Rulefrom rich.table import Tablefrom . import __version__+from .config_fields import CONFIG_SECTIONSfrom .managers.container_manager import ContainerManager, ServiceStatusfrom .managers.docling_manager import DoclingManagerfrom .managers.env_manager import EnvManagerfrom .utils.platform import PlatformDetector-from .utils.validation import (- validate_anthropic_api_key,- validate_documents_paths,- validate_ollama_endpoint,- validate_openai_api_key,- validate_url,- validate_watsonx_endpoint,-)console = Console()@@ -184,9 +178,10 @@ def _existing_config_menu(elif action == "stop":_stop_services_cli(container_manager, docling_manager)elif action == "open":- console.print("Opening http://localhost:3000 ...")+ frontend_url = f"http://localhost:{os.getenv('FRONTEND_PORT', '3000')}"+ console.print(f"Opening {frontend_url} ...")try:- webbrowser.open("http://localhost:3000")+ webbrowser.open(frontend_url)except Exception:passbreak@@ -206,7 +201,7 @@ def _setup_walkthrough(docling_manager: DoclingManager,):"""Orchestrate: collect config → save → optionally start services."""- _collect_essential_config(env_manager)+ _collect_config(env_manager, advanced=False)try:configure_advanced = input("Configure cloud connectors & advanced settings? [y/N]: ").strip().lower()@@ -215,7 +210,7 @@ def _setup_walkthrough(configure_advanced = "n"if configure_advanced == "y":- _collect_optional_config(env_manager)+ _collect_config(env_manager, advanced=True, advanced_only=True)if not _validate_and_save(env_manager):return@@ -235,164 +230,91 @@ def _setup_walkthrough(_start_services_cli(container_manager, docling_manager)console.print()- console.print("[bold green]OpenRAG is running at http://localhost:3000[/bold green]")+ frontend_url = f"http://localhost:{os.getenv('FRONTEND_PORT', '3000')}"+ console.print(f"[bold green]OpenRAG is running at {frontend_url}[/bold green]")try:- webbrowser.open("http://localhost:3000")+ webbrowser.open(frontend_url)except Exception:pass-def _collect_essential_config(env_manager: EnvManager):- """Collect OpenSearch password, Langflow password, AI keys, and docs path."""- config = env_manager.config-- # --- OpenSearch ---- console.print(Rule("OpenSearch"))- pw = _prompt_secret(- "Admin password (leave empty to auto-generate)",- default=config.opensearch_password,- )- if pw:- strength = _validate_password_strength(pw)- if strength is not None:- console.print(f" {strength}")- config.opensearch_password = pw- else:- config.opensearch_password = "" # Will be auto-generated by setup_secure_defaults-- # --- Langflow ---- console.print(Rule("Langflow"))- lf_pw = _prompt_secret(- "Admin password (leave empty for autologin)",- default=config.langflow_superuser_password,- )- config.langflow_superuser_password = lf_pw-- # --- AI Providers ---- console.print(Rule("AI Providers (all optional, Enter to skip)"))-- config.openai_api_key = _prompt_with_default(- "OpenAI API Key", config.openai_api_key, secret=True- )- config.anthropic_api_key = _prompt_with_default(- "Anthropic API Key", config.anthropic_api_key, secret=True- )- config.ollama_endpoint = _prompt_with_default(- "Ollama base URL", config.ollama_endpoint- )- config.watsonx_api_key = _prompt_with_default(- "watsonx API Key", config.watsonx_api_key, secret=True- )- if config.watsonx_api_key:- config.watsonx_endpoint = _prompt_with_default(- "watsonx endpoint URL", config.watsonx_endpoint- )- config.watsonx_project_id = _prompt_with_default(- "watsonx project ID", config.watsonx_project_id- )-- # --- Langfuse ---- console.print()- try:- use_langfuse = input("Configure Langfuse tracing? [y/N]: ").strip().lower()- except (EOFError, KeyboardInterrupt):- console.print()- use_langfuse = "n"-- if use_langfuse == "y":- config.langfuse_secret_key = _prompt_with_default(- "Langfuse secret key", config.langfuse_secret_key, secret=True- )- config.langfuse_public_key = _prompt_with_default(- "Langfuse public key", config.langfuse_public_key- )- config.langfuse_host = _prompt_with_default(- "Langfuse host URL", config.langfuse_host- )-- # --- Documents path ---- default_docs = config.openrag_documents_paths or "$HOME/.openrag/documents"- display_default = default_docs.replace("$HOME", str(Path.home()))- try:- docs_input = input(f" Documents path [{display_default}]: ").strip()- except (EOFError, KeyboardInterrupt):- console.print()- docs_input = ""-- if docs_input:- config.openrag_documents_paths = docs_input- # Keep the primary documents path in sync- first_path = docs_input.split(",")[0].strip()- config.openrag_documents_path = first_path- # else: keep existing default-+def _collect_config(+ env_manager: EnvManager,+ advanced: bool = False,+ advanced_only: bool = False,+):+ """Collect config by iterating CONFIG_SECTIONS.-def _collect_optional_config(env_manager: EnvManager):- """Collect OAuth, AWS, webhook, and advanced settings behind y/N gates."""+ Args:+ env_manager: The environment manager with config to populate.+ advanced: If True, include advanced sections/fields.+ advanced_only: If True, skip non-advanced sections (used for the+ second pass after user opts into advanced config).+ """config = env_manager.config- # --- Google OAuth ---- console.print(Rule("Google OAuth (optional)"))- try:- use_google = input("Configure Google OAuth? [y/N]: ").strip().lower()- except (EOFError, KeyboardInterrupt):- console.print()- use_google = "n"-- if use_google == "y":- config.google_oauth_client_id = _prompt_with_default(- "Google OAuth Client ID", config.google_oauth_client_id- )- config.google_oauth_client_secret = _prompt_with_default(- "Google OAuth Client Secret", config.google_oauth_client_secret, secret=True- )-- # --- Microsoft Graph OAuth ---- try:- use_ms = input("Configure Microsoft Graph OAuth? [y/N]: ").strip().lower()- except (EOFError, KeyboardInterrupt):- console.print()- use_ms = "n"-- if use_ms == "y":- config.microsoft_graph_oauth_client_id = _prompt_with_default(- "Microsoft Graph Client ID", config.microsoft_graph_oauth_client_id- )- config.microsoft_graph_oauth_client_secret = _prompt_with_default(- "Microsoft Graph Client Secret",- config.microsoft_graph_oauth_client_secret,- secret=True,- )-- # --- AWS ---- console.print(Rule("AWS (optional)"))- try:- use_aws = input("Configure AWS credentials? [y/N]: ").strip().lower()- except (EOFError, KeyboardInterrupt):- console.print()- use_aws = "n"-- if use_aws == "y":- config.aws_access_key_id = _prompt_with_default(- "AWS Access Key ID", config.aws_access_key_id- )- config.aws_secret_access_key = _prompt_with_default(- "AWS Secret Access Key", config.aws_secret_access_key, secret=True- )-- # --- Webhook ---- console.print(Rule("Advanced (optional)"))- config.webhook_base_url = _prompt_with_default(- "Webhook base URL", config.webhook_base_url- )- config.langflow_public_url = _prompt_with_default(- "Langflow public URL", config.langflow_public_url- )-- # --- OpenSearch advanced ---- config.opensearch_index_name = _prompt_with_default(- "OpenSearch index name", config.opensearch_index_name or "documents"- )+ for section in CONFIG_SECTIONS:+ # Skip advanced sections unless advanced mode is on+ if section.advanced and not advanced:+ continue+ # In advanced_only pass, skip non-advanced sections (already collected)+ if advanced_only and not section.advanced:+ # But still collect advanced fields within non-advanced sections+ has_advanced_fields = any(f.advanced for f in section.fields)+ if not has_advanced_fields:+ continue++ # Gate prompt for optional sections (e.g. "Configure Google OAuth? [y/N]")+ if section.gate_prompt:+ try:+ answer = input(f"{section.gate_prompt} [y/N]: ").strip().lower()+ except (EOFError, KeyboardInterrupt):+ console.print()+ answer = "n"+ if answer != "y":+ continue++ console.print(Rule(section.name))++ for field in section.fields:+ # Skip advanced fields unless advanced mode+ if field.advanced and not advanced:+ continue+ # In advanced_only pass within a non-advanced section, skip non-advanced fields+ if advanced_only and not section.advanced and not field.advanced:+ continue++ current = getattr(config, field.name, field.default) or ""++ # Prompt for the value+ if field.secret:+ value = _prompt_secret(+ f"{field.label} ({field.helper_text})" if field.helper_text else field.label,+ default=current,+ )+ else:+ value = _prompt_with_default(+ field.label,+ current or field.default,+ secret=False,+ )++ # Special handling: password strength check for opensearch_password+ if field.name == "opensearch_password" and value:+ strength = _validate_password_strength(value)+ if strength is not None:+ console.print(f" {strength}")++ # Special handling: sync documents path+ if field.name == "openrag_documents_paths" and value:+ first_path = value.split(",")[0].strip()+ config.openrag_documents_path = first_path++ # Run validator and warn (but don't block)+ if value and field.validator and not field.validator(value):+ console.print(f" [yellow]Warning: {field.validator_error}[/yellow]")++ setattr(config, field.name, value)def _validate_and_save(env_manager: EnvManager) -> bool:diff --git a/src/tui/config_fields.py b/src/tui/config_fields.pynew file mode 100644index 000000000..c13e2e126--- /dev/null+++ b/src/tui/config_fields.py@@ -0,0 +1,235 @@+"""Shared config field definitions for TUI and CLI wizard.++This is the single source of truth for all user-configurable fields.+Both the TUI config screen and the CLI wizard consume these definitions.+"""++from dataclasses import dataclass, field as dataclass_field+from typing import Callable, Optional++from .utils.validation import (+ validate_openai_api_key,+ validate_anthropic_api_key,+ validate_ollama_endpoint,+ validate_watsonx_endpoint,+)+++@dataclass+class ConfigField:+ """A single user-configurable field."""++ name: str # attribute name on EnvConfig+ env_var: str # environment variable name+ label: str # display label+ placeholder: str = ""+ default: str = ""+ secret: bool = False+ required: bool = False+ advanced: bool = False # only shown in full/advanced mode+ helper_text: str = ""+ validator: Optional[Callable[[str], bool]] = None+ validator_error: str = ""+++@dataclass+class ConfigSection:+ """A group of related config fields."""++ name: str # section header+ fields: list[ConfigField] = dataclass_field(default_factory=list)+ advanced: bool = False # entire section is advanced-only+ gate_prompt: str = "" # CLI y/N prompt to enter this section+++CONFIG_SECTIONS: list[ConfigSection] = [+ # ── OpenSearch ──────────────────────────────────────────────+ ConfigSection("OpenSearch", [+ ConfigField(+ "opensearch_password", "OPENSEARCH_PASSWORD", "Admin Password",+ placeholder="Auto-generated secure password",+ secret=True, required=True,+ helper_text="Validate your password here: https://lowe.github.io/tryzxcvbn/",+ ),+ ConfigField(+ "opensearch_username", "OPENSEARCH_USERNAME", "Admin Username",+ placeholder="admin", default="admin",+ helper_text="OpenSearch admin username (default: admin)",+ ),+ ConfigField(+ "opensearch_host", "OPENSEARCH_HOST", "Host",+ placeholder="opensearch", default="opensearch",+ helper_text="Override for remote OpenSearch instances (default: opensearch)",+ ),+ ConfigField(+ "opensearch_port", "OPENSEARCH_PORT", "Port",+ placeholder="9200", default="9200",+ helper_text="Override for remote OpenSearch instances (default: 9200)",+ ),+ ConfigField(+ "opensearch_data_path", "OPENSEARCH_DATA_PATH", "Data Path",+ placeholder="~/.openrag/data/opensearch-data",+ default="$HOME/.openrag/data/opensearch-data",+ helper_text="Directory to persist OpenSearch indices across upgrades",+ ),+ ConfigField(+ "opensearch_index_name", "OPENSEARCH_INDEX_NAME", "Index Name",+ placeholder="documents", default="documents",+ helper_text="Name of the index to use in OpenSearch",+ ),+ ]),++ # ── Langflow ────────────────────────────────────────────────+ ConfigSection("Langflow", [+ ConfigField(+ "langflow_superuser_password", "LANGFLOW_SUPERUSER_PASSWORD",+ "Admin Password",+ placeholder="Langflow password", secret=True,+ helper_text="Leave empty for autologin (no password required)",+ ),+ ConfigField(+ "langflow_superuser", "LANGFLOW_SUPERUSER", "Admin Username",+ placeholder="admin", default="admin",+ ),+ ConfigField(+ "langflow_public_url", "LANGFLOW_PUBLIC_URL", "Public URL",+ placeholder="http://localhost:7860",+ helper_text="External URL for Langflow access",+ advanced=True,+ ),+ ]),++ # ── AI Providers ────────────────────────────────────────────+ ConfigSection("AI Providers", [+ ConfigField(+ "openai_api_key", "OPENAI_API_KEY", "OpenAI API Key",+ placeholder="sk-...", secret=True,+ helper_text="Get a key: https://platform.openai.com/api-keys",+ validator=validate_openai_api_key,+ validator_error="Invalid OpenAI API key format (should start with sk-)",+ ),+ ConfigField(+ "anthropic_api_key", "ANTHROPIC_API_KEY", "Anthropic API Key",+ placeholder="sk-ant-...", secret=True,+ helper_text="Get a key: https://console.anthropic.com/settings/keys",+ validator=validate_anthropic_api_key,+ validator_error="Invalid Anthropic API key format (should start with sk-ant-)",+ ),+ ConfigField(+ "ollama_endpoint", "OLLAMA_ENDPOINT", "Ollama Base URL",+ placeholder="http://localhost:11434",+ helper_text="Endpoint of your Ollama server",+ validator=validate_ollama_endpoint,+ validator_error="Invalid Ollama endpoint URL format",+ ),+ ConfigField(+ "watsonx_api_key", "WATSONX_API_KEY", "IBM watsonx.ai API Key",+ placeholder="", secret=True,+ helper_text="Get a key: https://cloud.ibm.com/iam/apikeys",+ ),+ ConfigField(+ "watsonx_endpoint", "WATSONX_ENDPOINT", "IBM watsonx.ai Endpoint",+ placeholder="https://us-south.ml.cloud.ibm.com",+ helper_text="Example: https://us-south.ml.cloud.ibm.com",+ validator=validate_watsonx_endpoint,+ validator_error="Invalid watsonx.ai endpoint URL format",+ ),+ ConfigField(+ "watsonx_project_id", "WATSONX_PROJECT_ID", "IBM watsonx.ai Project ID",+ placeholder="",+ helper_text="Find in your IBM Cloud project settings",+ ),+ ]),++ # ── Google OAuth ────────────────────────────────────────────+ ConfigSection("Google OAuth", [+ ConfigField(+ "google_oauth_client_id", "GOOGLE_OAUTH_CLIENT_ID", "Client ID",+ placeholder="xxx.apps.googleusercontent.com",+ helper_text="Create credentials: https://console.cloud.google.com/apis/credentials",+ ),+ ConfigField(+ "google_oauth_client_secret", "GOOGLE_OAUTH_CLIENT_SECRET",+ "Client Secret",+ placeholder="", secret=True,+ ),+ ], advanced=True, gate_prompt="Configure Google OAuth?"),++ # ── Microsoft Graph OAuth ───────────────────────────────────+ ConfigSection("Microsoft Graph OAuth", [+ ConfigField(+ "microsoft_graph_oauth_client_id", "MICROSOFT_GRAPH_OAUTH_CLIENT_ID",+ "Client ID",+ placeholder="",+ helper_text="Create app: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",+ ),+ ConfigField(+ "microsoft_graph_oauth_client_secret",+ "MICROSOFT_GRAPH_OAUTH_CLIENT_SECRET", "Client Secret",+ placeholder="", secret=True,+ ),+ ], advanced=True, gate_prompt="Configure Microsoft Graph OAuth?"),++ # ── AWS ─────────────────────────────────────────────────────+ ConfigSection("AWS", [+ ConfigField(+ "aws_access_key_id", "AWS_ACCESS_KEY_ID", "Access Key ID",+ placeholder="",+ helper_text="Create keys: https://console.aws.amazon.com/iam/home#/security_credentials",+ ),+ ConfigField(+ "aws_secret_access_key", "AWS_SECRET_ACCESS_KEY", "Secret Access Key",+ placeholder="", secret=True,+ ),+ ], advanced=True, gate_prompt="Configure AWS credentials?"),++ # ── Langfuse ────────────────────────────────────────────────+ ConfigSection("Langfuse", [+ ConfigField(+ "langfuse_secret_key", "LANGFUSE_SECRET_KEY", "Secret Key",+ placeholder="sk-lf-...", secret=True,+ helper_text="Get keys from your Langfuse project settings",+ ),+ ConfigField(+ "langfuse_public_key", "LANGFUSE_PUBLIC_KEY", "Public Key",+ placeholder="pk-lf-...", secret=True,+ ),+ ConfigField(+ "langfuse_host", "LANGFUSE_HOST", "Host",+ placeholder="https://cloud.langfuse.com",+ helper_text="Leave empty for Langfuse Cloud, or set for self-hosted",+ ),+ ], gate_prompt="Configure Langfuse tracing?"),++ # ── Storage ─────────────────────────────────────────────────+ ConfigSection("Storage", [+ ConfigField(+ "openrag_documents_paths", "OPENRAG_DOCUMENTS_PATHS", "Documents Paths",+ placeholder="~/.openrag/documents",+ default="$HOME/.openrag/documents",+ helper_text="Directories containing documents to ingest (comma-separated)",+ ),+ ]),++ # ── Advanced ────────────────────────────────────────────────+ ConfigSection("Advanced", [+ ConfigField(+ "webhook_base_url", "WEBHOOK_BASE_URL", "Webhook Base URL",+ placeholder="https://your-domain.com",+ helper_text="External URL for continuous ingestion webhooks",+ ),+ ], advanced=True),+]+++def get_all_fields() -> list[ConfigField]:+ """Return a flat list of all config fields."""+ return [f for section in CONFIG_SECTIONS for f in section.fields]+++def get_field(name: str) -> Optional[ConfigField]:+ """Look up a config field by attribute name."""+ for f in get_all_fields():+ if f.name == name:+ return f+ return Nonediff --git a/src/tui/managers/container_manager.py b/src/tui/managers/container_manager.pyindex 11ea26ecf..89c0c121d 100644--- a/src/tui/managers/container_manager.py+++ b/src/tui/managers/container_manager.py@@ -51,6 +51,26 @@ class ServiceInfo:self.ports = []+def format_port_conflict_message(conflicts: List[tuple[str, int, str]], max_shown: int = 3) -> str:+ """Format port conflicts into a user-facing error message."""+ shown = [f"{name} (port {port})" for name, port, _ in conflicts[:max_shown]]+ conflict_str = ", ".join(shown)+ if len(conflicts) > max_shown:+ conflict_str += f" and {len(conflicts) - max_shown} more"++ msg = f"Cannot start services: Port conflicts detected for {conflict_str}."++ configurable = any(+ "frontend" in name.lower() or "langflow" in name.lower()+ for name, _, _ in conflicts+ )+ if configurable:+ msg += " You can set FRONTEND_PORT or LANGFLOW_PORT in your .env file to use different ports."+ else:+ msg += " Please stop the conflicting services first."+ return msg++class ContainerManager:"""Manages Docker/Podman container lifecycle for OpenRAG."""@@ -233,12 +253,19 @@ class ContainerManager:# Extract port mappingsif in_ports_section and current_service:- # Match patterns like: - "3000:3000", - "9200:9200", - 7860:7860- port_match = re.search(r'["\']?(\d+):\d+["\']?', line)- if port_match:- host_port = int(port_match.group(1))- if host_port not in service_ports[current_service]:- service_ports[current_service].append(host_port)+ host_port = None+ # Match env var patterns like: - "${FRONTEND_PORT:-3000}:3000"+ env_match = re.search(r'\$\{(\w+):-(\d+)\}:\d+', line)+ if env_match:+ var_name, default_port = env_match.group(1), env_match.group(2)+ host_port = int(os.getenv(var_name, default_port))+ else:+ # Match literal patterns like: - "3000:3000", - 9200:9200+ port_match = re.search(r'["\']?(\d+):\d+["\']?', line)+ if port_match:+ host_port = int(port_match.group(1))+ if host_port is not None and host_port not in service_ports[current_service]:+ service_ports[current_service].append(host_port)except Exception as e:logger.debug(f"Error parsing {compose_file} for ports: {e}")@@ -1012,18 +1039,8 @@ class ContainerManager:yield False, "ERROR: Port conflicts detected:", Falsefor service_name, port, error_msg in conflicts:yield False, f" - {service_name}: {error_msg}", False-- # Check if frontend or langflow ports are conflicted- frontend_conflict = any("frontend" in name.lower() or port == 3000 for name, port, _ in conflicts)- langflow_conflict = any("langflow" in name.lower() or port == 7860 for name, port, _ in conflicts)-- if frontend_conflict or langflow_conflict:- yield False, "", False- yield False, "You can set FRONTEND_PORT or LANGFLOW_PORT environment variables", False- yield False, "in your .env file to use different ports.", False- else:- yield False, "Please stop the conflicting services and try again.", False- yield False, "Services not started due to port conflicts.", False+ yield False, "", False+ yield False, format_port_conflict_message(conflicts), Falsereturnyield False, "Starting OpenRAG services...", Falsediff --git a/src/tui/managers/env_manager.py b/src/tui/managers/env_manager.pyindex 1657ea40e..bbe5968f2 100644--- a/src/tui/managers/env_manager.py+++ b/src/tui/managers/env_manager.py@@ -29,6 +29,9 @@ class EnvConfig:# Core settingsopenai_api_key: str = ""opensearch_password: str = ""+ opensearch_username: str = "admin"+ opensearch_host: str = "opensearch"+ opensearch_port: str = "9200"opensearch_index_name: str = "documents"langflow_secret_key: str = ""langflow_superuser: str = "admin"@@ -171,6 +174,9 @@ class EnvManager:"WATSONX_ENDPOINT": "watsonx_endpoint","WATSONX_PROJECT_ID": "watsonx_project_id","OPENSEARCH_PASSWORD": "opensearch_password", # pragma: allowlist secret+ "OPENSEARCH_USERNAME": "opensearch_username",+ "OPENSEARCH_HOST": "opensearch_host",+ "OPENSEARCH_PORT": "opensearch_port","OPENSEARCH_INDEX_NAME": "opensearch_index_name","LANGFLOW_SECRET_KEY": "langflow_secret_key", # pragma: allowlist secret"LANGFLOW_SUPERUSER": "langflow_superuser",@@ -390,6 +396,12 @@ class EnvManager:f.write(f"LANGFLOW_URL_INGEST_FLOW_ID={self._quote_env_value(self.config.langflow_url_ingest_flow_id)}\n")f.write(f"NUDGES_FLOW_ID={self._quote_env_value(self.config.nudges_flow_id)}\n")f.write(f"OPENSEARCH_PASSWORD={self._quote_env_value(self.config.opensearch_password)}\n")+ if self.config.opensearch_username and self.config.opensearch_username != "admin":+ f.write(f"OPENSEARCH_USERNAME={self._quote_env_value(self.config.opensearch_username)}\n")+ if self.config.opensearch_host and self.config.opensearch_host != "opensearch":+ f.write(f"OPENSEARCH_HOST={self._quote_env_value(self.config.opensearch_host)}\n")+ if self.config.opensearch_port and self.config.opensearch_port != "9200":+ f.write(f"OPENSEARCH_PORT={self._quote_env_value(self.config.opensearch_port)}\n")f.write(f"OPENSEARCH_INDEX_NAME={self._quote_env_value(self.config.opensearch_index_name)}\n")# Expand $HOME in paths before writing to .envdiff --git a/src/tui/screens/config.py b/src/tui/screens/config.pyindex dfa46d419..ed47ca169 100644--- a/src/tui/screens/config.py+++ b/src/tui/screens/config.py@@ -21,6 +21,7 @@ from textual.validation import ValidationResult, Validatorfrom rich.text import Textfrom pathlib import Path+from ..config_fields import CONFIG_SECTIONS, ConfigFieldfrom ..managers.env_manager import EnvManagerfrom ..utils.validation import (validate_openai_api_key,@@ -29,7 +30,6 @@ from ..utils.validation import (validate_watsonx_endpoint,validate_documents_paths,)-from pathlib import Pathclass OpenAIKeyValidator(Validator):@@ -193,482 +193,214 @@ class ConfigScreen(Screen):return header_text+ # Map validator functions to Textual Validator classes+ VALIDATOR_MAP: dict = {+ validate_openai_api_key: OpenAIKeyValidator,+ validate_anthropic_api_key: AnthropicKeyValidator,+ validate_ollama_endpoint: OllamaEndpointValidator,+ validate_watsonx_endpoint: WatsonxEndpointValidator,+ }++ # Fields that need custom rendering beyond the standard pattern+ SPECIAL_FIELDS = {+ "opensearch_password",+ "opensearch_data_path",+ "langflow_superuser_password",+ "langflow_superuser",+ "google_oauth_client_id",+ "microsoft_graph_oauth_client_id",+ "openrag_documents_paths",+ }+def _create_all_fields(self) -> ComposeResult:- """Create all configuration fields in a single scrollable layout."""+ """Create all configuration fields from shared CONFIG_SECTIONS."""+ for section in CONFIG_SECTIONS:+ if section.advanced and self.mode != "full":+ continue++ yield Static(section.name, classes="tab-header")+ yield Static(" ")++ for field in section.fields:+ if field.advanced and self.mode != "full":+ continue++ if field.name in self.SPECIAL_FIELDS:+ renderer = getattr(self, f"_render_{field.name}")+ yield from renderer(field)+ else:+ yield from self._render_standard_field(field)++ def _render_standard_field(self, field: ConfigField) -> ComposeResult:+ """Render a standard field: label + helper + input + optional toggle."""+ label_text = field.label+ if field.required:+ label_text += " *"+ elif not field.secret:+ label_text += " (optional)"+ else:+ label_text += " (optional)"+ yield Label(label_text)++ if field.helper_text:+ yield Static(+ Text(field.helper_text, style="dim"),+ classes="helper-text",+ )++ current_value = getattr(self.env_manager.config, field.name, field.default) or ""+ validators = []+ if field.validator and field.validator in self.VALIDATOR_MAP:+ validators = [self.VALIDATOR_MAP[field.validator]()]- # ===== OpenSearch Section =====- yield Static("OpenSearch", classes="tab-header")+ input_widget = Input(+ placeholder=field.placeholder,+ value=current_value,+ password=field.secret,+ validators=validators,+ id=f"input-{field.name}",+ )++ if field.secret:+ with Horizontal(id=f"{field.name}-row"):+ yield input_widget+ yield Button("Show", id=f"toggle-{field.name}", variant="default")+ else:+ yield input_widget++ self.inputs[field.name] = input_widgetyield Static(" ")- # OpenSearch Admin Password+ # ── Special field renderers ──────────────────────────────────++ def _render_opensearch_password(self, field: ConfigField) -> ComposeResult:+ """OpenSearch password with strength validator and eye toggle."""yield Label("Admin Password *")- yield Static(- "Validate your password here: https://lowe.github.io/tryzxcvbn/",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_password", "")+ yield Static(field.helper_text, classes="helper-text")+ current_value = getattr(self.env_manager.config, field.name, "")with Horizontal(id="opensearch-password-row"):input_widget = Input(- placeholder="Auto-generated secure password",+ placeholder=field.placeholder,value=current_value,password=True,- id="input-opensearch_password",+ id=f"input-{field.name}",validators=[PasswordValidator()],)yield input_widget- self.inputs["opensearch_password"] = input_widget- yield Button("👁", id="toggle-opensearch-password", variant="default")- yield Static(" ")-- # OpenSearch Username (optional)- yield Label("Admin Username (optional)")- yield Static(- "OpenSearch admin username (default: admin)",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_username", "")- input_widget = Input(- placeholder="admin",- value=current_value,- id="input-opensearch_username",- )- yield input_widget- self.inputs["opensearch_username"] = input_widget+ self.inputs[field.name] = input_widget+ yield Button("👁", id=f"toggle-{field.name}", variant="default")yield Static(" ")- # OpenSearch Host (optional - for remote instances)- yield Label("Host (optional)")- yield Static(- "Override for remote OpenSearch instances (default: opensearch)",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_host", "")+ def _render_opensearch_data_path(self, field: ConfigField) -> ComposeResult:+ """OpenSearch data path with file picker."""+ yield Label(field.label)+ yield Static(field.helper_text, classes="helper-text")+ current_value = getattr(self.env_manager.config, field.name, field.default)input_widget = Input(- placeholder="opensearch",+ placeholder=field.placeholder,value=current_value,- id="input-opensearch_host",+ id=f"input-{field.name}",)yield input_widget- self.inputs["opensearch_host"] = input_widget- yield Static(" ")-- # OpenSearch Port (optional)- yield Label("Port (optional)")- yield Static(- "Override for remote OpenSearch instances (default: 9200)",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_port", "")- input_widget = Input(- placeholder="9200",- value=current_value,- id="input-opensearch_port",- )- yield input_widget- self.inputs["opensearch_port"] = input_widget- yield Static(" ")-- # OpenSearch Data Path- yield Label("Data Path")- yield Static(- "Directory to persist OpenSearch indices across upgrades",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_data_path", "$HOME/.openrag/data/opensearch-data")- input_widget = Input(- placeholder="~/.openrag/data/opensearch-data",- value=current_value,- id="input-opensearch_data_path",- )- yield input_widget- # Actions row with pick buttonyield Horizontal(Button("Pick…", id="pick-opensearch-data-btn"),id="opensearch-data-path-actions",classes="controls-row",)- self.inputs["opensearch_data_path"] = input_widget+ self.inputs[field.name] = input_widgetyield Static(" ")- # OpenSearch Index Name- yield Label("Index Name")- yield Static(- "Name of the index to use in OpenSearch",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "opensearch_index_name", "documents")- input_widget = Input(- placeholder="documents",- value=current_value,- id="input-opensearch_index_name",- )- yield input_widget- self.inputs["opensearch_index_name"] = input_widget- yield Static(" ")-- # ===== Langflow Section =====- yield Static("Langflow", classes="tab-header")- yield Static(" ")-- # Langflow Admin Password+ def _render_langflow_superuser_password(self, field: ConfigField) -> ComposeResult:+ """Langflow password with generate checkbox and eye toggle."""with Horizontal():yield Label("Admin Password (optional)")yield Checkbox("Generate password", id="generate-langflow-password")- current_value = getattr(- self.env_manager.config, "langflow_superuser_password", ""- )+ current_value = getattr(self.env_manager.config, field.name, "")with Horizontal(id="langflow-password-row"):input_widget = Input(- placeholder="Langflow password",+ placeholder=field.placeholder,value=current_value,password=True,- id="input-langflow_superuser_password",+ id=f"input-{field.name}",)yield input_widget- self.inputs["langflow_superuser_password"] = input_widget- yield Button("👁", id="toggle-langflow-password", variant="default")+ self.inputs[field.name] = input_widget+ yield Button("👁", id=f"toggle-{field.name}", variant="default")yield Static(" ")- # Langflow Admin Username - conditionally displayed based on password- current_password = getattr(self.env_manager.config, "langflow_superuser_password", "")+ def _render_langflow_superuser(self, field: ConfigField) -> ComposeResult:+ """Langflow username with conditional visibility."""yield Label("Admin Username *", id="langflow-username-label")- current_value = getattr(self.env_manager.config, "langflow_superuser", "")+ current_value = getattr(self.env_manager.config, field.name, field.default)input_widget = Input(- placeholder="admin", value=current_value, id="input-langflow_superuser"- )- yield input_widget- self.inputs["langflow_superuser"] = input_widget- yield Static(" ", id="langflow-username-spacer")-- # Langflow Public URL (full mode only, but grouped here)- if self.mode == "full":- yield Label("Public URL (optional)")- yield Static(- "External URL for Langflow access",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "langflow_public_url", "")- input_widget = Input(- placeholder="http://localhost:7860",- value=current_value,- id="input-langflow_public_url",- )- yield input_widget- self.inputs["langflow_public_url"] = input_widget- yield Static(" ")-- # ===== AI Providers Section =====- yield Static("AI Providers", classes="tab-header")- yield Static(" ")-- # OpenAI API Key- yield Label("OpenAI API Key (optional)")- yield Static(- Text("Get a key: https://platform.openai.com/api-keys", style="dim"),- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "openai_api_key", "")- with Horizontal(id="openai-key-row"):- input_widget = Input(- placeholder="sk-...",- value=current_value,- password=True,- validators=[OpenAIKeyValidator()],- id="input-openai_api_key",- )- yield input_widget- self.inputs["openai_api_key"] = input_widget- yield Button("Show", id="toggle-openai-key", variant="default")- yield Static(" ")-- # Anthropic API Key- yield Label("Anthropic API Key (optional)")- yield Static(- Text("Get a key: https://console.anthropic.com/settings/keys", style="dim"),- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "anthropic_api_key", "")- with Horizontal(id="anthropic-key-row"):- input_widget = Input(- placeholder="sk-ant-...",- value=current_value,- password=True,- validators=[AnthropicKeyValidator()],- id="input-anthropic_api_key",- )- yield input_widget- self.inputs["anthropic_api_key"] = input_widget- yield Button("Show", id="toggle-anthropic-key", variant="default")- yield Static(" ")-- # Ollama Endpoint- yield Label("Ollama Base URL (optional)")- yield Static(- Text("Endpoint of your Ollama server", style="dim"),- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "ollama_endpoint", "")- input_widget = Input(- placeholder="http://localhost:11434",+ placeholder=field.placeholder,value=current_value,- validators=[OllamaEndpointValidator()],- id="input-ollama_endpoint",+ id=f"input-{field.name}",)yield input_widget- self.inputs["ollama_endpoint"] = input_widget- yield Static(" ")-- # IBM watsonx.ai API Key- yield Label("IBM watsonx.ai API Key (optional)")- yield Static(- Text("Get a key: https://cloud.ibm.com/iam/apikeys", style="dim"),- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "watsonx_api_key", "")- with Horizontal(id="watsonx-key-row"):- input_widget = Input(- placeholder="",- value=current_value,- password=True,- id="input-watsonx_api_key",- )- yield input_widget- self.inputs["watsonx_api_key"] = input_widget- yield Button("Show", id="toggle-watsonx-key", variant="default")- yield Static(" ")+ self.inputs[field.name] = input_widget+ yield Static(" ", id="langflow-username-spacer")- # IBM watsonx.ai Endpoint- yield Label("IBM watsonx.ai Endpoint (optional)")+ def _render_google_oauth_client_id(self, field: ConfigField) -> ComposeResult:+ """Google OAuth client ID with redirect URI helper."""+ yield Label(field.label)yield Static(- Text("Example: https://us-south.ml.cloud.ibm.com", style="dim"),+ Text(field.helper_text, style="dim"),classes="helper-text",)- current_value = getattr(self.env_manager.config, "watsonx_endpoint", "")- input_widget = Input(- placeholder="https://us-south.ml.cloud.ibm.com",- value=current_value,- validators=[WatsonxEndpointValidator()],- id="input-watsonx_endpoint",- )- yield input_widget- self.inputs["watsonx_endpoint"] = input_widget- yield Static(" ")-- # IBM watsonx.ai Project ID- yield Label("IBM watsonx.ai Project ID (optional)")+ frontend_port = os.getenv("FRONTEND_PORT", "3000")yield Static(- Text("Find in your IBM Cloud project settings", style="dim"),+ Text(+ f"Redirect URI: http://localhost:{frontend_port}/auth/callback (or your domain)",+ style="dim",+ ),classes="helper-text",)- current_value = getattr(self.env_manager.config, "watsonx_project_id", "")+ current_value = getattr(self.env_manager.config, field.name, "")input_widget = Input(- placeholder="",+ placeholder=field.placeholder,value=current_value,- id="input-watsonx_project_id",+ id=f"input-{field.name}",)yield input_widget- self.inputs["watsonx_project_id"] = input_widget- yield Static(" ")-- # ===== Cloud Connectors Section (full mode only) =====- if self.mode == "full":- yield Static("Cloud Connectors", classes="tab-header")- yield Static(" ")-- # Google OAuth Client ID- yield Label("Google OAuth Client ID")- yield Static(- Text(- "Create credentials: https://console.cloud.google.com/apis/credentials",- style="dim",- ),- classes="helper-text",- )- frontend_port = os.getenv("FRONTEND_PORT", "3000")- yield Static(- Text(- f"Redirect URI: http://localhost:{frontend_port}/auth/callback (or your domain)",- style="dim",- ),- classes="helper-text",- )- current_value = getattr(- self.env_manager.config, "google_oauth_client_id", ""- )- input_widget = Input(- placeholder="xxx.apps.googleusercontent.com",- value=current_value,- id="input-google_oauth_client_id",- )- yield input_widget- self.inputs["google_oauth_client_id"] = input_widget- yield Static(" ")-- # Google OAuth Client Secret- yield Label("Google OAuth Client Secret")- current_value = getattr(- self.env_manager.config, "google_oauth_client_secret", ""- )- with Horizontal(id="google-secret-row"):- input_widget = Input(- placeholder="",- value=current_value,- password=True,- id="input-google_oauth_client_secret",- )- yield input_widget- self.inputs["google_oauth_client_secret"] = input_widget- yield Button("Show", id="toggle-google-secret", variant="default")- yield Static(" ")-- # Microsoft Graph Client ID- yield Label("Microsoft Graph Client ID")- yield Static(- Text(- "Create app: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",- style="dim",- ),- classes="helper-text",- )- frontend_port = os.getenv("FRONTEND_PORT", "3000")- yield Static(- Text(- f"Redirect URI: http://localhost:{frontend_port}/auth/callback (or your domain)",- style="dim",- ),- classes="helper-text",- )- current_value = getattr(- self.env_manager.config, "microsoft_graph_oauth_client_id", ""- )- input_widget = Input(- placeholder="",- value=current_value,- id="input-microsoft_graph_oauth_client_id",- )- yield input_widget- self.inputs["microsoft_graph_oauth_client_id"] = input_widget- yield Static(" ")-- # Microsoft Graph Client Secret- yield Label("Microsoft Graph Client Secret")- current_value = getattr(- self.env_manager.config, "microsoft_graph_oauth_client_secret", ""- )- with Horizontal(id="microsoft-secret-row"):- input_widget = Input(- placeholder="",- value=current_value,- password=True,- id="input-microsoft_graph_oauth_client_secret",- )- yield input_widget- self.inputs["microsoft_graph_oauth_client_secret"] = input_widget- yield Button("Show", id="toggle-microsoft-secret", variant="default")- yield Static(" ")-- # AWS Access Key ID- yield Label("AWS Access Key ID")- yield Static(- Text(- "Create keys: https://console.aws.amazon.com/iam/home#/security_credentials",- style="dim",- ),- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "aws_access_key_id", "")- input_widget = Input(- placeholder="", value=current_value, id="input-aws_access_key_id"- )- yield input_widget- self.inputs["aws_access_key_id"] = input_widget- yield Static(" ")-- # AWS Secret Access Key- yield Label("AWS Secret Access Key")- current_value = getattr(- self.env_manager.config, "aws_secret_access_key", ""- )- input_widget = Input(- placeholder="",- value=current_value,- password=True,- id="input-aws_secret_access_key",- )- yield input_widget- self.inputs["aws_secret_access_key"] = input_widget- yield Static(" ")-- # ===== Langfuse Section =====- yield Static("Langfuse (Tracing)", classes="tab-header")+ self.inputs[field.name] = input_widgetyield Static(" ")- # Langfuse Secret Key- yield Label("Secret Key (optional)")+ def _render_microsoft_graph_oauth_client_id(self, field: ConfigField) -> ComposeResult:+ """Microsoft OAuth client ID with redirect URI helper."""+ yield Label(field.label)yield Static(- Text("Get keys from your Langfuse project settings", style="dim"),+ Text(field.helper_text, style="dim"),classes="helper-text",)- current_value = getattr(self.env_manager.config, "langfuse_secret_key", "")- with Horizontal(id="langfuse-secret-key-row"):- input_widget = Input(- placeholder="sk-lf-...",- value=current_value,- password=True,- id="input-langfuse_secret_key",- )- yield input_widget- self.inputs["langfuse_secret_key"] = input_widget- yield Button("Show", id="toggle-langfuse-secret-key", variant="default")- yield Static(" ")-- # Langfuse Public Key- yield Label("Public Key (optional)")- current_value = getattr(self.env_manager.config, "langfuse_public_key", "")- with Horizontal(id="langfuse-public-key-row"):- input_widget = Input(- placeholder="pk-lf-...",- value=current_value,- password=True,- id="input-langfuse_public_key",- )- yield input_widget- self.inputs["langfuse_public_key"] = input_widget- yield Button("Show", id="toggle-langfuse-public-key", variant="default")- yield Static(" ")-- # Langfuse Host- yield Label("Host (optional)")+ frontend_port = os.getenv("FRONTEND_PORT", "3000")yield Static(- Text("Leave empty for Langfuse Cloud, or set for self-hosted", style="dim"),+ Text(+ f"Redirect URI: http://localhost:{frontend_port}/auth/callback (or your domain)",+ style="dim",+ ),classes="helper-text",)- current_value = getattr(self.env_manager.config, "langfuse_host", "")+ current_value = getattr(self.env_manager.config, field.name, "")input_widget = Input(- placeholder="https://cloud.langfuse.com",+ placeholder=field.placeholder,value=current_value,- id="input-langfuse_host",+ id=f"input-{field.name}",)yield input_widget- self.inputs["langfuse_host"] = input_widget- yield Static(" ")-- # ===== Storage Section =====- yield Static("Storage", classes="tab-header")+ self.inputs[field.name] = input_widgetyield Static(" ")- # Documents Paths- yield Label("Documents Paths")- yield Static(- "Directories containing documents to ingest (comma-separated)",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "openrag_documents_paths", "")+ def _render_openrag_documents_paths(self, field: ConfigField) -> ComposeResult:+ """Documents paths with validator and file picker."""+ yield Label(field.label)+ yield Static(field.helper_text, classes="helper-text")+ current_value = getattr(self.env_manager.config, field.name, "")input_widget = Input(- placeholder="~/.openrag/documents",+ placeholder=field.placeholder,value=current_value,validators=[DocumentsPathValidator()],- id="input-openrag_documents_paths",+ id=f"input-{field.name}",)yield input_widgetyield Horizontal(@@ -676,81 +408,7 @@ class ConfigScreen(Screen):id="docs-path-actions",classes="controls-row",)- self.inputs["openrag_documents_paths"] = input_widget- yield Static(" ")-- # ===== Advanced Section (full mode only) =====- if self.mode == "full":- yield Static("Advanced", classes="tab-header")- yield Static(" ")-- # Webhook Base URL- yield Label("Webhook Base URL")- yield Static(- "External URL for continuous ingestion webhooks",- classes="helper-text",- )- current_value = getattr(self.env_manager.config, "webhook_base_url", "")- input_widget = Input(- placeholder="https://your-domain.com",- value=current_value,- id="input-webhook_base_url",- )- yield input_widget- self.inputs["webhook_base_url"] = input_widget- yield Static(" ")-- def _create_field(- self,- field_name: str,- display_name: str,- placeholder: str,- can_generate: bool,- required: bool = False,- ) -> ComposeResult:- """Create a single form field."""- # Create label- label_text = f"{display_name}"- if required:- label_text += " *"-- yield Label(label_text)-- # Get current value- current_value = getattr(self.env_manager.config, field_name, "")-- # Create input with appropriate validator- if field_name == "openai_api_key":- input_widget = Input(- placeholder=placeholder,- value=current_value,- password=True,- validators=[OpenAIKeyValidator()],- id=f"input-{field_name}",- )- elif field_name == "openrag_documents_paths":- input_widget = Input(- placeholder=placeholder,- value=current_value,- validators=[DocumentsPathValidator()],- id=f"input-{field_name}",- )- elif "password" in field_name or "secret" in field_name:- input_widget = Input(- placeholder=placeholder,- value=current_value,- password=True,- id=f"input-{field_name}",- )- else:- input_widget = Input(- placeholder=placeholder, value=current_value, id=f"input-{field_name}"- )-- yield input_widget- self.inputs[field_name] = input_widget-- # Add spacing+ self.inputs[field.name] = input_widgetyield Static(" ")def on_mount(self) -> None:@@ -800,42 +458,17 @@ class ConfigScreen(Screen):self.action_pick_documents_path()elif event.button.id == "pick-opensearch-data-btn":self.action_pick_opensearch_data_path()- elif event.button.id == "toggle-opensearch-password":- # Toggle OpenSearch password visibility- input_widget = self.inputs.get("opensearch_password")- if input_widget:- input_widget.password = not input_widget.password- event.button.label = "🙈" if not input_widget.password else "👁"- elif event.button.id == "toggle-langflow-password":- # Toggle Langflow password visibility- input_widget = self.inputs.get("langflow_superuser_password")- if input_widget:- input_widget.password = not input_widget.password- event.button.label = "🙈" if not input_widget.password else "👁"- elif event.button.id == "toggle-anthropic-key":- # Toggle Anthropic API key visibility- input_widget = self.inputs.get("anthropic_api_key")- if input_widget:- input_widget.password = not input_widget.password- event.button.label = "Hide" if not input_widget.password else "Show"- elif event.button.id == "toggle-watsonx-key":- # Toggle watsonx API key visibility- input_widget = self.inputs.get("watsonx_api_key")- if input_widget:- input_widget.password = not input_widget.password- event.button.label = "Hide" if not input_widget.password else "Show"- elif event.button.id == "toggle-langfuse-secret-key":- # Toggle Langfuse secret key visibility- input_widget = self.inputs.get("langfuse_secret_key")- if input_widget:- input_widget.password = not input_widget.password- event.button.label = "Hide" if not input_widget.password else "Show"- elif event.button.id == "toggle-langfuse-public-key":- # Toggle Langfuse public key visibility- input_widget = self.inputs.get("langfuse_public_key")+ elif event.button.id and event.button.id.startswith("toggle-"):+ # Generic toggle for password/secret field visibility+ field_name = event.button.id.removeprefix("toggle-")+ input_widget = self.inputs.get(field_name)if input_widget:input_widget.password = not input_widget.password- event.button.label = "Hide" if not input_widget.password else "Show"+ # Eye emoji for main password fields, Show/Hide for others+ if field_name in ("opensearch_password", "langflow_superuser_password"):+ event.button.label = "🙈" if not input_widget.password else "👁"+ else:+ event.button.label = "Hide" if not input_widget.password else "Show"def action_generate(self) -> None:"""Generate secure passwords for admin accounts."""diff --git a/src/tui/screens/monitor.py b/src/tui/screens/monitor.pyindex 5562c3390..b39bf91f1 100644--- a/src/tui/screens/monitor.py+++ b/src/tui/screens/monitor.py@@ -17,7 +17,7 @@ from textual.timer import Timerfrom rich.text import Textfrom rich.table import Table-from ..managers.container_manager import ContainerManager, ServiceStatus, ServiceInfo+from ..managers.container_manager import ContainerManager, ServiceStatus, ServiceInfo, format_port_conflict_messagefrom ..managers.docling_manager import DoclingManagerfrom ..utils.platform import RuntimeTypefrom ..widgets.command_modal import CommandOutputModal@@ -338,27 +338,8 @@ class MonitorScreen(Screen):conflicts,) = await self.container_manager.check_ports_available()if not ports_available:- # Show error notification instead of modal- conflict_msgs = []- for service_name, port, error_msg in conflicts[:3]: # Show first 3- conflict_msgs.append(f"{service_name} (port {port})")-- conflict_str = ", ".join(conflict_msgs)- if len(conflicts) > 3:- conflict_str += f" and {len(conflicts) - 3} more"-- # Check if frontend or langflow ports are conflicted- frontend_conflict = any("frontend" in name.lower() or port == 3000 for name, port, _ in conflicts)- langflow_conflict = any("langflow" in name.lower() or port == 7860 for name, port, _ in conflicts)-- error_msg = f"Cannot start services: Port conflicts detected for {conflict_str}."- if frontend_conflict or langflow_conflict:- error_msg += " You can set FRONTEND_PORT or LANGFLOW_PORT environment variables in your .env file to use different ports."- else:- error_msg += " Please stop the conflicting services first."-self.notify(- error_msg,+ format_port_conflict_message(conflicts),severity="error",timeout=15,)diff --git a/src/tui/screens/welcome.py b/src/tui/screens/welcome.pyindex e2f85e831..6a2619fd5 100644--- a/src/tui/screens/welcome.py+++ b/src/tui/screens/welcome.py@@ -11,7 +11,7 @@ from rich.align import Alignfrom dotenv import load_dotenvfrom .. import __version__-from ..managers.container_manager import ContainerManager, ServiceStatus+from ..managers.container_manager import ContainerManager, ServiceStatus, format_port_conflict_messagefrom ..managers.env_manager import EnvManagerfrom ..managers.docling_manager import DoclingManagerfrom ..widgets.command_modal import CommandOutputModal@@ -491,38 +491,24 @@ class WelcomeScreen(Screen):async def _start_all_services(self) -> None:"""Start all services: containers first, then native services."""# Check for port conflicts before attempting to start anything- conflicts = []+ conflicts: list[tuple[str, int, str]] = []# Check container ports only if services are not already runningif self.container_manager.is_available() and not self.services_running:ports_available, port_conflicts = await self.container_manager.check_ports_available()if not ports_available:- for service_name, port, error_msg in port_conflicts[:3]: # Show first 3- conflicts.append(f"{service_name} (port {port})")- if len(port_conflicts) > 3:- conflicts.append(f"and {len(port_conflicts) - 3} more")+ conflicts.extend(port_conflicts)# Check native service port only if it's not already runningif not self.docling_manager.is_running():port_available, error_msg = self.docling_manager.check_port_available()if not port_available:- conflicts.append(f"docling (port {self.docling_manager._port})")+ conflicts.append(("docling", self.docling_manager._port, error_msg or f"Port {self.docling_manager._port} is already in use"))# If there are any conflicts, show error and returnif conflicts:- conflict_str = ", ".join(conflicts)- # Check if frontend port conflict specifically- frontend_conflict = any("frontend" in c.lower() or "3000" in c for c in conflicts)- langflow_conflict = any("langflow" in c.lower() or "7860" in c for c in conflicts)-- error_msg = f"Cannot start services: Port conflicts detected for {conflict_str}."- if frontend_conflict or langflow_conflict:- error_msg += " You can set FRONTEND_PORT or LANGFLOW_PORT environment variables in your .env file to use different ports."- else:- error_msg += " Please stop the conflicting services first."-self.notify(- error_msg,+ format_port_conflict_message(conflicts),severity="error",timeout=15)@@ -646,10 +632,6 @@ class WelcomeScreen(Screen):self.docling_running = self.docling_manager.is_running()await self._refresh_welcome_content()- def action_open_app(self) -> None:- """Open the OpenRAG app in the default browser."""- self.run_worker(self._open_app_async())-def action_open_app(self) -> None:"""Open the OpenRAG app in the default browser."""import webbrowserdiff --git a/src/tui/widgets/command_modal.py b/src/tui/widgets/command_modal.pyindex 88ded89f7..0bc1413ae 100644--- a/src/tui/widgets/command_modal.py+++ b/src/tui/widgets/command_modal.py@@ -2,6 +2,7 @@import asyncioimport inspect+import osimport webbrowserfrom typing import Callable, Optional, AsyncIterator@@ -239,7 +240,7 @@ class CommandOutputModal(ModalScreen):def _launch_openrag(self) -> None:"""Open the OpenRAG app in the default browser."""try:- webbrowser.open("http://localhost:3000")+ webbrowser.open(f"http://localhost:{os.getenv('FRONTEND_PORT', '3000')}")self.notify("Opening OpenRAG app in browser...", severity="information")except Exception as e:self.notify(f"Error opening app: {e}", severity="error")