Skip to content

Comments

Fix Issues with Settings on Windows#17

Merged
iamEvanYT merged 3 commits intomainfrom
evan/windows-settings-issues
Mar 30, 2025
Merged

Fix Issues with Settings on Windows#17
iamEvanYT merged 3 commits intomainfrom
evan/windows-settings-issues

Conversation

@iamEvanYT
Copy link
Member

@iamEvanYT iamEvanYT commented Mar 30, 2025

Checklist

  • Remove support for Custom Icon on Windows
  • Fix Window Controls in Settings not showing on Windows
  • Omnibox not unfocusing after hidden on Windows

Summary by CodeRabbit

  • Bug Fixes

    • Improved focus behavior when closing the search box for a smoother transition.
  • New Features

    • Enhanced icon customization so that it’s now supported only on macOS and Linux.
    • Added platform detection in settings to notify users if icon customization isn’t available.
    • Updated the settings window appearance with a platform-specific title bar style for better consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 30, 2025

Walkthrough

This pull request refactors several parts of the code to improve clarity and platform-specific behavior. The omnibox now saves its focus state in a variable before hiding, and icon functionality has been updated to support only specific platforms. A new IPC handler and methods have been introduced to verify icon support, along with UI changes that prevent unnecessary data fetching when unsupported. Additionally, the settings window title bar style is now determined based on the operating system.

Changes

Files Change Summary
electron/browser/omnibox.ts Updated the hide method to capture the focus state using a new variable (omniboxWasFocused) instead of a direct check, and used this variable to conditionally focus the parent window.
electron/modules/icons.ts, electron/preload.ts, vite/.../section.tsx, vite/.../flow.ts Introduced a new constant supportedPlatforms (now excluding "win32") and updated icon management. Added an IPC handler (icon:is-platform-supported) and related asynchronous methods (isPlatformSupportedForIcon) in the preload and FlowSettingsAPI. The settings UI now checks platform support before fetching icons.
electron/settings/main.ts Modified the createSettingsWindow function to set titleBarStyle conditionally: "hiddenInset" for macOS and "hidden" for all other platforms.

Sequence Diagram(s)

sequenceDiagram
    participant Component as UI Component (Section)
    participant Flow as FlowSettingsAPI
    participant Preload as Preload Bridge
    participant Main as Main Process (Icons)

    Component->>Flow: call isPlatformSupportedForIcon()
    Flow->>Preload: invoke settings.isPlatformSupportedForIcon()
    Preload->>Main: ipcRenderer.invoke("icon:is-platform-supported")
    Main-->>Preload: return supported (boolean)
    Preload-->>Flow: return supported (boolean)
    Flow-->>Component: return supported (boolean)
Loading

Possibly related PRs

  • Fix Extensions & Improve Omnibox #13: Modifies the Omnibox class with a focus on logging and control flow improvements in the hide method, which is similar to the changes in this PR.

Suggested labels

bug, enhancement

Poem

I'm a rabbit coding through fields so bright,
Hopping over changes with delight,
I found a focus state to save and share,
And a platform check, handled with care.
With icons and titles now finely aligned,
I celebrate this diff with a joyful bunny mind! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71520bd and ea2cbe7.

📒 Files selected for processing (6)
  • electron/browser/omnibox.ts (1 hunks)
  • electron/modules/icons.ts (3 hunks)
  • electron/preload.ts (1 hunks)
  • electron/settings/main.ts (1 hunks)
  • vite/src/components/settings/sections/icon/section.tsx (3 hunks)
  • vite/src/lib/flow.ts (2 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
electron/browser/omnibox.ts (1)
electron/modules/output.ts (1)
  • debugPrint (15-21)
vite/src/components/settings/sections/icon/section.tsx (1)
vite/src/lib/flow.ts (1)
  • isPlatformSupportedForIcon (187-189)
🔇 Additional comments (12)
electron/settings/main.ts (1)

27-27: Platform-specific title bar style adjustment

This change addresses the issue with window controls in settings not displaying correctly on Windows by using a platform-specific title bar style. On macOS, it uses "hiddenInset" which shows the traffic light controls, while on other platforms (including Windows) it uses "hidden" which allows for a custom window control implementation.

electron/preload.ts (1)

124-127: Added platform support check for icon customization

This addition provides a way to verify if icon customization is supported on the current platform, which aligns with the PR objective to remove Custom Icon support on Windows. The method invokes an IPC call to check platform compatibility before attempting to use icon-related features.

electron/browser/omnibox.ts (1)

158-164: Fixed omnibox focus issue on Windows

The change improves focus handling by storing the omnibox focus state before hiding it, rather than checking it after. This addresses the issue where the omnibox was not properly unfocusing after being hidden on Windows platforms.

The approach of capturing the state in a variable before modifying the component is cleaner and more reliable than checking the state after modifications have begun.

vite/src/components/settings/sections/icon/section.tsx (4)

5-5: Added import for platform support check

Updated imports to include the new isPlatformSupportedForIcon function that will be used to conditionally render icon settings based on platform support.


20-20: Added state variable for platform support tracking

The new state variable isSupported properly tracks whether the current platform supports icon customization features.


26-34: Added platform compatibility check before fetching icons

This implementation efficiently checks if the platform supports icon customization before attempting to fetch icons, which prevents unnecessary API calls on unsupported platforms like Windows.


94-98: Added UI message for unsupported platforms

This change shows a helpful message when icon customization is not supported on the current platform, aligning with the PR objective to remove Custom Icon support on Windows.

electron/modules/icons.ts (3)

10-16: Good implementation of platform support restrictions for icon functionality.

The new supportedPlatforms constant clearly indicates which platforms support custom icon functionality, with helpful comments explaining the implementation approach for each platform. This aligns with the PR objective to remove custom icon support on Windows.


119-119: Windows support properly removed from updateAppIcon function.

The condition has been correctly modified to check only for "linux" platform, removing Windows support as intended.


194-196: Well-implemented IPC handler for platform support check.

This new handler provides a clean way for the frontend to check if the current platform supports custom icons, preventing unnecessary UI elements from being displayed on unsupported platforms like Windows.

vite/src/lib/flow.ts (2)

117-117: Good API interface extension.

Adding this method to the FlowSettingsAPI interface provides a clean way for components to check platform support for icon customization.


187-189: Clean implementation of platform support check function.

This exported function provides a simple interface for components to check if icon customization is supported on the current platform, which aligns well with the PR objective to remove custom icon support on Windows.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@iamEvanYT iamEvanYT marked this pull request as ready for review March 30, 2025 17:59
@iamEvanYT iamEvanYT added the bug Something isn't working label Mar 30, 2025
@iamEvanYT iamEvanYT self-assigned this Mar 30, 2025
@iamEvanYT iamEvanYT merged commit ee228e5 into main Mar 30, 2025
1 check passed
@iamEvanYT iamEvanYT deleted the evan/windows-settings-issues branch March 30, 2025 18:02
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