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 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 00:52:59 +02:00
parent a434626cb3
commit f21f652fea
2 changed files with 17 additions and 3 deletions

View File

@@ -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

View File

@@ -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__":