Skip to content

Commit a7bf984

Browse files
committed
[Condense] Move condense settings out of experimental and defualt enable
1 parent 2e5a1a8 commit a7bf984

File tree

17 files changed

+217
-208
lines changed

17 files changed

+217
-208
lines changed

evals/packages/types/src/roo-code.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export type CommandExecutionStatus = z.infer<typeof commandExecutionStatusSchema
297297
* ExperimentId
298298
*/
299299

300-
export const experimentIds = ["autoCondenseContext", "powerSteering"] as const
300+
export const experimentIds = ["powerSteering"] as const
301301

302302
export const experimentIdsSchema = z.enum(experimentIds)
303303

@@ -308,7 +308,6 @@ export type ExperimentId = z.infer<typeof experimentIdsSchema>
308308
*/
309309

310310
const experimentsSchema = z.object({
311-
autoCondenseContext: z.boolean(),
312311
powerSteering: z.boolean(),
313312
})
314313

packages/types/src/experiment.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js"
66
* ExperimentId
77
*/
88

9-
export const experimentIds = ["autoCondenseContext", "powerSteering"] as const
9+
export const experimentIds = ["powerSteering"] as const
1010

1111
export const experimentIdsSchema = z.enum(experimentIds)
1212

@@ -17,7 +17,6 @@ export type ExperimentId = z.infer<typeof experimentIdsSchema>
1717
*/
1818

1919
export const experimentsSchema = z.object({
20-
autoCondenseContext: z.boolean(),
2120
powerSteering: z.boolean(),
2221
})
2322

packages/types/src/global-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const globalSettingsSchema = z.object({
4646
alwaysAllowExecute: z.boolean().optional(),
4747
allowedCommands: z.array(z.string()).optional(),
4848
allowedMaxRequests: z.number().nullish(),
49+
autoCondenseContext: z.boolean().optional(),
4950
autoCondenseContextPercent: z.number().optional(),
5051

5152
browserToolEnabled: z.boolean().optional(),
@@ -131,6 +132,7 @@ export const GLOBAL_SETTINGS_KEYS = keysOf<GlobalSettings>()([
131132
"alwaysAllowExecute",
132133
"allowedCommands",
133134
"allowedMaxRequests",
135+
"autoCondenseContext",
134136
"autoCondenseContextPercent",
135137

136138
"browserToolEnabled",

src/core/task/Task.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,8 +1527,8 @@ export class Task extends EventEmitter<ClineEvents> {
15271527
autoApprovalEnabled,
15281528
alwaysApproveResubmit,
15291529
requestDelaySeconds,
1530-
experiments,
15311530
mode,
1531+
autoCondenseContext = true,
15321532
autoCondenseContextPercent = 100,
15331533
} = state ?? {}
15341534

@@ -1592,7 +1592,6 @@ export class Task extends EventEmitter<ClineEvents> {
15921592

15931593
const contextWindow = modelInfo.contextWindow
15941594

1595-
const autoCondenseContext = experiments?.autoCondenseContext ?? false
15961595
const truncateResult = await truncateConversationIfNeeded({
15971596
messages: this.apiConversationHistory,
15981597
totalTokens: contextTokens,

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ export class ClineProvider
12191219
alwaysAllowModeSwitch,
12201220
alwaysAllowSubtasks,
12211221
allowedMaxRequests,
1222+
autoCondenseContext,
12221223
autoCondenseContextPercent,
12231224
soundEnabled,
12241225
ttsEnabled,
@@ -1295,6 +1296,7 @@ export class ClineProvider
12951296
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
12961297
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
12971298
allowedMaxRequests,
1299+
autoCondenseContext: autoCondenseContext ?? true,
12981300
autoCondenseContextPercent: autoCondenseContextPercent ?? 100,
12991301
uriScheme: vscode.env.uriScheme,
13001302
currentTaskItem: this.getCurrentCline()?.taskId
@@ -1409,6 +1411,7 @@ export class ClineProvider
14091411
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
14101412
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
14111413
allowedMaxRequests: stateValues.allowedMaxRequests,
1414+
autoCondenseContext: stateValues.autoCondenseContext ?? true,
14121415
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
14131416
taskHistory: stateValues.taskHistory,
14141417
allowedCommands: stateValues.allowedCommands,

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ describe("ClineProvider", () => {
422422
showRooIgnoredFiles: true,
423423
renderContext: "sidebar",
424424
maxReadFileLine: 500,
425+
autoCondenseContext: true,
425426
autoCondenseContextPercent: 100,
426427
}
427428

@@ -594,6 +595,24 @@ describe("ClineProvider", () => {
594595
expect(state.alwaysApproveResubmit).toBe(false)
595596
})
596597

598+
test("autoCondenseContext defaults to true", async () => {
599+
// Mock globalState.get to return undefined for autoCondenseContext
600+
;(mockContext.globalState.get as jest.Mock).mockImplementation((key: string) =>
601+
key === "autoCondenseContext" ? undefined : null,
602+
)
603+
const state = await provider.getState()
604+
expect(state.autoCondenseContext).toBe(true)
605+
})
606+
607+
test("handles autoCondenseContext message", async () => {
608+
await provider.resolveWebviewView(mockWebviewView)
609+
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
610+
await messageHandler({ type: "autoCondenseContext", bool: false })
611+
expect(updateGlobalStateSpy).toHaveBeenCalledWith("autoCondenseContext", false)
612+
expect(mockContext.globalState.update).toHaveBeenCalledWith("autoCondenseContext", false)
613+
expect(mockPostMessage).toHaveBeenCalled()
614+
})
615+
597616
test("autoCondenseContextPercent defaults to 100", async () => {
598617
// Mock globalState.get to return undefined for autoCondenseContextPercent
599618
;(mockContext.globalState.get as jest.Mock).mockImplementation((key: string) =>

src/core/webview/webviewMessageHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
173173
case "askResponse":
174174
provider.getCurrentCline()?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
175175
break
176+
case "autoCondenseContext":
177+
await updateGlobalState("autoCondenseContext", message.bool)
178+
await provider.postStateToWebview()
179+
break
176180
case "autoCondenseContextPercent":
177181
await updateGlobalState("autoCondenseContextPercent", message.value)
178182
await provider.postStateToWebview()

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export type ExtensionState = Pick<
210210
renderContext: "sidebar" | "editor"
211211
settingsImportedAt?: number
212212
historyPreviewCollapsed?: boolean
213+
autoCondenseContext: boolean
213214
autoCondenseContextPercent: number
214215
}
215216

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface WebviewMessage {
6060
| "alwaysAllowModeSwitch"
6161
| "allowedMaxRequests"
6262
| "alwaysAllowSubtasks"
63+
| "autoCondenseContext"
6364
| "autoCondenseContextPercent"
6465
| "condensingApiConfigId"
6566
| "updateCondensingPrompt"

src/shared/__tests__/experiments.test.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,26 @@ describe("experiments", () => {
1414
})
1515
})
1616

17-
describe("AUTO_CONDENSE_CONTEXT", () => {
18-
it("is configured correctly", () => {
19-
expect(EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT).toBe("autoCondenseContext")
20-
expect(experimentConfigsMap.AUTO_CONDENSE_CONTEXT).toMatchObject({
21-
enabled: false,
22-
})
23-
})
24-
})
25-
2617
describe("isEnabled", () => {
2718
it("returns false when POWER_STEERING experiment is not enabled", () => {
2819
const experiments: Record<ExperimentId, boolean> = {
2920
powerSteering: false,
30-
autoCondenseContext: false,
3121
}
3222
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false)
3323
})
3424

3525
it("returns true when experiment POWER_STEERING is enabled", () => {
3626
const experiments: Record<ExperimentId, boolean> = {
3727
powerSteering: true,
38-
autoCondenseContext: false,
3928
}
4029
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(true)
4130
})
4231

4332
it("returns false when experiment is not present", () => {
4433
const experiments: Record<ExperimentId, boolean> = {
4534
powerSteering: false,
46-
autoCondenseContext: false,
4735
}
4836
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false)
4937
})
50-
51-
it("returns false when AUTO_CONDENSE_CONTEXT experiment is not enabled", () => {
52-
const experiments: Record<ExperimentId, boolean> = {
53-
powerSteering: false,
54-
autoCondenseContext: false,
55-
}
56-
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT)).toBe(false)
57-
})
58-
59-
it("returns true when AUTO_CONDENSE_CONTEXT experiment is enabled", () => {
60-
const experiments: Record<ExperimentId, boolean> = {
61-
powerSteering: false,
62-
autoCondenseContext: true,
63-
}
64-
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT)).toBe(true)
65-
})
6638
})
6739
})

0 commit comments

Comments
 (0)