fix: enable --agent respects settings.local.json overrides#339
fix: enable --agent respects settings.local.json overrides#339adrianmg wants to merge 3 commits intoentireio:mainfrom
Conversation
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
| // 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.
|
Thanks for the contribution! We ask that all PRs have a corresponding GitHub issue so we can discuss the approach first. Could you open an issue describing the problem this solves? Once we've aligned there, we'll prioritize the review. This helps make sure your effort doesn't go to waste. |
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.