Skip to content

Commit 169bd47

Browse files
fix(web): idle compaction compares selected environments by mode
Servers store the idle compaction mode differently by version, so comparing the raw fields showed "Mixed" for environments that resolve to the same mode, and "Never" followed one representative environment while a server with only the on/off switch received "When you return". The row now compares resolved modes and offers "Never" only when every selected server can store it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d7ff637 commit 169bd47

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
type DesktopUpdateChannel,
99
IDLE_COMPACTION_MODES,
1010
globalIdleCompaction,
11-
readsIdleCompactionModes,
1211
ProviderDriverKind,
1312
type ProviderInstanceId,
1413
type SidebarProjectGroupingMode,
@@ -53,6 +52,7 @@ import {
5352
} from "./useScopedSettings";
5453
import { useScopedModelDisabledReason } from "./useScopedModelAvailability";
5554
import { useSettingsScope } from "./SettingsScopeContext";
55+
import { scopedIdleCompaction } from "./scopedSettings";
5656
import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";
5757
import { useDesktopUpdateState } from "../../state/desktopUpdate";
5858
import {
@@ -787,7 +787,8 @@ export function GeneralSettingsPanel() {
787787
const settings = useScopedSettings();
788788
const updateSettings = useUpdateScopedSettings();
789789
const navigate = useNavigate();
790-
const { scope, environment, connectedEnvironments, target } = useSettingsScope();
790+
const { scope, environment, connectedEnvironments, target, targets } = useSettingsScope();
791+
const idleCompaction = scopedIdleCompaction(targets.length > 0 ? targets : [{ settings }]);
791792
const environmentId = environment?.environmentId ?? null;
792793
const isEnvironmentScope = scope.environmentIds.length === 1 && environmentId !== null;
793794
const hasServerTargets = connectedEnvironments.length > 0;
@@ -999,6 +1000,7 @@ export function GeneralSettingsPanel() {
9991000
<SettingsRow
10001001
serverScoped
10011002
settingKeys={["idleCompaction", "compactIdleThreads"]}
1003+
mixed={idleCompaction.mixed}
10021004
{...searchableSetting("compact-idle-threads")}
10031005
description="When to compact an idle Claude thread over 200,000 tokens: after you return, just before its prompt cache expires, or never. Each Claude provider can override this."
10041006
resetAction={
@@ -1035,7 +1037,7 @@ export function GeneralSettingsPanel() {
10351037
key={mode.value}
10361038
value={mode.value}
10371039
// A server from before modes has only the on/off switch, so it cannot store "Never".
1038-
disabled={mode.value === "off" && !readsIdleCompactionModes(settings)}
1040+
disabled={mode.value === "off" && !idleCompaction.neverAvailable}
10391041
>
10401042
{mode.label}
10411043
</SelectItem>

‎apps/web/src/components/settings/scopedSettings.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
planProjectOverridesClear,
1818
planScopedSettingsClear,
1919
planScopedSettingsPatch,
20+
scopedIdleCompaction,
2021
resolveScopedSettingsTargets,
2122
scopedSettingsAreMixed,
2223
scopedSettingsSource,
@@ -192,6 +193,26 @@ describe("scoped settings writes", () => {
192193
]);
193194
});
194195

196+
it("compares idle compaction by mode, and offers Never only where every server stores it", () => {
197+
const fixed = {
198+
settings: {
199+
...DEFAULT_SERVER_SETTINGS,
200+
compactIdleThreads: false,
201+
idleCompaction: "onReturn" as const,
202+
},
203+
};
204+
const modes = {
205+
settings: { ...DEFAULT_SERVER_SETTINGS, compactIdleThreads: "onReturn" as const },
206+
};
207+
const legacy = { settings: { ...DEFAULT_SERVER_SETTINGS, compactIdleThreads: false } };
208+
expect(scopedIdleCompaction([fixed, modes])).toEqual({ mixed: false, neverAvailable: true });
209+
expect(scopedIdleCompaction([fixed, legacy])).toEqual({ mixed: false, neverAvailable: false });
210+
expect(
211+
scopedIdleCompaction([fixed, { settings: { ...fixed.settings, idleCompaction: "off" } }])
212+
.mixed,
213+
).toBe(true);
214+
});
215+
195216
it("sends an idle compaction mode in the form each environment's server reads", () => {
196217
const targets = [
197218
environment("Fixed", { settings: { compactIdleThreads: false, idleCompaction: "onReturn" } }),

‎apps/web/src/components/settings/scopedSettings.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import {
22
ClientSettingsSchema,
33
type ClientSettingsPatch,
44
type EnvironmentId,
5+
globalIdleCompaction,
56
idleCompactionPatch,
67
isNullableProjectSettingsOverride,
8+
readsIdleCompactionModes,
79
PROJECT_SCOPED_SERVER_SETTING_KEYS,
810
type ProjectId,
911
type ProjectScopedServerSettingKey,
@@ -139,6 +141,19 @@ export function scopedSettingsAreMixed(
139141
);
140142
}
141143

144+
/**
145+
* Servers store the idle compaction mode differently by version, so selected
146+
* environments are compared by the mode each resolves to, and "Never" is offered
147+
* only when every one of them can store it.
148+
*/
149+
export function scopedIdleCompaction(targets: readonly Pick<ScopedSettingsTarget, "settings">[]) {
150+
const modes = targets.map((candidate) => globalIdleCompaction(candidate.settings));
151+
return {
152+
mixed: modes.some((mode) => mode !== modes[0]),
153+
neverAvailable: targets.every((candidate) => readsIdleCompactionModes(candidate.settings)),
154+
};
155+
}
156+
142157
export type ScopedSettingSource = ProjectSettingSource | "mixed";
143158

144159
export function scopedSettingsSource(

0 commit comments

Comments
 (0)