Skip to content

Commit 22931c0

Browse files
committed
add vibecommit exe as resource into electron exe, and also allow devtools in production build for now while testing
1 parent 25398fa commit 22931c0

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

electron/ipc/vibe-handlers.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ const execFileAsync = promisify(execFile);
1212

1313
// Helper function to get the correct path to vibe.exe
1414
function getVibeExecutablePath() {
15-
// Use app.getAppPath() for both development and production
16-
// This points to the app's root directory in both cases
15+
// In production, binaries should be outside the ASAR, under resources
16+
if (app.isPackaged) {
17+
return join(process.resourcesPath, "vibecommit", "win64", "vibe.exe");
18+
}
19+
// In development, resolve relative to the project root
1720
const appPath = app.getAppPath();
1821
return join(appPath, "vibecommit", "win64", "vibe.exe");
1922
}
@@ -88,12 +91,7 @@ function registerVibeHandlers() {
8891
}
8992

9093
// Check if executable exists
91-
const executablePath = join(
92-
process.cwd(),
93-
"vibecommit",
94-
"win64",
95-
"vibe.exe",
96-
);
94+
const executablePath = getVibeExecutablePath();
9795

9896
if (!existsSync(executablePath)) {
9997
throw new Error("vibe.exe not found in vibecommit/win64/ directory");

electron/main.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
const { app, BrowserWindow, Menu, dialog } = require("electron");
1+
const { app, BrowserWindow, Menu, dialog, globalShortcut } = require("electron");
22
const path = require("path");
33
const { registerGitHandlers } = require("./ipc/git-handlers");
44
const { registerVibeHandlers } = require("./ipc/vibe-handlers");
55
const { registerCommonHandlers } = require("./ipc/common-handlers");
66
const { registerSecureStoreHandlers } = require("./ipc/secure-store");
77
const { createLogger } = require('./logger');
88
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
9+
// Allow enabling DevTools in production via env var or CLI flag
10+
const enableDevTools =
11+
isDev ||
12+
process.env.ELECTRON_ENABLE_DEVTOOLS === "1" ||
13+
process.argv.includes("--enable-devtools");
914

1015
const logger = createLogger({ component: 'main' });
1116

@@ -41,11 +46,20 @@ function createWindow() {
4146
});
4247

4348
// Open DevTools in development
44-
if (isDev) {
49+
if (enableDevTools) {
4550
mainWindow.webContents.openDevTools();
4651
logger.info('DevTools opened for development');
4752
}
4853

54+
// Keyboard toggles for DevTools even without a menu
55+
mainWindow.webContents.on('before-input-event', (event, input) => {
56+
const isToggle = (input.key?.toUpperCase() === 'I' && input.control && input.shift) || input.code === 'F12';
57+
if (isToggle) {
58+
mainWindow.webContents.toggleDevTools();
59+
event.preventDefault();
60+
}
61+
});
62+
4963
// Handle window closed
5064
mainWindow.on("closed", () => {
5165
mainWindow = null;
@@ -82,6 +96,21 @@ app.whenReady().then(() => {
8296

8397
createWindow();
8498

99+
// Global shortcuts to toggle DevTools in production builds
100+
try {
101+
globalShortcut.register('Control+Shift+I', () => {
102+
const win = BrowserWindow.getFocusedWindow();
103+
if (win) win.webContents.toggleDevTools();
104+
});
105+
globalShortcut.register('F12', () => {
106+
const win = BrowserWindow.getFocusedWindow();
107+
if (win) win.webContents.toggleDevTools();
108+
});
109+
logger.info('Global shortcuts for DevTools registered');
110+
} catch (e) {
111+
logger.error('Failed to register global shortcuts', { error: e?.message });
112+
}
113+
85114
// On macOS, re-create window when dock icon is clicked
86115
app.on("activate", () => {
87116
if (BrowserWindow.getAllWindows().length === 0) {
@@ -98,6 +127,14 @@ app.on("window-all-closed", () => {
98127
}
99128
});
100129

130+
// Unregister global shortcuts on quit
131+
app.on('will-quit', () => {
132+
try {
133+
globalShortcut.unregisterAll();
134+
logger.info('Global shortcuts unregistered');
135+
} catch {}
136+
});
137+
101138
// Security: Prevent new window creation
102139
app.on("web-contents-created", (event, contents) => {
103140
contents.on("new-window", (event, navigationUrl) => {

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@
100100
"files": [
101101
"out/**/*",
102102
"electron/**/*",
103-
"node_modules/**/*",
104-
"vibecommit/**/*"
103+
"node_modules/**/*"
104+
],
105+
"extraResources": [
106+
{
107+
"from": "vibecommit",
108+
"to": "vibecommit"
109+
}
105110
],
106111
"win": {
107112
"target": "nsis",

0 commit comments

Comments
 (0)