Skip to content

fix(desktop): make Cmd/Ctrl +/-/0 zoom the app window on every platform - #5737

Merged
lidge-jun merged 1 commit into
devfrom
codex/desktop-zoom-hotkeys
Sep 24, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/desktop-zoom-hotkeys

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

The desktop window ignored the zoom shortcuts on every platform: Cmd +/-/0 on macOS and Ctrl +/-/0 on Windows and Linux did nothing. Tauri leaves zoom hotkeys off by default, so WebView2's zoom control was disabled on Windows, and macOS and Linux had no handler.

  • The main window now sets zoom_hotkeys_enabled(true). WebView2 zooms natively (keys and Ctrl+wheel). On macOS and Linux, Tauri injects its keydown polyfill (Cmd on macOS, Ctrl elsewhere, 20% steps, 0 resets), which calls set_webview_zoom.
  • The dashboard runs on the loopback proxy (http://127.0.0.1:<port>/#/usage), which Tauri treats as a remote origin, so the polyfill's call would be refused without a grant. The new capabilities/dashboard-zoom.json grants only core:webview:allow-set-webview-zoom, only to the main window, and only for http://127.0.0.1:*. default.json still has no remote entry, so the dashboard can reach no other command.
  • structure/desktop-shell.md now documents this as the one exception to "the loopback dashboard reaches no command."

Verification

  • cargo fmt --check, cargo clippy --all-targets -D warnings, and cargo test for desktop/src-tauri on macOS: 128 passed. tauri-build accepted the new capability, which it validates at compile time.
  • New test window::tests::the_dashboard_reaches_only_the_zoom_command fixes the capability's window, origin, and permission. It also parses the origin with Tauri's own RemoteUrlPattern and checks that it matches the real dashboard URL while rejecting localhost, https, 127.0.0.2, and unrelated hosts.
  • bun run structure:check and bun run privacy:scan pass.
  • Not verified: the keys in a running packaged app on each OS. A second local desktop instance would collide with the installed app's single-instance lock. The Linux and Windows desktop CI jobs cover build and tests only.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. The only new IPC reach is the zoom setter for the main window on the loopback origin, and the main window's navigation handler already limits it to the resolved proxy endpoint.

Summary by CodeRabbit

  • New Features
    • Added keyboard zoom controls to the desktop dashboard, including shortcuts to zoom in, zoom out, and reset zoom.
  • Documentation
    • Updated the desktop shell documentation to describe the dashboard’s zoom controls and their limited access scope.

The desktop window never enabled page zoom. Tauri leaves zoom hotkeys off by
default, so WebView2 on Windows had its zoom control disabled and macOS/Linux
had no handler at all.

The main window now enables Tauri's zoom hotkeys. WebView2 zooms natively; on
macOS and Linux Tauri injects a keydown polyfill that calls set_webview_zoom.
The dashboard is served from the loopback proxy, a remote origin to Tauri, so a
new capability grants that one command to the main window for
http://127.0.0.1:* only. A test pins the capability's window, origin and
permission, and checks the pattern against the real dashboard URL.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 24, 2026 07:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T07:06:51.901475Z 9471fbd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 24, 2026
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d38442f9-a638-4434-a751-9bd7ac3a0e54

📥 Commits

Reviewing files that changed from the base of the PR and between be0b529 and 9471fbd.

📒 Files selected for processing (4)
  • desktop/src-tauri/capabilities/dashboard-zoom.json
  • desktop/src-tauri/src/lib.rs
  • desktop/src-tauri/src/window.rs
  • structure/desktop-shell.md
 _______________________________________________
< Show me the code! And I'll show you the bugs. >
 -----------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer-directed squash merge into dev before CI finished, at head 9471fbd29b. At merge time, 18 of 32 checks had passed with none failing; the four test shards, windows-schtasks, storage policy, and the desktop jobs were still running. Local cargo fmt/clippy/test for desktop/src-tauri, structure:check, and privacy:scan passed.

@lidge-jun
lidge-jun merged commit 742ee16 into dev Sep 24, 2026
34 of 35 checks passed
@lidge-jun
lidge-jun deleted the codex/desktop-zoom-hotkeys branch September 24, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant