Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eager-buckets-feel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": major
---

Default enabled autoCondenseContext and moved settings out of Experimental
3 changes: 1 addition & 2 deletions evals/packages/types/src/roo-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export type CommandExecutionStatus = z.infer<typeof commandExecutionStatusSchema
* ExperimentId
*/

export const experimentIds = ["autoCondenseContext", "powerSteering"] as const
export const experimentIds = ["powerSteering"] as const

export const experimentIdsSchema = z.enum(experimentIds)

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

const experimentsSchema = z.object({
autoCondenseContext: z.boolean(),
powerSteering: z.boolean(),
})

Expand Down
3 changes: 1 addition & 2 deletions packages/types/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js"
* ExperimentId
*/

export const experimentIds = ["autoCondenseContext", "powerSteering"] as const
export const experimentIds = ["powerSteering"] as const

export const experimentIdsSchema = z.enum(experimentIds)

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

export const experimentsSchema = z.object({
autoCondenseContext: z.boolean(),
powerSteering: z.boolean(),
})

Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const globalSettingsSchema = z.object({
alwaysAllowExecute: z.boolean().optional(),
allowedCommands: z.array(z.string()).optional(),
allowedMaxRequests: z.number().nullish(),
autoCondenseContext: z.boolean().optional(),
autoCondenseContextPercent: z.number().optional(),

browserToolEnabled: z.boolean().optional(),
Expand Down Expand Up @@ -131,6 +132,7 @@ export const GLOBAL_SETTINGS_KEYS = keysOf<GlobalSettings>()([
"alwaysAllowExecute",
"allowedCommands",
"allowedMaxRequests",
"autoCondenseContext",
"autoCondenseContextPercent",

"browserToolEnabled",
Expand Down
3 changes: 1 addition & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,8 @@ export class Task extends EventEmitter<ClineEvents> {
autoApprovalEnabled,
alwaysApproveResubmit,
requestDelaySeconds,
experiments,
mode,
autoCondenseContext = true,
autoCondenseContextPercent = 100,
} = state ?? {}

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

const contextWindow = modelInfo.contextWindow

const autoCondenseContext = experiments?.autoCondenseContext ?? false
const truncateResult = await truncateConversationIfNeeded({
messages: this.apiConversationHistory,
totalTokens: contextTokens,
Expand Down
3 changes: 3 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ export class ClineProvider
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
allowedMaxRequests,
autoCondenseContext,
autoCondenseContextPercent,
soundEnabled,
ttsEnabled,
Expand Down Expand Up @@ -1295,6 +1296,7 @@ export class ClineProvider
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
allowedMaxRequests,
autoCondenseContext: autoCondenseContext ?? true,
autoCondenseContextPercent: autoCondenseContextPercent ?? 100,
uriScheme: vscode.env.uriScheme,
currentTaskItem: this.getCurrentCline()?.taskId
Expand Down Expand Up @@ -1409,6 +1411,7 @@ export class ClineProvider
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
allowedMaxRequests: stateValues.allowedMaxRequests,
autoCondenseContext: stateValues.autoCondenseContext ?? true,
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
taskHistory: stateValues.taskHistory,
allowedCommands: stateValues.allowedCommands,
Expand Down
19 changes: 19 additions & 0 deletions src/core/webview/__tests__/ClineProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ describe("ClineProvider", () => {
showRooIgnoredFiles: true,
renderContext: "sidebar",
maxReadFileLine: 500,
autoCondenseContext: true,
autoCondenseContextPercent: 100,
}

Expand Down Expand Up @@ -594,6 +595,24 @@ describe("ClineProvider", () => {
expect(state.alwaysApproveResubmit).toBe(false)
})

test("autoCondenseContext defaults to true", async () => {
// Mock globalState.get to return undefined for autoCondenseContext
;(mockContext.globalState.get as jest.Mock).mockImplementation((key: string) =>
key === "autoCondenseContext" ? undefined : null,
)
const state = await provider.getState()
expect(state.autoCondenseContext).toBe(true)
})

test("handles autoCondenseContext message", async () => {
await provider.resolveWebviewView(mockWebviewView)
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
await messageHandler({ type: "autoCondenseContext", bool: false })
expect(updateGlobalStateSpy).toHaveBeenCalledWith("autoCondenseContext", false)
expect(mockContext.globalState.update).toHaveBeenCalledWith("autoCondenseContext", false)
expect(mockPostMessage).toHaveBeenCalled()
})

test("autoCondenseContextPercent defaults to 100", async () => {
// Mock globalState.get to return undefined for autoCondenseContextPercent
;(mockContext.globalState.get as jest.Mock).mockImplementation((key: string) =>
Expand Down
4 changes: 4 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
case "askResponse":
provider.getCurrentCline()?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
break
case "autoCondenseContext":
await updateGlobalState("autoCondenseContext", message.bool)
await provider.postStateToWebview()
break
case "autoCondenseContextPercent":
await updateGlobalState("autoCondenseContextPercent", message.value)
await provider.postStateToWebview()
Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export type ExtensionState = Pick<
renderContext: "sidebar" | "editor"
settingsImportedAt?: number
historyPreviewCollapsed?: boolean
autoCondenseContext: boolean
autoCondenseContextPercent: number
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface WebviewMessage {
| "alwaysAllowModeSwitch"
| "allowedMaxRequests"
| "alwaysAllowSubtasks"
| "autoCondenseContext"
| "autoCondenseContextPercent"
| "condensingApiConfigId"
| "updateCondensingPrompt"
Expand Down
28 changes: 0 additions & 28 deletions src/shared/__tests__/experiments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,26 @@ describe("experiments", () => {
})
})

describe("AUTO_CONDENSE_CONTEXT", () => {
it("is configured correctly", () => {
expect(EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT).toBe("autoCondenseContext")
expect(experimentConfigsMap.AUTO_CONDENSE_CONTEXT).toMatchObject({
enabled: false,
})
})
})

describe("isEnabled", () => {
it("returns false when POWER_STEERING experiment is not enabled", () => {
const experiments: Record<ExperimentId, boolean> = {
powerSteering: false,
autoCondenseContext: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false)
})

it("returns true when experiment POWER_STEERING is enabled", () => {
const experiments: Record<ExperimentId, boolean> = {
powerSteering: true,
autoCondenseContext: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(true)
})

it("returns false when experiment is not present", () => {
const experiments: Record<ExperimentId, boolean> = {
powerSteering: false,
autoCondenseContext: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false)
})

it("returns false when AUTO_CONDENSE_CONTEXT experiment is not enabled", () => {
const experiments: Record<ExperimentId, boolean> = {
powerSteering: false,
autoCondenseContext: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT)).toBe(false)
})

it("returns true when AUTO_CONDENSE_CONTEXT experiment is enabled", () => {
const experiments: Record<ExperimentId, boolean> = {
powerSteering: false,
autoCondenseContext: true,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.AUTO_CONDENSE_CONTEXT)).toBe(true)
})
})
})
2 changes: 0 additions & 2 deletions src/shared/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { AssertEqual, Equals, Keys, Values, ExperimentId } from "@roo-code/

export const EXPERIMENT_IDS = {
POWER_STEERING: "powerSteering",
AUTO_CONDENSE_CONTEXT: "autoCondenseContext",
} as const satisfies Record<string, ExperimentId>

type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
Expand All @@ -15,7 +14,6 @@ interface ExperimentConfig {

export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
POWER_STEERING: { enabled: false },
AUTO_CONDENSE_CONTEXT: { enabled: false }, // Keep this last, there is a slider below it in the UI
}

export const experimentDefault = Object.fromEntries(
Expand Down
Loading