fix(webview): pin Vite to port 1420 + manage.sh auto-starts Vite for debug builds
vite.config.ts: - Set server.port = 1420 with strictPort = true to match tauri.conf.json devUrl - Add clearScreen = false to keep Vite output readable alongside Rust logs manage.sh: - start: auto-detects debug build + absent dev server, launches Vite via nvm - stop: also kills Vite dev server if running - This makes ./manage.sh start a single command that handles everything lib.rs: - Switch to Builder::build() + App::run(event_handler) form - Intercept RunEvent::ExitRequested to prevent process exit when chat window closes — keeps Robin alive in tray indefinitely
This commit is contained in:
parent
5142e29ad9
commit
d6252cf16c
2 changed files with 28 additions and 2 deletions
25
manage.sh
25
manage.sh
|
|
@ -52,17 +52,33 @@ case "$cmd" in
|
||||||
|
|
||||||
start)
|
start)
|
||||||
# Start Robin in the background (daemonised via nohup).
|
# Start Robin in the background (daemonised via nohup).
|
||||||
|
# Also starts the Vite dev server if a release binary is not available
|
||||||
|
# and Node/nvm is present, so the webview has something to connect to.
|
||||||
if pgrep -x "$APP_NAME" > /dev/null 2>&1; then
|
if pgrep -x "$APP_NAME" > /dev/null 2>&1; then
|
||||||
echo "Robin is already running (PID $(pgrep -x "$APP_NAME"))"
|
echo "Robin is already running (PID $(pgrep -x "$APP_NAME"))"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
bin="$(_require_binary)"
|
bin="$(_require_binary)"
|
||||||
echo "Starting Robin in background..."
|
|
||||||
export DISPLAY="${DISPLAY:-:0}"
|
export DISPLAY="${DISPLAY:-:0}"
|
||||||
export RUST_LOG="${RUST_LOG:-robin_lib=info,warn}"
|
export RUST_LOG="${RUST_LOG:-robin_lib=info,warn}"
|
||||||
mkdir -p "$(dirname "$LOG_FILE")"
|
mkdir -p "$(dirname "$LOG_FILE")"
|
||||||
|
|
||||||
|
# If using the debug binary and no Vite server is running, start one.
|
||||||
|
if [[ "$bin" == *"target/debug"* ]] && ! curl -sf http://localhost:1420 > /dev/null 2>&1; then
|
||||||
|
NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||||||
|
if [[ -s "$NVM_DIR/nvm.sh" ]] && command -v npm > /dev/null 2>&1 || { source "$NVM_DIR/nvm.sh" 2>/dev/null && command -v npm > /dev/null 2>&1; }; then
|
||||||
|
echo "Starting Vite dev server on :1420..."
|
||||||
|
nohup npm --prefix "$SCRIPT_DIR" run dev >> /tmp/robin-vite.log 2>&1 &
|
||||||
|
echo "Vite PID $! — logs: /tmp/robin-vite.log"
|
||||||
|
sleep 2 # give Vite time to bind before Robin connects
|
||||||
|
else
|
||||||
|
echo "Note: no release binary and Node not found — webview will show connection error."
|
||||||
|
echo "Run 'npm install && npm run dev' in $SCRIPT_DIR to fix this."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
nohup "$bin" >> "$LOG_FILE" 2>&1 &
|
nohup "$bin" >> "$LOG_FILE" 2>&1 &
|
||||||
echo "Started (PID $!). Logs: $LOG_FILE"
|
echo "Robin started (PID $!). Logs: $LOG_FILE"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
|
|
@ -72,6 +88,11 @@ case "$cmd" in
|
||||||
else
|
else
|
||||||
echo "Robin is not running."
|
echo "Robin is not running."
|
||||||
fi
|
fi
|
||||||
|
# Stop Vite dev server if we started it.
|
||||||
|
if pgrep -f "vite" > /dev/null 2>&1; then
|
||||||
|
pkill -f "node.*vite" 2>/dev/null || true
|
||||||
|
echo "Vite dev server stopped."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart)
|
restart)
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,9 @@ import vue from '@vitejs/plugin-vue'
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
|
server: {
|
||||||
|
port: 1420,
|
||||||
|
strictPort: true, // fail loudly if 1420 is taken rather than silently shifting
|
||||||
|
},
|
||||||
|
clearScreen: false, // keep terminal output readable alongside cargo/Tauri logs
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue