Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Releases/v4.0.3/.claude/PAI-Install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ fi
info "Launching installer..."
echo ""

# Auto-detect headless/SSH environments and fall back to CLI mode
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(uname)" != "Darwin" ]; then
# Auto-detect headless/SSH environments and fall back to CLI mode.
# Use ${VAR:-} to tolerate `set -u` (nounset, enabled on line 8) — on SSH/headless
# Linux hosts DISPLAY and WAYLAND_DISPLAY are typically unset, which would abort
# the script before the detection runs.
if [ -z "${DISPLAY:-}" ] && [ -z "${WAYLAND_DISPLAY:-}" ] && [ "$(uname)" != "Darwin" ]; then
INSTALL_MODE="cli"
info "Headless environment detected — using CLI installer."
else
Expand Down
13 changes: 12 additions & 1 deletion Releases/v4.0.3/.claude/PAI-Install/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ import { existsSync } from "fs";

const args = process.argv.slice(2);
const modeIdx = args.indexOf("--mode");
const mode = modeIdx >= 0 ? args[modeIdx + 1] : "gui";

// Auto-detect headless (no DISPLAY/WAYLAND_DISPLAY on non-Darwin) when --mode
// is omitted. install.sh already does this when invoked via bash, but running
// main.ts directly (e.g. `bun PAI-Install/main.ts`) bypassed that check and
// unconditionally launched the Electron GUI, which fails on headless Linux.
function defaultMode(): "gui" | "cli" {
if (process.platform === "darwin") return "gui";
if (!process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) return "cli";
return "gui";
}

const mode = modeIdx >= 0 ? args[modeIdx + 1] : defaultMode();

const ROOT = import.meta.dir;

Expand Down