Skip to content

Commit e3f91b2

Browse files
Benjamin Smithclaude
authored andcommitted
Open external links (update banner) in the system browser instead of an in-app window
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 07f15bb commit e3f91b2

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

main.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const {
2222
app,
2323
BrowserWindow,
2424
ipcMain,
25-
Menu
25+
Menu,
26+
shell
2627
} = require('electron')
2728

2829
// Initialize global variables early - BEFORE any windows are created
@@ -80,6 +81,12 @@ function createmainWindow(token, authWindow) {
8081

8182
mainWindow.setResizable(false);
8283

84+
// External links open in the user's default browser, not an in-app window.
85+
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
86+
shell.openExternal(url);
87+
return { action: 'deny' };
88+
});
89+
8390
// and load the index.html of the app.
8491
mainWindow.loadURL('file://' + __dirname + '/index.html', {
8592
userAgent: 'Chrome'
@@ -140,6 +147,13 @@ function createauthWindow() {
140147
});
141148
authWindow.setResizable(false);
142149

150+
// Open external links (e.g. the "new version available" banner) in the user's
151+
// default browser instead of a cramped in-app Electron window.
152+
authWindow.webContents.setWindowOpenHandler(({ url }) => {
153+
shell.openExternal(url);
154+
return { action: 'deny' };
155+
});
156+
143157
// Load your custom loading page first
144158
authWindow.loadURL(`file://${__dirname}/auth-loading.html`);
145159

0 commit comments

Comments
 (0)