Skip to content

Refactor theme resource dictionary retrieval logic#4331

Open
Jack251970 wants to merge 1 commit intodevfrom
UpdateResourceDictionary
Open

Refactor theme resource dictionary retrieval logic#4331
Jack251970 wants to merge 1 commit intodevfrom
UpdateResourceDictionary

Conversation

@Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Mar 9, 2026

CHANGES

No need to update the resource dictionary in this place. Since it will be updated later in this function.

Separated from #4302.

TEST

  • Changing themes still works.

Summary by cubic

Refactors theme resource dictionary handling in Theme.ChangeTheme to use a single GetThemeResourceDictionary call. Simplifies blur enablement logic without changing user-visible behavior.

  • Summary of changes
    • Changed: Blur enablement now uses the dictionary from GetThemeResourceDictionary(theme). Dictionary retrieval happens once and is used directly for IsThemeBlurEnabled.
    • Added: Use of GetThemeResourceDictionary(theme) to centralize getting the font-applied theme resources used during theme change.
    • Removed: Explicit calls to GetResourceDictionary(theme) and UpdateResourceDictionary(...).
    • Memory: No impact. Only a local variable is introduced; no long-lived allocations.
    • Security: No new risks. No I/O, deserialization, or permission changes.
    • Tests: No new unit tests. Manually verified that changing themes still works.

Written for commit c0134d5. Summary will update on new commits.

Replaced separate calls to GetResourceDictionary and UpdateResourceDictionary with a single GetThemeResourceDictionary call in Theme.cs. Updated blur enablement check to use the new dictionary variable, simplifying theme resource management.
Copilot AI review requested due to automatic review settings March 9, 2026 10:36
@prlabeler prlabeler bot added Code Refactor enhancement New feature or request labels Mar 9, 2026
@github-actions github-actions bot added this to the 2.2.0 milestone Mar 9, 2026
@Jack251970 Jack251970 added the Small PR Items that are short and don't have much impact. Quick reviews are good. label Mar 9, 2026
@gitstream-cm
Copy link

gitstream-cm bot commented Mar 9, 2026

🥷 Code experts: no user but you matched threshold 10

Jack251970 has most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Resource/Theme.cs

Activity based on git-commit:

Jack251970
MAR 64 additions & 79 deletions
FEB
JAN
DEC
NOV
OCT 12 additions & 2 deletions

Knowledge based on git-blame:
Jack251970: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link

gitstream-cm bot commented Mar 9, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@coderabbitai coderabbitai bot removed the enhancement New feature or request label Mar 9, 2026
@Jack251970 Jack251970 enabled auto-merge March 9, 2026 10:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors how Theme.ChangeTheme retrieves the theme ResourceDictionary (separating “raw theme dictionary” retrieval from the dictionary used for applying runtime font/window-size settings), and uses the refactored retrieval for blur capability detection.

Changes:

  • Removed direct theme resource application (UpdateResourceDictionary) from ChangeTheme.
  • Switched blur detection in ChangeTheme to use GetThemeResourceDictionary(theme).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@prlabeler prlabeler bot added the enhancement New feature or request label Mar 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

The ChangeTheme method in Theme.cs is refactored to use GetThemeResourceDictionary() and IsThemeBlurEnabled() instead of GetResourceDictionary() and UpdateResourceDictionary() for retrieving the theme dictionary and checking blur settings. The rest of the method logic remains unchanged.

Changes

Cohort / File(s) Summary
Theme Resource Dictionary Retrieval
Flow.Launcher.Core/Resource/Theme.cs
Refactored ChangeTheme method to use GetThemeResourceDictionary(theme) for dictionary retrieval and IsThemeBlurEnabled(dict) for blur detection instead of previous method calls; remaining theme application logic unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • Improve code quality #4312: Mirrors the switch to using GetThemeResourceDictionary() and IsThemeBlurEnabled() for blur detection in the ChangeTheme method refactor.
  • Fix font select function #3377: Also modifies Theme.cs's ChangeTheme method and theme resource retrieval logic with blur-enabled check updates.

Suggested reviewers

  • taooceros
  • jjw24
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: refactoring how theme resource dictionaries are retrieved in the ChangeTheme method.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the refactoring of theme resource dictionary retrieval in Theme.cs and why the update was removed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch UpdateResourceDictionary

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Flow.Launcher.Core/Resource/Theme.cs`:
- Around line 430-434: ChangeTheme currently only sets BlurEnabled and defers
swapping Application.Current.Resources.MergedDictionaries to
RefreshFrameAsync/SetBlurForWindow, breaking the synchronous contract; update
ChangeTheme to synchronously apply the new resource dictionary returned by
GetThemeResourceDictionary(theme) into
Application.Current.Resources.MergedDictionaries (perform the swap before
calling RefreshFrameAsync), then compute BlurEnabled and finally fire
RefreshFrameAsync/SetBlurForWindow asynchronously if needed so callers see the
new theme immediately; reference GetThemeResourceDictionary, BlurEnabled,
RefreshFrameAsync, SetBlurForWindow, ChangeTheme, and
Application.Current.Resources.MergedDictionaries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fa6601a-6cb8-4a00-ad0d-46dacceacdc3

📥 Commits

Reviewing files that changed from the base of the PR and between 916b4ff and c0134d5.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Resource/Theme.cs

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Flow.Launcher.Core/Resource/Theme.cs">

<violation number="1" location="Flow.Launcher.Core/Resource/Theme.cs:430">
P2: `ChangeTheme` now returns success before the theme resource is actually applied, so async apply failures can be missed and leave state inconsistent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Jack251970 Jack251970 removed the enhancement New feature or request label Mar 9, 2026
@Jack251970 Jack251970 mentioned this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Refactor Small PR Items that are short and don't have much impact. Quick reviews are good.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants