fix: enable --agent respects settings.local.json overrides#339
Open
adrianmg wants to merge 1 commit intoentireio:mainfrom
Open
fix: enable --agent respects settings.local.json overrides#339adrianmg wants to merge 1 commit intoentireio:mainfrom
adrianmg wants to merge 1 commit intoentireio:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where entire enable --agent <name> failed to respect stale enabled: false settings in .entire/settings.local.json, causing entire status to incorrectly show "Disabled" immediately after a successful enable operation.
Changes:
- Added cleanup logic in
setupAgentHooksNonInteractiveto detect and clear staleenabled: falseinsettings.local.jsonafter writingenabled: truetosettings.json
Comment on lines
+614
to
+623
| // Clear stale enabled:false in settings.local.json left by a prior "entire disable" | ||
| localPath, pathErr := paths.AbsPath(EntireSettingsLocalFile) | ||
| if pathErr == nil { | ||
| if ls, err := settings_pkg.LoadFromFile(localPath); err == nil && !ls.Enabled { | ||
| ls.Enabled = true | ||
| if err := SaveEntireSettingsLocal(ls); err != nil { | ||
| return fmt.Errorf("failed to clear stale local settings: %w", err) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This bug fix lacks test coverage. Consider adding a test that reproduces the original bug scenario: enable with --agent, disable, then enable again with --agent, and verify that the status shows "Enabled". The existing TestEnableDisable integration test uses --strategy which already handled this correctly via determineSettingsTarget, so it wouldn't catch this specific bug in the --agent code path.
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
entire enable --agent <name>always wrote tosettings.json, ignoring a staleenabled: falseinsettings.local.jsonleft by a priorentire disableentire statusto show "Disabled" immediately after a successful enableRoot Cause
runDisable()writesenabled: falsetosettings.local.json. ButsetupAgentHooksNonInteractive()(the--agentcode path) only wroteenabled: truetosettings.json. Sincesettings.Load()merges local over project, the stalefalseinsettings.local.jsonalways won.The interactive enable and
--strategypaths already handled this correctly viadetermineSettingsTarget()— the--agentpath was the only one missing it.Fix
After writing
enabled: truetosettings.json, check ifsettings.local.jsonexists with a staleenabled: falseand clear it. No signature changes, no new params — just 4 lines of targeted cleanup.Repro (before fix)
Affects
All agents using the `--agent` flag — not specific to any one agent.