mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-04 10:14:47 +08:00
feat(setup): headless-aware Claude sign-in pre-message
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user