Skip to content

Commit 4804e3b

Browse files
authored
[Condense] Move condense settings out of experimental and defualt enable (#4088)
* [Condense] Move condense settings out of experimental and defualt enable * tests * wip * Update translations * fixes * more tests * changeset * wip * update translations * fix more translations
1 parent 12669e1 commit 4804e3b

35 files changed

+1025
-565
lines changed

.changeset/eager-buckets-feel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": major
3+
---
4+
5+
Default enabled autoCondenseContext and moved settings out of Experimental

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
@@ -1225,6 +1225,7 @@ export class ClineProvider
12251225
alwaysAllowModeSwitch,
12261226
alwaysAllowSubtasks,
12271227
allowedMaxRequests,
1228+
autoCondenseContext,
12281229
autoCondenseContextPercent,
12291230
soundEnabled,
12301231
ttsEnabled,
@@ -1301,6 +1302,7 @@ export class ClineProvider
13011302
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
13021303
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
13031304
allowedMaxRequests,
1305+
autoCondenseContext: autoCondenseContext ?? true,
13041306
autoCondenseContextPercent: autoCondenseContextPercent ?? 100,
13051307
uriScheme: vscode.env.uriScheme,
13061308
currentTaskItem: this.getCurrentCline()?.taskId
@@ -1415,6 +1417,7 @@ export class ClineProvider
14151417
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
14161418
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
14171419
allowedMaxRequests: stateValues.allowedMaxRequests,
1420+
autoCondenseContext: stateValues.autoCondenseContext ?? true,
14181421
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
14191422
taskHistory: stateValues.taskHistory,
14201423
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"

0 commit comments

Comments
 (0)