Compare commits

...
Author SHA1 Message Date
Cline Evaluation fda89166a0 addressing comments 2025-07-03 22:49:42 -07:00
Cline Evaluation 114126e1f5 showOpenDialogue host bridge migration 2025-07-03 18:13:53 -07:00
4 changed files with 55 additions and 12 deletions
+16
View File
@@ -10,6 +10,7 @@ import "common.proto";
service WindowService {
// Opens a text document in the editor and returns editor information.
rpc showTextDocument(ShowTextDocumentRequest) returns (TextEditorInfo);
rpc showOpenDialogue(ShowOpenDialogueRequest) returns (SelectedResources);
}
message ShowTextDocumentRequest {
@@ -30,3 +31,18 @@ message TextEditorInfo {
optional int32 view_column = 2;
bool is_active = 3;
}
message ShowOpenDialogueRequest {
cline.Metadata metadata = 1;
optional bool can_select_many = 2;
optional string open_label = 3;
optional ShowOpenDialogueFilterOption filters = 4;
}
message ShowOpenDialogueFilterOption {
repeated string files = 1;
}
message SelectedResources {
repeated string paths = 1;
}
@@ -0,0 +1,27 @@
import * as vscode from "vscode"
import { ShowOpenDialogueRequest, SelectedResources } from "@/shared/proto/host/window"
export async function showOpenDialogue(request: ShowOpenDialogueRequest): Promise<SelectedResources> {
const options: vscode.OpenDialogOptions = {}
if (request.canSelectMany !== undefined) {
options.canSelectMany = request.canSelectMany
}
if (request.openLabel !== undefined) {
options.openLabel = request.openLabel
}
if (request.filters?.files) {
options.filters = {
Files: request.filters.files,
}
}
const selectedResources = await vscode.window.showOpenDialog(options)
// Convert back to path format
return SelectedResources.create({
paths: selectedResources ? selectedResources.map((uri) => uri.fsPath) : [],
})
}
+12 -8
View File
@@ -2,6 +2,8 @@ import * as vscode from "vscode"
import fs from "fs/promises"
import * as path from "path"
import sizeOf from "image-size"
import { getHostBridgeProvider } from "@/hosts/host-providers"
import { ShowOpenDialogueRequest } from "@/shared/proto/host/window"
/**
* Supports processing of images and other file types
@@ -11,15 +13,17 @@ export async function selectFiles(imagesAllowed: boolean): Promise<{ images: str
const IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp"] // supported by anthropic and openrouter
const OTHER_FILE_EXTENSIONS = ["xml", "json", "txt", "log", "md", "docx", "ipynb", "pdf", "xlsx", "csv"]
const options: vscode.OpenDialogOptions = {
canSelectMany: true,
openLabel: "Select",
filters: {
Files: imagesAllowed ? [...IMAGE_EXTENSIONS, ...OTHER_FILE_EXTENSIONS] : OTHER_FILE_EXTENSIONS,
},
}
const showDialogueResponse = await getHostBridgeProvider().windowClient.showOpenDialogue(
ShowOpenDialogueRequest.create({
canSelectMany: true,
openLabel: "Select",
filters: {
files: imagesAllowed ? [...IMAGE_EXTENSIONS, ...OTHER_FILE_EXTENSIONS] : OTHER_FILE_EXTENSIONS,
},
}),
)
const fileUris = await vscode.window.showOpenDialog(options)
const fileUris = showDialogueResponse.paths.map((path) => vscode.Uri.file(path))
if (!fileUris || fileUris.length === 0) {
return { images: [], files: [] }
@@ -672,10 +672,6 @@ vscode.window.showWorkspaceFolderPick = function (options) {
console.log("Called stubbed function: vscode.window.showWorkspaceFolderPick")
return Promise.resolve(null)
}
vscode.window.showOpenDialog = function (options) {
console.log("Called stubbed function: vscode.window.showOpenDialog")
return []
}
vscode.window.showSaveDialog = function (options) {
console.log("Called stubbed function: vscode.window.showSaveDialog")
return Promise.resolve(null)