Repository navigation
fix(claude): prefer OAuth before CLI PTY in Linux Auto mode - #4615
Conversation
Add a `cli-auto-fallback-oauth` step between Web and CLI in the CLI Auto plan, included only when the planning input says OAuth should be attempted. CLI runtime never sets that today, so the plan stays web -> cli on every platform until a caller opts in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Linux cannot import browser cookies, so CLI Auto went straight from an unavailable Web step to the Claude CLI PTY fallback, which boots a full interactive `claude` session (~9 s on WSL2) even when Claude Code OAuth credentials are readable. Off macOS, plan OAuth between Web and CLI, check it with the same noninteractive credential read used by explicit sources (logged-out users still get noAvailableStrategy), and let OAuth failures such as rate limits fall back to the CLI. macOS is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR inserts OAuth between Web and Claude CLI in Linux CLI Auto mode, retaining CLI fallback and terminal cancellation. Example: WSL2 Ubuntu 24.04.4 with usable Claude Code OAuth credentials and no manual Web cookie.
Review scores
ProductKind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this PR offers a focused Linux performance improvement that current main lacks, with no definite introduced code defect found; changing the documented authentication-source default needs an owner decision. Priority: P2 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared Claude provider planner converts runtime, source selection, and credential availability into fetch strategies that return usage snapshots to the CLI or app. flowchart TD
A[Linux CLI Auto] --> B[Claude source planner]
B --> C[Web strategy]
C --> D[OAuth strategy]
D --> E[Claude CLI fallback]
C --> F[Usage snapshot]
D --> F
E --> F
Technical reviewBest possible solution: Use the existing shared OAuth strategy for an owner-approved Linux Auto order, preserving credential ownership, CLI fallback, cancellation, and explicit-source behavior. Do we have a high-confidence way to reproduce the issue? Current-main planner, documentation, and Linux tests establish that Auto omits OAuth; the PTY latency and improvement are contributor-reported, and no target code was executed during this read-only review. Is this the best way to solve the issue? Reusing the existing planner and OAuth strategy is a focused approach; explicit --source oauth already provides the fast path, but does not provide the requested automatic selection and fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6480977b47f6. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 9:09 AM ET / 13:09 UTC. |
Keep the contributor's Web → OAuth → CLI plan on Linux while trimming one-use predicates and duplicate source labels. Assert actual explicit-mode fallback behavior, remove stale help text, and add the 0.77.1 credit. Refs steipete#4613, steipete#4615. Co-authored-by: 이예서 <49704047+yeseoLee@users.noreply.github.com>
# Conflicts: # CHANGELOG.md
|
Merged in 7f7977b, thanks @yeseoLee! Linux CLI Auto now tries Claude OAuth before falling back to the slow PTY session. We kept your routing fix, trimmed a few redundant predicates and source labels, strengthened the explicit-OAuth test, removed a stale help sentence, and added the changelog credit. It will ship in the next release. |
Summary
Fixes #4613.
On Linux, Claude CLI Auto went from an unavailable Web source straight to the interactive Claude CLI PTY. That took
~9 seconds even when OAuth credentials were readable.
This change adds OAuth between Web and CLI on non-macOS platforms.
Changes
web → oauth → cli.allowKeychainPrompt: false). Withoutusable credentials, the OAuth step is skipped and CLI remains the fallback.
web → cli, same attempt list), explicit source modes, and app runtime behavior.Credential safety: the new path does not refresh or rewrite CLI-owned credentials. In the tested expired
CLI-owned credential cases, OAuth was skipped and no OAuth or token-refresh request was sent, so refresh stays with
Claude Code. This avoids reintroducing the refresh-token ownership issue in #1161.
The change reuses the CLI-runtime OAuth isolation from #1776 and adds no new subprocess.
Tests added
ClaudeSourcePlannerTests: the CLI Auto plan includes OAuth only when the input requests it.ClaudeBaselineCharacterizationTests(macOS): with readable OAuth credentials, CLI Auto still resolves toclaude.web,claude.cli.ClaudeCLIAutoOAuthLinuxTests:notFound, 401, 429 and 503 fall back to the CLI.PlatformGatingTestsandClaudeWebManualCookieLinuxTests: updated attempt lists.The new ordering and fallback tests fail on unpatched
mainand pass with this change. The cancellation test passeson both, because it guards existing behavior.
Verification
Real WSL2 account
Ubuntu 24.04.4, x86_64, Swift 6.3.3.
--provider bothclaudeoauth87% faster, with matching usage windows.
Test suites
swift test --parallel: 1,105 tests / 149 suites. One failure,ProcessOwnershipReaperTests, reproduces on unpatchedmainin the same container.main; pass with this fixOffline E2E
Ubuntu Docker, with synthetic credentials, a local HTTPS mock for the OAuth endpoints and a stub Claude CLI.
Each scenario ran 5 times, except the expired-token variants, which ran 3 times each. In the expired-token cases, no
OAuth or token-refresh request reached the mock, and the credentials file stayed byte-identical.
Compatibility and limitations
make checkreports an unrelated SwiftLint line-length violation inTypeSafeWebFetchStrategy.swift:175thatalready exists on
main.Related: #4241, #1776, #1161.
🤖 Generated with Claude Code