Skip to content

fix: replace settings when switching providers, update docs and tests#7

Merged
jigonr merged 4 commits into
mainfrom
fix/settings-replace-and-docs
Jan 6, 2026
Merged

fix: replace settings when switching providers, update docs and tests#7
jigonr merged 4 commits into
mainfrom
fix/settings-replace-and-docs

Conversation

@jigonr

@jigonr jigonr commented Jan 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix Issue bug: Settings are merged instead of replaced when switching providers #6: Settings are now fully replaced (not merged) when switching providers, fixing stale configuration persistence
  • Fix CLI options: Enable positional options so --json flag works on subcommands
  • Update documentation: Correct config paths from ~/.config/claude-code/ to ~/.claude/, document all commands and flags
  • Improve tests: Add real-world scenario tests for config detection, comprehensive CLI integration tests

Test plan

  • bun run test - all 113 unit tests pass
  • node --test tests/integration/cli.test.js - all 15 integration tests pass
  • bun run lint - no Biome errors
  • bun run typecheck - no TypeScript errors
  • Manual: claude-switch z.ai then claude-switch claude-pro-max - GLM settings removed

Fixes #6

🤖 Generated with Claude Code

jigonr and others added 4 commits January 5, 2026 21:29
Settings are now fully replaced when switching providers instead of being
merged. This fixes the issue where stale settings from previous providers
(like GLM model configuration from z.ai) would persist after switching.

Fixes #6

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add enablePositionalOptions() and passThroughOptions() to fix --json flag
not being passed to list and status subcommands when a default argument
is defined on the program.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix config paths from ~/.config/claude-code/ to ~/.claude/
- Document import-bash command, --local and --json flags
- Simplify and consolidate docs to minimize overlap
- Make each page self-contained and easy to follow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 6 real-world scenario tests for config detection
- Rewrite integration tests for comprehensive CLI coverage
- Test project config override behavior
- Test --json flag on all commands

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

codecov Bot commented Jan 6, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@jigonr

jigonr commented Jan 6, 2026

Copy link
Copy Markdown
Owner Author

@claude could you correct the pr? did we manage to close the issue? did you mention the commits the issues the related? why did claude code review not pass?

@claude

claude Bot commented Jan 6, 2026

Copy link
Copy Markdown

Claude finished @jigonr's task in 1m 57s —— View job


PR Review Complete

I've analyzed the PR and here are the answers to your questions:

Did we manage to close the issue?

Yes! The PR properly references issue #6 and will auto-close it when merged:

  • The PR body includes Fixes #6
  • The main fix commit (7157aa7) also includes Fixes #6 in its message
  • Both will trigger GitHub's auto-close feature when this PR is merged

Did commits mention the related issue?

Yes! The key commit that fixes the issue includes a proper reference:

commit 7157aa7d2dd860a1effcb4cdbca675e52d504320
fix: replace env settings instead of merging when switching providers

Settings are now fully replaced when switching providers instead of being
merged. This fixes the issue where stale settings from previous providers
(like GLM model configuration from z.ai) would persist after switching.

Fixes #6

The other commits (docs, tests, CLI fix) don't reference the issue, which is appropriate since they're supporting changes rather than the actual fix.

Why did Claude Code Review not pass?

The workflow failed due to missing API credentials. The error is:

Action failed with error: Environment variable validation failed:
  - Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required when using direct Anthropic API.

How to fix it:

  1. Add ANTHROPIC_API_KEY to your repository secrets (Settings → Secrets and variables → Actions)
  2. Update .github/workflows/claude-code-review.yml to include:
    env:
      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

This is not a problem with your PR code - it's a workflow configuration issue.


Code Quality Review

The PR looks solid! Here are my findings:

Strengths:

  1. Clean fix in src/config/manager.ts:209-210 - replaces env completely instead of merging, which properly addresses issue bug: Settings are merged instead of replaced when switching providers #6
  2. Excellent test coverage - 113 unit tests + 15 integration tests all passing
  3. Comprehensive documentation updates - fixed incorrect paths throughout docs
  4. Well-structured commits - each commit is focused and has a clear purpose

📝 Minor Observations:

The core fix is simple and correct:

// Replace env settings completely (providers are mutually exclusive)
settings.env = { ...env };

However, I notice the spread operator { ...env } creates a shallow copy. This is fine for the current use case since all values are strings, but worth noting for future maintenance.


Summary

This PR is ready to merge. The issue will be automatically closed when merged. The only failing CI check is the Claude Code Review workflow, which requires you to add API credentials to your repository secrets - this is not blocking for the PR itself.


@jigonr jigonr merged commit 3e2e421 into main Jan 6, 2026
11 of 12 checks passed
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.

bug: Settings are merged instead of replaced when switching providers

1 participant