Auto-enable first theme when no active theme is set on plugin launch or pull #3635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When users launch the plugin or pull variables from Figma without any stored active theme information, no theme is automatically enabled. This requires users to manually select a theme even when themes are available, creating unnecessary friction in the workflow.
Solution
This PR implements automatic activation of the first available theme when:
activeThemeis empty{})The auto-enable behavior occurs in two key scenarios:
setTokenDatasetThemesFromVariablesImplementation Details
The solution modifies two key reducers to detect when no active theme is set and automatically enable the first available theme:
setThemesFromVariables(when pulling variables)setTokenData(on plugin startup)Similar logic is applied when loading token data during plugin initialization, ensuring the first theme is auto-enabled if no active theme exists.
Both functions update not only
activeThemebut alsousedTokenSetbased on the theme'sselectedTokenSets, ensuring that the correct token sets are properly enabled when the theme is activated.Theme Group Handling
groupproperty, it's used as the key inactiveThemegroup, theINTERNAL_THEMES_NO_GROUPconstant is usedTesting
Added comprehensive test suite covering:
INTERNAL_THEMES_NO_GROUP)All existing tests continue to pass, confirming backward compatibility.
Changeset
Created a patch-level changeset as required by repository guidelines.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.