fix(setup): enable writes the enabled flag to the resolved settings scope · Entire

fix(setup): enable writes the enabled flag to the resolved settings scope

558836b→main·

suhaanthayyil·1w ago·2 files·+36 added/-1 removed

On a repo disabled at the project level, entire enable --checkpoint-remote ... (no --project) reported success but left .entire/settings.json enabled=false:
the strategy write resolved to the existing project settings.json while the
enabled flag was written to settings.local.json (raw opts.UseProjectSettings
bool). Resolve the enable target with settingsTargetFile, matching where the
strategy options were written, so the enabled flag lands in the same file.

Closes #1140

Co-authored-by: Cursor cursoragent@cursor.com

Changes

2

1117 unmodified lines

1118
1119
1120
1121
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130

1117 unmodified lines

printEnabledStatus(ctx, w)
    return nil
}
return runEnable(ctx, w, opts.UseProjectSettings)
// Enable in the same file the setup flow just wrote to. Without this, a plain
// `entire enable` (no --project/--local) resolves the strategy write to the
// existing project settings.json but wrote the enabled flag to
// settings.local.json, leaving the project file the user disabled still
// enabled=false (#1140). settingsTargetFile picks the correct scope.
targetFile, _ := settingsTargetFile(ctx, opts.UseLocalSettings, opts.UseProjectSettings)
return runEnable(ctx, w, targetFile == settings.EntireSettingsFile)
}

func runEnableInteractive(ctx context.Context, w io.Writer, agents []agent.Agent, opts EnableOptions) error {

Mcmd/entire/cli/setup.go+7/-1

1164 unmodified lines

1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199

1164 unmodified lines

}
// Regression for #1140: `entire enable --checkpoint-remote ...` (no --project)
// on a repo disabled at the project level must re-enable the project
// settings.json, not write the enabled flag to a shadow settings.local.json —
// which left the file the user disabled still enabled=false.
func TestEnableCmd_StrategyFlagsOnDisabledProjectRepo_EnablesProjectFile(t *testing.T) {
setupTestRepo(t)
writeSettings(t, testSettingsDisabled) // settings.json: {"enabled": false}
writeClaudeHooksFixture(t)

cmd := newEnableCmd()
var stdout, stderr bytes.Buffer
cmd.SetOut(&stdout)
cmd.SetErr(&stderr)
cmd.SetArgs([]string{"--checkpoint-remote", "github:org/repo", "--skip-push-sessions"})

if err := cmd.Execute(); err != nil {
t.Fatalf("enable error = %v\nstdout: %s\nstderr: %s", err, stdout.String(), stderr.String())
}

// The project file the user disabled must be enabled again.
projectS, err := settings.LoadFromFile(EntireSettingsFile)
if err != nil {
t.Fatalf("load project settings: %v", err)
}
if !projectS.Enabled {
t.Errorf("settings.json still enabled=false after enable; the enabled flag went to the wrong file (#1140)")
}
}

// Tests for detectOrSelectAgent

func TestDetectOrSelectAgent_AgentDetected(t *testing.T) {