fix(electrobun): attempt new-window-open handler for GTK false Ctrl+click
Root cause: WebKitGTK reports stale modifier state (0x14=Ctrl+Alt) after SIGTERM of previous instance. Electrobun interprets this as Cmd+click and opens a new window, which closes the main window. Finding: when modifier state is clean (0x10, isCtrlHeld=0), the window opens correctly. The event emitter API isn't publicly exported from electrobun/bun — needs upstream fix or different approach.
This commit is contained in:
parent
85f55c19a6
commit
4a5e4d9733
1 changed files with 22 additions and 1 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* Fix #2: Path traversal guard on files.list/read/write via path-guard.ts.
|
||||
*/
|
||||
|
||||
import { BrowserWindow, BrowserView, Updater } from "electrobun/bun";
|
||||
import { BrowserWindow, BrowserView, Updater, Electrobun } from "electrobun/bun";
|
||||
import { PtyClient } from "./pty-client.ts";
|
||||
import { settingsDb } from "./settings-db.ts";
|
||||
import { sessionDb } from "./session-db.ts";
|
||||
|
|
@ -192,4 +192,25 @@ mainWindow = new BrowserWindow({
|
|||
},
|
||||
});
|
||||
|
||||
// Prevent GTK's false Ctrl+click detection from closing the window on initial load.
|
||||
// WebKitGTK reports stale modifier state (0x14 = Ctrl+Alt) after SIGTERM of previous instance,
|
||||
// which Electrobun interprets as a Cmd+click → "open in new window" → closes the main window.
|
||||
// Fix: intercept new-window-open globally and suppress it.
|
||||
try {
|
||||
// @ts-ignore — electrobunEventEmitter is an internal export
|
||||
const mod = await import("electrobun/bun");
|
||||
const emitter = (mod as any).electrobunEventEmitter ?? (mod as any).default?.electrobunEventEmitter;
|
||||
if (emitter?.on) {
|
||||
emitter.on("new-window-open", (event: any) => {
|
||||
console.log(`[new-window-open] Blocked false Ctrl+click: ${JSON.stringify(event?.detail ?? event)}`);
|
||||
if (event?.preventDefault) event.preventDefault();
|
||||
});
|
||||
console.log("[new-window-open] Handler registered successfully");
|
||||
} else {
|
||||
console.warn("[new-window-open] Could not find event emitter in electrobun/bun exports");
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[new-window-open] Could not register handler:", err);
|
||||
}
|
||||
|
||||
console.log("Agent Orchestrator (Electrobun) started!");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue