Skip to content

fix(theme-builder): make Hyva and TailwindCSS detection mutually exclusive - #289

Merged
dermatz merged 3 commits into
mainfrom
fix/builder-detection-exclusive
Nov 12, 2026
Merged

dermatz merged 3 commits into
mainfrom
fix/builder-detection-exclusive

Conversation

@dermatz

@dermatz dermatz commented Nov 12, 2026

Copy link
Copy Markdown
Member

Problem

Hyva and TailwindCSS builders decided independently in detect(). A theme with web/tailwind and mixed signals (neutral theme.xml but composer name hyva-themes/..., or the reverse) matched both; BuilderPool picked the first, so the result depended on the order in di.xml.

Fix

  • New HyvaThemeDetector::isHyvaTheme() (same logic as before) shared by both builders.
  • Hyva: web/tailwind exists and detector matches.
  • TailwindCSS: web/tailwind exists, theme.xml or composer.json exists, and detector does not match.
  • Docs note on mutually exclusive detection.

Verification

  • New unit tests for the detector and both mixed cases; the TailwindCSS mixed-case tests fail on the old builder.
  • phpunit ThemeBuilder/Hyva tests, phpcs, phpstan, mago lint/fmt/analyze: no new findings (remaining ones are pre-existing on main / missing Magento classes).

…usive

Both builders decided independently in detect(), so a theme with
mixed Hyva signals (theme.xml vs. composer name) matched both and the
result depended on the order in di.xml. Share the decision through a
new HyvaThemeDetector and make TailwindCSS reject Hyva themes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 22:18
@github-actions github-actions Bot added documentation Improvements or additions to documentation Fix Theme-Builder labels Nov 12, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the changes making Hyvä and TailwindCSS builder detection mutually exclusive.

No open issues 🎉

What changed in this PR

This PR makes Hyvä and TailwindCSS builder detection mutually exclusive, removing their dependence on registration order in BuilderPool when theme metadata contains mixed signals.

Changes:

  • Extracts existing Hyvä identification logic into a shared HyvaThemeDetector.
  • Updates both builders to use complementary detection rules.
  • Adds detector and mixed-metadata regression tests, and documents detection exclusivity.
File Description
tests/​Unit/​Service/​ThemeBuilder/​TailwindCSS/​BuilderTest.php Adds mixed-metadata regression tests and injects the detector.
tests/​Unit/​Service/​ThemeBuilder/​HyvaThemes/​BuilderTest.php Updates test construction to inject the detector.
tests/​Unit/​Service/​Hyva/​HyvaThemeDetectorTest.php Tests Hyvä identification across metadata combinations.
src/​Service/​ThemeBuilder/​TailwindCSS/​Builder.php Excludes themes identified as Hyvä by the shared detector.
src/​Service/​ThemeBuilder/​HyvaThemes/​Builder.php Delegates Hyvä identification to the shared detector.
src/​Service/​Hyva/​HyvaThemeDetector.php Centralises Hyvä identification from theme and Composer metadata.
docs/​custom_theme_builders.md Explains first-match selection and mutually exclusive detection.

Review effort: Balanced

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Summary

Both theme builders now share HyvaThemeDetector, so mixed theme declarations no longer make both builders match.

  • Hyvä and TailwindCSS builders now agree on which themes they claim.
  • Three existing tests use updated test doubles or formatting.

No actionable new issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Theme path] --> B{web/tailwind exists?}
    B -->|No| C[Neither builder matches]
    B -->|Yes| D{HyvaThemeDetector matches?}
    D -->|Yes| E[Hyva builder]
    D -->|No| F{theme.xml or composer.json exists?}
    F -->|Yes| G[TailwindCSS builder]
    F -->|No| C
Loading

Reviews (2) · Last reviewed commit: "style(theme-builder): apply mago formatt..." · Reviewed by Greptile

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 22:20

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the changes making Hyvä and TailwindCSS theme detection mutually exclusive.

No open issues 🎉

Review effort: Balanced

@dermatz
dermatz merged commit fa8ea08 into main Nov 12, 2026
23 checks passed
@dermatz
dermatz deleted the fix/builder-detection-exclusive branch November 12, 2026 22:33
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026
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 Fix Theme-Builder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants