Skip to content

Commit 579dcd5

Browse files
committed
Merge remote-tracking branch 'origin/main' into support-roo-directory
2 parents 0670844 + cf74568 commit 579dcd5

File tree

11 files changed

+109
-6
lines changed

11 files changed

+109
-6
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@
174174
"command": "roo-cline.setCustomStoragePath",
175175
"title": "Set Custom Storage Path",
176176
"category": "Roo Code"
177+
},
178+
{
179+
"command": "roo-cline.focusInput",
180+
"title": "Focus Input Field",
181+
"category": "Roo Code"
177182
}
178183
],
179184
"menus": {

src/activate/registerCommands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
114114
const { promptForCustomStoragePath } = await import("../shared/storagePathManager")
115115
await promptForCustomStoragePath()
116116
},
117+
"roo-cline.focusInput": () => {
118+
provider.postMessageToWebview({ type: "action", action: "focusInput" })
119+
},
117120
}
118121
}
119122

src/core/assistant-message/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const toolParamNames = [
6060
"cwd",
6161
"follow_up",
6262
"task",
63+
"size",
6364
] as const
6465

6566
export type ToolParamName = (typeof toolParamNames)[number]
@@ -115,7 +116,7 @@ export interface ListCodeDefinitionNamesToolUse extends ToolUse {
115116

116117
export interface BrowserActionToolUse extends ToolUse {
117118
name: "browser_action"
118-
params: Partial<Pick<Record<ToolParamName, string>, "action" | "url" | "coordinate" | "text">>
119+
params: Partial<Pick<Record<ToolParamName, string>, "action" | "url" | "coordinate" | "text" | "size">>
119120
}
120121

121122
export interface UseMcpToolToolUse extends ToolUse {

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,19 +2714,26 @@ Parameters:
27142714
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
27152715
- Use with the \`url\` parameter to provide the URL.
27162716
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
2717+
* hover: Move the cursor to a specific x,y coordinate.
2718+
- Use with the \`coordinate\` parameter to specify the location.
2719+
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
27172720
* click: Click at a specific x,y coordinate.
27182721
- Use with the \`coordinate\` parameter to specify the location.
27192722
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
27202723
* type: Type a string of text on the keyboard. You might use this after clicking on a text field to input text.
27212724
- Use with the \`text\` parameter to provide the string to type.
2725+
* resize: Resize the viewport to a specific w,h size.
2726+
- Use with the \`size\` parameter to specify the new size.
27222727
* scroll_down: Scroll down the page by one page height.
27232728
* scroll_up: Scroll up the page by one page height.
27242729
* close: Close the Puppeteer-controlled browser instance. This **must always be the final browser action**.
27252730
- Example: \`<action>close</action>\`
27262731
- url: (optional) Use this for providing the URL for the \`launch\` action.
27272732
* Example: <url>https://example.com</url>
2728-
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **900x600** resolution.
2733+
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **900x600** resolution.
27292734
* Example: <coordinate>450,300</coordinate>
2735+
- size: (optional) The width and height for the \`resize\` action.
2736+
* Example: <size>1280,720</size>
27302737
- text: (optional) Use this for providing the text for the \`type\` action.
27312738
* Example: <text>Hello, world!</text>
27322739
Usage:
@@ -3625,19 +3632,26 @@ Parameters:
36253632
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
36263633
- Use with the \`url\` parameter to provide the URL.
36273634
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
3635+
* hover: Move the cursor to a specific x,y coordinate.
3636+
- Use with the \`coordinate\` parameter to specify the location.
3637+
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
36283638
* click: Click at a specific x,y coordinate.
36293639
- Use with the \`coordinate\` parameter to specify the location.
36303640
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
36313641
* type: Type a string of text on the keyboard. You might use this after clicking on a text field to input text.
36323642
- Use with the \`text\` parameter to provide the string to type.
3643+
* resize: Resize the viewport to a specific w,h size.
3644+
- Use with the \`size\` parameter to specify the new size.
36333645
* scroll_down: Scroll down the page by one page height.
36343646
* scroll_up: Scroll up the page by one page height.
36353647
* close: Close the Puppeteer-controlled browser instance. This **must always be the final browser action**.
36363648
- Example: \`<action>close</action>\`
36373649
- url: (optional) Use this for providing the URL for the \`launch\` action.
36383650
* Example: <url>https://example.com</url>
3639-
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **1280x800** resolution.
3651+
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **1280x800** resolution.
36403652
* Example: <coordinate>450,300</coordinate>
3653+
- size: (optional) The width and height for the \`resize\` action.
3654+
* Example: <size>1280,720</size>
36413655
- text: (optional) Use this for providing the text for the \`type\` action.
36423656
* Example: <text>Hello, world!</text>
36433657
Usage:

src/core/prompts/tools/browser-action.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ Parameters:
1515
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
1616
- Use with the \`url\` parameter to provide the URL.
1717
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
18+
* hover: Move the cursor to a specific x,y coordinate.
19+
- Use with the \`coordinate\` parameter to specify the location.
20+
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
1821
* click: Click at a specific x,y coordinate.
1922
- Use with the \`coordinate\` parameter to specify the location.
2023
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
2124
* type: Type a string of text on the keyboard. You might use this after clicking on a text field to input text.
2225
- Use with the \`text\` parameter to provide the string to type.
26+
* resize: Resize the viewport to a specific w,h size.
27+
- Use with the \`size\` parameter to specify the new size.
2328
* scroll_down: Scroll down the page by one page height.
2429
* scroll_up: Scroll up the page by one page height.
2530
* close: Close the Puppeteer-controlled browser instance. This **must always be the final browser action**.
2631
- Example: \`<action>close</action>\`
2732
- url: (optional) Use this for providing the URL for the \`launch\` action.
2833
* Example: <url>https://example.com</url>
29-
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **${args.browserViewportSize}** resolution.
34+
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **${args.browserViewportSize}** resolution.
3035
* Example: <coordinate>450,300</coordinate>
36+
- size: (optional) The width and height for the \`resize\` action.
37+
* Example: <size>1280,720</size>
3138
- text: (optional) Use this for providing the text for the \`type\` action.
3239
* Example: <text>Hello, world!</text>
3340
Usage:

src/core/tools/browserActionTool.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function browserActionTool(
2121
const url: string | undefined = block.params.url
2222
const coordinate: string | undefined = block.params.coordinate
2323
const text: string | undefined = block.params.text
24+
const size: string | undefined = block.params.size
2425
if (!action || !browserActions.includes(action)) {
2526
// checking for action to ensure it is complete and valid
2627
if (!block.partial) {
@@ -72,7 +73,7 @@ export async function browserActionTool(
7273
await cline.browserSession.launchBrowser()
7374
browserActionResult = await cline.browserSession.navigateToUrl(url)
7475
} else {
75-
if (action === "click") {
76+
if (action === "click" || action === "hover") {
7677
if (!coordinate) {
7778
cline.consecutiveMistakeCount++
7879
pushToolResult(await cline.sayAndCreateMissingParamError("browser_action", "coordinate"))
@@ -88,6 +89,14 @@ export async function browserActionTool(
8889
return
8990
}
9091
}
92+
if (action === "resize") {
93+
if (!size) {
94+
cline.consecutiveMistakeCount++
95+
pushToolResult(await cline.sayAndCreateMissingParamError("browser_action", "size"))
96+
await cline.browserSession.closeBrowser()
97+
return
98+
}
99+
}
91100
cline.consecutiveMistakeCount = 0
92101
await cline.say(
93102
"browser_action",
@@ -103,6 +112,9 @@ export async function browserActionTool(
103112
case "click":
104113
browserActionResult = await cline.browserSession.click(coordinate!)
105114
break
115+
case "hover":
116+
browserActionResult = await cline.browserSession.hover(coordinate!)
117+
break
106118
case "type":
107119
browserActionResult = await cline.browserSession.type(text!)
108120
break
@@ -112,6 +124,9 @@ export async function browserActionTool(
112124
case "scroll_up":
113125
browserActionResult = await cline.browserSession.scrollUp()
114126
break
127+
case "resize":
128+
browserActionResult = await cline.browserSession.resize(size!)
129+
break
115130
case "close":
116131
browserActionResult = await cline.browserSession.closeBrowser()
117132
break
@@ -121,9 +136,11 @@ export async function browserActionTool(
121136
switch (action) {
122137
case "launch":
123138
case "click":
139+
case "hover":
124140
case "type":
125141
case "scroll_down":
126142
case "scroll_up":
143+
case "resize":
127144
await cline.say("browser_action_result", JSON.stringify(browserActionResult))
128145
pushToolResult(
129146
formatResponse.toolResult(

src/exports/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,21 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
132132
return taskId
133133
}
134134

135+
public async resumeTask(taskId: string): Promise<void> {
136+
const { historyItem } = await this.provider.getTaskWithId(taskId)
137+
await this.provider.initClineWithHistoryItem(historyItem)
138+
await this.provider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
139+
}
140+
141+
public async isTaskInHistory(taskId: string): Promise<boolean> {
142+
try {
143+
await this.provider.getTaskWithId(taskId)
144+
return true
145+
} catch {
146+
return false
147+
}
148+
}
149+
135150
public getCurrentTaskStack() {
136151
return this.sidebarProvider.getCurrentTaskStack()
137152
}

src/exports/roo-code.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,20 @@ interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
551551
images?: string[]
552552
newTab?: boolean
553553
}): Promise<string>
554+
/**
555+
* Resumes a task with the given ID.
556+
* @param taskId The ID of the task to resume.
557+
* @throws Error if the task is not found in the task history.
558+
*/
559+
resumeTask(taskId: string): Promise<void>
560+
561+
/**
562+
* Checks if a task with the given ID is in the task history.
563+
* @param taskId The ID of the task to check.
564+
* @returns True if the task is in the task history, false otherwise.
565+
*/
566+
isTaskInHistory(taskId: string): Promise<boolean>
567+
554568
/**
555569
* Returns the current task stack.
556570
* @returns An array of task IDs.

src/services/browser/BrowserSession.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,17 @@ export class BrowserSession {
538538
})
539539
})
540540
}
541+
542+
async resize(size: string): Promise<BrowserActionResult> {
543+
return this.doAction(async (page) => {
544+
const [width, height] = size.split(",").map(Number)
545+
const session = await page.createCDPSession()
546+
await page.setViewport({ width, height })
547+
const { windowId } = await session.send("Browser.getWindowForTarget")
548+
await session.send("Browser.setWindowBounds", {
549+
bounds: { width, height },
550+
windowId,
551+
})
552+
})
553+
}
541554
}

src/shared/ExtensionMessage.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface ExtensionMessage {
7777
| "historyButtonClicked"
7878
| "promptsButtonClicked"
7979
| "didBecomeVisible"
80+
| "focusInput"
8081
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
8182
state?: ExtensionState
8283
images?: string[]
@@ -232,13 +233,23 @@ export interface ClineSayTool {
232233
}
233234

234235
// Must keep in sync with system prompt.
235-
export const browserActions = ["launch", "click", "hover", "type", "scroll_down", "scroll_up", "close"] as const
236+
export const browserActions = [
237+
"launch",
238+
"click",
239+
"hover",
240+
"type",
241+
"scroll_down",
242+
"scroll_up",
243+
"resize",
244+
"close",
245+
] as const
236246

237247
export type BrowserAction = (typeof browserActions)[number]
238248

239249
export interface ClineSayBrowserAction {
240250
action: BrowserAction
241251
coordinate?: string
252+
size?: string
242253
text?: string
243254
}
244255

0 commit comments

Comments
 (0)