Skip to content

Commit 4b9ed9f

Browse files
committed
fix(settings): changing the inactivity scope keeps each environment's duration
Picking a scope on web wrote the representative environment's duration to every selected target. It now writes a duration only when the selection includes a target with inactivity off. On mobile, an older reference environment hid a capable target set to skip threads with a PR. Such a reference settles every thread, so it now compares as "all".
1 parent 3206ece commit 4b9ed9f

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

‎apps/mobile/src/features/settings/autoSettleSettingsSync.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe("auto-settle settings sync", () => {
3636
expect(plan.patch).toEqual({
3737
sidebarAutoSettleAfterDays: 7,
3838
sidebarAutoSettleOnMerge: true,
39+
sidebarAutoSettleScope: "all",
3940
});
4041
});
4142

@@ -67,7 +68,7 @@ describe("auto-settle settings sync", () => {
6768
expect(updated.sourceControlWritingStyle).toEqual(target.settings.sourceControlWritingStyle);
6869
});
6970

70-
it("syncs differing scope only between servers supporting it", () => {
71+
it("compares scope only on targets supporting it", () => {
7172
const target = {
7273
environmentId: EnvironmentId.make("remote"),
7374
label: "Remote",
@@ -82,7 +83,10 @@ describe("auto-settle settings sync", () => {
8283
{ ...target, supportsScope: false },
8384
]).mismatches,
8485
).toEqual([]);
85-
expect(planAutoSettleSettingsSync(reference, [target]).mismatches).toEqual([]);
86+
// A reference without scope support settles every thread.
87+
const legacyPlan = planAutoSettleSettingsSync(reference, [target]);
88+
expect(legacyPlan.mismatches).toEqual([target]);
89+
expect(legacyPlan.patch.sidebarAutoSettleScope).toBe("all");
8690
});
8791

8892
it("does not compare the reference or a target without loaded settings", () => {

‎apps/mobile/src/features/settings/autoSettleSettingsSync.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export function planAutoSettleSettingsSync(
2626
const patch = {
2727
sidebarAutoSettleAfterDays: reference.settings.sidebarAutoSettleAfterDays,
2828
sidebarAutoSettleOnMerge: reference.settings.sidebarAutoSettleOnMerge,
29-
...(reference.supportsScope
30-
? { sidebarAutoSettleScope: reference.settings.sidebarAutoSettleScope }
31-
: {}),
29+
// A reference without scope support settles every thread, so it stands for "all".
30+
sidebarAutoSettleScope: reference.supportsScope
31+
? reference.settings.sidebarAutoSettleScope
32+
: ("all" as const),
3233
};
3334
const mismatches = targets.filter(
3435
(target) =>
@@ -38,7 +39,6 @@ export function planAutoSettleSettingsSync(
3839
(target.settings.sidebarAutoSettleAfterDays !== patch.sidebarAutoSettleAfterDays ||
3940
target.settings.sidebarAutoSettleOnMerge !== patch.sidebarAutoSettleOnMerge ||
4041
(target.supportsScope === true &&
41-
patch.sidebarAutoSettleScope !== undefined &&
4242
target.settings.sidebarAutoSettleScope !== patch.sidebarAutoSettleScope)),
4343
);
4444
return { patch, mismatches };

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ export function GeneralSettingsPanel() {
21952195
const settings = useScopedSettings();
21962196
const updateSettings = useUpdateScopedSettings();
21972197
const navigate = useNavigate();
2198-
const { scope, environment, connectedEnvironments } = useSettingsScope();
2198+
const { scope, environment, connectedEnvironments, targets } = useSettingsScope();
21992199
// The representative environment supplies the provider list for pickers;
22002200
// a fanned-out model choice is validated against every target before it
22012201
// is written. Per-machine tuning (background activity overrides) still
@@ -2231,11 +2231,20 @@ export function GeneralSettingsPanel() {
22312231

22322232
function changeAutoSettleMode(value: AutoSettleMode | null) {
22332233
if (value === null) return;
2234-
const sidebarAutoSettleAfterDays =
2235-
value === "off" ? null : (autoSettleAfterDays ?? AUTO_SETTLE_DEFAULT_DAYS);
2234+
if (value === "off") {
2235+
updateSettings({ sidebarAutoSettleAfterDays: null, sidebarAutoSettleScope: "all" });
2236+
return;
2237+
}
2238+
// A scope change keeps each target's own duration. Only a selection that
2239+
// includes a target with inactivity off needs a duration written.
2240+
const turnsOn =
2241+
autoSettleAfterDays === null ||
2242+
targets.some((target) => target.settings.sidebarAutoSettleAfterDays === null);
22362243
updateSettings({
2237-
sidebarAutoSettleAfterDays,
2238-
sidebarAutoSettleScope: value === "off" ? "all" : value,
2244+
...(turnsOn
2245+
? { sidebarAutoSettleAfterDays: autoSettleAfterDays ?? AUTO_SETTLE_DEFAULT_DAYS }
2246+
: {}),
2247+
sidebarAutoSettleScope: value,
22392248
});
22402249
}
22412250

0 commit comments

Comments
 (0)