Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions emain/emain-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { focusedBuilderWindow, getBuilderWindowById } from "./emain-builder";
import { openBuilderWindow } from "./emain-ipc";
import { isDev, unamePlatform } from "./emain-platform";
import { clearTabCache } from "./emain-tabview";
import { decreaseZoomLevel, increaseZoomLevel } from "./emain-util";
import { decreaseZoomLevel, increaseZoomLevel, resetZoomLevel } from "./emain-util";
import {
createNewWaveWindow,
createWorkspace,
Expand Down Expand Up @@ -238,8 +238,7 @@ function makeViewMenu(
click: (_, window) => {
const wc = getWindowWebContents(window) ?? webContents;
if (wc) {
wc.setZoomFactor(1);
wc.send("zoom-factor-change", 1);
resetZoomLevel(wc);
}
},
},
Expand Down
9 changes: 3 additions & 6 deletions emain/emain-tabview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
handleCtrlShiftFocus,
handleCtrlShiftState,
increaseZoomLevel,
resetZoomLevel,
shFrameNavHandler,
shNavHandler,
} from "./emain-util";
Expand Down Expand Up @@ -48,8 +49,7 @@ function handleWindowsMenuAccelerators(
}

if (checkKeyPressed(waveEvent, "Ctrl:0")) {
tabView.webContents.setZoomFactor(1);
tabView.webContents.send("zoom-factor-change", 1);
resetZoomLevel(tabView.webContents);
return true;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ export class WaveTabView extends WebContentsView {
removeWaveTabView(this.waveTabId);
this.isDestroyed = true;
});
this.webContents.on("zoom-changed", (_event, zoomDirection) => {
this.webContents.on("zoom-changed", (_event, _zoomDirection) => {
this.webContents.send("zoom-factor-change", this.webContents.getZoomFactor());
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

zoom-changed still bypasses the new broadcast path.

This handler only sends "zoom-factor-change" back to this.webContents, so any zoom change that comes through Electron's native zoom-changed flow remains local even after this refactor. If zoom notifications are supposed to be app-wide now, this should route through the same shared zoom sync/broadcast path instead of doing a per-tab send.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@emain/emain-tabview.ts` around lines 168 - 170, The "zoom-changed" handler
currently sends "zoom-factor-change" only to this.webContents, bypassing the new
app-wide broadcast; replace the local send in the
this.webContents.on("zoom-changed", ...) handler with a call into the shared
zoom sync/broadcast path (i.e., invoke the central zoom broadcast/sync function
used elsewhere in the refactor rather than
this.webContents.send("zoom-factor-change", ...)) and pass the current zoom
factor from this.webContents.getZoomFactor() so all tabs receive the update.

this.setBackgroundColor(computeBgColor(fullConfig));
Expand Down Expand Up @@ -339,9 +339,6 @@ export async function getOrCreateWebViewForTab(waveWindowId: string, tabId: stri
}
}
});
tabView.webContents.on("zoom-changed", (e) => {
tabView.webContents.send("zoom-changed");
});
tabView.webContents.setWindowOpenHandler(({ url, frameName }) => {
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file://")) {
console.log("openExternal fallback", url);
Expand Down
18 changes: 16 additions & 2 deletions emain/emain-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,30 @@ const MinZoomLevel = 0.4;
const MaxZoomLevel = 2.6;
const ZoomDelta = 0.2;

function broadcastZoomFactorChanged(newZoomFactor: number): void {
for (const wc of electron.webContents.getAllWebContents()) {
if (wc.isDestroyed()) {
continue;
}
wc.send("zoom-factor-change", newZoomFactor);
}
Comment on lines +21 to +27
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Broadcasting only the IPC leaves other WebContents on a stale zoom factor.

Right now only the initiating webContents gets setZoomFactor(...); every other renderer just receives "zoom-factor-change". That makes the CSS update propagate, but getZoomFactor() in those other windows/tabs still returns the old value, so newly initialized views and the next +/- step start from the wrong baseline. This helper needs to synchronize the actual Electron zoom state for each app-owned WebContents, or the app needs a single shared zoom source that new tabs hydrate from.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@emain/emain-util.ts` around lines 15 - 21, broadcastZoomFactorChanged
currently only sends an IPC message ("zoom-factor-change") which leaves other
WebContents' internal zoom state stale; update the function
(broadcastZoomFactorChanged) to also call wc.setZoomFactor(newZoomFactor) for
each non-destroyed, app-owned electron.webContents (in addition to wc.send) so
getZoomFactor() reflects the new value, or alternatively implement/consume a
single shared zoom source that new WebContents hydrate from; ensure you only
call setZoomFactor on appropriate WebContents (skip destroyed or external/guest
contents).

}

export function increaseZoomLevel(webContents: electron.WebContents): void {
const newZoom = Math.min(MaxZoomLevel, webContents.getZoomFactor() + ZoomDelta);
webContents.setZoomFactor(newZoom);
webContents.send("zoom-factor-change", newZoom);
broadcastZoomFactorChanged(newZoom);
}

export function decreaseZoomLevel(webContents: electron.WebContents): void {
const newZoom = Math.max(MinZoomLevel, webContents.getZoomFactor() - ZoomDelta);
webContents.setZoomFactor(newZoom);
webContents.send("zoom-factor-change", newZoom);
broadcastZoomFactorChanged(newZoom);
}

export function resetZoomLevel(webContents: electron.WebContents): void {
webContents.setZoomFactor(1);
broadcastZoomFactorChanged(1);
}

export function getElectronExecPath(): string {
Expand Down
Loading