Skip to content

Fix theme preview using the previous theme's border style - #4666

Merged
jjw24 merged 2 commits into
Flow-Launcher:devfrom
kalelooz:fix/theme-preview-border
Sep 28, 2026
Merged

jjw24 merged 2 commits into
Flow-Launcher:devfrom
kalelooz:fix/theme-preview-border

Conversation

@kalelooz

@kalelooz kalelooz commented Sep 19, 2026 •

Copy link
Copy Markdown

Fixes #4655.

Theme previews could inherit border styling from the previously selected theme because ApplyPreviewBackground read WindowBorderStyle from application resources before the new theme's resources were installed.

Pass the selected theme's border style from ColorizeWindow into the preview helper. This preserves the existing resource-loading order, preview background handling, and blur-specific corner rules.

Adds a WPF regression covering selection order (A → B → A and B after A, C, or B), inherited border properties, light/dark backgrounds, blur overrides, and previous styles containing runtime shadow effects and enlarged margins.

Before / after

Selecting Sublime immediately after Darker. The original preview misses Sublime’s gray outline; the fixed preview uses it. These are matching crops from the original Windows screenshots, enlarged 4× with arrows added.

Before and after: Sublime preview border, original screenshot crops

Validation

  • The regression fails against the original code and passes with the fix.
  • All 10 related UI/theme tests pass.
  • Reproduced the missing Sublime preview border in the original Windows app after selecting Darker.
  • Visually checked the fixed app: Darker → Sublime → Darker, Circle → Sublime, shadow on/off, and SlimLight → Sublime.
  • Closed Settings, restarted the app, and reopened Settings: the selected theme and preview border persisted.
  • Inspected the main launcher's border and shadow behavior before/after.
  • git diff --check passes.

Visual checks used an isolated portable profile. A temporary local plugin opened Settings through the public API; it is not included in this PR. The full repository test suite and exhaustive native backdrop rendering checks were not run. No recording is included.


Summary by cubic

Summary of changes

Fixes #4655. Theme previews now use the selected theme's border style instead of inheriting the previously selected theme's style.

  • ApplyPreviewBackground now receives the selected theme's WindowBorderStyle from ColorizeWindow instead of reading it from Application.Current.Resources.
  • Added Flow.Launcher.Test/ThemePreviewTest.cs, a WPF regression test covering selection order, inherited border properties, light/dark backgrounds, blur overrides, and prior styles with runtime shadow effects and enlarged margins. The test refuses to run when the WPF application dispatcher is unavailable.
  • Removed the Application.Current.Resources lookup and Contains check that caused the previous theme's style to be copied into the preview.
  • No meaningful memory usage impact; only a style reference is passed into the preview helper.
  • No new security risk; the change only affects WPF theme preview styling.
  • The regression test fails against the original code and passes with this fix.

Release Note

Theme previews now show the border style of the theme you select instead of borrowing the border from the theme you had open before.

Written for commit 6c15eb1. Summary will update on new commits.

Review in cubic

@github-actions github-actions Bot added this to the 2.2.0 milestone Sep 19, 2026
@kalelooz
kalelooz marked this pull request as ready for review September 19, 2026 17:16
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 06453538-49ae-43ce-b051-469ba1802821

📥 Commits

Reviewing files that changed from the base of the PR and between 9d70b38 and 6c15eb1.

📒 Files selected for processing (1)
  • Flow.Launcher.Test/ThemePreviewTest.cs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

ApplyPreviewBackground now uses the selected theme's border style. ThemePreviewTest checks preview styling across theme transitions, blur, shadow, and color-scheme combinations, and restores application state.

Changes

Theme preview border styling

Layer / File(s) Summary
Use the selected theme border style
Flow.Launcher.Core/Resource/Theme.cs
ColorizeWindow passes the selected WindowBorderStyle to ApplyPreviewBackground, which uses it for the preview style.
Set up the preview test
Flow.Launcher.Test/ThemePreviewTest.cs
The test creates or reuses a WPF application, prepares temporary theme dictionaries, and runs checks on the application dispatcher.
Validate theme transitions and cleanup
Flow.Launcher.Test/ThemePreviewTest.cs
The test checks preview styling across theme and display-state combinations, then restores application state and temporary data.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 6c15e

The preview now uses the selected theme’s border style, with regression coverage for theme-order changes. No concrete merge-blocking risk is evident from the supplied context.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the theme preview bug involving the previous theme's border style and matches the main code change.
Description check ✅ Passed The description directly explains the border-style fix, regression test coverage, validation results, and scope of the changes.
Linked Issues check ✅ Passed Issue #4655 requires the preview to use the selected theme border styling regardless of theme selection order. ColorizeWindow passes the selected theme's WindowBorderStyle to `ApplyPreviewBackgrou…
Out of Scope Changes check ✅ Passed The product change is limited to the preview border-style source in Flow.Launcher.Core/Resource/Theme.cs. The added Flow.Launcher.Test/ThemePreviewTest.cs provides regression coverage and WPF test…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files

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.Test/ThemePreviewTest.cs">

<violation number="1" location="Flow.Launcher.Test/ThemePreviewTest.cs:40">
P3: This fixture permanently leaves a live WPF `Application` and its STA dispatcher thread running for the rest of the test process, and `GetApplicationAsync` unconditionally reuses any pre-existing `Application.Current` without verifying its dispatcher is still healthy. NUnit may run the whole assembly in one process, so after this test any other fixture that constructs `System.Windows.Application` (including the real Flow `App`, which derives from it) throws "Cannot create more than one Application instance in the same AppDomain", and the background thread is never joined or shut down. Guard the reuse path (check `HasShutdownStarted` / `Dispatcher.HasShutdownPendingShutdown` and create a fresh app instead) so the fixture does not poison the process for later tests.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

if (Application.Current != null)
return Task.FromResult(Application.Current);

var ready = new TaskCompletionSource<Application>(TaskCreationOptions.RunContinuationsAsynchronously);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: This fixture permanently leaves a live WPF Application and its STA dispatcher thread running for the rest of the test process, and GetApplicationAsync unconditionally reuses any pre-existing Application.Current without verifying its dispatcher is still healthy. NUnit may run the whole assembly in one process, so after this test any other fixture that constructs System.Windows.Application (including the real Flow App, which derives from it) throws "Cannot create more than one Application instance in the same AppDomain", and the background thread is never joined or shut down. Guard the reuse path (check HasShutdownStarted / Dispatcher.HasShutdownPendingShutdown and create a fresh app instead) so the fixture does not poison the process for later tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Flow.Launcher.Test/ThemePreviewTest.cs, line 40:

<comment>This fixture permanently leaves a live WPF `Application` and its STA dispatcher thread running for the rest of the test process, and `GetApplicationAsync` unconditionally reuses any pre-existing `Application.Current` without verifying its dispatcher is still healthy. NUnit may run the whole assembly in one process, so after this test any other fixture that constructs `System.Windows.Application` (including the real Flow `App`, which derives from it) throws "Cannot create more than one Application instance in the same AppDomain", and the background thread is never joined or shut down. Guard the reuse path (check `HasShutdownStarted` / `Dispatcher.HasShutdownPendingShutdown` and create a fresh app instead) so the fixture does not poison the process for later tests.</comment>

<file context>
@@ -0,0 +1,160 @@
+        if (Application.Current != null)
+            return Task.FromResult(Application.Current);
+
+        var ready = new TaskCompletionSource<Application>(TaskCreationOptions.RunContinuationsAsynchronously);
+        // WPF permits only one Application per process. Keep its STA dispatcher alive for reuse.
+        var thread = new Thread(() =>
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed the unsafe reuse path in 6c15eb1: the helper now rejects a dispatcher whose shutdown has started/finished or whose thread is no longer alive, with an explicit fresh-process diagnostic.

The suggested shutdown-and-recreate approach is not valid for WPF: only one Application can be created per AppDomain, including after shutdown (https://learn.microsoft.com/en-us/dotnet/api/system.windows.application#remarks). The existing background dispatcher is intentionally retained for the repeated regression test; resources, MainWindow and ShutdownMode are restored after each verification.

This change does not provide process isolation for another fixture that independently constructs an Application. I am leaving the thread open rather than claiming that broader lifetime concern is resolved. The new commit has not been run locally on Windows; its CI result still needs verification.

@jjw24 jjw24 added the bug Something isn't working label Sep 28, 2026
@jjw24
jjw24 merged commit af725b7 into Flow-Launcher:dev Sep 28, 2026
3 checks passed
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.

BUG: Theme preview not referencing the correct border stylings

2 participants