From f21f652fea97364fa2f81b5b77d44224a00f67d4 Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 00:52:59 +0200 Subject: [PATCH] Add web GUI mode via textual-serve Run `gniza web` or `gniza --web` to serve the TUI as a web app on port 8080. Use --port to change. Requires textual-serve. Co-Authored-By: Claude Opus 4.6 --- bin/gniza | 5 ++++- tui/__main__.py | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/gniza b/bin/gniza index 9c905ca..8a16779 100755 --- a/bin/gniza +++ b/bin/gniza @@ -431,7 +431,10 @@ run_cli() { } # ── Mode selection ─────────────────────────────────────────── -if [[ -n "$SUBCOMMAND" ]]; then +if [[ "$SUBCOMMAND" == "web" || " $* " == *" --web "* ]]; then + # Web GUI mode + PYTHONPATH="$GNIZA_DIR:${PYTHONPATH:-}" exec python3 -m tui --web "$@" +elif [[ -n "$SUBCOMMAND" ]]; then # Explicit subcommand: always CLI run_cli elif [[ "$FORCE_CLI" == "true" ]]; then diff --git a/tui/__main__.py b/tui/__main__.py index 25c13d5..aa65d7d 100644 --- a/tui/__main__.py +++ b/tui/__main__.py @@ -1,9 +1,20 @@ +import sys + from tui.app import GnizaApp def main(): - app = GnizaApp() - app.run() + if "--web" in sys.argv: + from textual_serve.server import Server + port = 8080 + for i, arg in enumerate(sys.argv): + if arg == "--port" and i + 1 < len(sys.argv): + port = int(sys.argv[i + 1]) + server = Server("python3 -m tui", host="0.0.0.0", port=port) + server.serve() + else: + app = GnizaApp() + app.run() if __name__ == "__main__":