Skip to content

fix(login): full stdio inheritance for claude setup-token + paste prompt#25

Merged
itsgg merged 1 commit into
mainfrom
fix/login-tty-paste
May 1, 2026
Merged

fix(login): full stdio inheritance for claude setup-token + paste prompt#25
itsgg merged 1 commit into
mainfrom
fix/login-tty-paste

Conversation

@itsgg
Copy link
Copy Markdown
Owner

@itsgg itsgg commented May 1, 2026

Summary

User report with screenshots: `maru profile login work` showed garbled output — Claude Code's splash screen ("Opening browser to sign in... Welcome to Claude Code v2.1.112" + ASCII art) repeated three times. After login, `claude` showed first-time onboarding instead of an authenticated session.

Diagnosis

Two bugs in alpha.5/alpha.6's `maru profile login`:

  1. TUI corruption. Claude Code's `setup-token` is a full TUI app. Piping its stdout (to auto-capture the printed token) made it detect a non-TTY stdout and re-render the splash multiple times trying to refresh.
  2. Wrong token captured. The "last non-empty line" extraction reliably grabbed the hint line — `Use this token by setting: export CLAUDE_CODE_OAUTH_TOKEN=` (with the literal placeholder ``) — rather than the actual token printed below it. The saved token was therefore invalid, and Claude Code silently fell back to the OAuth flow on next launch.

Fix

Replace the auto-capture with full stdio inheritance for `setup-token`. The OAuth flow runs as if invoked directly (TUI works, browser callback works, token prints normally). After `setup-token` exits, maru prompts the user to paste the printed token. They have full scrollback to copy from.

`--stdin` mode is unchanged for piped/scripted use:
```sh
claude setup-token | maru profile login work --stdin
```

Test plan

  • cargo fmt / clippy / nextest 240/240 clean
  • manual: review the new `run_claude_setup_token_and_capture` flow
  • CI green
  • After merge + retag (`v0.1.0-alpha.7`): full live test on the user's Mac

Bumps workspace to 0.1.0-alpha.7. Updates docs/limitations.md + docs/quickstart.md to describe the paste step.

Live test surfaced two bugs in `maru profile login` (alpha.5/.6):

1. Claude Code's `setup-token` is a TUI app. Piping its stdout (to
   capture the token) made it detect a non-TTY and re-render the
   splash multiple times — the user saw three repetitions of
   "Opening browser to sign in..." with cloud-and-C ASCII art.
2. The "last non-empty line" extraction reliably grabbed the hint
   line `Use this token by setting: export CLAUDE_CODE_OAUTH_TOKEN=<token>`
   (with the literal placeholder `<token>`) rather than the actual
   token printed a few lines below. The saved token was therefore
   invalid; Claude Code silently fell back to the OAuth flow on next
   launch and showed the first-time onboarding instead of an
   authenticated session.

Replace the auto-capture path with full stdio inheritance:
`setup-token` runs as if invoked directly (no TUI corruption, OAuth
flow + browser handoff work normally), and after it exits, maru
prompts the user to paste the token they just saw printed. The
`--stdin` mode is unchanged for piped/scripted use.

Updates docs/limitations.md + docs/quickstart.md to describe the
paste step. Workspace 240/240 tests pass.

Bumps to 0.1.0-alpha.7.
@itsgg itsgg merged commit 8dd0555 into main May 1, 2026
18 checks passed
@itsgg itsgg deleted the fix/login-tty-paste branch May 1, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant