Skip to content

fix(tui): use existing complete .env instead of forcing onboarding#8

Merged
awrobel-gd merged 2 commits into
mainfrom
fix/env-file-resolution
Jul 1, 2026
Merged

fix(tui): use existing complete .env instead of forcing onboarding#8
awrobel-gd merged 2 commits into
mainfrom
fix/env-file-resolution

Conversation

@akozak-gd

Copy link
Copy Markdown
Contributor

Summary

When a fresh checkout already has a hand-written .env containing all required secrets, the TUI now uses it instead of forcing the user through the onboarding wizard. Previously the startup gate always launched the wizard because setup-complete detection also requires the mcp-config file, which only exists after init runs.

Entrypoint

SpecFlowTUI._startup_gate in mcp_server/tui/app.py now branches on onboarding.env_satisfies_requirements(load_env_secrets(root)): a complete .env goes to the new RunInitScreen (runs specflow init directly, no wizard), otherwise the existing OnboardingScreen.

Details

The required-vars contract stays in one place: env_satisfies_requirements reuses validate_all across both providers rather than adding a second validator. Running init is still necessary even with a complete .env because init writes the mcp-config and provisions workspace repos; specflow-init.sh already reads the existing .env, validates it, and resolves DEFAULT_PROVIDER from whichever LLM key is present. The repo-resolve plus streamed run_init logic was extracted into _run_init_streamed, shared by OnboardingScreen and RunInitScreen. The non-TTY path is intentionally unchanged, since auto-running init from a headless invocation would be surprising.

When a fresh checkout has a hand-written .env with all required secrets but
no mcp-config yet, the startup gate forced the full onboarding wizard because
is_setup_complete requires both artifacts. Now the gate detects a complete
.env and runs `specflow init` directly (RunInitScreen) with no wizard; init
already reads the existing .env, validates it, and resolves DEFAULT_PROVIDER.

- onboarding.env_satisfies_requirements reuses validate_all (single source of
  truth for required vars) across both providers
- extract _run_init_streamed shared by OnboardingScreen and RunInitScreen
@akozak-gd akozak-gd added the bug Something isn't working label Jul 1, 2026
Resolve conflicts in mcp_server/tui/app.py from the MCP client-setup feature
(PR #7): keep both the new _run_init_streamed helper / RunInitScreen and main's
ClientSetupScreen additions, and merge the CSS block (#runinit-log plus the
#client-* rules). Update test_complete_env_skips_wizard_runs_init to patch
is_any_client_connected=True so the gate reaches SessionsScreen past the new
first-run client-setup step.
@awrobel-gd
awrobel-gd merged commit a887147 into main Jul 1, 2026
3 checks passed
@mkonopelski-gd
mkonopelski-gd deleted the fix/env-file-resolution branch July 1, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants