fix(electrobun): no double dialog on cancel, browser closes on select + max-height

- pickDirectory: removed Electrobun fallback on zenity cancel (was causing
  second dialog to appear). Cancel = return null, no fallback.
- PathBrowser: handleBrowserSelect closes browser after selection
- PathBrowser container: max-height 16rem with overflow scroll + border
This commit is contained in:
Hibryda 2026-03-22 12:25:18 +01:00
parent d444e8aecd
commit 0d163f77e8
2 changed files with 6 additions and 14 deletions

View file

@ -133,24 +133,15 @@ const rpc = BrowserView.defineRPC<PtyRPCSchema>({
try { try {
const { execSync } = await import("child_process"); const { execSync } = await import("child_process");
const start = startingFolder?.replace(/^~/, process.env.HOME || "/home") || process.env.HOME || "/home"; 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( const result = execSync(
`zenity --file-selection --directory --title="Select Project Folder" --filename="${start}/"`, `zenity --file-selection --directory --title="Select Project Folder" --filename="${start}/"`,
{ encoding: "utf-8", timeout: 120_000 } { encoding: "utf-8", timeout: 120_000 }
).trim(); ).trim();
return { path: result || null }; return { path: result || null };
} catch { } catch (e: any) {
// User cancelled or zenity not found — try Electrobun fallback // zenity exits with code 1 on cancel, code 5 if not found
try { // Do NOT fall back to Electrobun dialog — just return null
const paths = await Utils.openFileDialog({ return { path: null };
startingFolder: startingFolder || "~/",
canChooseFiles: false,
canChooseDirectory: true,
allowsMultipleSelection: false,
});
return { path: paths?.[0] ?? null };
} catch { return { path: null }; }
} }
}, },

View file

@ -210,6 +210,7 @@
function handleBrowserSelect(path: string) { function handleBrowserSelect(path: string) {
localPath = path; localPath = path;
showBrowser = false;
validatePath(path); validatePath(path);
} }
@ -304,7 +305,7 @@
</span> </span>
{/if} {/if}
</div> </div>
<div style:display={showBrowser ? 'block' : 'none'}> <div style:display={showBrowser ? 'block' : 'none'} style="max-height: 16rem; overflow-y: auto; border: 1px solid var(--ctp-surface1); border-radius: 0.375rem; margin-top: 0.5rem;">
<PathBrowser onSelect={handleBrowserSelect} onClose={() => showBrowser = false} /> <PathBrowser onSelect={handleBrowserSelect} onClose={() => showBrowser = false} />
</div> </div>
{#if pathValid === 'valid' && isGitRepo} {#if pathValid === 'valid' && isGitRepo}