Skip to content

fix(agent-setup): ask before a sign-in changes the selected account - #9181

Open
tsavo-at-pieces wants to merge 4 commits into
ParadevAI:mainfrom
tsavo-at-pieces:fix/codex-login-default-home
Open

tsavo-at-pieces wants to merge 4 commits into
ParadevAI:mainfrom
tsavo-at-pieces:fix/codex-login-default-home

Conversation

@tsavo-at-pieces

@tsavo-at-pieces tsavo-at-pieces commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Fixes #9172.

Once an account is the default for new agents (Settings → Usage), the codex and claude wrappers point every launch at it. That included codex login, codex logout, claude auth login and claude auth logout. A bare codex login in a workspace terminal signed in to the selected home rather than ~/.codex, and so did env -u CODEX_HOME codex login, because the resolver filled an unset value from the pointer file. Current Codex releases log out the target home's stored login before the browser step, so the selected account lost its login even when the sign-in was cancelled. Another tool that manages logins in the same home lost its login too.

buildDefaultAccountResolver now takes each wrapper's sign-in commands and looks for their words as whole arguments anywhere before --: login or logout for Codex, auth and then login or logout for Claude. Root options in front of the subcommand (codex -c key=value login, codex --enable hooks logout, claude --verbose auth login) do not hide it, and a one-argument prompt such as claude "auth login" does not count. codex login status and launches that ask for help (-h, --help, or help first) are left alone. For the sign-in commands:

  • An unset CODEX_HOME / CLAUDE_CONFIG_DIR stays unset, so env -u CODEX_HOME codex login reaches the CLI's own default, as it does outside Paradev.
  • When the value is the injected selection (it equals its SUPERSET_DEFAULT_* twin and, for Codex, is not SUPERSET_AMBIENT_CODEX_HOME), the wrapper names the home and asks Continue? [y/N] if stderr is a terminal. The answer comes from stdin, or from /dev/tty when stdin carries the CLI's input, as when an API key is piped into codex login --with-api-key. Only y or yes continues. Any other answer exits 1 and prints the same command aimed at the system default (CODEX_HOME=<ambient home> codex …, or env -u CLAUDE_CONFIG_DIR claude …).
  • Callers without a terminal get exit 2 and a message that names the home and says a person has to confirm in a terminal. It prints no command to run instead. A script that means to change the selected account's login empties the twin for that one command (SUPERSET_DEFAULT_CODEX_HOME= CODEX_HOME=<home> codex login); docs/agent-tooling.md describes this.

A pseudo-terminal counts as a terminal, so an agent whose shell tool runs commands in a PTY can still answer the question. The guard catches a sign-in typed out of habit and an agent's ordinary tool call; it does not stop a caller that is set on signing in to that home.

The guard checks the SUPERSET_DEFAULT_* twin, not SUPERSET_TERMINAL_ID, so it also covers chat agents, whose environment carries the selection without a terminal id. Matching errs toward asking: an unquoted prompt word (codex exec login) and codex mcp login <server> ask too.

One desktop change: the Usage card's API-key re-sign for the system-default Codex login pointed at "${CODEX_HOME:-$HOME/.codex}". In a workspace terminal with an account selected, that is the selected account, so the command signed the selected profile in with the key and marked it API-billed. It now uses "${SUPERSET_AMBIENT_CODEX_HOME:-${CODEX_HOME:-$HOME/.codex}}", the home the Usage tab calls the system default, and is unchanged in any other shell.

Unchanged: agent runs, codex login status, --help, a login into a home the user named that is not the selection (the Add account command, Switch sign-in for another profile), logins when nothing is selected, and the Usage dialog's own terminal, which has no SUPERSET_DEFAULT_* variables. Paradev's own commands that point at the selected home (the chat's sign-in command, and the Usage card's re-sign command for that profile, the API-key one included) work after one confirmation.

The third parameter of buildDefaultAccountResolver is now an options object (ambientEnvVar, credentialCommands, readOnlyCommands). Both callers are in agent-setup. docs/agent-tooling.md describes the guard, the override for scripts, and its reach: launches through the wrappers only, not the real binary run by path or /login and /logout inside a running session.

Not in this PR: the Usage card still suggests a bare codex login / claude auth login when the system-default login has expired. In a workspace terminal with an account selected, that command stops at the question, which names the selected home; on n the wrapper prints the system-default form. Changing that card's command would be a separate change in the desktop app.

How I tested it

Everything ran in Docker on oven/bun:1.4.3, the version .bun-version pins: one container at a time, the tree streamed in with git archive, dependencies from bun install --frozen --ignore-scripts, and no network for tests, typecheck or lint. The i18n catalogs were compiled first (bun run compile in packages/i18n), as turbo's ^build does before test and typecheck.

  • Tests first. The final test files, run against the first commit of this PR (643ba76e), fail 11 tests in packages/agent-setup and 2 in the desktop app (one is the runner of the shell checks), each on its assertion: root options before the subcommand (Codex and Claude, refused and kept unset, end to end through the generated wrappers), the one-argument claude "auth login" prompt, the refusal printing no command, the piped API-key login asking through /dev/tty (resolver and generated wrapper), the hint after a "no", and the system-default Codex API re-sign targeting the ambient home.

  • With the change, bun test in packages/agent-setup: 403 pass, 37 fail. Unchanged main in the same container: 380 pass, 37 fail. The 37 are the same tests by name in both runs: notify-hook, shell-wrapper fallback and Codex session-log tests that need curl, jq, python3 or ps, which the slim image does not have. None of them touches the resolver. The two touched test files pass at each of the three new commits, apart from the same three session-log tests.

  • Desktop: the two touched test files, switchSignInCommand.test.ts and apiBilling.test.ts (which runs the shell checks, two of them new, in a separate process), 11 pass.

  • The prompt tests run on a real pseudo-terminal (Bun.spawn with terminal, which makes it the controlling terminal): y continues; n and a bare Enter exit 1 and the CLI does not run. The piped tests feed printf '%s' sk-test | … login --with-api-key and check that the answer came from the terminal and the key reached the CLI.

  • Mutation check. 22 small changes to the new shell and to the wrapper options, each run against the two test files: 21 make a test fail. The one that survives drops the [ -t 2 ] check, which only matters when stderr is redirected (codex login 2>/dev/null on a terminal), where the command is refused without a visible message.

  • bun run typecheck: packages/agent-setup no errors; apps/desktop no errors (unchanged main: no errors either).

  • biome check . over the whole repo (what scripts/lint.sh runs), Biome 2.4.2: no diagnostics.

  • bash -n on the generated codex and claude wrappers. The new shell uses only what bash 3.2 (macOS /bin/bash) has (case, [ -t ], read -r, printf %q, a subshell redirect from /dev/tty); I did not run it on macOS.

  • Flows with the generated wrappers and the commands the desktop code itself generates (addAccountCommand, switchSignInCommand, agentLoginCommand), stub CLIs that print what they got, accounts selected:

    • Usage dialog's own terminal: Add account and Switch sign-in (subscription and API key, selected profile and system default) run with no question, as before.
    • Pasted into a workspace terminal: Switch sign-in for the selected API-billed Codex profile asks once after the key is entered; y signs in with the key and writes the marker, n changes nothing. The system-default API re-sign goes to the ambient home with no question and leaves the selected profile alone.
    • No terminal: codex login, codex login --with-api-key, codex -c model=x logout, claude auth login --console, claude --verbose auth logout, and codex --config foo=bar login in a chat agent's environment all exit 2 without printing a command. The documented override runs.
    • Nothing selected: login and logout run unchanged, with or without a terminal.
  • No screenshots, because no UI changed. These are the generated wrappers in the container with /home/u/.codex-work and /home/u/.claude-work selected, over stub CLIs that print the home and the arguments they got (REAL codex …):

    # No terminal (a script or an agent's tool call):
    $ codex login
    Paradev: codex login would change the login in /home/u/.codex-work, the account you made the default for new agents. Nothing was run: a person has to confirm this in a terminal.
    [exit 2]
    $ codex -c model=x logout
    Paradev: codex logout would change the login in /home/u/.codex-work, the account you made the default for new agents. Nothing was run: a person has to confirm this in a terminal.
    [exit 2]
    $ env -u CODEX_HOME codex -c model=x login
    REAL codex CODEX_HOME=<unset> args=[--enable hooks --dangerously-bypass-hook-trust -c model=x login]
    [exit 0]
    $ claude 'auth login'
    REAL claude CLAUDE_CONFIG_DIR=/home/u/.claude-work args=[auth login]
    [exit 0]
    
    # On a terminal (script -qec echoes the answer before the prompt):
    $ codex login
    n
    Paradev: codex login will change the login in /home/u/.codex-work, the account you made the default for new agents. Continue? [y/N] Paradev: cancelled. To run it on the system default instead: CODEX_HOME=/home/u/.codex codex login
    [exit 1]
    $ CODEX_HOME=/home/u/.codex codex login
    REAL codex CODEX_HOME=/home/u/.codex args=[--enable hooks --dangerously-bypass-hook-trust login]
    [exit 0]
    
    # The Usage card's re-sign command for the selected, API-billed profile; the key, then y, typed a second apart:
    $ (printf 'OpenAI API key: ' && read -rs OPENAI_KEY && echo && printf '%s' "$OPENAI_KEY" | CODEX_HOME=/home/u/.codex-work codex login --with-api-key && printf codex > /home/u/.codex-work/.superset-api-billing; SUPERSET_LOGIN_STATUS=$?; unset OPENAI_KEY; exit "$SUPERSET_LOGIN_STATUS")
    OpenAI API key:
    Paradev: codex login will change the login in /home/u/.codex-work, the account you made the default for new agents. Continue? [y/N] y
    REAL codex CODEX_HOME=/home/u/.codex-work args=[--enable hooks --dangerously-bypass-hook-trust login --with-api-key] key=sk-test-C3
    [exit 0]
    

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too). Lint passes over the whole repo. Typecheck passes for packages/agent-setup and apps/desktop, the two packages changed; the repo-wide run is left to CI.
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR). Signed on fix(usage): keep Codex workspace seats that share an email #9059.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Codex and Claude sign-in or sign-out commands launched through the wrappers ask for confirmation before changing the selected account’s login. Declining stops the command; if no terminal is available, the command also stops.
    • Commands preserve an unset account selection when no account is selected. For system-default Codex API-key sign-ins, the billing marker now follows the ambient Codex home when available, with the CLI home as a fallback.
  • Documentation
    • Updated the account setup guide with details on confirmation prompts and how scripts can bypass them for a single command.

In a workspace terminal the codex and claude wrappers point every launch
at the account selected for new agents. That included `codex login`,
`codex logout`, `claude auth login` and `claude auth logout`. A bare
`codex login` signed in to the selected home instead of ~/.codex, and so
did `env -u CODEX_HOME codex login`, because the resolver filled an
unset CODEX_HOME from the pointer file. Current Codex releases log out
the target home's stored login before the browser step, so this ended
the selected account's login even when the sign-in was cancelled.

buildDefaultAccountResolver now takes each wrapper's sign-in commands
and matches them against the leading words of the arguments. For those
commands an unset value stays unset. When the value is the injected
selection (it equals its SUPERSET_DEFAULT_* twin and, for Codex, is not
the ambient home), the wrapper names the home and asks on a terminal.
Without a terminal it exits 2 and prints how to run the command on that
account or without it. Agent runs, `codex login status`, --help,
explicit homes and logins with no selection are unchanged.

Fixes ParadevAI#9172

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45392583-94ca-4355-b15c-a1d79868c4cb
Commits

Reviewing files that changed from the base of the PR and between 643ba76 and da6e8d9.

Files selected for processing: 8
  • apps/desktop/src/renderer/routes/_authenticated/settings/usage/components/UsageView/utils/apiBilling/fixtures/shell-checks.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/usage/components/UsageView/utils/switchSignInCommand/switchSignInCommand.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/usage/components/UsageView/utils/switchSignInCommand/switchSignInCommand.ts
  • docs/agent-tooling.md
  • packages/agent-setup/src/agent-wrappers-claude-codex-opencode.ts
  • packages/agent-setup/src/agent-wrappers-common.ts
  • packages/agent-setup/src/agent-wrappers.test.ts
  • packages/agent-setup/src/default-account-resolver.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

Codex and Claude wrappers now identify configured credential commands and prompt before using a selected account, or refuse when no terminal is available. The Codex API-key re-sign command also checks the ambient home before other home values.

Changes: Credential command guard

Layer / File(s) Summary
Resolver options and credential guard
packages/agent-setup/src/agent-wrappers-common.ts
The resolver accepts ambient-home and command options. It matches configured credential commands, excludes read-only commands, and prompts or refuses when a selected account would be used.
Wrapper configuration and behavior checks
packages/agent-setup/src/agent-wrappers-claude-codex-opencode.ts, packages/agent-setup/src/default-account-resolver.test.ts, packages/agent-setup/src/agent-wrappers.test.ts, docs/agent-tooling.md
The Claude and Codex wrappers configure credential commands. Tests cover command parsing, account selection, terminal confirmation, refusal, and piped input. The documentation describes the wrapper behavior.

System-default Codex API re-sign

Layer / File(s) Summary
Ambient-home resolution and checks
apps/desktop/src/renderer/routes/_authenticated/settings/usage/components/UsageView/utils/switchSignInCommand/*, apps/desktop/src/renderer/routes/_authenticated/settings/usage/components/UsageView/utils/apiBilling/fixtures/shell-checks.ts
The system-default API-key command checks SUPERSET_AMBIENT_CODEX_HOME before CODEX_HOME and $HOME/.codex. Tests verify the selected home and billing-marker location.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant CodexWrapper
  participant DefaultAccountResolver
  participant Terminal
  participant CodexCLI
  CodexWrapper->>DefaultAccountResolver: Resolve account and inspect credential command
  alt Selected account would be used
    DefaultAccountResolver->>Terminal: Request confirmation
    Terminal-->>DefaultAccountResolver: Return yes or no
    alt Confirmation accepted
      DefaultAccountResolver->>CodexCLI: Continue credential command
    else Confirmation declined
      DefaultAccountResolver-->>CodexWrapper: Exit with status 1
    end
  else No terminal is available
    DefaultAccountResolver-->>CodexWrapper: Exit with status 2 without running command
  else Account variable is unset or account is not selected
    DefaultAccountResolver->>CodexCLI: Run command with resolved account environment
  end
Loading

Possibly related issues

  • #9173: The changes resolve the system-default Codex home for API-key re-sign commands, but do not change the Usage card’s status classification or signed-out card behavior.

Suggested reviewers: kitenite

Merge Risk: Minimal · up to da6e8

The change makes Codex and Claude sign-in and sign-out commands ask for confirmation, or refuse without a terminal, before touching the selected account. No concrete merge-blocking defect was found in the reviewed changes.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #9172 has coding requirements. The PR meets most of them. buildDefaultAccountResolver (agent-wrappers-common.ts) matches whole argument words for Codex login/logout and Claude auth login… Make the non-terminal refusal in buildCredentialCommandGuard print how to name the home explicitly, as #9172 requires. Use the same form as the declined-answer hint, for example CODEX_HOME=<selected home> codex … or `env -u CLAUDE_CONFI…
Docstring Coverage Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title uses conventional commit format and clearly describes the main change: prompting before sign-in changes the selected account.
Description check Passed The description includes the required What & why, How I tested it, and Checklist sections. It explains the behavior, scope, tests, known environment limitations, and incomplete repository-wide typeche…
Out of Scope Changes check Passed The reviewed changes stay within #9172. The resolver, wrapper callers, and tests in packages/agent-setup implement the credential-command guard. docs/agent-tooling.md describes that guard. The des…
Full details: Description check

Explanation

The description includes the required What & why, How I tested it, and Checklist sections. It explains the behavior, scope, tests, known environment limitations, and incomplete repository-wide typecheck status. The unchecked checklist item accurately notes that CI must run the full repository checks.

Full details: Out of Scope Changes check

Explanation

The reviewed changes stay within #9172. The resolver, wrapper callers, and tests in packages/agent-setup implement the credential-command guard. docs/agent-tooling.md describes that guard. The desktop change in switchSignInCommand.ts and its test and fixture files alters the system-default Codex API re-sign target. The issue names this path: the Usage card's advised command in a workspace terminal re-signs the selected home. The PR description and objectives now include this change. Its test files cover the change. No unrelated product behavior appears in the summary.

Full details: Linked Issues check

Explanation

Issue #9172 has coding requirements. The PR meets most of them. buildDefaultAccountResolver (agent-wrappers-common.ts) matches whole argument words for Codex login/logout and Claude auth login/auth logout, with root options allowed before the subcommand. login status and help launches are excluded through readOnlyCommands and the help check. An unset CODEX_HOME/CLAUDE_CONFIG_DIR stays unset for credential commands. The guard compares against the SUPERSET_DEFAULT_* twin. On a terminal it asks [y/N]. Only y/yes continues. A declined answer prints the system-default command. The desktop API re-sign now uses SUPERSET_AMBIENT_CODEX_HOME first. The unmet requirement: #9172 requires that, without a terminal, the wrapper refuse "with instructions for explicitly naming the home" (issue body: "it refuses and says how to name the home explicitly"). The current refusal names the home but prints no command, and says only that a person must confirm in a terminal. The earlier head printed the explicit-home command. The incremental commit that removed it makes this requirement unmet. docs/agent-tooling.md documents an override for scripts, but the refusal output itself does not give the instructions. I checked source diffs only and did not run the tests.

Resolution

Make the non-terminal refusal in buildCredentialCommandGuard print how to name the home explicitly, as #9172 requires. Use the same form as the declined-answer hint, for example CODEX_HOME=&lt;selected home&gt; codex … or env -u CLAUDE_CONFIG_DIR claude … for the system default, or the form the issue owner accepts. Update the tests that assert the refusal prints no command. If the author keeps the no-command design, #9172 must first be revised by its owner to drop that requirement. The PR cannot change the requirement alone.

Full details: Docstring Coverage

Explanation

Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change is limited to credential commands in the Codex and Claude wrappers.

Fix the leading-option bypass before merging so credential commands cannot silently change the selected account.

Findings

  1. P1 Leading options bypass confirmation ▶
  2. P2 Quoted prompts get refused ▶
Fix with agent prompt
### Issue 1
packages/agent-setup/src/agent-wrappers-common.ts:207-209
With an account selected, `codex -c 'model="gpt-5"' logout` stops this scan at `-c`, leaving `superset_credential_command` empty. Logout then changes the selected account without asking. With `env -u CODEX_HOME`, the missed match also lets the resolver fill the selected home back in.

The Codex wrapper already passes global options before subcommands, so this is a supported argument order. Skip supported global options and their values before checking the command.

### Issue 2
packages/agent-setup/src/agent-wrappers-common.ts:211-215
Joining arguments with spaces makes `claude "auth login"` indistinguishable from `claude auth login`. The first command passes one ordinary prompt; it does not sign in. With an injected selection, the wrapper now asks for confirmation or exits 2 instead of starting that chat.

Match separate arguments rather than a joined string, and add a test for the quoted prompt.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds confirmation before Codex and Claude sign-in commands change the selected account. Commands without a terminal are refused, and recognized credential commands leave an unset home unset.

  • Codex and Claude ask before changing the selected account’s login.

Acknowledged by tsavo-at-pieces: the Usage card still suggests bare sign-in commands for an expired system-default login. Updating those hints is explicitly deferred.

Reviews (1) · Last reviewed commit: "fix(agent-setup): ask before a sign-in c..." · Reviewed by Greptile

Comment on lines +207 to +209
case "$superset_arg" in
-h|--help) superset_command_words=""; break ;;
-*) break ;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Leading options bypass confirmation

With an account selected, codex -c 'model="gpt-5"' logout stops this scan at -c, leaving superset_credential_command empty. Logout then changes the selected account without asking. With env -u CODEX_HOME, the missed match also lets the resolver fill the selected home back in.

The Codex wrapper already passes global options before subcommands, so this is a supported argument order. Skip supported global options and their values before checking the command.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent-setup/src/agent-wrappers-common.ts
Line: 207-209

Comment:
**Leading options bypass confirmation**

With an account selected, `codex -c 'model="gpt-5"' logout` stops this scan at `-c`, leaving `superset_credential_command` empty. Logout then changes the selected account without asking. With `env -u CODEX_HOME`, the missed match also lets the resolver fill the selected home back in.

The Codex wrapper already passes global options before subcommands, so this is a supported argument order. Skip supported global options and their values before checking the command.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +211 to +215
superset_command_words="\${superset_command_words:+$superset_command_words }$superset_arg"
done
superset_credential_command=""
case "$superset_command_words" in
${pattern}) superset_credential_command="\${0##*/} $superset_command_words" ;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Quoted prompts get refused

Joining arguments with spaces makes claude "auth login" indistinguishable from claude auth login. The first command passes one ordinary prompt; it does not sign in. With an injected selection, the wrapper now asks for confirmation or exits 2 instead of starting that chat.

Match separate arguments rather than a joined string, and add a test for the quoted prompt.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent-setup/src/agent-wrappers-common.ts
Line: 211-215

Comment:
**Quoted prompts get refused**

Joining arguments with spaces makes `claude "auth login"` indistinguishable from `claude auth login`. The first command passes one ordinary prompt; it does not sign in. With an injected selection, the wrapper now asks for confirmation or exits 2 instead of starting that chat.

Match separate arguments rather than a joined string, and add a test for the quoted prompt.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

tsavo-at-pieces and others added 3 commits October 31, 2026 00:23
The match stopped at the first argument that starts with "-", so a
sign-in written with a root option before the subcommand
(`codex -c key=value login`, `codex --enable hooks logout`,
`claude --verbose auth login`) was not recognised. It ran on the
selected account without asking, and `env -u CODEX_HOME codex -c
key=value login` got CODEX_HOME filled in from the pointer file again.
Codex takes its global options before any subcommand, and the wrapper's
own exec line puts some there.

The wrappers now look for the command words as whole arguments anywhere
before `--`: `login` or `logout` for Codex, `auth` and then `login` or
`logout` for Claude. `codex login status` stays read-only, and a launch
that asks for help (-h, --help, or help first) is left alone. Because
only whole arguments count, a one-argument prompt such as
`claude "auth login"` starts a chat instead of stopping at the guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…v/tty

Without a terminal the refusal printed two runnable lines: one ran the
same sign-in on the selected account with no confirmation, the other
sent it to the CLI's default home. In a workspace most callers without a
terminal are agents' tool calls, so an agent could follow either line and
end the login the guard is there to protect. The refusal now names the
home and says a person has to confirm in a terminal, and prints no
command. docs/agent-tooling.md describes the override for scripts.

The question also needed stdin to be a terminal, so a sign-in that pipes
its input was refused inside an interactive terminal. That includes the
Usage card's re-sign command for an API-billed Codex profile, which pipes
the key into `codex login --with-api-key`. The wrapper now asks whenever
stderr is a terminal, and reads the answer from /dev/tty when stdin is
not one.

After a "no", the hint points at the system default: for Codex that is
the preserved ambient home rather than the CLI's own ~/.codex. The hint
keeps the original arguments, so `--with-api-key` and `--device-auth`
are no longer dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Usage card's API re-sign command for the system-default Codex login
pointed at "${CODEX_HOME:-$HOME/.codex}". In a Paradev terminal with an
account selected, CODEX_HOME holds that account, so the command signed
the selected profile in with the key and marked it API-billed. With the
wrapper guard it stopped at a question about the selected home instead.
It now prefers the ambient home such a terminal preserves
(SUPERSET_AMBIENT_CODEX_HOME), which is the home the Usage tab calls the
system default, and behaves as before in any other shell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

A bare codex login in a workspace terminal signs in to the Usage default account's home, not ~/.codex

1 participant