From 9e6bcc102e6eea3489ed74ff026ec3bc95150f20 Mon Sep 17 00:00:00 2001 From: meetp06 <65815199+meetp06@users.noreply.github.com> Date: Thu, 11 Jun 2026 03:07:17 -0700 Subject: [PATCH] fix(vscode): wire native file dialog for embedded-app Browse button (#1011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Dropper "Browse" button posts {type:'requestFileDialog'}, which the openLink webview bridge forwards to the extension host. But the host's onDidReceiveMessage only implemented clipboard paste/copy — it never handled requestFileDialog. So the request arrived, no native dialog opened, and nativeFilesSelected was never posted back: the button did nothing, while clicking elsewhere in the drop zone (the in-iframe ) still worked. That matches the report exactly. Add the missing requestFileDialog case: open vscode.window.showOpenDialog, read the selected files, and post them back as nativeFilesSelected (buffers as number[] so they survive webview message serialization). Mirrors the existing clipboard and drag-drop bridges in the same handler. Co-Authored-By: Claude Opus 4.8 --- apps/vscode/src/providers/ProjectProvider.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apps/vscode/src/providers/ProjectProvider.ts b/apps/vscode/src/providers/ProjectProvider.ts index 425ccc9f8..cc7271968 100644 --- a/apps/vscode/src/providers/ProjectProvider.ts +++ b/apps/vscode/src/providers/ProjectProvider.ts @@ -858,6 +858,28 @@ export class ProjectProvider implements vscode.CustomTextEditorProvider { panel.webview.postMessage({ type: 'pasteContent', text }); } else if (msg?.type === 'copyText' && typeof msg.text === 'string') { await vscode.env.clipboard.writeText(msg.text); + } else if (msg?.type === 'requestFileDialog') { + // The embedded app's "Browse" button can't open an OS file picker from + // inside the sandboxed iframe, so it posts {type:'requestFileDialog'} up to + // the bridge, which forwards it here. Open the native dialog on the host, + // read the chosen files, and post them back as {type:'nativeFilesSelected'}; + // the bridge relays that into the iframe. Buffers go as number[] so they + // survive webview message serialization. + try { + const uris = await vscode.window.showOpenDialog({ canSelectMany: true, openLabel: 'Select' }); + if (!uris || uris.length === 0) return; + const files = await Promise.all( + uris.map(async (uri) => ({ + name: uri.path.split('/').pop() || 'file', + type: '', + lastModified: Date.now(), + buffer: Array.from(await vscode.workspace.fs.readFile(uri)), + })) + ); + panel.webview.postMessage({ type: 'nativeFilesSelected', files }); + } catch (error) { + this.logger.error(`[ProjectProvider] Native file dialog failed: ${error}`); + } } }); }