fix: prevent zoom reset during in-page navigation (#12257)

Fixes an Electron bug where zoom factor resets during route changes by listening to the 'did-navigate-in-page' event and reapplying the configured zoom factor.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
beyondkmp 2026-01-03 22:07:53 +08:00 committed by GitHub
parent 56cf347909
commit e3d1996254
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -1061,12 +1061,18 @@ export async function registerIpc(mainWindow: BrowserWindow, app: Electron.App)
} catch (error) {
const pluginError = extractPluginError(error)
if (pluginError) {
logger.error('Failed to list installed plugins', { agentId, error: pluginError })
logger.error('Failed to list installed plugins', {
agentId,
error: pluginError
})
return { success: false, error: pluginError }
}
const err = normalizeError(error)
logger.error('Failed to list installed plugins', { agentId, error: err })
logger.error('Failed to list installed plugins', {
agentId,
error: err
})
return {
success: false,
error: {

View File

@ -255,6 +255,12 @@ export class WindowService {
}
private setupWebContentsHandlers(mainWindow: BrowserWindow) {
// Fix for Electron bug where zoom resets during in-page navigation (route changes)
// This complements the resize-based workaround by catching navigation events
mainWindow.webContents.on('did-navigate-in-page', () => {
mainWindow.webContents.setZoomFactor(configManager.getZoomFactor())
})
mainWindow.webContents.on('will-navigate', (event, url) => {
if (url.includes('localhost:517')) {
return
@ -516,7 +522,9 @@ export class WindowService {
miniWindowState.manage(this.miniWindow)
//miniWindow should show in current desktop
this.miniWindow?.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })
this.miniWindow?.setVisibleOnAllWorkspaces(true, {
visibleOnFullScreen: true
})
//make miniWindow always on top of fullscreen apps with level set
//[mac] level higher than 'floating' will cover the pinyin input method
this.miniWindow.setAlwaysOnTop(true, 'floating')