Skip to content

Commit 9164e5e

Browse files
committed
Merge branch 'main' into cte/benchmark-monorepo
2 parents 61efee8 + a73fce9 commit 9164e5e

File tree

22 files changed

+253
-230
lines changed

22 files changed

+253
-230
lines changed

e2e/src/suite/extension.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import * as assert from "assert"
22
import * as vscode from "vscode"
33

44
suite("Roo Code Extension", () => {
5-
test("OPENROUTER_API_KEY environment variable is set", () => {
6-
if (!process.env.OPENROUTER_API_KEY) {
7-
assert.fail("OPENROUTER_API_KEY environment variable is not set")
8-
}
9-
})
10-
115
test("Commands should be registered", async () => {
126
const expectedCommands = [
137
"roo-cline.plusButtonClicked",

e2e/src/suite/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as vscode from "vscode"
55

66
import type { RooCodeAPI } from "../../../src/exports/roo-code"
77

8-
import { waitUntilReady } from "./utils"
8+
import { waitFor } from "./utils"
99

1010
declare global {
1111
var api: RooCodeAPI
@@ -18,18 +18,25 @@ export async function run() {
1818
throw new Error("Extension not found")
1919
}
2020

21-
// Activate the extension if it's not already active.
2221
const api = extension.isActive ? extension.exports : await extension.activate()
2322

24-
// TODO: We might want to support a "free" model out of the box so
25-
// contributors can run the tests locally without having to pay.
2623
await api.setConfiguration({
27-
apiProvider: "openrouter",
24+
apiProvider: "openrouter" as const,
2825
openRouterApiKey: process.env.OPENROUTER_API_KEY!,
29-
openRouterModelId: "anthropic/claude-3.5-sonnet",
26+
openRouterModelId: "google/gemini-2.0-flash-001",
27+
openRouterModelInfo: {
28+
maxTokens: 8192,
29+
contextWindow: 1000000,
30+
supportsImages: true,
31+
supportsPromptCache: false,
32+
inputPrice: 0.1,
33+
outputPrice: 0.4,
34+
thinking: false,
35+
},
3036
})
3137

32-
await waitUntilReady({ api })
38+
await vscode.commands.executeCommand("roo-cline.SidebarProvider.focus")
39+
await waitFor(() => api.isReady())
3340

3441
// Expose the API to the tests.
3542
globalThis.api = api

e2e/src/suite/modes.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ suite("Roo Code Modes", () => {
1818

1919
let messages: ClineMessage[] = []
2020

21-
api.on("message", ({ message }) => messages.push(message))
21+
api.on("message", ({ message }) => {
22+
if (message.type === "say" && message.partial === false) {
23+
messages.push(message)
24+
}
25+
})
2226

2327
const switchModesTaskId = await api.startNewTask({
2428
configuration: { mode: "Code", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
@@ -31,22 +35,25 @@ suite("Roo Code Modes", () => {
3135
* Grade the response.
3236
*/
3337

34-
const gradePrompt =
35-
`Given this prompt: ${switchModesPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ` +
36-
messages
37-
.filter(({ type }) => type === "say")
38-
.map(({ text }) => text ?? "")
39-
.join("\n")
38+
const response = messages
39+
.filter(({ type, say, partial }) => say === "text")
40+
.map(({ text }) => text ?? "")
41+
.join("\n")
42+
43+
const gradePrompt = `Given this prompt: ${switchModesPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)". For example: Grade 7\n\nResponse: ${response}`
4044

4145
messages = []
4246

4347
const gradeTaskId = await api.startNewTask({ configuration: { mode: "Ask" }, text: gradePrompt })
44-
await waitUntilCompleted({ api, taskId: gradeTaskId, timeout: 60_000 })
48+
await waitUntilCompleted({ api, taskId: gradeTaskId })
4549

46-
const completion = messages.find(({ type, say, partial }) => say === "completion_result" && partial === false)
50+
const completion = messages.find(({ type, say, partial }) => say === "completion_result")
4751
const match = completion?.text?.match(/Grade: (\d+)/)
4852
const score = parseInt(match?.[1] ?? "0")
49-
assert.ok(score >= 7 && score <= 10, `Grade must be between 7 and 10 - ${completion?.text}`)
53+
assert.ok(
54+
score >= 7 && score <= 10,
55+
`Grade must be between 7 and 10. DEBUG: score = ${score}, completion = ${completion?.text}`,
56+
)
5057

5158
await api.cancelCurrentTask()
5259
})

e2e/src/suite/subtasks.test.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ suite("Roo Code Subtasks", () => {
88
test("Should handle subtask cancellation and resumption correctly", async () => {
99
const api = globalThis.api
1010

11-
const messages: ClineMessage[] = []
12-
api.on("message", ({ message }) => messages.push(message))
11+
const messages: Record<string, ClineMessage[]> = {}
12+
13+
api.on("message", ({ taskId, message }) => {
14+
if (message.type === "say" && message.partial === false) {
15+
messages[taskId] = messages[taskId] || []
16+
messages[taskId].push(message)
17+
}
18+
})
1319

1420
await api.setConfiguration({
15-
mode: "Code",
21+
mode: "ask",
1622
alwaysAllowModeSwitch: true,
1723
alwaysAllowSubtasks: true,
1824
autoApprovalEnabled: true,
@@ -34,23 +40,19 @@ suite("Roo Code Subtasks", () => {
3440
// Wait for the subtask to be spawned and then cancel it.
3541
api.on("taskSpawned", (_, childTaskId) => (spawnedTaskId = childTaskId))
3642
await waitFor(() => !!spawnedTaskId)
37-
await sleep(2_000) // Give the task a chance to start and populate the history.
43+
await sleep(1_000) // Give the task a chance to start and populate the history.
3844
await api.cancelCurrentTask()
3945

4046
// Wait a bit to ensure any task resumption would have happened.
4147
await sleep(2_000)
4248

4349
// The parent task should not have resumed yet, so we shouldn't see
4450
// "Parent task resumed".
45-
// assert.ok(
46-
// getMessage({
47-
// api,
48-
// taskId: parentTaskId,
49-
// include: "Parent task resumed",
50-
// exclude: "You are the parent task",
51-
// }) === undefined,
52-
// "Parent task should not have resumed after subtask cancellation",
53-
// )
51+
assert.ok(
52+
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
53+
undefined,
54+
"Parent task should not have resumed after subtask cancellation",
55+
)
5456

5557
// Start a new task with the same message as the subtask.
5658
const anotherTaskId = await api.startNewTask({ text: childPrompt })
@@ -60,15 +62,11 @@ suite("Roo Code Subtasks", () => {
6062
await sleep(2_000)
6163

6264
// The parent task should still not have resumed.
63-
// assert.ok(
64-
// getMessage({
65-
// api,
66-
// taskId: parentTaskId,
67-
// include: "Parent task resumed",
68-
// exclude: "You are the parent task",
69-
// }) === undefined,
70-
// "Parent task should not have resumed after subtask cancellation",
71-
// )
65+
assert.ok(
66+
messages[parentTaskId].find(({ type, text }) => type === "say" && text === "Parent task resumed") ===
67+
undefined,
68+
"Parent task should not have resumed after subtask cancellation",
69+
)
7270

7371
// Clean up - cancel all tasks.
7472
await api.clearCurrentTask()

e2e/src/suite/task.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ suite("Roo Code Task", () => {
99
const api = globalThis.api
1010

1111
const messages: ClineMessage[] = []
12-
api.on("message", ({ message }) => messages.push(message))
12+
13+
api.on("message", ({ message }) => {
14+
if (message.type === "say" && message.partial === false) {
15+
messages.push(message)
16+
}
17+
})
1318

1419
const taskId = await api.startNewTask({
1520
configuration: { mode: "Ask", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
@@ -18,7 +23,7 @@ suite("Roo Code Task", () => {
1823

1924
await waitUntilCompleted({ api, taskId })
2025

21-
const completion = messages.find(({ type, say, partial }) => say === "completion_result" && partial === false)
26+
const completion = messages.find(({ say, partial }) => say === "completion_result")
2227

2328
assert.ok(
2429
completion?.text?.includes("My name is Roo"),

e2e/src/suite/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type WaitForOptions = {
99

1010
export const waitFor = (
1111
condition: (() => Promise<boolean>) | (() => boolean),
12-
{ timeout = 60_000, interval = 250 }: WaitForOptions = {},
12+
{ timeout = 30_000, interval = 250 }: WaitForOptions = {},
1313
) => {
1414
let timeoutId: NodeJS.Timeout | undefined = undefined
1515

@@ -41,15 +41,6 @@ export const waitFor = (
4141
])
4242
}
4343

44-
type WaitUntilReadyOptions = WaitForOptions & {
45-
api: RooCodeAPI
46-
}
47-
48-
export const waitUntilReady = async ({ api, ...options }: WaitUntilReadyOptions) => {
49-
await vscode.commands.executeCommand("roo-cline.SidebarProvider.focus")
50-
await waitFor(() => api.isReady(), options)
51-
}
52-
5344
type WaitUntilAbortedOptions = WaitForOptions & {
5445
api: RooCodeAPI
5546
taskId: string

knip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"benchmark/**",
1818
"src/activate/**",
1919
"src/exports/**",
20-
"src/schemas/**",
20+
"src/schemas/ipc.ts",
2121
"src/extension.ts",
2222
"scripts/**"
2323
],

0 commit comments

Comments
 (0)