fix(tui): resolve Claude Code config import failure on clean Windows install#33
Merged
Merged
Conversation
…install Two related fixes for Peri startup on Windows when API keys are configured via Claude Code's ~/.claude/settings.json: 1. `inject_env_from_settings()` now falls back from `config.env` to top-level `env` when the standard format is absent — compatible with both Peri's expected schema and the format produced by config migration. 2. `needs_setup()` no longer unconditionally blocks the TUI when `providers` is empty; now checks `LlmProvider::from_env()` first, allowing users with environment-variable-only configuration to bypass the setup wizard. Extracted `inject_env_from_file()` shared helper used by both Peri and Claude Code config loading paths. Added 9 unit tests covering standard format, fallback format, priority ordering, process-env override, and non-panicking edge cases. Tested: cargo test (660 passed), cargo check, end-to-end LLM invocation. Co-Authored-By: deepseek-v4-pro <deepseek-ai@claude-code-best.win>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the issue where Peri fails to import API keys from Claude Code configuration on Windows, causing the TUI to be blocked by the setup wizard.
Two related fixes:
Env var injection:
inject_env_from_settings()now falls back fromconfig.envto top-levelenvwhen the standard schema is absent. This handles config files written by migration or manual creation that use the top-level format.Setup wizard bypass:
needs_setup()no longer unconditionally blocks whenprovidersis empty — it now checksLlmProvider::from_env()first, allowing users with environment-variable-only configuration to enter the conversation.Changes:
peri-tui/src/main.rsinject_env_from_file()shared helper for config + Claude path loading; addedinject_env_from_claude_settings()for~/.claude/settings.jsonenv import;needs_setupcheck now considersfrom_env(); added 9 unit testsperi-tui/src/app/setup_wizard/ops.rsneeds_setup()checksLlmProvider::from_env()when providers emptyperi-tui/src/app/setup_wizard/setup_wizard_test.rsTest plan
cargo check -p peri-tui— passescargo test -p peri-tui -- --test-threads=1— 660 tests passperi -p "say hello"— LLM responds correctlyperi(TUI mode) — no setup wizard blockage, provider detectedRoot cause
On Windows 10,
~/.peri/settings.jsonhadenvat the top level ({"env": {...}}) instead of the expected{"config": {"env": {...}}}. This caused:inject_env_from_settings()to silently fail (looked forconfig.env)LlmProvider::from_config()to returnNone(noconfig.providers)needs_setup()to unconditionally show the wizard (empty providers →true)The Claude Code settings path did not help because the
envhad already been migrated to Peri's config (in the wrong format) by the setup wizard.🤖 Generated with Claude Code Best