Skip to content

Commit d9743b0

Browse files
committed
feat(settings): Introduce the "auto-approve request count" feature from Cline
This is the first minor UI feature I've added, so please let me know if I'm missing anything! (translations, organization, etc!) Please see commits for details introduce allowedMaxRequests to globalSettingsSchema update ExtensionState and its context with allowedMaxRequests implement UI for setting max requests in AutoApproveMenu component prompt user when auto-approval limit is reached with i18n support increment consecutiveAutoApprovedRequestsCount and reset upon user approval add translations for auto-approved request limit reached prompt in multiple languages add new UI for "auto_approval_max_req_reached" in ChatRowContent display prompt with title, description, and button for user action 🔧 chore(gitignore): add .idea to .gitignore to exclude IDE-specific files - remove .idea/workspace.xml to clean up repository
1 parent dc694ef commit d9743b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+317
-2
lines changed

.changeset/fruity-spoons-smash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": minor
3+
---
4+
5+
Added an auto-approve API request limit setting similar to Cline

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ export const clineAsks = [
961961
"resume_task",
962962
"resume_completed_task",
963963
"mistake_limit_reached",
964+
"auto_approval_max_req_reached",
964965
"browser_action_launch",
965966
"use_mcp_server",
966967
] as const

src/core/task/Task.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { processUserContentMentions } from "../mentions/processUserContentMentio
7878
import { ApiMessage } from "../task-persistence/apiMessages"
7979
import { getMessagesSinceLastSummary } from "../condense"
8080
import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
81+
import { t } from "../../i18n"
8182

8283
export type ClineEvents = {
8384
message: [{ action: "created" | "updated"; message: ClineMessage }]
@@ -134,6 +135,7 @@ export class Task extends EventEmitter<ClineEvents> {
134135
readonly apiConfiguration: ProviderSettings
135136
api: ApiHandler
136137
private lastApiRequestTime?: number
138+
private consecutiveAutoApprovedRequestsCount: number = 0
137139

138140
toolRepetitionDetector: ToolRepetitionDetector
139141
rooIgnoreController?: RooIgnoreController
@@ -1494,6 +1496,28 @@ export class Task extends EventEmitter<ClineEvents> {
14941496
({ role, content }) => ({ role, content }),
14951497
)
14961498

1499+
// Check if we've reached the maximum number of auto-approved requests
1500+
const { allowedMaxRequests } = (await this.providerRef.deref()?.getState()) ?? {}
1501+
const maxRequests = allowedMaxRequests || Infinity
1502+
1503+
// Increment the counter for each new API request
1504+
this.consecutiveAutoApprovedRequestsCount++
1505+
1506+
if (this.consecutiveAutoApprovedRequestsCount > maxRequests) {
1507+
const { response } = await this.ask(
1508+
"auto_approval_max_req_reached",
1509+
JSON.stringify({
1510+
title: t("common:ask.autoApprovedRequestLimitReached.title"),
1511+
description: t("common:ask.autoApprovedRequestLimitReached.description", { count: maxRequests }),
1512+
button: t("common:ask.autoApprovedRequestLimitReached.button"),
1513+
}),
1514+
)
1515+
// If we get past the promise, it means the user approved and did not start a new task
1516+
if (response === "yesButtonClicked") {
1517+
this.consecutiveAutoApprovedRequestsCount = 0
1518+
}
1519+
}
1520+
14971521
const stream = this.api.createMessage(systemPrompt, cleanConversationHistory)
14981522
const iterator = stream[Symbol.asyncIterator]()
14991523

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
11911191
alwaysAllowMcp,
11921192
alwaysAllowModeSwitch,
11931193
alwaysAllowSubtasks,
1194+
allowedMaxRequests,
11941195
soundEnabled,
11951196
ttsEnabled,
11961197
ttsSpeed,
@@ -1261,6 +1262,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12611262
alwaysAllowMcp: alwaysAllowMcp ?? false,
12621263
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
12631264
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
1265+
allowedMaxRequests: allowedMaxRequests ?? Infinity,
12641266
uriScheme: vscode.env.uriScheme,
12651267
currentTaskItem: this.getCurrentCline()?.taskId
12661268
? (taskHistory || []).find((item: HistoryItem) => item.id === this.getCurrentCline()?.taskId)
@@ -1335,7 +1337,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13351337

13361338
async getState() {
13371339
const stateValues = this.contextProxy.getValues()
1338-
13391340
const customModes = await this.customModesManager.getCustomModes()
13401341

13411342
// Determine apiProvider with the same logic as before.
@@ -1364,6 +1365,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13641365
alwaysAllowMcp: stateValues.alwaysAllowMcp ?? false,
13651366
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
13661367
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
1368+
allowedMaxRequests: stateValues.allowedMaxRequests ?? Infinity,
13671369
taskHistory: stateValues.taskHistory,
13681370
allowedCommands: stateValues.allowedCommands,
13691371
soundEnabled: stateValues.soundEnabled ?? false,

src/core/webview/webviewMessageHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
161161
await updateGlobalState("alwaysAllowModeSwitch", message.bool)
162162
await provider.postStateToWebview()
163163
break
164+
case "allowedMaxRequests":
165+
await updateGlobalState("allowedMaxRequests", message.value)
166+
await provider.postStateToWebview()
167+
break
164168
case "alwaysAllowSubtasks":
165169
await updateGlobalState("alwaysAllowSubtasks", message.bool)
166170
await provider.postStateToWebview()

src/exports/roo-code.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type GlobalSettings = {
7070
alwaysAllowSubtasks?: boolean | undefined
7171
alwaysAllowExecute?: boolean | undefined
7272
allowedCommands?: string[] | undefined
73+
allowedMaxRequests?: number | undefined
7374
browserToolEnabled?: boolean | undefined
7475
browserViewportSize?: string | undefined
7576
screenshotQuality?: number | undefined
@@ -357,6 +358,7 @@ type ClineMessage = {
357358
| "mistake_limit_reached"
358359
| "browser_action_launch"
359360
| "use_mcp_server"
361+
| "auto_approval_max_req_reached"
360362
)
361363
| undefined
362364
say?:
@@ -432,6 +434,7 @@ type RooCodeEvents = {
432434
| "mistake_limit_reached"
433435
| "browser_action_launch"
434436
| "use_mcp_server"
437+
| "auto_approval_max_req_reached"
435438
)
436439
| undefined
437440
say?:
@@ -760,6 +763,7 @@ type IpcMessage =
760763
alwaysAllowSubtasks?: boolean | undefined
761764
alwaysAllowExecute?: boolean | undefined
762765
allowedCommands?: string[] | undefined
766+
allowedMaxRequests?: number | undefined
763767
browserToolEnabled?: boolean | undefined
764768
browserViewportSize?: string | undefined
765769
screenshotQuality?: number | undefined
@@ -901,6 +905,7 @@ type IpcMessage =
901905
| "mistake_limit_reached"
902906
| "browser_action_launch"
903907
| "use_mcp_server"
908+
| "auto_approval_max_req_reached"
904909
)
905910
| undefined
906911
say?:
@@ -1223,6 +1228,7 @@ type TaskCommand =
12231228
alwaysAllowSubtasks?: boolean | undefined
12241229
alwaysAllowExecute?: boolean | undefined
12251230
allowedCommands?: string[] | undefined
1231+
allowedMaxRequests?: number | undefined
12261232
browserToolEnabled?: boolean | undefined
12271233
browserViewportSize?: string | undefined
12281234
screenshotQuality?: number | undefined
@@ -1360,6 +1366,7 @@ type TaskEvent =
13601366
| "mistake_limit_reached"
13611367
| "browser_action_launch"
13621368
| "use_mcp_server"
1369+
| "auto_approval_max_req_reached"
13631370
)
13641371
| undefined
13651372
say?:

src/exports/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type GlobalSettings = {
7070
alwaysAllowSubtasks?: boolean | undefined
7171
alwaysAllowExecute?: boolean | undefined
7272
allowedCommands?: string[] | undefined
73+
allowedMaxRequests?: number | undefined
7374
browserToolEnabled?: boolean | undefined
7475
browserViewportSize?: string | undefined
7576
screenshotQuality?: number | undefined
@@ -363,6 +364,7 @@ type ClineMessage = {
363364
| "mistake_limit_reached"
364365
| "browser_action_launch"
365366
| "use_mcp_server"
367+
| "auto_approval_max_req_reached"
366368
)
367369
| undefined
368370
say?:
@@ -442,6 +444,7 @@ type RooCodeEvents = {
442444
| "mistake_limit_reached"
443445
| "browser_action_launch"
444446
| "use_mcp_server"
447+
| "auto_approval_max_req_reached"
445448
)
446449
| undefined
447450
say?:
@@ -772,6 +775,7 @@ type IpcMessage =
772775
alwaysAllowSubtasks?: boolean | undefined
773776
alwaysAllowExecute?: boolean | undefined
774777
allowedCommands?: string[] | undefined
778+
allowedMaxRequests?: number | undefined
775779
browserToolEnabled?: boolean | undefined
776780
browserViewportSize?: string | undefined
777781
screenshotQuality?: number | undefined
@@ -913,6 +917,7 @@ type IpcMessage =
913917
| "mistake_limit_reached"
914918
| "browser_action_launch"
915919
| "use_mcp_server"
920+
| "auto_approval_max_req_reached"
916921
)
917922
| undefined
918923
say?:
@@ -1237,6 +1242,7 @@ type TaskCommand =
12371242
alwaysAllowSubtasks?: boolean | undefined
12381243
alwaysAllowExecute?: boolean | undefined
12391244
allowedCommands?: string[] | undefined
1245+
allowedMaxRequests?: number | undefined
12401246
browserToolEnabled?: boolean | undefined
12411247
browserViewportSize?: string | undefined
12421248
screenshotQuality?: number | undefined
@@ -1376,6 +1382,7 @@ type TaskEvent =
13761382
| "mistake_limit_reached"
13771383
| "browser_action_launch"
13781384
| "use_mcp_server"
1385+
| "auto_approval_max_req_reached"
13791386
)
13801387
| undefined
13811388
say?:

src/i18n/locales/ca/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,12 @@
9696
"groqApiKey": "Clau API de Groq",
9797
"getGroqApiKey": "Obté la clau API de Groq"
9898
}
99+
},
100+
"ask": {
101+
"autoApprovedRequestLimitReached": {
102+
"title": "Límit de Sol·licituds Aprovades Automàticament Assolit",
103+
"description": "Roo ha assolit el límit de {{count}} sol·licituds d'API aprovades automàticament. Vols restablir el comptador i continuar amb la tasca?",
104+
"button": "Restablir i Continuar"
105+
}
99106
}
100107
}

src/i18n/locales/de/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,12 @@
9696
"groqApiKey": "Groq API-Schlüssel",
9797
"getGroqApiKey": "Groq API-Schlüssel erhalten"
9898
}
99+
},
100+
"ask": {
101+
"autoApprovedRequestLimitReached": {
102+
"title": "Limit für automatisch genehmigte Anfragen erreicht",
103+
"description": "Roo hat das Limit von {{count}} automatisch genehmigten API-Anfragen erreicht. Möchten Sie den Zähler zurücksetzen und mit der Aufgabe fortfahren?",
104+
"button": "Zurücksetzen und Fortfahren"
105+
}
99106
}
100107
}

src/i18n/locales/en/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,12 @@
9090
"input": {
9191
"task_prompt": "What should Roo do?",
9292
"task_placeholder": "Type your task here"
93+
},
94+
"ask": {
95+
"autoApprovedRequestLimitReached": {
96+
"title": "Auto-Approved Request Limit Reached",
97+
"description": "Roo has reached the auto-approved limit of {{count}} API requests. Would you like to reset the count and proceed with the task?",
98+
"button": "Reset and Continue"
99+
}
93100
}
94101
}

0 commit comments

Comments
 (0)