Skip to content

[V3] Add getAccentColor method #4330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v3-alpha
Choose a base branch
from

Conversation

Etesam913
Copy link

@Etesam913 Etesam913 commented May 31, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #4329

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

etesam@etesams-MacBook-Air ~/C/w/wails (getAccentColor)> wails3 doctor
 Wails (v3.0.0-dev)  Wails Doctor 
                                                                                                                                    
# System 

┌──────────────────────────────────────────────────┐
| Name          | MacOS                            |
| Version       | 15.5                             |
| ID            | 24F74                            |
| Branding      | Sequoia                          |
| Platform      | darwin                           |
| Architecture  | arm64                            |
| Apple Silicon | true                             |
| CPU           | Apple M2                         |
| CPU 1         | Apple M2                         |
| CPU 2         | Apple M2                         |
| GPU           | 10 cores, Metal Support: Metal 3 |
| Memory        | 24 GB                            |
└──────────────────────────────────────────────────┘

# Build Environment 

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.24.3                                 |
| Revision     | 83005be066de63f70141cdc7443f7885c34bb300 |
| Modified     | false                                    |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOARCH       | arm64                                    |
| GOARM64      | v8.0                                     |
| GOOS         | darwin                                   |
| vcs          | git                                      |
| vcs.modified | false                                    |
| vcs.revision | 83005be066de63f70141cdc7443f7885c34bb300 |
| vcs.time     | 2025-05-26T11:03:37Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies 

┌────────────────────────────────────────────────────────────────────────┐
| Xcode cli tools | 2409                                                 |
| npm             | 10.9.2                                               |
| *NSIS           | Not Installed. Install with `brew install makensis`. |
|                                                                        |
└─────────────────────── * - Optional Dependency ────────────────────────┘

# Checking for issues 

 SUCCESS  No issues found

# Diagnosis 

 SUCCESS  Your system is ready for Wails development!

Need documentation? Run: wails3 docs
 ♥   If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Introduced the ability to retrieve the system accent color as an RGB string on macOS.
    • Provided default accent color values for Linux and Windows platforms to ensure consistent appearance across systems.

Copy link
Contributor

coderabbitai bot commented May 31, 2025

"""

Walkthrough

A new feature was introduced to retrieve the system accent color on macOS. This includes adding a GetAccentColor() method to the application API, platform-specific implementation for macOS using Objective-C, and documentation of the change in the changelog. No other logic or control flow was modified.

Changes

File(s) Change Summary
docs/src/content/docs/changelog.mdx Added changelog entry for new app.GetAccentColor() feature in v3.0.0-alpha.9.
v3/pkg/application/application.go Added GetAccentColor() to App struct; updated interface; default/fallback value logic added.
v3/pkg/application/application_darwin.go Implemented macOS-specific accent color retrieval in C/Objective-C; added getAccentColor() method.
v3/pkg/application/application_linux.go, application_windows.go Added getAccentColor() methods returning default color strings for Linux and Windows platforms.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant platformApp (macosApp)
    participant macOS System

    App->>platformApp (macosApp): GetAccentColor()
    alt platformApp is nil
        App->>App: return "rgb(0,122,255)"
    else platformApp is macosApp
        platformApp (macosApp)->>macOS System: getAccentColor()
        macOS System-->>platformApp (macosApp): "rgb(r,g,b)"
        platformApp (macosApp)-->>App: "rgb(r,g,b)"
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add a getAccentColor method to retrieve the macOS system accent color (#4329)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

A hop and a skip, a color so bright,
Now apps can match your Mac just right!
With GetAccentColor() in the code,
The user's style is now bestowed.
Rabbits cheer, the theme's in sync—
Blue, green, or pink, what do you think?
🐇🌈
"""


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7da370 and be184c1.

📒 Files selected for processing (2)
  • v3/pkg/application/application_linux.go (1 hunks)
  • v3/pkg/application/application_windows.go (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • v3/pkg/application/application_linux.go
  • v3/pkg/application/application_windows.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

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.

@github-actions github-actions bot added Documentation Improvements or additions to documentation MacOS v3-alpha labels May 31, 2025
@Etesam913
Copy link
Author

I'm not sure where any tests for this feature would be added in the project?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/src/content/docs/changelog.mdx (1)

164-164: Fix the macOS branding.

Apple's operating system should be written as "macOS" not "MacOS".

-- `app.GetAccentColor()` to get the accent color of a user's system. Works on MacOS. by [@etesam913](https://github.com/etesam913)
+- `app.GetAccentColor()` to get the accent color of a user's system. Works on macOS. by [@etesam913](https://github.com/etesam913)
🧰 Tools
🪛 LanguageTool

[grammar] ~164-~164: The operating system from Apple is written “macOS”.
Context: ...cent color of a user's system. Works on MacOS. by [@Etesam913](https://github.com/ete...

(MAC_OS)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae4ed4f and b7da370.

📒 Files selected for processing (3)
  • docs/src/content/docs/changelog.mdx (1 hunks)
  • v3/pkg/application/application.go (3 hunks)
  • v3/pkg/application/application_darwin.go (2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/src/content/docs/changelog.mdx

[grammar] ~164-~164: The operating system from Apple is written “macOS”.
Context: ...cent color of a user's system. Works on MacOS. by [@Etesam913](https://github.com/ete...

(MAC_OS)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
  • GitHub Check: semgrep/ci
🔇 Additional comments (4)
v3/pkg/application/application_darwin.go (2)

76-104: Excellent implementation with robust error handling.

The C implementation demonstrates several best practices:

  • Proper memory management with @autoreleasepool
  • Version-aware API usage with fallback for older macOS versions
  • Graceful handling of color space conversion failures
  • Consistent RGB formatting for cross-platform compatibility

219-223: Proper CGO memory management.

The Go wrapper correctly handles memory management by using defer C.free() to ensure the allocated C string is properly freed.

v3/pkg/application/application.go (2)

208-208: Interface extension follows established patterns.

The addition of getAccentColor() string to the platformApp interface is consistent with other platform-specific methods.


1051-1056: Well-designed public API with sensible defaults.

The method correctly handles the nil platform implementation case and provides a reasonable default blue color that matches Apple's system blue. The implementation follows the same pattern as other platform-dependent methods.

@leaanthony
Copy link
Member

leaanthony commented Jun 1, 2025

Thanks for opening this. Do you think it might be better to use something like app.Mac.GetAccentColour?
Also https://github.com/wailsapp/wails/actions/runs/15365920957/job/43238816949?pr=4330 shows that as there is no implementation (even a nop one) on Linux, the build fails. Same will be true for Windows.

@leaanthony
Copy link
Member

@Etesam913 thoughts?

The PR added getAccentColor() method to the interface and implemented it for macOS,
but missed the Linux and Windows implementations, causing build failures.

- Added getAccentColor() method to linuxApp that returns default blue color
- Added getAccentColor() method to windowsApp that returns default blue color
- Both implementations return "rgb(0,122,255)" as fallback since these platforms
  don't have unified system accent color APIs readily available

Fixes build failures on Linux and Windows CI runners.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 12, 2025
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Linux MacOS size:M This PR changes 30-99 lines, ignoring generated files. v3-alpha Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants