Skip to content

Refactor window handling, improve theme support, and update dependencies#1807

Open
ItsEeleeya wants to merge 148 commits into
CapSoftware:mainfrom
ItsEeleeya:next-base-improvements
Open

Refactor window handling, improve theme support, and update dependencies#1807
ItsEeleeya wants to merge 148 commits into
CapSoftware:mainfrom
ItsEeleeya:next-base-improvements

Conversation

@ItsEeleeya

@ItsEeleeya ItsEeleeya commented May 12, 2026

Copy link
Copy Markdown
Contributor

Refactor window handling, improve theme support, and modernize native integration

Overview

This PR refactors a few things with small improvements as a base for upcoming PRs. The changes modernize how windows are revealed, streamline macOS integration with native AppKit APIs, and better theme handling.

Key Changes

Window Management Refactoring

  • Re-implemented auto-show window logic: Windows are now only shown when fully ready, completely eliminating white flashing (except during dev when Vinxi may interfere)
    • AutoRevealWindowOnReady: Automatically shows windows once content is loaded
    • RevealWindowWithSuspense: Defers visibility for windows like Settings until routing and child mounting completes
  • Renamed ShowCapWindowCapWindow throughout the codebase
  • Main window changes:
    • Removed fake traffic lights (Tauri now handles native positioning)
    • Removed custom AppDelegate as Tauri now supports custom traffic lights inset
  • Simplified drag region handling with new data-tauri-drag-region="deep" attribute (eliminates scattered manual markers)
  • Restored proper native menu behavior: onMouseDown={showCropOptionsMenu} in Editor crop section with onClick as keyboard/touch fallback

Theme/Appearance Improvements

  • Renamed AppThemeAppearance (with serde fallback for backward compatibility)
  • Fixed system theme toggle: Changing theme back to "system" now properly takes effect without requiring a reload
  • Removed window_transparency from general settings (not visible in UI; will return with full support in future)

Code Organization

  • Extracted display utilities to new src-tauri/src/display_utils.rs out of windows.rs
    • Monitor and display helper logic consolidated
    • MonitorExt and CursorMonitorInfo types organized
  • Cleaned up panel_manager.rs: Now macOS-only with streamlined logic
  • Moved AppKit menu configuration to new menu.rs module
  • Added help menu items with native AppKit integration

Native Platform Integration

  • macOS: Increased usage of objc2 ecosystem crates (app-kit, foundation, permissions)
    • Bumped objc2-app-kit version
  • Linux: Now using Windows 11-style caption controls
  • Added new WebviewWindowExt trait with with_nswindow_on_main() utility for direct AppKit window access
  • Settings window: Now persists position across restarts (removed from tauri_plugin_window_state denylist)

UI/UX Enhancements

  • Editor window header height now matches windows with toolbars on macOS 26
  • Fixed invisible target-select-overlay appearing over Settings/Upgrade windows when they close (no longer auto-opens)
  • Fixed Cropper bounds display (removed incorrect scale-50 class)
  • Small visual refinements in debug window
  • (macOS) With the introduction of proper menu items, Settings can now be opened with the +, shortcut

Dependencies & Plugins

  • Updated Tauri and associated plugins to latest versions
  • Added tauri-plugin-prevent-default: Enables default context menu only during development

Technical Notes

  • All changes maintain backward compatibility where applicable
  • Window reveal logic fully tested with zero white-flash regressions
  • AppKit integration now uses modern objc2 crates instead of legacy objc/cocoa
  • Future improvements planned for macOS focus handling via custom NSTrackingArea in dedicated Tauri plugin
  • This refactor lays groundwork for upcoming window management and platform-specific enhancements

Suggested changelog entires:

  • (macOS) App's menu has been overhauled with the correct menu items and help menu.
    • Some menu items may show an icon depending on system version (macOS 15, 26, 27 beta)
  • (macOS) Settings can now be opened with the +, shortcut.
  • (macOS) Once again using the native traffic lights
  • Fixed an visual issue within the full screen Cropper experience where the bounds tooltip appeared at the incorrect scale.
  • (Linux) Now using the same style of caption buttons as Windows.
  • Fixed an issue where changing the appearance back to system didn't always effect the window's content view.
  • The default context menu has been disabled. Default WebView shortcuts should now also be disabled.

Greptile Summary

This PR refactors desktop window handling and native integration. The main changes are:

  • New hidden-window reveal helpers for routed desktop windows.
  • Renamed ShowCapWindow to CapWindow across Rust and generated bindings.
  • Theme settings moved from theme to appearance with persisted-store compatibility.
  • macOS menu and AppKit helpers moved into platform modules.
  • Display utilities and panel/window handling were reorganized.
  • Tauri plugins and Rust/JS dependencies were updated.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/desktop/src/utils/RevealWindow.tsx Adds shared helpers for revealing windows after routing or suspense readiness.
apps/desktop/src/app.tsx Wires the reveal helper into the desktop router and updates app-level theme behavior.
apps/desktop/src-tauri/src/general_settings.rs Renames the stored theme setting to appearance while accepting the old persisted key.
apps/desktop/src-tauri/src/windows.rs Refactors Cap window creation, reuse, sizing, visibility, and macOS window configuration.
apps/desktop/src-tauri/src/platform/macos/menu.rs Adds native macOS menu setup and termination handling.
apps/desktop/src-tauri/src/platform/macos/mod.rs Adds AppKit window helpers for main-thread native window access.
apps/desktop/src-tauri/src/lib.rs Registers renamed commands, platform menu hooks, plugins, and startup window behavior.

Reviews (3): Last reviewed commit: "Merge branch 'main' into pr/1807" | Re-trigger Greptile

Context used:

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

ItsEeleeya added 30 commits May 7, 2026 15:37
The header height now matches that of windows with Toolbars on macOS 26
The header height now matches that of windows with Toolbars on macOS 26

meta.save_for_project()
.map_err(|e| anyhow!("Failed to save in-progress meta: {:?}", e))
.map_err(|e| anyhow!("Failed to save in-progress meta: {e}"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using {e} here drops potentially-useful debug context; :? tends to be more helpful when chasing rare save failures.

Suggested change
.map_err(|e| anyhow!("Failed to save in-progress meta: {e}"))
.map_err(|e| anyhow!("Failed to save in-progress meta: {e:?}"))

Comment thread apps/desktop/src-tauri/src/windows.rs Outdated
)
}

pub fn appears_transparent(&self) -> bool {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor clarity: this helper is used to decide shadow behavior, and it’s not necessarily a 1:1 mapping with .transparent(true) (e.g. Main). A short doc comment would help prevent future confusion.

Suggested change
pub fn appears_transparent(&self) -> bool {
/// Used to decide whether to disable the native window shadow (not a 1:1 mapping with `.transparent(true)`).
pub fn appears_transparent(&self) -> bool {

Comment thread apps/desktop/src-tauri/src/lib.rs Outdated
self.run_on_main_thread({
let webview = self.clone();
move || {
let Ok(ns_window) = webview.ns_window() else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

with_nswindow_on_main() always returns Ok(()) even when the callback never runs (e.g. ns_window() not ready / no MainThreadMarker). That makes it hard for callers to reason about failure vs success. Might be worth returning a boolean / result back to the caller via a oneshot, or renaming to try_* to make the best-effort semantics explicit.

Comment thread apps/desktop/src-tauri/src/platform/macos/menu.rs Outdated
Comment thread apps/desktop/src-tauri/Cargo.toml Outdated
ItsEeleeya and others added 2 commits July 6, 2026 14:20
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
Comment thread apps/desktop/src-tauri/src/platform/macos/mod.rs
Comment thread apps/desktop/src-tauri/src/platform/macos/menu.rs Outdated
Comment thread apps/desktop/src-tauri/src/platform/macos/mod.rs
Comment thread apps/desktop/src-tauri/src/platform/macos/mod.rs
Comment thread apps/desktop/src/utils/RevealWindow.tsx
Comment thread apps/desktop/src-tauri/src/windows.rs Outdated
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
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