Skip to content

broadcast zoom changed notifications#2989

Merged
sawka merged 3 commits intomainfrom
sawka/fix-zoom-notifications
Mar 6, 2026
Merged

broadcast zoom changed notifications#2989
sawka merged 3 commits intomainfrom
sawka/fix-zoom-notifications

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 6, 2026

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fdaea056-fc99-4ef7-a2a7-8a822a52d78f

📥 Commits

Reviewing files that changed from the base of the PR and between b99bde9 and f62b47e.

📒 Files selected for processing (1)
  • emain/emain-util.ts

Walkthrough

Adds an exported resetZoomLevel(webContents) and a non-exported broadcastZoomFactorChanged helper in emain-util.ts. Replaces direct zoom-reset logic and per-webContents send("zoom-factor-change", ...) calls in emain-menu.ts and emain-tabview.ts with calls to the new utility functions. Removes zoom-changed forwarding listeners in emain-tabview.ts. No other public API changes reported.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate whether it relates to the changeset. Add a description explaining the purpose of centralizing zoom change broadcasting and how it improves the codebase.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'broadcast zoom changed notifications' directly and specifically describes the main change: centralizing zoom change broadcasting via a new helper function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/fix-zoom-notifications

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 6, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
emain/emain-util.ts 27 Broadcast function only sends IPC, doesn't sync actual zoom factor state on other WebContents
Other Observations (not in diff)
  • The existing CodeRabbit comment on emain/emain-tabview.ts about the "zoom-changed" handler refers to code that is being deleted in this PR (the handler is removed). This issue is resolved by the removal.
  • The broadcast function relies on Chromium's automatic zoom sync across WebContents sharing the same origin/session. The comment acknowledges this is a design decision.
Files Reviewed (3 files)
  • emain/emain-menu.ts - No new issues
  • emain/emain-tabview.ts - Zoom-changed handler removed (issue resolved)
  • emain/emain-util.ts - 1 existing issue (broadcast doesn't call setZoomFactor on other WebContents)

Note: The PR successfully centralizes zoom handling through the new broadcastZoomFactorChanged function and removes the problematic zoom-changed handlers. The remaining warning is that other WebContents receive the IPC notification but their internal getZoomFactor() state remains stale - they only get the notification, not the actual zoom level update via setZoomFactor.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@emain/emain-tabview.ts`:
- Around line 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.

In `@emain/emain-util.ts`:
- Around line 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).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b46512af-794f-4616-88d6-3d340903f70e

📥 Commits

Reviewing files that changed from the base of the PR and between f59fdb5 and aaefd3a.

📒 Files selected for processing (3)
  • emain/emain-menu.ts
  • emain/emain-tabview.ts
  • emain/emain-util.ts

Comment on lines 168 to 170
this.webContents.on("zoom-changed", (_event, _zoomDirection) => {
this.webContents.send("zoom-factor-change", this.webContents.getZoomFactor());
});
Copy link
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.

Comment on lines +15 to +21
function broadcastZoomFactorChanged(newZoomFactor: number): void {
for (const wc of electron.webContents.getAllWebContents()) {
if (wc.isDestroyed()) {
continue;
}
wc.send("zoom-factor-change", newZoomFactor);
}
Copy link
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).

@sawka sawka merged commit 0f60c70 into main Mar 6, 2026
4 of 5 checks passed
@sawka sawka deleted the sawka/fix-zoom-notifications branch March 6, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant