Skip to content

fix: enable --agent respects settings.local.json overrides#339

Open
adrianmg wants to merge 1 commit intoentireio:mainfrom
adrianmg:fix/enable-agent-settings-local
Open

fix: enable --agent respects settings.local.json overrides#339
adrianmg wants to merge 1 commit intoentireio:mainfrom
adrianmg:fix/enable-agent-settings-local

Conversation

@adrianmg
Copy link

@adrianmg adrianmg commented Feb 15, 2026

Summary

  • entire enable --agent <name> always wrote to settings.json, ignoring a stale enabled: false in settings.local.json left by a prior entire disable
  • This caused entire status to show "Disabled" immediately after a successful enable
image

Root Cause

runDisable() writes enabled: false to settings.local.json. But setupAgentHooksNonInteractive() (the --agent code path) only wrote enabled: true to settings.json. Since settings.Load() merges local over project, the stale false in settings.local.json always won.

The interactive enable and --strategy paths already handled this correctly via determineSettingsTarget() — the --agent path was the only one missing it.

Fix

After writing enabled: true to settings.json, check if settings.local.json exists with a stale enabled: false and clear it. No signature changes, no new params — just 4 lines of targeted cleanup.

Repro (before fix)

entire enable --agent gemini     # writes enabled:true → settings.json
entire disable                   # writes enabled:false → settings.local.json
entire enable --agent gemini     # writes enabled:true → settings.json (local untouched)
entire status                    # → "Disabled (manual-commit)"

Affects

All agents using the `--agent` flag — not specific to any one agent.

@adrianmg adrianmg requested a review from a team as a code owner February 15, 2026 06:26
Copilot AI review requested due to automatic review settings February 15, 2026 06:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 setupAgentHooksNonInteractive to detect and clear stale enabled: false in settings.local.json after writing enabled: true to settings.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)
}
}
}
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant