Fix web GUI by setting PYTHONPATH in spawned command

textual-serve spawns the app as a subprocess which doesn't
inherit PYTHONPATH. Bake the project root into the command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 00:55:43 +02:00
parent f21f652fea
commit bd25d99056

View File

@@ -1,7 +1,12 @@
import os
import sys
from pathlib import Path
from tui.app import GnizaApp
# Resolve project root (parent of tui/)
_PROJECT_ROOT = str(Path(__file__).resolve().parent.parent)
def main():
if "--web" in sys.argv:
@@ -10,7 +15,9 @@ def main():
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)
env_path = f"{_PROJECT_ROOT}:{os.environ.get('PYTHONPATH', '')}"
cmd = f"PYTHONPATH={env_path} GNIZA_DIR={_PROJECT_ROOT} python3 -m tui"
server = Server(cmd, host="0.0.0.0", port=port)
server.serve()
else:
app = GnizaApp()