fix(tui): use existing complete .env instead of forcing onboarding#8
Merged
Conversation
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
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
approved these changes
Jul 1, 2026
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
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.