From e34380656c4c086f7c9a2ddceed560b62197000c Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Sun, 3 May 2026 12:38:30 +0000 Subject: [PATCH] feat(setup): headless-aware Claude sign-in pre-message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pre-message printed by setup/register-claude-token.sh used to say "A browser window will open for you to sign in with your Claude account." Accurate on a laptop or desktop, but a lie on headless devices (Pi, SSH'd-into Linux server, CI) where the browser auto-open never lands and the user actually has to copy the URL `claude setup-token` prints to another device. Add a small bash isHeadless check (mirrors `isHeadless()` in setup/platform.ts: Linux without DISPLAY / WAYLAND_DISPLAY) and swap the heredoc accordingly: - Headless: "A sign-in link will appear for you to sign in with your Claude account. When you finish, we'll save the token to your OneCLI vault automatically." - GUI: existing "A browser window will open…" copy, unchanged. The trailing "Press Enter to continue, or edit the command first." line and the actual `claude setup-token` invocation are unchanged — only the leading sentence flips. --- setup/register-claude-token.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/setup/register-claude-token.sh b/setup/register-claude-token.sh index e0adfc628..324b1becb 100755 --- a/setup/register-claude-token.sh +++ b/setup/register-claude-token.sh @@ -51,13 +51,34 @@ command -v script >/dev/null \ tmpfile=$(mktemp -t claude-setup-token.XXXXXX) trap 'rm -f "$tmpfile"' EXIT -cat <<'EOF' +# Detect headless. Mirrors `isHeadless()` in setup/platform.ts: on Linux +# with neither DISPLAY nor WAYLAND_DISPLAY set, no graphical session +# exists, so `claude setup-token` won't be able to auto-open a browser +# and the user will need to copy the printed sign-in URL by hand. The +# pre-message copy below is swapped accordingly so we don't promise a +# browser pop that will never happen. +is_headless=0 +if [ "$(uname -s)" = "Linux" ] && [ -z "${DISPLAY:-}" ] && [ -z "${WAYLAND_DISPLAY:-}" ]; then + is_headless=1 +fi + +if [ "$is_headless" = "1" ]; then + cat <<'EOF' +A sign-in link will appear for you to sign in with your Claude account. +When you finish, we'll save the token to your OneCLI vault automatically. + +Press Enter to continue, or edit the command first. + +EOF +else + cat <<'EOF' A browser window will open for you to sign in with your Claude account. When you finish, we'll save the token to your OneCLI vault automatically. Press Enter to continue, or edit the command first. EOF +fi cmd="claude setup-token" if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then