fix(cli): prevent welcome() from re-triggering setup when global config exists#2859
Closed
Bernardxu123 wants to merge 1 commit into
Closed
fix(cli): prevent welcome() from re-triggering setup when global config exists#2859Bernardxu123 wants to merge 1 commit into
Bernardxu123 wants to merge 1 commit into
Conversation
…ig exists When running `reasonix` without arguments from a directory that lacks `reasonix.toml`, the old code treated it as a first-run scenario and re-triggered the setup wizard, even though a valid global config (`~/.config/reasonix/config.toml`) was loaded successfully. Fix by moving `config.Load()` before the setup-trigger check, and changing the trigger condition from `src == ""` to `src == "" && cfgErr != nil`. This ensures the wizard only runs when no config can be loaded from ANY source (neither cwd-local nor user-global). Also remove the redundant `src != ""` guard on the chat entry path (`cfgErr == nil` is sufficient — if config loads, we can chat). Closes esengine#2856
Owner
|
Good catch and a clean diagnosis — The branch had drifted into a conflict with main-v2 (the Closing in favour of #2906 — thanks for the contribution! |
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.
Problem
When running
reasonixwithout arguments from a directory that lacksreasonix.toml, the setup wizard is re-triggered even though a valid global config (~/.config/reasonix/config.toml) exists and loads successfully.Root Cause
In
welcome()(internal/cli/cli.go), the setup trigger condition was:SourcePath()checks forreasonix.tomlin cwd first, then falls back to the global user config. When the user runsreasonixfrom a different directory (e.g., aftercd), ``SourcePath()returns""` because there's no cwd-local file — even though `config.Load()` would succeed from the global path.The chat entry path also unnecessarily required
src != "":Fix
config.Load()before the setup-trigger checksrc == ""tosrc == "" && cfgErr != nil— wizard only runs when no config loads from ANY sourcesrc != ""guard on chat entry —cfgErr == nilis sufficientTesting
go build ./...— compiles successfullygo test ./internal/config/— all tests passgo test ./internal/cli/— 5 pre-existing i18n test failures unrelated to this changeCloses #2856