fix(electrobun): native folder picker via zenity — proper dark theme + folder mode
- Uses zenity --file-selection --directory for proper GTK folder chooser (correct "Select Project Folder" title, dirs sorted first, dark theme) - Falls back to Electrobun Utils.openFileDialog if zenity unavailable - RPC timeout increased to 120s (native dialogs block until user closes) - zenity respects system GTK theme + color-scheme prefer-dark
This commit is contained in:
parent
41d5cc3c12
commit
d444e8aecd
1 changed files with 23 additions and 10 deletions
|
|
@ -105,7 +105,7 @@ const gitHandlers = createGitHandlers();
|
||||||
// ── RPC definition ─────────────────────────────────────────────────────────
|
// ── RPC definition ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const rpc = BrowserView.defineRPC<PtyRPCSchema>({
|
const rpc = BrowserView.defineRPC<PtyRPCSchema>({
|
||||||
maxRequestTime: 15_000,
|
maxRequestTime: 120_000, // 2 min — native dialogs block until user closes
|
||||||
handlers: {
|
handlers: {
|
||||||
requests: {
|
requests: {
|
||||||
// PTY
|
// PTY
|
||||||
|
|
@ -128,8 +128,20 @@ const rpc = BrowserView.defineRPC<PtyRPCSchema>({
|
||||||
// Git
|
// Git
|
||||||
...gitHandlers,
|
...gitHandlers,
|
||||||
|
|
||||||
// Native folder picker dialog
|
// Native folder picker dialog via zenity (proper GTK folder chooser)
|
||||||
"files.pickDirectory": async ({ startingFolder }) => {
|
"files.pickDirectory": async ({ startingFolder }) => {
|
||||||
|
try {
|
||||||
|
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 {
|
try {
|
||||||
const paths = await Utils.openFileDialog({
|
const paths = await Utils.openFileDialog({
|
||||||
startingFolder: startingFolder || "~/",
|
startingFolder: startingFolder || "~/",
|
||||||
|
|
@ -139,6 +151,7 @@ const rpc = BrowserView.defineRPC<PtyRPCSchema>({
|
||||||
});
|
});
|
||||||
return { path: paths?.[0] ?? null };
|
return { path: paths?.[0] ?? null };
|
||||||
} catch { return { path: null }; }
|
} catch { return { path: null }; }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Home directory
|
// Home directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue