Skip to content

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

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

Refactor window handling, improve theme support, and update dependencies#1807
ItsEeleeya wants to merge 126 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

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

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
Comment thread apps/desktop/src-tauri/src/platform/macos/menu.rs Outdated
Comment thread apps/desktop/src-tauri/src/platform/macos/mod.rs Outdated
Comment thread apps/desktop/src-tauri/src/window_position_persistence.rs
Comment thread apps/desktop/src/app.tsx
Comment thread apps/desktop/src/utils/RevealWindow.tsx
Comment thread apps/desktop/src/utils/RevealWindow.tsx Outdated
Comment thread apps/desktop/src-tauri/src/recording.rs Outdated
ItsEeleeya and others added 6 commits July 3, 2026 12:16
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
Comment thread apps/desktop/src-tauri/src/platform/macos/menu.rs Outdated
Comment thread apps/desktop/src-tauri/src/windows.rs Outdated
Comment thread apps/desktop/src/routes/(window-chrome)/settings/general.tsx Outdated
Comment thread apps/desktop/src-tauri/src/recording.rs Outdated
);
}
}
} No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: this file is missing a trailing newline (\\ No newline at end of file), which tends to cause noisy diffs.

Suggested change
}
}

"core:webview:default",
"core:webview:allow-create-webview-window",
"core:app:allow-version",
"core:app:allow-set-app-theme",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This adds core:app:allow-set-app-theme to the default capability. If this is only needed for specific windows/flows, consider scoping it to a narrower capability to keep the allowlist tight.

Comment thread apps/desktop/src-tauri/src/windows.rs Outdated
ItsEeleeya and others added 2 commits July 3, 2026 13:37
Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
@richiemcilroy

Copy link
Copy Markdown
Member

hey @greptileai please review the PR

@richiemcilroy

Copy link
Copy Markdown
Member

hey @greptileai please re-review the pr


#[cfg(target_os = "macos")]
const DEFAULT_TRAFFIC_LIGHTS_INSET: LogicalPosition<f64> = LogicalPosition::new(12.0, 12.0);
const DEFAULT_TRAFFIC_LIGHTS_INSET: LogicalPosition<f64> = LogicalPosition::new(12.0, 20.0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small maintainability nit: these inset values are pretty tuned; a short note helps prevent someone from “fixing” them later without realizing this is for macOS 26 titlebar spacing.

Suggested change
const DEFAULT_TRAFFIC_LIGHTS_INSET: LogicalPosition<f64> = LogicalPosition::new(12.0, 20.0);
const DEFAULT_TRAFFIC_LIGHTS_INSET: LogicalPosition<f64> = LogicalPosition::new(12.0, 20.0); // tuned for macOS 26 titlebar spacing

showMinimize={false}
showZoom={false}
/>
{isMacOS && !isSettings() && <div class="h-full w-[70px]" />}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This spacer is purely layout; adding aria-hidden avoids it ever being treated as meaningful structure (and makes the intent a bit clearer).

Suggested change
{isMacOS && !isSettings() && <div class="h-full w-[70px]" />}
{isMacOS && !isSettings() && <div class="h-full w-[70px]" aria-hidden="true" />}

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