feat: open WebUI after fresh desktop install

This commit is contained in:
chengyongru
2026-07-26 03:28:15 +08:00
committed by chengyongru
parent b0ef759e2c
commit 55405f6cd6
8 changed files with 130 additions and 71 deletions
+43 -4
View File
@@ -36,7 +36,7 @@ Usage: install.sh [--dev] [--dry-run]
By default this installs or upgrades nanobot-ai from PyPI.
Use --dev to install from the current main branch on GitHub.
Use --dry-run to print what would happen without installing or starting the wizard.
Use --dry-run to print what would happen without installing or starting setup.
EOF
}
@@ -104,6 +104,30 @@ nanobot_try_command() {
esac
}
is_fresh_nanobot_install() {
[ -n "${HOME:-}" ] || return 1
[ ! -e "$HOME/.nanobot/config.json" ]
}
has_browser_session() {
if [ -n "${SSH_CONNECTION:-}${SSH_TTY:-}" ]; then
return 1
fi
if ! : 2>/dev/null < /dev/tty; then
return 1
fi
case "$(uname -s)" in
Darwin)
command -v launchctl >/dev/null 2>&1 &&
launchctl print "gui/$(id -u)" >/dev/null 2>&1
;;
*)
[ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]
;;
esac
}
install_with_active_python() {
info "Detected an active virtual environment. Installing into it..."
ensure_pip "$python_bin" || return 1
@@ -225,7 +249,10 @@ if [ "$dry_run" = "1" ]; then
info "Dry run: would run nanobot as: $venv_dir/bin/python -m nanobot"
fi
if [ "${NANOBOT_SKIP_WIZARD:-}" = "1" ]; then
info "Dry run: would skip setup wizard because NANOBOT_SKIP_WIZARD=1."
info "Dry run: would skip automatic setup because NANOBOT_SKIP_WIZARD=1."
elif is_fresh_nanobot_install && has_browser_session; then
info "Dry run: would start the WebUI for this fresh desktop install."
info "Dry run: would fall back to the setup wizard for older releases."
else
info "Dry run: would run the setup wizard."
fi
@@ -264,11 +291,23 @@ info "Installed nanobot:"
run_nanobot --version
if [ "${NANOBOT_SKIP_WIZARD:-}" = "1" ]; then
info "Skipping setup wizard because NANOBOT_SKIP_WIZARD=1."
info "Run this later: $(nanobot_try_command) onboard --wizard"
info "Skipping automatic setup because NANOBOT_SKIP_WIZARD=1."
info "Run this later: $(nanobot_try_command) webui"
exit 0
fi
if is_fresh_nanobot_install && has_browser_session; then
if run_nanobot webui --help >/dev/null 2>&1; then
info "Starting nanobot WebUI..."
info "Configure your first provider and model in Settings > Models."
info "Run this later: $(nanobot_try_command) webui"
run_nanobot webui --yes
exit 0
fi
info "The installed release does not support nanobot webui yet."
info "Falling back to the setup wizard..."
fi
if [ -t 0 ]; then
info "Starting setup wizard..."
run_nanobot onboard --wizard