Skip to content

fix: improve remove command query and pipe flows#23

Merged
Loongphy merged 17 commits intomainfrom
fix/remove-command
Mar 21, 2026
Merged

fix: improve remove command query and pipe flows#23
Loongphy merged 17 commits intomainfrom
fix/remove-command

Conversation

@Loongphy
Copy link
Copy Markdown
Owner

@Loongphy Loongphy commented Mar 20, 2026

This PR improves the remove command workflow and related cleanup behavior.

Summary:

  • add codex-auth remove <query> with case-insensitive alias/email fragment matching
  • require confirmation when one query matches multiple accounts
  • fall back to the numbered selector when stdin is not a TTY
  • print Removed N account(s): ... after successful deletion
  • delete the removed account snapshot and any parseable accounts/auth.json.bak.* backups whose record_key matches the removed account
  • if the removed account was active, switch to the first remaining account in registry order
  • if no accounts remain after remove, delete ~/.codex/auth.json
  • leave malformed auth.json.bak.* backups in place for manual cleanup or codex-auth clean

Validation:

  • env ZIG_GLOBAL_CACHE_DIR=.zig-cache/test-global ZIG_LOCAL_CACHE_DIR=.zig-cache/test-local zig test src/main.zig -lc
  • zig build run -- list

Plan and review log:

  • tracked in plans/2026-03-20-remove-command.md

Current status:

  • implementation committed and pushed
  • latest follow-up commit: 7c7b247
  • PR checks are running again after the active-auth cleanup change

Note

Improve remove command to support query-driven, --all, and non-TTY pipe flows

  • Adds optional <query> and --all arguments to the remove command in cli.zig, replacing the previously interactive-only flow.
  • In TTY mode, a query matching multiple accounts prompts for confirmation; in non-TTY (pipe) mode, multi-match queries return an error instead of hanging on stdin.
  • Non-TTY sessions fall back to a numbered selector for interactive removal; numbered input is now strictly validated to reject non-numeric characters.
  • After removal, the active account is reconciled: the best remaining account is promoted, or auth.json is deleted if none remain. Auth backup files for removed accounts are also cleaned up.
  • Behavioral Change: handled CLI errors (no match, invalid selection, non-TTY confirmation unavailable) now exit with code 1 instead of surfacing internal error details.

Macroscope summarized 2fdfd98.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 20, 2026

Open in StackBlitz

@loongphy/codex-auth-darwin-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-arm64@23

@loongphy/codex-auth-darwin-x64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-x64@23

@loongphy/codex-auth-linux-x64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-x64@23

@loongphy/codex-auth-win32-x64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-x64@23

@loongphy/codex-auth

npx https://pkg.pr.new/@loongphy/codex-auth@23

commit: 2fdfd98

@Loongphy
Copy link
Copy Markdown
Owner Author

/review PR

@Loongphy Loongphy marked this pull request as ready for review March 21, 2026 05:38
@Loongphy Loongphy merged commit 201ca6f into main Mar 21, 2026
10 checks passed
@Loongphy Loongphy deleted the fix/remove-command branch March 21, 2026 05: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