Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ dependencies = [
"agentd>=0.2.2",
"aiofiles>=24.1.0",
"cryptography>=45.0.6",
"docling>=2.41.0",
"docling[vlm]>=2.41.0; sys_platform != 'darwin'",
"docling[ocrmac,vlm]>=2.41.0; sys_platform == 'darwin'",
"google-api-python-client>=2.143.0",
"google-auth-httplib2>=0.2.0",
"google-auth-oauthlib>=1.2.0",
Expand All @@ -27,6 +28,7 @@ dependencies = [
"python-dotenv>=1.0.0",
"textual-fspicker>=0.6.0",
"structlog>=25.4.0",
"docling-serve>=1.4.1",
]

[project.scripts]
Expand Down
93 changes: 89 additions & 4 deletions src/tui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .screens.diagnostics import DiagnosticsScreen
from .managers.env_manager import EnvManager
from .managers.container_manager import ContainerManager
from .managers.docling_manager import DoclingManager
from .utils.platform import PlatformDetector
from .widgets.diagnostics_notification import notify_with_diagnostics

Expand All @@ -26,7 +27,7 @@ class OpenRAGTUI(App):

CSS = """
Screen {
background: $background;
background: #0f172a;
}

#main-container {
Expand Down Expand Up @@ -114,7 +115,8 @@ class OpenRAGTUI(App):
}

#services-table {
height: 1fr;
height: auto;
max-height: 12;
margin-bottom: 1;
}

Expand Down Expand Up @@ -174,13 +176,90 @@ class OpenRAGTUI(App):
height: 100%;
padding: 1;
}

/* Frontend-inspired color scheme */
Static {
color: #f1f5f9;
}

Button.success {
background: #4ade80;
color: #000;
}

Button.error {
background: #ef4444;
color: #fff;
}

Button.warning {
background: #eab308;
color: #000;
}

Button.primary {
background: #2563eb;
color: #fff;
}

Button.default {
background: #475569;
color: #f1f5f9;
border: solid #64748b;
}

DataTable {
background: #1e293b;
color: #f1f5f9;
}

DataTable > .datatable--header {
background: #334155;
color: #f1f5f9;
}

DataTable > .datatable--cursor {
background: #475569;
}

Input {
background: #334155;
color: #f1f5f9;
border: solid #64748b;
}

Label {
color: #f1f5f9;
}

Footer {
background: #334155;
color: #f1f5f9;
}

#runtime-status {
background: #1e293b;
border: solid #64748b;
color: #f1f5f9;
}

#system-info {
background: #1e293b;
border: solid #64748b;
color: #f1f5f9;
}

#services-table, #images-table {
background: #1e293b;
}
"""

def __init__(self):
super().__init__()
self.platform_detector = PlatformDetector()
self.container_manager = ContainerManager()
self.env_manager = EnvManager()
self.docling_manager = DoclingManager() # Initialize singleton instance

def on_mount(self) -> None:
"""Initialize the application."""
Expand All @@ -201,6 +280,8 @@ def on_mount(self) -> None:

async def action_quit(self) -> None:
"""Quit the application."""
# Cleanup docling manager before exiting
self.docling_manager.cleanup()
self.exit()

def check_runtime_requirements(self) -> tuple[bool, str]:
Expand All @@ -222,15 +303,19 @@ def check_runtime_requirements(self) -> tuple[bool, str]:

def run_tui():
"""Run the OpenRAG TUI application."""
app = None
try:
app = OpenRAGTUI()
app.run()
except KeyboardInterrupt:
logger.info("OpenRAG TUI interrupted by user")
sys.exit(0)
except Exception as e:
logger.error("Error running OpenRAG TUI", error=str(e))
sys.exit(1)
finally:
# Ensure cleanup happens even on exceptions
if app and hasattr(app, 'docling_manager'):
app.docling_manager.cleanup()
sys.exit(0)


if __name__ == "__main__":
Expand Down
Loading