Skip to content

fix(tui): resolve Claude Code config import failure on clean Windows install#33

Merged
claude-code-best merged 1 commit into
KonghaYao:mainfrom
wuxiaoweisjz:main
Jun 15, 2026
Merged

fix(tui): resolve Claude Code config import failure on clean Windows install#33
claude-code-best merged 1 commit into
KonghaYao:mainfrom
wuxiaoweisjz:main

Conversation

@wuxiaoweisjz

Copy link
Copy Markdown
Contributor

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:

  1. Env var injection: inject_env_from_settings() now falls back from config.env to top-level env when the standard schema is absent. This handles config files written by migration or manual creation that use the top-level format.

  2. Setup wizard bypass: needs_setup() no longer unconditionally blocks when providers is empty — it now checks LlmProvider::from_env() first, allowing users with environment-variable-only configuration to enter the conversation.

Changes:

File What
peri-tui/src/main.rs Extracted inject_env_from_file() shared helper for config + Claude path loading; added inject_env_from_claude_settings() for ~/.claude/settings.json env import; needs_setup check now considers from_env(); added 9 unit tests
peri-tui/src/app/setup_wizard/ops.rs needs_setup() checks LlmProvider::from_env() when providers empty
peri-tui/src/app/setup_wizard/setup_wizard_test.rs Updated tests for new env-aware logic

Test plan

  • cargo check -p peri-tui — passes
  • cargo test -p peri-tui -- --test-threads=1 — 660 tests pass
  • End-to-end: peri -p "say hello" — LLM responds correctly
  • End-to-end: peri (TUI mode) — no setup wizard blockage, provider detected

Root cause

On Windows 10, ~/.peri/settings.json had env at the top level ({"env": {...}}) instead of the expected {"config": {"env": {...}}}. This caused:

  • inject_env_from_settings() to silently fail (looked for config.env)
  • LlmProvider::from_config() to return None (no config.providers)
  • needs_setup() to unconditionally show the wizard (empty providers → true)

The Claude Code settings path did not help because the env had already been migrated to Peri's config (in the wrong format) by the setup wizard.

🤖 Generated with Claude Code Best

…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>
@claude-code-best claude-code-best merged commit c244943 into KonghaYao:main Jun 15, 2026
3 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.

2 participants