workstation: stop the Claude Code onboarding wizard reappearing for terminal users
All checks were successful
ci/woodpecker/push/default Pipeline was successful
All checks were successful
ci/woodpecker/push/default Pipeline was successful
emo reported being "logged out" on terminal.viktorbarzin.me: every new shell dropped him at the first-run "Choose the text style" wizard, even though he'd used many sessions and is in fact fully authenticated. Root cause is NOT a logout — ~/.claude.json is a single file that all of a user's concurrent claude processes (the ttyd terminal + their t3-serve instance + agent sessions) read-modify-write, and a stale writer periodically drops top-level keys, including hasCompletedOnboarding. That bounces the next interactive session back to onboarding; credentials are safe in the separate ~/.claude/.credentials.json (which is why T3 kept working). wizard's own ~/.claude.json showed the same key loss, so this hits any heavy multi-session user. Fix: - skel/start-claude.sh: ensure_onboarding() idempotently re-asserts hasCompletedOnboarding (+ lastOnboardingVersion) in ~/.claude.json right before launching claude. Merge-only (never clobbers other keys), runs as the user, and no-ops if jq is missing or the file is empty/corrupt. So even if the race drops the flag, the next launch restores it before claude reads it. - t3-provision-users.sh: deploy_user_launcher() re-copies skel/start-claude.sh into every non-admin home (copy-if-changed) on the hourly reconcile. /etc/skel only seeds the launcher at account creation, so without this the fix (and any future launcher edit) would never reach existing users. .tmux.conf is deliberately not re-copied — terminal-lobby appends a managed section to it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
82a0c5aedf
commit
bb3f5f2329
3 changed files with 52 additions and 0 deletions
|
|
@ -51,6 +51,37 @@ launch() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Re-assert Claude Code's first-run onboarding flag before launch. ~/.claude.json is a
|
||||
# SINGLE file that ALL of a user's concurrent claude processes (this terminal, their
|
||||
# t3-serve instance, agent/SDK sessions) read-modify-write; a stale writer periodically
|
||||
# drops top-level keys — including hasCompletedOnboarding — which throws the next
|
||||
# interactive session back to the "Choose the text style" wizard even though the user is
|
||||
# fully logged in (credentials live in the SEPARATE ~/.claude/.credentials.json, which is
|
||||
# never affected). Idempotent, runs as the user right before launch, never clobbers other
|
||||
# keys. Best-effort: no-op if jq is missing or the file is empty/corrupt (claude self-heals).
|
||||
ensure_onboarding() {
|
||||
command -v jq >/dev/null 2>&1 || return 0
|
||||
local cfg="$HOME/.claude.json" ver tmp
|
||||
ver="$(claude --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)"
|
||||
if [ -s "$cfg" ]; then
|
||||
jq -e . "$cfg" >/dev/null 2>&1 || return 0 # corrupt -> leave for claude
|
||||
[ "$(jq -r '.hasCompletedOnboarding // false' "$cfg")" = "true" ] && return 0 # already set -> no write
|
||||
elif [ -e "$cfg" ]; then
|
||||
return 0 # empty (mid-write?) -> leave it
|
||||
fi
|
||||
tmp="$(mktemp "${cfg}.XXXXXX")" || return 0
|
||||
if [ -f "$cfg" ]; then
|
||||
jq --arg v "$ver" '.hasCompletedOnboarding = true
|
||||
| (if $v != "" then .lastOnboardingVersion = $v else . end)' "$cfg" > "$tmp" 2>/dev/null \
|
||||
&& chmod 600 "$tmp" && mv "$tmp" "$cfg" || rm -f "$tmp"
|
||||
else
|
||||
jq -n --arg v "$ver" '{hasCompletedOnboarding: true}
|
||||
+ (if $v != "" then {lastOnboardingVersion: $v} else {} end)' > "$tmp" 2>/dev/null \
|
||||
&& chmod 600 "$tmp" && mv "$tmp" "$cfg" || rm -f "$tmp"
|
||||
fi
|
||||
}
|
||||
ensure_onboarding
|
||||
|
||||
# Deliberately not `exec` so we can branch on the exit code: clean quit ends the
|
||||
# pane (ttyd closes the terminal); a crash drops to a shell so the tmux session
|
||||
# isn't destroyed-and-recreated in a ttyd auto-reconnect loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue