Skip to content

feat(desktop-shell): add native Windows zoom with percentage feedback - #1088

Closed
hhucz wants to merge 8 commits into
BytePioneer-AI:mainfrom
hhucz:feat/windows-shell-zoom-hotkeys
Closed

hhucz wants to merge 8 commits into
BytePioneer-AI:mainfrom
hhucz:feat/windows-shell-zoom-hotkeys

Conversation

@hhucz

@hhucz hhucz commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this implements

The Windows CodexHost shell now provides browser-like global zoom with immediate visual feedback.

  • Standard Ctrl keyboard and mouse-wheel zoom works across the chooser, loading page, and embedded workspace.
  • A lightweight top-center indicator shows the actual percentage whenever WebView2 reports a zoom change.
  • The indicator fades automatically and does not intercept pointer input.
  • Ctrl+0 continues to reset zoom through WebView2.

Implementation

Native zoom uses Tauri’s zoom_hotkeys_enabled, mapped directly to WebView2’s IsZoomControlEnabled. A Windows-only ZoomFactorChanged handler reads the controller’s real ZoomFactor; it does not maintain a second estimated zoom state.

The indicator is a passive shell-layer element. No React components, CSS transforms, custom zoom shortcuts, polling, or persistent settings are involved. macOS remains unchanged.

Validation

  • The original zoom-enabled shell was deployed locally and produced a visible global scale change with responsive layout reflow.
  • The percentage indicator is compiled by CI and requires a final Windows visual smoke test.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能
    • Windows 桌面应用现已支持使用快捷键放大、缩小和重置窗口缩放。
    • 调整缩放时会显示当前缩放百分比,并在短暂显示后淡出。
    • 快捷键设置中新增放大、缩小和重置缩放操作,并提供中文和英文标签。

Windows 桌面端新增缩放快捷命令。主窗口启用缩放快捷键,并在 WebView2 缩放变化时显示百分比提示。提示在 1100 毫秒后淡出。

Changes: Windows 缩放处理

Layer / File(s) Summary
添加 Windows 缩放快捷命令
apps/web-ui/packages/client/ui-shortcuts/src/client/fixed.ts, apps/web-ui/packages/client/ui-shortcuts/src/client/index.ts, apps/web-ui/packages/client/ui-shortcuts/src/client/locales.ts, apps/web-ui/packages/client/ui-shortcuts/src/client/Reference.tsx
固定快捷命令仅在 Windows 桌面端加入放大、缩小和重置缩放命令,分别绑定 Equal、Minus 和 Digit0 键码及 primary 修饰键。中英文目录新增对应标签,核心操作顺序加入这些命令。
定义页面缩放提示
apps/desktop-shell/src-tauri/src/navigation.rs
Windows 页面初始化脚本新增缩放提示函数。页面存在 body 时,函数显示传入的百分比,并在 1100 毫秒后淡出。
配置并安装缩放处理
apps/desktop-shell/src-tauri/Cargo.toml, apps/desktop-shell/src-tauri/src/lib.rs, apps/desktop-shell/src-tauri/src/zoom.rs
新增 Windows 专属 webview2-com 依赖。主窗口启用缩放快捷键,并在窗口创建后安装缩放变化监听器。监听器将缩放因子换算为整数百分比,再调用页面提示函数。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant WebView2
  participant 缩放监听器
  participant 页面脚本
  participant 页面DOM
  WebView2->>缩放监听器: 发送缩放变化事件
  缩放监听器->>页面脚本: 传入换算后的百分比
  页面脚本->>页面DOM: 更新提示并启动淡出计时器
Loading

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · previous review 04f2c · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“feat(desktop-shell): add native Windows zoom with percentage feedback”描述了主要变更:为 Windows 外壳新增原生缩放,并显示百分比提示。变更集中包含 zoom.rs 的 WebView2 缩放监听、navigation.rs 中的百分比提示函数以及快捷键命令,与标题一致。
Description check Passed 描述说明了 Windows 外壳中的浏览器式缩放、百分比提示、基于 WebView2 的 Ctrl+0 重置,以及通过 zoom_hotkeys_enabled 和 ZoomFactorChanged 的实现方式。这些内容与变更集中的 zoom.rs、navigation.rs、Cargo.toml 和快捷键文件相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Deployed the CI-built shell locally and verified native zoom with real WebView2 input. Ctrl+zoom shortcuts produced a visible global scale change and responsive layout reflow across the embedded workspace; Ctrl+0 reset was then issued. No CSS or React changes were needed.

@hhucz hhucz changed the title feat(desktop-shell): enable native Windows zoom shortcuts feat(desktop-shell): add native Windows zoom with percentage feedback Nov 23, 2026
@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The Windows desktop shortcut reference now also lists Zoom in, Zoom out, and Reset zoom under Application. These read-only entries reserve their physical combinations against editable shortcuts and are not shown for Web or macOS runtimes. Ctrl+wheel remains available through WebView2 as an additional zoom gesture.

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The percentage feedback build is now verified locally. A native zoom action displayed a top-center 110% indicator with visible opacity and role="status"; the value came from WebView2 rather than an estimated counter. Ctrl+0 reset was issued after the check.

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Deployed the updated Web UI locally and opened the native shortcut reference with Ctrl+/. The page contains Zoom in, Zoom out, and Reset zoom in Chinese as expected. The saved both launch preference was left unchanged during verification.

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Corrected the native-shell visibility check and redeployed the Web UI. Verification now inspects only the shortcut dialog: Zoom in, Zoom out, and Reset zoom appear immediately after Open keyboard shortcuts. Searching 界面 returns all three rows and does not show the empty state. Ordinary browser Web and official Codex Desktop remain unchanged.

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Refined the shortcut dialog after local feedback: zoom rows now follow Open settings rather than appearing at the top. DOM verification confirms the exact keycap sequences Ctrl + +, Ctrl + −, and Ctrl + 0, matching the read-only shortcut presentation.

@hhucz

hhucz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Persistent zoom is now verified with a full native-client restart. A zoom action displayed 110% and wrote shell-zoom-v1.json with factor 1.1; after restarting, the restored page had the same enlarged rendering. The test state was then reset and saved as 100%.

@iruriQ

iruriQ commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

感谢贡献!我们计划对自有桌面壳的原生缩放做 macOS 与 Windows 双端统一设计与实现(统一快捷键体系、顶部气泡避让与设置项),避免先在单平台分叉,因此这个仅面向 Windows 的 PR 先行关闭。非常感谢你的反馈和思路!

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.

2 participants