Skip to content

Commit cc1bf25

Browse files
committed
fix: update interactive CLI menu to use serve (Jinja2 web UI)
- Replace menu item 7 /ui (Streamlit) with /serve (FastAPI Jinja2 UI) - _handle_serve launches uvicorn + opens browser at localhost:8000 - Update banner tip and COMMANDS/HANDLERS dicts accordingly - Remove "React UI" from serve command description
1 parent 30cf5c1 commit cc1bf25

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/metascreener/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def serve(
6767
False, "--api-only", help="Only start API server, skip frontend."
6868
),
6969
) -> None:
70-
"""Launch the FastAPI web server with React UI."""
70+
"""Launch the FastAPI web server."""
7171
import uvicorn # noqa: PLC0415
7272

7373
typer.echo(f"Starting MetaScreener server on http://{host}:{port}")

src/metascreener/cli/interactive.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
[bold cyan]MetaScreener {VERSION}[/bold cyan]
2424
[dim]AI-assisted systematic review tool[/dim]
2525
[dim]Hierarchical Consensus Network (HCN) with 4 open-source LLMs[/dim]
26-
[dim]Tip: Enter [bold]7[/bold] or [bold]/ui[/bold] to open the web dashboard[/dim]
26+
[dim]Tip: Enter [bold]7[/bold] or [bold]/serve[/bold] to open the web UI[/dim]
2727
"""
2828

2929
# Numbered menu items: (number, slash_cmd, description, handler_name)
@@ -34,7 +34,7 @@
3434
("/assess-rob", "Assess risk of bias (RoB 2 / ROBINS-I / QUADAS-2)", "_handle_assess_rob"),
3535
("/evaluate", "Evaluate screening performance", "_handle_evaluate"),
3636
("/export", "Export results (CSV, JSON, Excel, RIS)", "_handle_export"),
37-
("/ui", "Open web dashboard (Streamlit)", "_handle_ui"),
37+
("/serve", "Open web UI (http://localhost:8000)", "_handle_serve"),
3838
]
3939

4040
COMMANDS: dict[str, str] = {
@@ -44,7 +44,7 @@
4444
"/assess-rob": "Assess risk of bias (RoB 2 / ROBINS-I / QUADAS-2)",
4545
"/evaluate": "Evaluate screening performance and compute metrics",
4646
"/export": "Export results (CSV, JSON, Excel, RIS)",
47-
"/ui": "Open web dashboard (Streamlit)",
47+
"/serve": "Launch web server and open browser (http://localhost:8000)",
4848
"/help": "Show this help message",
4949
"/status": "Show current working files and project state",
5050
"/quit": "Exit MetaScreener",
@@ -58,7 +58,7 @@
5858
"/assess-rob": "_handle_assess_rob",
5959
"/evaluate": "_handle_evaluate",
6060
"/export": "_handle_export",
61-
"/ui": "_handle_ui",
61+
"/serve": "_handle_serve",
6262
}
6363

6464

@@ -571,28 +571,32 @@ def _handle_export() -> None:
571571

572572

573573
# ---------------------------------------------------------------------------
574-
# /ui — Launch Streamlit Web Dashboard
574+
# /serve — Launch FastAPI Web UI
575575
# ---------------------------------------------------------------------------
576-
def _handle_ui() -> None:
577-
"""Launch the Streamlit web dashboard in the user's browser."""
578-
app_path = Path(__file__).parent.parent / "app" / "main.py"
579-
if not app_path.exists():
580-
console.print("[red]Streamlit app not found. Reinstall MetaScreener.[/red]")
581-
return
576+
def _handle_serve() -> None:
577+
"""Launch the FastAPI web server and open the browser."""
578+
import webbrowser # noqa: PLC0415
579+
580+
port = 8000
581+
url = f"http://localhost:{port}"
582582

583583
console.print(
584-
"[cyan]Launching Streamlit dashboard...[/cyan]\n"
585-
"[dim]Opening http://localhost:8501 in your browser.[/dim]\n"
584+
f"[cyan]Launching MetaScreener web UI...[/cyan]\n"
585+
f"[dim]Opening {url} in your browser.[/dim]\n"
586586
"[dim]Press Ctrl+C to stop the server and return here.[/dim]"
587587
)
588588
try:
589+
webbrowser.open(url)
589590
subprocess.run(
590-
[sys.executable, "-m", "streamlit", "run", str(app_path),
591-
"--server.headless=true"],
591+
[sys.executable, "-m", "uvicorn",
592+
"metascreener.api.main:create_app",
593+
"--factory",
594+
"--host", "127.0.0.1",
595+
"--port", str(port)],
592596
check=False,
593597
)
594598
except KeyboardInterrupt:
595-
console.print("\n[dim]Streamlit server stopped.[/dim]")
599+
console.print("\n[dim]Web server stopped.[/dim]")
596600

597601

598602
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)