#!/bin/bash # Open TalkEdit app (Tauri dev mode) cd "$(dirname "$0")" PROJECT_DIR="$PWD" BACKEND_PORT=8000 BACKEND_URL="http://127.0.0.1:${BACKEND_PORT}/health" # Check if backend is already running if curl -sf "$BACKEND_URL" > /dev/null 2>&1; then echo "Backend already running on port ${BACKEND_PORT}." else echo "Backend not running — starting it in a new terminal..." VENV_PYTHON="${PROJECT_DIR}/.venv312/bin/python" BACKEND_DIR="${PROJECT_DIR}/backend" # Try common terminal emulators in order if command -v ghostty &>/dev/null; then ghostty -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & elif command -v kitty &>/dev/null; then kitty --title "TalkEdit Backend" -- bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & elif command -v alacritty &>/dev/null; then alacritty --title "TalkEdit Backend" -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & elif command -v konsole &>/dev/null; then konsole --new-tab -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & elif command -v gnome-terminal &>/dev/null; then gnome-terminal --title "TalkEdit Backend" -- bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & elif command -v xterm &>/dev/null; then xterm -T "TalkEdit Backend" -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" & else echo "No supported terminal emulator found. Starting backend in background..." cd "${BACKEND_DIR}" && "${VENV_PYTHON}" -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT} & fi # Wait up to 15s for backend to become ready echo -n "Waiting for backend" for i in $(seq 1 15); do sleep 1 echo -n "." if curl -sf "$BACKEND_URL" > /dev/null 2>&1; then echo " ready!" break fi if [[ $i -eq 15 ]]; then echo " timed out. Check the backend terminal for errors." fi done fi npx tauri dev