diff --git a/ui-electrobun/src/bun/index.ts b/ui-electrobun/src/bun/index.ts index 92903ec..d23bcfd 100644 --- a/ui-electrobun/src/bun/index.ts +++ b/ui-electrobun/src/bun/index.ts @@ -105,7 +105,7 @@ const gitHandlers = createGitHandlers(); // ── RPC definition ───────────────────────────────────────────────────────── const rpc = BrowserView.defineRPC({ - maxRequestTime: 15_000, + maxRequestTime: 120_000, // 2 min — native dialogs block until user closes handlers: { requests: { // PTY @@ -128,17 +128,30 @@ const rpc = BrowserView.defineRPC({ // Git ...gitHandlers, - // Native folder picker dialog + // Native folder picker dialog via zenity (proper GTK folder chooser) "files.pickDirectory": async ({ startingFolder }) => { try { - const paths = await Utils.openFileDialog({ - startingFolder: startingFolder || "~/", - canChooseFiles: false, - canChooseDirectory: true, - allowsMultipleSelection: false, - }); - return { path: paths?.[0] ?? null }; - } catch { return { path: null }; } + const { execSync } = await import("child_process"); + const start = startingFolder?.replace(/^~/, process.env.HOME || "/home") || process.env.HOME || "/home"; + // zenity --file-selection --directory gives a proper "Select Folder" dialog + // with dark theme support, dirs sorted first, and correct title + const result = execSync( + `zenity --file-selection --directory --title="Select Project Folder" --filename="${start}/"`, + { encoding: "utf-8", timeout: 120_000 } + ).trim(); + return { path: result || null }; + } catch { + // User cancelled or zenity not found — try Electrobun fallback + try { + const paths = await Utils.openFileDialog({ + startingFolder: startingFolder || "~/", + canChooseFiles: false, + canChooseDirectory: true, + allowsMultipleSelection: false, + }); + return { path: paths?.[0] ?? null }; + } catch { return { path: null }; } + } }, // Home directory